Hide Forgot
Version-Release number of selected component (if applicable): libvirt-2.0.0-10.el7 How reproducible: 100 % Steps to Reproduce: 1. start a new domain 2. restart libvirtd 3. attach a USB device: $ cat disk.xml <disk type='file' device='disk'> <driver name='qemu' type='raw'/> <source file='/var/lib/libvirt/images/raw'/> <backingStore/> <target dev='sda' bus='usb'/> </disk> $ virsh attach-device domain disk.xml Actual results: The device does not get a USB address. Expected results: The device does get a USB address. Additional info:
Proposed upstream patch: https://www.redhat.com/archives/libvir-list/2016-October/msg00972.html
I can reproduce it. Version: libvirt-2.0.0-10.el7.x86_64 qemu-kvm-rhev-2.6.0-28.el7.x86_64 Steps : 1. start a guest # virsh list Id Name State ---------------------------------------------------- 19 vm1 running 2. restart libvirtd # systemctl restart libvirtd 3. prepare an usb virtual disk, hotplug to guest # cat usb_file_disk1.xml <disk type='file' device='disk'> <driver name='qemu' type='raw'/> <source file='/mnt/USB/usb1.img'/> <target dev='sdc' bus='usb'/> </disk> # virsh attach-device vm1 usb_file_disk1.xml Device attached successfully 4. dumpxml to check # virsh dumpxml vm1 | grep disk -A 9 ...... <disk type='file' device='disk'> <driver name='qemu' type='raw'/> <source file='/mnt/USB/usb1.img'> <seclabel model='selinux' labelskip='yes'/> </source> <backingStore/> <target dev='sdc' bus='usb'/> <alias name='usb-disk2'/> </disk> ...... 5. prepare a usb host device # cat usb_hostdev.xml <hostdev mode='subsystem' type='usb' managed='no'> <source startupPolicy='optional'> <address bus='2' device='4'/> </source> </hostdev> # virsh attach-device vm1 usb_hostdev.xml Device attached successfully # virsh dumpxml vm1 | grep hostdev -A 5 ...... <hostdev mode='subsystem' type='usb' managed='no'> <source startupPolicy='optional'> <address bus='2' device='4'/> </source> <alias name='hostdev0'/> </hostdev> ...... After libvirtd restart, hotplugged USB devices cannot generate addresses.
Fixed upstream by: commit dc67d00cd22844dbe4c57134e3ab21abd6742235 Author: Ján Tomko <jtomko> CommitDate: 2016-10-27 13:38:56 +0200 Recreate the USB address cache at reconnect When starting a new domain, we allocate the USB addresses and keep an address cache in the domain object's private data. However this data is lost on libvirtd restart. Also generate the address cache if all the addresses have been specified, so that devices hotplugged after libvirtd restart also get theirs assigned. https://bugzilla.redhat.com/show_bug.cgi?id=1387666 git describe: v2.3.0-220-gdc67d00
Verify version : libvirt-3.2.0-3.el7.x86_64 qemu-kvm-rhev-2.9.0-1.el7.x86_64 Steps : 1. Prepare a guest with USB controller. # virsh list Id Name State ---------------------------------------------------- 5 r74 running 2. Restart libvirtd service # systemctl restart libvirtd 3.Prepare an usb disk with address, hotplug this disk # cat vusb.xml <disk type='block' device='disk'> <driver name='qemu' type='raw'/> <source dev='/dev/sdb9'/> <target dev='sde' bus='usb'/> </disk> # virsh attach-device r74 vusb.xml Device attached successfully 4. Check guest xml, the hotplugged USB device can generated address # virsh dumpxml r74|grep disk -A 9 <disk type='block' device='disk'> <driver name='qemu' type='raw'/> <source dev='/dev/sdb9'/> <backingStore/> <target dev='sde' bus='usb'/> <alias name='usb-disk4'/> <address type='usb' bus='0' port='3'/> </disk> 5. Prepare a USB hostdev device with address, hotplug it to guest # cat hostdev.xml <hostdev mode='subsystem' type='usb' managed='no'> <source startupPolicy='optional'> <address bus='2' device='6'/> </source> </hostdev> # virsh attach-device r74 hostdev.xml Device attached successfully 6.check guest xml, hotplugged USB hostdev device can generated address # virsh dumpxml r74 | grep hostdev -A 6 <hostdev mode='subsystem' type='usb' managed='no'> <source startupPolicy='optional'> <address bus='2' device='6'/> </source> <alias name='hostdev0'/> <address type='usb' bus='0' port='4'/> </hostdev> As above, after libvirtd restart, hotplugged USB devices can generate addresses.
Thanks for your info. Filed Bug 1447505 to track comment 6. As steps in comment 5, move this bug to verified.
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://access.redhat.com/errata/RHEA-2017:1846