Bug 915335
Summary: | RFE: Multiple virtio-rng devices support | |||
---|---|---|---|---|
Product: | Red Hat Enterprise Linux 7 | Reporter: | Peter Krempa <pkrempa> | |
Component: | kernel | Assignee: | Amos Kong <akong> | |
kernel sub component: | KVM | QA Contact: | Virtualization Bugs <virt-bugs> | |
Status: | CLOSED ERRATA | Docs Contact: | ||
Severity: | unspecified | |||
Priority: | unspecified | CC: | ailan, akong, amit.shah, bsarathy, juzhang, knoel, mazhang, michen, mkenneth, mzhan, qiguo, rbalakri, virt-maint, xfu, xuhan | |
Version: | 7.0 | Keywords: | FutureFeature | |
Target Milestone: | rc | |||
Target Release: | --- | |||
Hardware: | x86_64 | |||
OS: | Linux | |||
Whiteboard: | ||||
Fixed In Version: | kernel-3.10.0-146.el7 | Doc Type: | Enhancement | |
Doc Text: | Story Points: | --- | ||
Clone Of: | ||||
: | 1119206 (view as bug list) | Environment: | ||
Last Closed: | 2015-03-05 11:29:48 UTC | Type: | Bug | |
Regression: | --- | Mount Type: | --- | |
Documentation: | --- | CRM: | ||
Verified Versions: | Category: | --- | ||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | ||
Cloudforms Team: | --- | Target Upstream Version: | ||
Embargoed: | ||||
Bug Depends On: | ||||
Bug Blocks: | 917953, 1119206, 1119299 |
Description
Peter Krempa
2013-02-25 14:37:58 UTC
A log of the crash would've been helpful. The kernel driver is written with the assumption that there's only one virtio-rng device. That does make sense as well: why have two rng devices of the same kind anyway? If the host has multiple sources to feed from, the host can multiplex them and send the entropy the guest's way. This one virtio-rng device limit should be enforced in qemu and libvirt. Switching component to qemu-kvm, where we'll do this. I agree with forbidding to use multiple virtio-rng devices as I can't think of a useful use-case. Libvirt isn't currently allowing multiple RNG's and I will not push the patch adding the support ( http://www.redhat.com/archives/libvir-list/2013-February/msg01423.html ). Adjusting summary. A brief chat with Anthony on IRC indicated he's not fine restricting qemu, and that it is a valid use-case to have multiple devices. If indeed we do that, we'll flip this bug back to the kernel component to modify the hwrng layer in the kernel to use > 1 virtio-rng device and > 1 rng devices at the same time. Additional info: In bug 953097, we already fixed the kernel crash by rejecting to register multiple virtio-rng devices. I tested with RHEL6.5 guest & upstream qemu, no crash, and the data comes from first rng-random backend. Hi Amit I found that kernel(drivers/char/hw_random/core.c) supports to register multiple hwrng devices, I just posted a patch to kernel driver to support multiple virtio-rng device. https://lists.linux-foundation.org/pipermail/virtualization/2014-April/026535.html (In reply to Amos Kong from comment #9) > Hi Amit > > I found that kernel(drivers/char/hw_random/core.c) supports to register > multiple hwrng devices, I just posted a patch to kernel driver to support > multiple virtio-rng device. > > https://lists.linux-foundation.org/pipermail/virtualization/2014-April/ > 026535.html Hi Amos, I saw the patch, and as I observed above, and Rusty the reply in that thread, I don't see much value in the virtio-rng driver itself supporting multiple devices. If the kernel's hwrng core could itself support multiplexing from multiple devices, that would be great. So, with the current kernel-core design, only one hwrng can be active. For the virtio-rng case, that means only one virtio-rng can be active. We could easily switch the device side by using hotplug instead of the patch you propsed. However, as Rusty says: 'why not' :-) Upstream exists in Upstream (with some fixes), backport is needed. commit a17597d3b418ca5a394d14724ccfc295cb3186c8 Author: Sasha Levin <sasha.levin> Date: Fri May 16 11:42:43 2014 +0930 virtio-rng: fixes for device registration/unregistration There are several fixes in this patch (mostly because it's hard splitting them up): - Revert the name field in struct hwrng back to 'const'. Also, don't do an extra kmalloc for the name - just wasteful. - Deal with allocation failures properly. - Use IDA to allocate device number instead of brute forcing one. Signed-off-by: Sasha Levin <sasha.levin> Signed-off-by: Rusty Russell <rusty.au> commit e5d23a8cc38c555f9f3a40dcc5d14030105df9a8 Author: Sasha Levin <sasha.levin> Date: Fri May 16 11:41:57 2014 +0930 virtio-rng: fix boot with virtio-rng device Commit "virtio-rng: support multiple virtio-rng devices" has broken boot with a virtio-rng device because the 'init' callback of the virtio-rng device was left unitialized to garbage, and got called by the hwrng infrastructure, killing the guest on boot. Signed-off-by: Sasha Levin <sasha.levin> Signed-off-by: Rusty Russell <rusty.au> Fixes: 08e53fbdb85c0f6f45c0f7c1ea3defc1752a95ce commit 08e53fbdb85c0f6f45c0f7c1ea3defc1752a95ce Author: Amos Kong <akong> Date: Wed May 14 10:33:46 2014 +0930 virtio-rng: support multiple virtio-rng devices Current hwrng core supports to register multiple hwrng devices, and there is only one device really works in the same time. QEMU alsu supports to have multiple virtio-rng backends. This patch changes virtio-rng driver to support multiple virtio-rng devices. ]# cat /sys/class/misc/hw_random/rng_available virtio_rng.0 virtio_rng.1 ]# cat /sys/class/misc/hw_random/rng_current virtio_rng.0 ]# echo -n virtio_rng.1 > /sys/class/misc/hw_random/rng_current ]# dd if=/dev/hwrng of=/dev/null Signed-off-by: Amos Kong <akong> Signed-off-by: Rusty Russell <rusty.au> Tried to backported 4 patches to rhel7 kernel Last patch relies on new interface(eg: ida_simple_get()), some dependence backporting is needed. [PATCH 1/4]virtio-rng: don't crash if virtqueue is broken. [PATCH 2/4]virtio-rng: support multiple virtio-rng devices [PATCH 3/4]virtio-rng: fix boot with virtio-rng device [PATCH 4/4]virtio-rng: fixes for device registration/unregistration Upstream Virtio-rng driver still has some new issues, I will post this backport when all the issues are resolved. Some additional fixes will be backported in another bugs. Bug 1121540 - Hot-unplugging a busy virtio-rng device from Linux guest causes rng device stuck Bug 1081431 - virtio-rng module does not increment its reference count when /dev/hwrng in the guest is open, making it appear to be unused when it is in use Patch(es) available on kernel-3.10.0-146.el7 Reproduced this bug with kernel-3.10.0-123.el7.x86_64 Steps: 1.Boot RHEL7 guest with 2 virtio-rng deivces: # /usr/libexec/qemu-kvm -cpu SandyBridge -enable-kvm -m 4G -smp 4,sockets=1,cores=4,threads=1 -name test -rtc base=localtime,clock=host,driftfix=slew -k en-us -boot menu=on -vnc :3 -vga cirrus -usb -device usb-tablet -monitor stdio -drive file=/home/rhel7/rhel7basecp1.qcow2,if=none,id=drive-system-disk,media=disk,format=qcow2,aio=native,werror=stop,rerror=stop -device virtio-blk-pci,drive=drive-system-disk,id=system-disk,addr=0x3 -qmp unix:/tmp/q1,server,nowait -net none -object rng-random,id=rng0,filename=/dev/urandom -device virtio-rng-pci,rng=rng0 -object rng-random,id=rng1,filename=/dev/urandom -device virtio-rng-pci,rng=rng1 -netdev tap,id=hostnet0,vhost=on,script=/etc/qemu-ifup -device virtio-net-pci,netdev=hostnet0,id=vnet0,mac=52:54:00:1a:2b:02 2.In guest, from dmesg: # dmesg |grep rng [ 0.540247] alg: No test for stdrng (krng) [ 3.207351] virtio_rng: probe of virtio2 failed with error -16 3.And only 1 virtio-rng found in guest: # cat /sys/class/misc/hw_random/rng_available virtio # cat /sys/class/misc/hw_random/rng_current virtio 4.In guest, use the rng device. # dd if=/dev/hwrng of=test bs=512 count=10 Result: 1.Did not crash (the reporter crash since its guest is rhel6 and bug 917505 has been fixed ) 2.Only can get virtio from /sys/class/misc/hw_random/xx So according to above, this bug is reproduced. Verify this bug with kernel-3.10.0-148.el7.x86_64 (guest and host both installed) Steps: 1.Boot rhel7 guest with kernel-3.10.0-148.el7.x86_64, and cli is same as above. 2.In guest, from dmesg, no error prints about rng: # dmesg |grep rng [ 0.534911] alg: No test for stdrng (krng) 3.Check rng_available rng_current # cat /sys/class/misc/hw_random/rng_current virtio_rng.0 # cat /sys/class/misc/hw_random/rng_available virtio_rng.0 virtio_rng.1 4.Check if it works # dd if=/dev/hwrng of=/dev/null bs=512 count=100 100+0 records in 100+0 records out 51200 bytes (51 kB) copied,0.0851136 s,602 kB/s 5.Change current rng device # echo -n virtio_rng.1 > /sys/class/misc/hw_random/rng_current 6.Recheck if it works # dd if=/dev/hwrng of=/dev/null bs=512 count=100 100+0 records in 100+0 records out 51200 bytes (51 kB) copied,0.0672739 s,761 kB/s So according to above, this bug is fixed. Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHSA-2015-0290.html |