Bug 1656014
Summary: | Libvirt doesn't unplug RNG fully | ||
---|---|---|---|
Product: | Red Hat Enterprise Linux Advanced Virtualization | Reporter: | Michal Privoznik <mprivozn> |
Component: | libvirt | Assignee: | Michal Privoznik <mprivozn> |
Status: | CLOSED CURRENTRELEASE | QA Contact: | Yanqiu Zhang <yanqzhan> |
Severity: | unspecified | Docs Contact: | |
Priority: | unspecified | ||
Version: | 8.0 | CC: | jdenemar, xuzhang, yalzhang, yanqzhan |
Target Milestone: | rc | Keywords: | TestOnly, Upstream |
Target Release: | 8.0 | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | libvirt-5.0.0-1.el8 | Doc Type: | If docs needed, set a value |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2020-03-11 22:32:49 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: | 1543416 |
Description
Michal Privoznik
2018-12-04 13:19:21 UTC
Patches proposed upstream: https://www.redhat.com/archives/libvir-list/2018-December/msg00069.html I've just pushed the patch upstream: commit 7730a2ead4279e3a11771e1069096747988410cf Author: Michal Privoznik <mprivozn> AuthorDate: Tue Dec 4 14:30:37 2018 +0100 Commit: Michal Privoznik <mprivozn> CommitDate: Wed Dec 5 15:07:29 2018 +0100 qemuDomainRemoveRNGDevice: Remove associated chardev too https://bugzilla.redhat.com/show_bug.cgi?id=1656014 An RNG device can consists of more devices than RND device itself. For instance, in case of EGD there is a chardev that connects to EGD daemon and feeds the qemu with random data. When doing RNG device removal we have to remove the associated chardev as well. Signed-off-by: Michal Privoznik <mprivozn> Reviewed-by: Ján Tomko <jtomko> v4.10.0-24-g7730a2ead4 Reproduced on latest rhel7.6.z: libvirt-4.5.0-10.el7_6.3.x86_64 qemu-kvm-rhev-2.12.0-19.el7_6.2.x86_64 Follow steps in comment 0, get error: # virsh attach-device rhel7.6 udp-connect.xml error: Failed to attach device from udp-connect.xml error: internal error: unable to execute QEMU command 'chardev-add': attempt to add duplicate property 'charrng0' to object (type 'container') Verify this bug with: libvirt-daemon-5.0.0-11.module+el8.0.1+3459+e357ef2f.x86_64 qemu-kvm-3.1.0-27.module+el8.0.1+3253+c5371cb3.x86_64 (Egd rng devices are hard to be removed due to Bug 1543416, and if with udp rng dev, rhel8 guest os can not be accessed due to Bug 1660802, except "tcp connect mode rng dev". So using this one as an example to verify this bug.) Steps: 1. Start a guest with tcp connect mode egd rng device: # cat /dev/urandom |nc -l 1024 # virsh start avocado-vt-vm1 Domain avocado-vt-vm1 started Check qemu cli, 3 parameters for egd rng dev: "chardev, object, device" # ps aux|grep qemu|grep rng ... -chardev socket,id=charrng0,host=localhost,port=1024 -object rng-egd,id=objrng0,chardev=charrng0 -device virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.6,addr=0x0 # virsh dumpxml avocado-vt-vm1|grep rng -3 ... <rng model='virtio'> <backend model='egd' type='tcp'> <source mode='connect' host='localhost' service='1024' tls='no'/> <protocol type='raw'/> </backend> <alias name='rng0'/> <address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/> </rng> ... [In guest]# python3 >>> import os >>> f=os.open('/dev/hwrng', os.O_RDONLY) >>> os.read(f,10) b'iI\x0c\xc0bN\x8e\x80\x11\x7f' >>> 2. Hot-unplug the egd rng device: # cat rng-tcp.xml <rng model='virtio'> <backend model='egd' type='tcp'> <source mode='connect' host='localhost' service='1024'/> <protocol type='raw'/> </backend> </rng> # virsh detach-device avocado-vt-vm1 rng-tcp.xml Device detached successfully # virsh dumpxml avocado-vt-vm1|grep rng -3 [In guest]# cat /dev/hwrng cat: /dev/hwrng: No such device Check libvirtd.log, 3 are all deleted separately by: "qemuMonitorDelDevice, qemuMonitorDelObject, qemuMonitorDetachCharDev" # cat libvirt.log-rng |grep -E "Del|CharDev" 2019-07-08 09:04:00.516+0000: 9286: debug : ***qemuMonitorDelDevice***:3011 : devalias=rng0 2019-07-08 09:04:00.516+0000: 9286: debug : qemuMonitorDelDevice:3013 : mon:0x7f096c0d23c0 vm:0x7f09141ae4d0 json:1 fd:30 2019-07-08 09:04:06.912+0000: 9282: debug : qemuMonitorJSONHandleDeviceDeleted:1127 : missing device in device deleted event 2019-07-08 09:04:06.965+0000: 9282: debug : qemuMonitorEmitDeviceDeleted:1544 : mon=0x7f096c0d23c0 2019-07-08 09:04:06.965+0000: 9282: debug : qemuProcessHandleDeviceDeleted:1301 : Device rng0 removed from domain 0x7f09141ae4d0 avocado-vt-vm1 2019-07-08 09:04:06.966+0000: 9920: debug : processDeviceDeletedEvent:4278 : Removing device rng0 from domain 0x7f09141ae4d0 avocado-vt-vm1 2019-07-08 09:04:06.966+0000: 9920: debug : ***qemuMonitorDelObject***:3187 : objalias=objrng0 2019-07-08 09:04:06.966+0000: 9920: debug : qemuMonitorDelObject:3189 : mon:0x7f096c0d23c0 vm:0x7f09141ae4d0 json:1 fd:30 2019-07-08 09:04:06.971+0000: 9920: debug : ***qemuMonitorDetachCharDev***:4004 : chrID=charrng0 2019-07-08 09:04:06.972+0000: 9920: debug : qemuMonitorDetachCharDev:4006 : mon:0x7f096c0d23c0 vm:0x7f09141ae4d0 json:1 fd:30 3.Hotplug the egd rng device again: # cat /dev/urandom |nc -l 1024 # virsh attach-device avocado-vt-vm1 rng-tcp.xml Device attached successfully Additional info: 1.With same steps, bug can be reproduced on rhel7.6 with error below in step3: "unable to execute QEMU command 'chardev-add': attempt to add duplicate property 'charrng0' to object (type 'container')" And in step2, will see from libvirtd.log, no "qemuMonitorDetachCharDev" action when detach the egd rng device. # cat libvirtd.log-rng |grep -E "Del|CharDev" 2019-07-08 11:20:38.429+0000: 28197: debug : ***qemuMonitorDelDevice***:2976 : devalias=rng0 2019-07-08 11:20:38.429+0000: 28197: debug : qemuMonitorDelDevice:2978 : mon:0x7fab240137f0 vm:0x7faad82a7940 json:1 fd:29 2019-07-08 11:20:38.670+0000: 28192: debug : qemuMonitorJSONHandleDeviceDeleted:1102 : missing device in device deleted event 2019-07-08 11:20:38.719+0000: 28192: debug : qemuMonitorEmitDeviceDeleted:1544 : mon=0x7fab240137f0 2019-07-08 11:20:38.719+0000: 28192: debug : qemuProcessHandleDeviceDeleted:1279 : Device rng0 removed from domain 0x7faad82a7940 avocado-vt-vm1 2019-07-08 11:20:38.719+0000: 28197: debug : ***qemuMonitorDelObject***:3152 : objalias=objrng0 2019-07-08 11:20:38.719+0000: 28197: debug : qemuMonitorDelObject:3154 : mon:0x7fab240137f0 vm:0x7faad82a7940 json:1 fd:29 This was verified and shipped long ago. Closing the bug report. |