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

Re: [libvirt-users] How to attach USB disk to specified USB controller in domian?



Is there anyone who know detailed address formats for particular USB controller in attached USB disk of Domain XML?

BR,
Jianwei
----- Original Message -----
From: "Jianwei Hu" <jiahu redhat com>
To: "Eric Blake" <eblake redhat com>, libvirt-users redhat com
Sent: Wednesday, December 18, 2013 11:21:36 AM
Subject: Re: [libvirt-users] How to attach USB disk to specified USB controller in domian?

Hi all,

According to Eric's approach, I dumped its xml, but can not find its address as mentioned in former mail(Or,is it a bug?). Could you show me a detailed example for my doubt, thanks.

# 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 other address assigned to it.
      <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>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/usb-img/usb-3.img'/>
      <target dev='sdc' bus='usb'/>
      <alias name='usb-disk2'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/usb-img/usb-4.img'/>
      <target dev='sdd' bus='usb'/>
      <alias name='usb-disk3'/>
    </disk>
...


BR,
Jianwei

----- Original Message -----
From: "Eric Blake" <eblake redhat com>
To: "Jianwei Hu" <jiahu redhat com>, libvirt-users redhat com
Sent: Tuesday, December 17, 2013 11:58:08 PM
Subject: Re: [libvirt-users] How to attach USB disk to specified USB controller in domian?

On 12/17/2013 02:47 AM, Jianwei Hu wrote:
> 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>

To force the guest to see the device under a particular UBS controller,
you need to include an <address> designation in your XML.

Check the 'virsh dumpxml' output to see what <address> got autogenerated
for your use case, then adjust the bus number in that address to instead
point to the controller number you want it associated with.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


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