From: Hongxu Jia <hongxu.jia@windriver.com>
To: <openembedded-core@lists.openembedded.org>,
<richard.purdie@linuxfoundation.org>,
"Burton, Ross" <ross.burton@intel.com>
Subject: Re: [PATCH V2] machine/qemu*: fix kernel finish crng init more and more slowly
Date: Wed, 7 Nov 2018 09:45:38 +0800 [thread overview]
Message-ID: <58a09038-bc29-6ea0-1dca-c7ac8501d670@windriver.com> (raw)
In-Reply-To: <1540866169-70689-1-git-send-email-hongxu.jia@windriver.com>
On 2018/10/30 上午10:22, Hongxu Jia wrote:
> Just adding `-device virtio-rng-pci' to the QEMU invocation will
> add the device with a default host backend. As of QEMU 1.3+,
> the default backend is to use the host's /dev/random as a
> source of entropy. [1]
>
> When the entropy pool is empty, reads from /dev/random will
> block until additional environmental noise is gathered. [2]
>
> For Yocto, if call runqemu frequently, it will consume lots
> of host's /dev/random, and kernel finish crng init in guest get
> more and more slowly.
>
> Here are 4 times runqemu boot test:
>
> [ 3.464432] random: crng init done
> [ 20.874030] random: crng init done
> [ 23.583589] random: crng init done
> [ 23.858945] random: crng init done
>
> Modify entropy source to /dev/urandom device on the host which
> returns random bytes using a pseudorandom number generator seeded
> from the entropy pool. Reads from this device do not block and
> kernel finish crng init in guest will not delay.
>
> Of course, the side effect is obviously, we lost the quality of
> randomness, but the modification is only on runqemu script
> rather than real embedded device, and it benefits oeqa efficiency
> in which many cases call runqemu especially multiple oeqa builds
> on one host.
>
> After apply the fix:
>
> [ 3.364670] random: crng init done
> [ 4.619061] random: crng init done
> [ 3.403897] random: crng init done
> [ 3.450717] random: crng init done
>
> [1] https://wiki.qemu.org/Features/VirtIORNG
> [2] http://man7.org/linux/man-pages/man4/random.4.html
>
> Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
> ---
> meta/conf/machine/include/qemuboot-mips.inc | 3 ++-
> meta/conf/machine/include/qemuboot-x86.inc | 3 ++-
> meta/conf/machine/qemuarm.conf | 3 ++-
> meta/conf/machine/qemuarm64.conf | 4 +++-
> meta/conf/machine/qemuppc.conf | 3 ++-
> 5 files changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/meta/conf/machine/include/qemuboot-mips.inc b/meta/conf/machine/include/qemuboot-mips.inc
> index 7d9fa52..75bb988 100644
> --- a/meta/conf/machine/include/qemuboot-mips.inc
> +++ b/meta/conf/machine/include/qemuboot-mips.inc
> @@ -3,6 +3,7 @@ IMAGE_CLASSES += "qemuboot"
> QB_MEM = "-m 256"
> QB_MACHINE = "-machine malta"
> QB_KERNEL_CMDLINE_APPEND = "console=ttyS0 console=tty"
> +QB_OPT_APPEND = "-vga cirrus -show-cursor -usb -device usb-tablet"
> # Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy
> -QB_OPT_APPEND = "-vga cirrus -show-cursor -usb -device usb-tablet -device virtio-rng-pci"
> +QB_OPT_APPEND += "-object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0"
> QB_SYSTEM_NAME = "qemu-system-${TUNE_ARCH}"
> diff --git a/meta/conf/machine/include/qemuboot-x86.inc b/meta/conf/machine/include/qemuboot-x86.inc
> index 1456bf7..5fdbe4d 100644
> --- a/meta/conf/machine/include/qemuboot-x86.inc
> +++ b/meta/conf/machine/include/qemuboot-x86.inc
> @@ -11,7 +11,8 @@ QB_CPU_KVM_x86-64 = "-cpu core2duo"
> QB_AUDIO_DRV = "alsa"
> QB_AUDIO_OPT = "-soundhw ac97,es1370"
> QB_KERNEL_CMDLINE_APPEND = "vga=0 uvesafb.mode_option=${UVESA_MODE} oprofile.timer=1 uvesafb.task_timeout=-1"
> +QB_OPT_APPEND = "-vga vmware -show-cursor -usb -device usb-tablet"
Hi Ross,
I am afraid the patch you merged to master-next is V1 which caused runqemu
failure on qemux86/qemux86-64, we should use V2
[v1 snip]
--- a/meta/conf/machine/include/qemuboot-x86.inc
+++ b/meta/conf/machine/include/qemuboot-x86.inc
@@ -11,7 +11,8 @@ QB_CPU_KVM_x86-64 = "-cpu core2duo"
+QB_OPT_APPEND = "-vga vmware -show-cursor -usb -device usb-tablet -device"
# Add the 'virtio-rng-pci' device otherwise the guest may run out of
entropy
-QB_OPT_APPEND = "-vga vmware -show-cursor -usb -device usb-tablet
-device virtio-rng-pci"
+QB_OPT_APPEND += "-object rng-random,filename=/dev/urandom,id=rng0
-device virtio-rng-pci,rng=rng0
[v1 snip]
//Hongxu
> # Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy
> -QB_OPT_APPEND = "-vga vmware -show-cursor -usb -device usb-tablet -device virtio-rng-pci"
> +QB_OPT_APPEND += "-object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0"
>
> UVESA_MODE ?= "640x480-32"
> diff --git a/meta/conf/machine/qemuarm.conf b/meta/conf/machine/qemuarm.conf
> index d2f2c85..a544312 100644
> --- a/meta/conf/machine/qemuarm.conf
> +++ b/meta/conf/machine/qemuarm.conf
> @@ -14,7 +14,8 @@ SERIAL_CONSOLES ?= "115200;ttyAMA0 115200;ttyAMA1"
> QB_SYSTEM_NAME = "qemu-system-arm"
> QB_MACHINE = "-machine versatilepb"
> QB_KERNEL_CMDLINE_APPEND = "console=ttyAMA0,115200 console=tty"
> +QB_OPT_APPEND = "-show-cursor -usb -device usb-tablet"
> # Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy
> -QB_OPT_APPEND = "-show-cursor -usb -device usb-tablet -device virtio-rng-pci"
> +QB_OPT_APPEND += "-object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0"
> PREFERRED_VERSION_linux-yocto ??= "4.18%"
> QB_DTB = "${@oe.utils.version_less_or_equal('PREFERRED_VERSION_linux-yocto', '4.7', '', 'zImage-versatile-pb.dtb', d)}"
> diff --git a/meta/conf/machine/qemuarm64.conf b/meta/conf/machine/qemuarm64.conf
> index 242889a..34fcd2a 100644
> --- a/meta/conf/machine/qemuarm64.conf
> +++ b/meta/conf/machine/qemuarm64.conf
> @@ -16,7 +16,9 @@ QB_MACHINE = "-machine virt"
> QB_CPU = "-cpu cortex-a57"
> QB_KERNEL_CMDLINE_APPEND = "console=ttyAMA0,38400"
> # Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy
> -QB_OPT_APPEND = "-show-cursor -device virtio-rng-pci -monitor null"
> +QB_OPT_APPEND = "-show-cursor -monitor null"
> +# 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"
> 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"
> diff --git a/meta/conf/machine/qemuppc.conf b/meta/conf/machine/qemuppc.conf
> index 537b2f6..743d261 100644
> --- a/meta/conf/machine/qemuppc.conf
> +++ b/meta/conf/machine/qemuppc.conf
> @@ -16,6 +16,7 @@ QB_SYSTEM_NAME = "qemu-system-ppc"
> QB_MACHINE = "-machine mac99"
> QB_CPU = "-cpu G4"
> QB_KERNEL_CMDLINE_APPEND = "console=tty console=ttyS0"
> +QB_OPT_APPEND = "-show-cursor -usb -device usb-tablet"
> # Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy
> -QB_OPT_APPEND = "-show-cursor -usb -device usb-tablet -device virtio-rng-pci"
> +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"
next prev parent reply other threads:[~2018-11-07 1:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-26 13:59 [PATCH] machine/qemu*: fix kernel finish crng init more and more slowly Hongxu Jia
2018-10-29 15:07 ` richard.purdie
2018-10-30 2:22 ` [PATCH V2] " Hongxu Jia
2018-10-30 6:59 ` Hongxu Jia
2018-11-07 1:45 ` Hongxu Jia [this message]
2018-11-07 9:25 ` richard.purdie
2018-10-30 2:00 ` [PATCH] " Hongxu Jia
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=58a09038-bc29-6ea0-1dca-c7ac8501d670@windriver.com \
--to=hongxu.jia@windriver.com \
--cc=openembedded-core@lists.openembedded.org \
--cc=richard.purdie@linuxfoundation.org \
--cc=ross.burton@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox