How to attach USB disk to specified USB controller in domian?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi guys,

I want to attach a few USB disks to specified USB controller in domain on libvirt layer, but I didn't find any method to deal with it. Anyone can help me on that?

I added some USB type disk to my domain, started it, I found all USB disk had been attached to same USB controller automatically, 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 )

Action steps:
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'/>
      <alias name='usb-disk0'/>
    </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'/>
      <alias name='usb-disk1'/>
    </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 device
[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 ~]#

BR,
Jianwei


_______________________________________________
libvirt-users mailing list
libvirt-users@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvirt-users




[Index of Archives]     [Virt Tools]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]

  Powered by Linux