Bug 1046267 - Libvirt can not assign particular USB controller to USB disk in Domain
Summary: Libvirt can not assign particular USB controller to USB disk in Domain
Keywords:
Status: CLOSED DUPLICATE of bug 1215968
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.0
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Martin Kletzander
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-12-24 09:40 UTC by Hu Jianwei
Modified: 2015-07-22 14:18 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-07-22 14:18:33 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description Hu Jianwei 2013-12-24 09:40:45 UTC
Description of problem:
Libvirt can not assign particular USB controller to USB disk in Domain

Version-Release number of selected component (if applicable):
libvirt-1.1.1-16.el7.x86_64
qemu-kvm-rhev-1.5.3-21.el7.x86_64
kernel-3.10.0-60.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Add some USB disks to domain xml
...
<disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/usb-img/usb-1.img'/>
      <target dev='sda' bus='usb'/>
    </disk>
<disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/usb-img/usb-2.img'/>
      <target dev='sdb' bus='usb'/>
    </disk>
...

2. Added more than 2 USB controller to domain xml
 ...  
   <controller type='usb' index='0'>
      <alias name='usb0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <controller type='usb' index='1'>
      <alias name='usb1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </controller>
    <controller type='usb' index='2'>
      <alias name='usb2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </controller>
    <controller type='usb' index='3'>
      <alias name='usb3'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </controller>
...

3. Enter into guest OS to check those usb devices
[root@localhost ~]# lsusb -t
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
    |__ Port 1: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 12M
    |__ Port 2: Dev 3, If 0, Class=Hub, Driver=hub/8p, 12M
        |__ Port 1: Dev 4, If 0, Class=Mass Storage, Driver=usb-storage, 12M
        |__ Port 2: Dev 5, If 0, Class=Mass Storage, Driver=usb-storage, 12M
        |__ Port 3: Dev 6, If 0, Class=Mass Storage, Driver=usb-storage, 12M
        |__ Port 4: Dev 7, If 0, Class=Mass Storage, Driver=usb-storage, 12M
        |__ Port 5: Dev 8, If 0, Class=Mass Storage, Driver=usb-storage, 12M
        |__ Port 6: Dev 9, If 0, Class=Mass Storage, Driver=usb-storage, 12M
        |__ Port 7: Dev 10, If 0, Class=Mass Storage, Driver=usb-storage, 12M
        |__ Port 8: Dev 11, If 0, Class=Hub, Driver=hub/8p, 12M
            |__ Port 1: Dev 12, If 0, Class=Mass Storage, Driver=usb-storage, 12M
            |__ Port 2: Dev 13, If 0, Class=Mass Storage, Driver=usb-storage, 12M
            |__ Port 3: Dev 14, If 0, Class=Mass Storage, Driver=usb-storage, 12M
            |__ Port 4: Dev 15, If 0, Class=Mass Storage, Driver=usb-storage, 12M
            |__ Port 5: Dev 16, If 0, Class=Mass Storage, Driver=usb-storage, 12M
            |__ Port 6: Dev 17, If 0, Class=Mass Storage, Driver=usb-storage, 12M
            |__ Port 7: Dev 18, If 0, Class=Mass Storage, Driver=usb-storage, 12M
            |__ Port 8: Dev 19, If 0, Class=Hub, Driver=hub/8p, 12M
                |__ Port 1: Dev 20, If 0, Class=Mass Storage, Driver=usb-storage, 12M
                |__ Port 2: Dev 21, If 0, Class=Mass Storage, Driver=usb-storage, 12M
                |__ Port 3: Dev 22, If 0, Class=Mass Storage, Driver=usb-storage, 12M
                |__ Port 4: Dev 23, If 0, Class=Mass Storage, Driver=usb-storage, 12M
                |__ Port 5: Dev 24, If 0, Class=Mass Storage, Driver=usb-storage, 12M
                |__ Port 6: Dev 25, If 0, Class=Mass Storage, Driver=usb-storage, 12M
                |__ Port 7: Dev 26, If 0, Class=Mass Storage, Driver=usb-storage, 12M
                |__ Port 8: Dev 27, If 0, Class=Hub, Driver=hub/8p, 12M
                    |__ Port 1: Dev 28, If 0, Class=Mass Storage, Driver=usb-storage, 12M
                    |__ Port 2: Dev 29, If 0, Class=Mass Storage, Driver=usb-storage, 12M
                    |__ Port 3: Dev 30, If 0, Class=Mass Storage, Driver=usb-storage, 12M
                    |__ Port 4: Dev 31, If 0, Class=Mass Storage, Driver=usb-storage, 12M
                    |__ Port 5: Dev 32, If 0, Class=Mass Storage, Driver=usb-storage, 12M
                    |__ Port 6: Dev 33, If 0, Class=Mass Storage, Driver=usb-storage, 12M
                    |__ Port 7: Dev 34, If 0, Class=Mass Storage, Driver=usb-storage, 12M
                    |__ Port 8: Dev 35, If 0, Class=Hub, Driver=hub/8p, 12M
                        |__ Port 1: Dev 36, If 0, Class=Mass Storage, Driver=usb-storage, 12M
                        |__ Port 2: Dev 37, If 0, Class=Mass Storage, Driver=usb-storage, 12M
                        |__ Port 3: Dev 38, If 0, Class=Mass Storage, Driver=usb-storage, 12M
                        |__ Port 4: Dev 39, If 0, Class=Mass Storage, Driver=usb-storage, 12M
                        |__ Port 5: Dev 40, If 0, Class=Mass Storage, Driver=usb-storage, 12M
                        |__ Port 6: Dev 41, If 0, Class=Mass Storage, Driver=usb-storage, 12M
                        |__ Port 7: Dev 42, If 0, Class=Mass Storage, Driver=usb-storage, 12M
                        |__ Port 8: Dev 43, If 0, Class=Mass Storage, Driver=usb-storage, 12M
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
[root@localhost ~]#

4. To check the address of USB devices
# virsh dumpxml rhel
<domain type='kvm' id='7'>
  <name>rhel</name>
  <uuid>205c40e0-e917-47fe-9c4a-1f35748ffd21</uuid>
  <memory unit='KiB'>1048576</memory>
  <currentMemory unit='KiB'>1048576</currentMemory>
 ...
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='none'/>
      <source file='/mnt/jiahu/images/rhel.img'>
        <seclabel model='selinux' labelskip='yes'/>
      </source>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>  
    </disk>
    <disk type='file' device='disk'>                                            
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/usb-img/usb-1.img'/>
      <target dev='sda' bus='usb'/>                                        <======== no USB bus related address or bus address assigned to usb disk.
      <alias name='usb-disk0'/>                      
    </disk>
...

5. Assign one <address> line to USB disk like scsi disk.

[root@ibm-x3650m3-03 ~]# virsh dumpxml r7
...(snipped)
 <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/usb-img/usb-1.img'/>
      <target dev='sda' bus='usb'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>  =======> added
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/usb-img/usb-2.img'/>
      <target dev='sdb' bus='usb'/>
      <address type='drive' controller='1' bus='0' target='0' unit='0'/>  =======> added
    </disk>
...(snipped)

6. Check the usb controller,the controllers can not be generated automatically.(scsi controllers were generated automatically.)
[root@ibm-x3650m3-03 ~]# virsh dumpxml r7
...(snipped)
 <controller type='scsi' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </controller>
    <controller type='scsi' index='1'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
    </controller>
    <controller type='usb' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
...(snipped)

Actual results:
I found all USB disk had been attached to same USB controller(default) automatically, maybe this is default routine. However I want to assign some USB disks to another controller manually but I can't find the entry.

qemu-kvm has provided command line to support it by using "bus" argument.(like: device_add usb-storage,id=my_usb_disk,drive=my_usb_disk,bus=usb.0 )

Expected results:
Libvirt should provide entry to configure this feature, like scsi disk below:

<disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='none'/>
      <source file='/var/lib/libvirt/images/iscsi_1.img'/>
      <target dev='sda' bus='scsi'/>
      <address type='drive' controller='1' bus='0' target='0' unit='0'/>      <===here
    </disk>

Comment 7 Martin Kletzander 2015-07-22 14:15:39 UTC
Moreover, the problem here is that we do not generate the address automatically, but we leave it to qemu and then we don't know what address qemu picked.

Comment 8 Martin Kletzander 2015-07-22 14:18:33 UTC
This is actually the same as Bug 1215968 and Bug 1176772, so I'll mark it as a duplicate.

*** This bug has been marked as a duplicate of bug 1215968 ***


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