RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1387666 - USB addresses are not assigned on hotplug after libvirtd restart
Summary: USB addresses are not assigned on hotplug after libvirtd restart
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.3
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Ján Tomko
QA Contact: Pei Zhang
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-10-21 13:41 UTC by Ján Tomko
Modified: 2017-08-01 23:59 UTC (History)
6 users (show)

Fixed In Version: libvirt-2.5.0-1.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-08-01 17:19:14 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2017:1846 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2017-08-01 18:02:50 UTC

Description Ján Tomko 2016-10-21 13:41:36 UTC
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:

Comment 1 Ján Tomko 2016-10-21 14:00:06 UTC
Proposed upstream patch:
https://www.redhat.com/archives/libvir-list/2016-October/msg00972.html

Comment 2 Pei Zhang 2016-10-25 05:51:14 UTC
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.

Comment 3 Ján Tomko 2016-10-27 11:46:37 UTC
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

Comment 5 Pei Zhang 2017-04-26 02:16:12 UTC
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.

Comment 8 Pei Zhang 2017-05-03 03:17:45 UTC
Thanks for your info.
Filed Bug 1447505 to track comment 6.
As steps in comment 5, move this bug to verified.

Comment 9 errata-xmlrpc 2017-08-01 17:19:14 UTC
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

Comment 10 errata-xmlrpc 2017-08-01 23:59:00 UTC
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


Note You need to log in before you can comment on or make changes to this bug.