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 1175668 - Attach a usb disk to guest failed.
Summary: Attach a usb disk to guest failed.
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.1
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Ján Tomko
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-12-18 10:23 UTC by lcheng
Modified: 2015-03-05 07:48 UTC (History)
7 users (show)

Fixed In Version: libvirt-1.2.8-12.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-03-05 07:48:29 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2015:0323 0 normal SHIPPED_LIVE Low: libvirt security, bug fix, and enhancement update 2015-03-05 12:10:54 UTC

Description lcheng 2014-12-18 10:23:30 UTC
Description of problem:
Attach a usb disk to guest failed.


Version-Release number of selected component (if applicable):
qemu-kvm-rhev-2.1.2-17.el7.x86_64
libvirt-1.2.8-10.el7.x86_64


How reproducible:
100%

Steps to Reproduce:
1. Add the following xml to guest xml. And then start guest.
    <disk type='block' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source dev='/dev/sdc'/>
      <target dev='sdg' bus='usb'/>
      <alias name='usb-disk6'/>
    </disk>

[root@localhost ~]# virsh start r7
Domain r7 started

[root@localhost ~]# virsh dumpxml r7
...
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/r7.qcow2'/>
      <backingStore/>
      <target dev='hda' bus='ide'/>
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='block' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source dev='/dev/sdc'/>
      <backingStore/>
      <target dev='sdg' bus='usb'/>
      <alias name='usb-disk6'/>
    </disk>

2. Attach the disk to guest.

[root@localhost ~]# cat disk.xml
<disk type='block' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source dev='/dev/sdc'/>
      <target dev='sdh' bus='usb'/>
      <alias name='virtio-disk0'/>
</disk>

[root@localhost ~]# virsh attach-device r7 disk.xml
Device attached successfully

[root@localhost ~]# virsh dumpxml r7 | grep -A10 disk
...
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/r7.qcow2'/>
      <backingStore/>
      <target dev='hda' bus='ide'/>
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='block' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source dev='/dev/sdc'/>
      <backingStore/>
      <target dev='sdg' bus='usb'/>
      <alias name='usb-disk6'/>
    </disk>
    <disk type='block' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source dev='/dev/sdc'/>
      <backingStore/>
      <target dev='sdh' bus='usb'/>
      <alias name='usb-disk7'/>
    </disk>

3. Destroy guest and remove the disk from guest xml.
[root@localhost ~]# virsh destroy r7
Domain r7 destroyed

[root@localhost ~]# virsh edit r7
Domain r7 XML configuration edited.

[root@localhost ~]# virsh start r7
Domain r7 started

[root@localhost ~]# virsh dumpxml r7 | grep -A10 disk
...
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/r7.qcow2'/>
      <backingStore/>
      <target dev='hda' bus='ide'/>
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
...

4. Attach the disk to guest again.
[root@localhost ~]# virsh attach-device r7 disk.xml
error: Failed to attach device from disk.xml
error: internal error: unable to execute QEMU command '__com.redhat_drive_add': Device 'drive-usb-disk7' could not be initialized


Actual results:
As steps.

Expected results:
The disk should be attached successfully.

Additional info:

Comment 2 Jiri Denemark 2014-12-18 11:43:02 UTC
Actually, this turns out to be a regression since 7.0 caused by Peter's refactoring.

Comment 4 Ján Tomko 2014-12-18 12:12:28 UTC
Upstream patch:
https://www.redhat.com/archives/libvir-list/2014-December/msg00934.html

Comment 5 Ján Tomko 2014-12-18 12:22:15 UTC
Now fixed upstream:
commit 1cddf0001f5f1af10791181229148f36fd6d94c5
Author:     Ján Tomko <jtomko>
CommitDate: 2014-12-18 12:53:56 +0100

    Fix hotplugging of block device-backed usb disks
    
    Commit ca91ba7 moved qemuSetupDiskCgroup into the qemuDomainPrepareDisk
    helper, but failed to call it for usb disks.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1175668`

git describe: v1.2.11-58-g1cddf00

Comment 8 Pei Zhang 2015-01-15 02:01:08 UTC
verify version:
kernel-3.10.0-222.el7.x86_64
qemu-kvm-rhev-2.1.2-18.el7.x86_64
libvirt-1.2.8-12.el7.x86_64

verify steps:
1.prepare a block disk like following

# cat block-disk.xml 
<disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/sdb'/>
      <target dev='sdg' bus='usb'/>
    </disk>

2.start a guest  which has no block-backed usb disks . 

# virsh dumpxml r7 | grep disk -A 8

  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/vm1.qcow2'/>
      <backingStore/>
      <target dev='hda' bus='ide'/>
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

3.attach the block disk , attach successfully 

# virsh attach-device r7 block-disk.xml 
Device attached successfully

4.chech domaim XML  
# virsh dumpxml r7 | grep disk -A 8
  
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/vm1.qcow2'/>
      <backingStore/>
      <target dev='hda' bus='ide'/>
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/sdb'/>
      <backingStore/>
      <target dev='sdg' bus='usb'/>
      <alias name='usb-disk6'/>
    </disk>

4.detach the hotplug disk
# virsh detach-device r7 block-disk.xml 
Device detached successfully

check domain XML ,detach successfully
# virsh dumpxml r7 |grep disk -A 9 |grep sdg

5.attach block device usb disk again 

# virsh attach-device r7 block-disk.xml 
Device attached successfully

# virsh dumpxml r7 |grep disk -A 9 | grep sdg
 
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/sdb'/>
      <backingStore/>
      <target dev='sdg' bus='usb'/>
      <alias name='usb-disk6'/>
    </disk>
block-backed usb device can be hotplug , move to verified.

Comment 10 errata-xmlrpc 2015-03-05 07:48:29 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://rhn.redhat.com/errata/RHSA-2015-0323.html


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