qemuboot: Add QB_RNG variable
PATCH 1/1 qemuboot: Add QB_RNG variable
RNG passthru has been enabled on all qemu machines but its being added to each one of them, with this patch its turned into QB variables which defaults to host passthru, yet it can be overridden if needed via machine or config metadata if needed.
Signed-off-by Khem Raj <[email protected]>
--- meta/classes/qemuboot.bbclass | 4 ++++ meta/conf/machine/include/qemuboot-mips.inc | 2 -- meta/conf/machine/include/qemuboot-x86.inc | 2 -- meta/conf/machine/include/riscv/qemuriscv.inc | 3 --- meta/conf/machine/qemuarm.conf | 2 -- meta/conf/machine/qemuarm64.conf | 2 -- meta/conf/machine/qemuarmv5.conf | 2 -- meta/conf/machine/qemuppc.conf | 2 -- scripts/runqemu | 2 +- 9 files changed, 5 insertions(+), 16 deletions(-)
meta/classes/qemuboot.bbclass +4 -0
@@ -29,6 +29,9 @@ # QB_AUDIO_OPT: qemu audio option, e.g., "-soundhw ac97,es1370", used # when QB_AUDIO_DRV is set. # +# QB_RNG: Pass-through for host random number generator, it can speedup boot +# in system mode, where system is experiencing entropy starvation +# # QB_KERNEL_ROOT: kernel's root, e.g., /dev/vda # # QB_NETWORK_DEVICE: network device, e.g., "-device virtio-net-pci,netdev=net0,mac=@MAC@",
@@ -77,6 +80,7 @@ QB_MEM ?= "-m 256" QB_SERIAL_OPT ?= "-serial mon:stdio -serial null" QB_DEFAULT_KERNEL ?= "${KERNEL_IMAGETYPE}" QB_DEFAULT_FSTYPE ?= "ext4" +QB_RNG ?= "-object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0" QB_OPT_APPEND ?= "" QB_NETWORK_DEVICE ?= "-device virtio-net-pci,netdev=net0,mac=@MAC@" QB_CMDLINE_IP_SLIRP ?= "ip=dhcp"
meta/conf/machine/include/qemuboot-mips.inc +0 -2
@@ -3,8 +3,6 @@ IMAGE_CLASSES += "qemuboot" QB_MACHINE = "-machine malta" QB_KERNEL_CMDLINE_APPEND = "console=ttyS0 console=tty" QB_OPT_APPEND = "-usb -device usb-tablet" -# Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy -QB_OPT_APPEND += "-object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0" # For graphics to work we need to define the VGA device as well as the necessary USB devices QB_OPT_APPEND += "-vga std"
meta/conf/machine/include/qemuboot-x86.inc +0 -2
@@ -10,6 +10,4 @@ QB_AUDIO_DRV = "alsa" QB_AUDIO_OPT = "-soundhw ac97,es1370" QB_KERNEL_CMDLINE_APPEND = "oprofile.timer=1" QB_OPT_APPEND = "-usb -device usb-tablet" -# Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy -QB_OPT_APPEND += "-object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0"
meta/conf/machine/include/riscv/qemuriscv.inc +0 -3
@@ -33,6 +33,3 @@ QB_NETWORK_DEVICE = "-device virtio-net-device,netdev=net0,mac=@MAC@" QB_ROOTFS_OPT = "-drive id=disk0,file=@ROOTFS@,if=none,format=raw -device virtio-blk-device,drive=disk0" QB_SERIAL_OPT = "-device virtio-serial-device -chardev null,id=virtcon -device virtconsole,chardev=virtcon" QB_TCPSERIAL_OPT = " -device virtio-serial-device -chardev socket,id=virtcon,port=@PORT@,host=127.0.0.1 -device virtconsole,chardev=virtcon" -# Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy -QB_OPT_APPEND = " -object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-device,rng=rng0" -
meta/conf/machine/qemuarm.conf +0 -2
@@ -21,8 +21,6 @@ QB_KERNEL_CMDLINE_APPEND = "console=ttyAMA0" # For graphics to work we need to define the VGA device as well as the necessary USB devices QB_OPT_APPEND = "-device VGA,edid=on" QB_OPT_APPEND += "-device qemu-xhci -device usb-tablet -device usb-kbd" -# Add the virtio RNG -QB_OPT_APPEND += "-object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0" # Virtio Networking support QB_TAP_OPT = "-netdev tap,id=net0,ifname=@TAP@,script=no,downscript=no" QB_NETWORK_DEVICE = "-device virtio-net-device,netdev=net0,mac=@MAC@"
meta/conf/machine/qemuarm64.conf +0 -2
@@ -22,8 +22,6 @@ QB_KERNEL_CMDLINE_APPEND = "console=ttyAMA0" # For graphics to work we need to define the VGA device as well as the necessary USB devices QB_OPT_APPEND = "-device VGA,edid=on" QB_OPT_APPEND += "-device qemu-xhci -device usb-tablet -device usb-kbd" -# Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy -QB_OPT_APPEND += "-object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0" # Virtio Networking support QB_TAP_OPT = "-netdev tap,id=net0,ifname=@TAP@,script=no,downscript=no" QB_NETWORK_DEVICE = "-device virtio-net-device,netdev=net0,mac=@MAC@"
meta/conf/machine/qemuarmv5.conf +0 -2
@@ -14,8 +14,6 @@ QB_SYSTEM_NAME = "qemu-system-arm" QB_MACHINE = "-machine versatilepb" QB_KERNEL_CMDLINE_APPEND = "console=ttyAMA0,115200 console=tty" QB_OPT_APPEND = "-usb -device usb-tablet" -# Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy -QB_OPT_APPEND += "-object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0" PREFERRED_VERSION_linux-yocto ??= "5.8%" QB_DTB = "${@oe.utils.version_less_or_equal('PREFERRED_VERSION_linux-yocto', '4.7', '', 'zImage-versatile-pb.dtb', d)}"
meta/conf/machine/qemuppc.conf +0 -2
@@ -17,6 +17,4 @@ QB_MACHINE = "-machine mac99" QB_CPU = "-cpu G4" QB_KERNEL_CMDLINE_APPEND = "console=tty console=ttyS0" QB_OPT_APPEND = "-usb -device usb-tablet" -# Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy -QB_OPT_APPEND += "-object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0" QB_TAP_OPT = "-netdev tap,id=net0,ifname=@TAP@,script=no,downscript=no"
scripts/runqemu +1 -1
@@ -1336,7 +1336,7 @@ class BaseConfig(object): if not os.access(qemu_bin, os.X_OK): raise OEPathError("No QEMU binary '%s' could be found" % qemu_bin) - self.qemu_opt = "%s %s %s %s" % (qemu_bin, self.get('NETWORK_CMD'), self.get('ROOTFS_OPTIONS'), self.get('QB_OPT_APPEND')) + self.qemu_opt = "%s %s %s %s %s" % (qemu_bin, self.get('NETWORK_CMD'), self.get('QB_RNG'), self.get('ROOTFS_OPTIONS'), self.get('QB_OPT_APPEND')) for ovmf in self.ovmf_bios: format = ovmf.rsplit('.', 1)[-1]
Signature · 1 line
2.28.0
Quoted 7 lines · Khem Raj
RNG passthru has been enabled on all qemu machines but its being added to each one of them, with this patch its turned into QB variables which defaults to host passthru, yet it can be overridden if needed via machine or config metadata if needed.
Signed-off-by Khem Raj <[email protected]>
Good idea!
Reviewed-by Alistair Francis <[email protected]>
Alistair
Quoted 138 lines
--- meta/classes/qemuboot.bbclass | 4 ++++ meta/conf/machine/include/qemuboot-mips.inc | 2 -- meta/conf/machine/include/qemuboot-x86.inc | 2 -- meta/conf/machine/include/riscv/qemuriscv.inc | 3 --- meta/conf/machine/qemuarm.conf | 2 -- meta/conf/machine/qemuarm64.conf | 2 -- meta/conf/machine/qemuarmv5.conf | 2 -- meta/conf/machine/qemuppc.conf | 2 -- scripts/runqemu | 2 +- 9 files changed, 5 insertions(+), 16 deletions(-)meta/classes/qemuboot.bbclass +4
-0@@ -29,6 +29,9 @@ # QB_AUDIO_OPT: qemu audio option, e.g., "-soundhw ac97,es1370", used # when QB_AUDIO_DRV is set. # +# QB_RNG: Pass-through for host random number generator, it can speedup boot +# in system mode, where system is experiencing entropy starvation +# # QB_KERNEL_ROOT: kernel's root, e.g., /dev/vda # # QB_NETWORK_DEVICE: network device, e.g., "-device virtio-net-pci,netdev=net0,mac=@MAC@",@@ -77,6 +80,7 @@ QB_MEM ?= "-m 256" QB_SERIAL_OPT ?= "-serial mon:stdio -serial null" QB_DEFAULT_KERNEL ?= "${KERNEL_IMAGETYPE}" QB_DEFAULT_FSTYPE ?= "ext4" +QB_RNG ?= "-object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0" QB_OPT_APPEND ?= "" QB_NETWORK_DEVICE ?= "-device virtio-net-pci,netdev=net0,mac=@MAC@" QB_CMDLINE_IP_SLIRP ?= "ip=dhcp"meta/conf/machine/include/qemuboot-mips.inc +0
-2@@ -3,8 +3,6 @@ IMAGE_CLASSES += "qemuboot" QB_MACHINE = "-machine malta" QB_KERNEL_CMDLINE_APPEND = "console=ttyS0 console=tty" QB_OPT_APPEND = "-usb -device usb-tablet" -# Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy -QB_OPT_APPEND += "-object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0" # For graphics to work we need to define the VGA device as well as the necessary USB devices QB_OPT_APPEND += "-vga std"meta/conf/machine/include/qemuboot-x86.inc +0
-2@@ -10,6 +10,4 @@ QB_AUDIO_DRV = "alsa" QB_AUDIO_OPT = "-soundhw ac97,es1370" QB_KERNEL_CMDLINE_APPEND = "oprofile.timer=1" QB_OPT_APPEND = "-usb -device usb-tablet" -# Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy -QB_OPT_APPEND += "-object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0"meta/conf/machine/include/riscv/qemuriscv.inc +0
-3@@ -33,6 +33,3 @@ QB_NETWORK_DEVICE = "-device virtio-net-device,netdev=net0,mac=@MAC@" QB_ROOTFS_OPT = "-drive id=disk0,file=@ROOTFS@,if=none,format=raw -device virtio-blk-device,drive=disk0" QB_SERIAL_OPT = "-device virtio-serial-device -chardev null,id=virtcon -device virtconsole,chardev=virtcon" QB_TCPSERIAL_OPT = " -device virtio-serial-device -chardev socket,id=virtcon,port=@PORT@,host=127.0.0.1 -device virtconsole,chardev=virtcon" -# Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy -QB_OPT_APPEND = " -object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-device,rng=rng0" -meta/conf/machine/qemuarm.conf +0
-2@@ -21,8 +21,6 @@ QB_KERNEL_CMDLINE_APPEND = "console=ttyAMA0" # For graphics to work we need to define the VGA device as well as the necessary USB devices QB_OPT_APPEND = "-device VGA,edid=on" QB_OPT_APPEND += "-device qemu-xhci -device usb-tablet -device usb-kbd" -# Add the virtio RNG -QB_OPT_APPEND += "-object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0" # Virtio Networking support QB_TAP_OPT = "-netdev tap,id=net0,ifname=@TAP@,script=no,downscript=no" QB_NETWORK_DEVICE = "-device virtio-net-device,netdev=net0,mac=@MAC@"meta/conf/machine/qemuarm64.conf +0
-2@@ -22,8 +22,6 @@ QB_KERNEL_CMDLINE_APPEND = "console=ttyAMA0" # For graphics to work we need to define the VGA device as well as the necessary USB devices QB_OPT_APPEND = "-device VGA,edid=on" QB_OPT_APPEND += "-device qemu-xhci -device usb-tablet -device usb-kbd" -# Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy -QB_OPT_APPEND += "-object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0" # Virtio Networking support QB_TAP_OPT = "-netdev tap,id=net0,ifname=@TAP@,script=no,downscript=no" QB_NETWORK_DEVICE = "-device virtio-net-device,netdev=net0,mac=@MAC@"meta/conf/machine/qemuarmv5.conf +0
-2@@ -14,8 +14,6 @@ QB_SYSTEM_NAME = "qemu-system-arm" QB_MACHINE = "-machine versatilepb" QB_KERNEL_CMDLINE_APPEND = "console=ttyAMA0,115200 console=tty" QB_OPT_APPEND = "-usb -device usb-tablet" -# Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy -QB_OPT_APPEND += "-object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0" PREFERRED_VERSION_linux-yocto ??= "5.8%" QB_DTB = "${@oe.utils.version_less_or_equal('PREFERRED_VERSION_linux-yocto', '4.7', '', 'zImage-versatile-pb.dtb', d)}"meta/conf/machine/qemuppc.conf +0
-2@@ -17,6 +17,4 @@ QB_MACHINE = "-machine mac99" QB_CPU = "-cpu G4" QB_KERNEL_CMDLINE_APPEND = "console=tty console=ttyS0" QB_OPT_APPEND = "-usb -device usb-tablet" -# Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy -QB_OPT_APPEND += "-object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0" QB_TAP_OPT = "-netdev tap,id=net0,ifname=@TAP@,script=no,downscript=no"scripts/runqemu +1
-2@@ -1336,7 +1336,7 @@ class BaseConfig(object): if not os.access(qemu_bin, os.X_OK): raise OEPathError("No QEMU binary '%s' could be found" % qemu_bin) - self.qemu_opt = "%s %s %s %s" % (qemu_bin, self.get('NETWORK_CMD'), self.get('ROOTFS_OPTIONS'), self.get('QB_OPT_APPEND')) + self.qemu_opt = "%s %s %s %s %s" % (qemu_bin, self.get('NETWORK_CMD'), self.get('QB_RNG'), self.get('ROOTFS_OPTIONS'), self.get('QB_OPT_APPEND')) for ovmf in self.ovmf_bios: format = ovmf.rsplit('.', 1)[-1] --2.28.0