[kolla-ansible][all][nova][zed][latest] USB passthrough / Hot-plug / Cold-plug

Sean Mooney smooney at redhat.com
Tue May 2 15:43:07 UTC 2023


On Sun, 2023-04-30 at 13:34 +0330, Modyngs wrote:
> 090c090cFolks,
> 
> A USB device (not necessarily a mass/Flash drive) needs to be connected to
> one of the VMs (an openstack instance).
> 
> Openstack installed with kolla-ansible{Latest version/ Also tested on Zed}
> ALL IN ONE Deployments on ubuntu server 22.04 ( Core i9 12900K).
> 
> I found the [nova-libvirt] container which contains *virsh *and is able to
> edit it or use custom config for VMs.
> 
> I've gone through lots of the docs, to name a few:
> https://libvirt.org/formatdomain.html
> https://wiki.openstack.org/wiki/Nova/USB_device_hot_cold_plug
> https://wiki.openstack.org/wiki/Nova/proposal_about_usb_passthrough
> https://documentation.suse.com/sles/15-SP1/html/SLES-all/cha-libvirt-config-virsh.html
> https://wiki.openstack.org/wiki/Nova/USB_device_hot_cold_plug
> https://docs.nxp.com/bundle/GUID-487B2E69-BB19-42CB-AC38-7EF18C0FE3AE/page/GUID-A658B311-CE08-4496-9491-1F00687EC4AE.html
> 
> but none of them worked for me!!
we do not supprot usb passthough in nova

the only way to do this is by doing pci passthough of a usb contoller but there is no support offically for usb pasthoough

currently we do not plan to add it in the future either and instead suggest that support be added to cybrog
and then that leveraged with nova.

for stateles device is would not be hard to add supprot in nova but there has been relucatance to do that.
> 
> To reproduce:
> 
> *Cold-Plug :*
> *$ lsusb  (on host)*
> Bus 001 Device 014: ID 090c:1000 Silicon Motion >>>> Note Device number
> changed every time I disconnect the device. So it might be different in the
> changed attempt shown below)
> 
> *$ docker exec -it nova_libvirt /bin/bash*
> *%Turn the Desired VM off*
> *# virsh list --all*
>  Id   Name                State
> ---------------------------------------------
>  2    instance-00000002   running
> 19   instance-00000008   running
>   -    instance-0000000a   shut off
> *# virsh edit instance-0000000a*
>                     Add the changes [1][2][3][4],... ( many efforts have
> been done but few samples of them are)
> [1]: under <devices> added
> 
> <hostdev mode='subsystem' type='usb'>
>   <source>
>     <vendor id='0x090c'/>
>     <product id='0x1000'/>
>   </source>
> </hostdev>
> 
> [2]:under <devices> added
> 
>   <controller type='usb' index='0'/>
>   <hostdev mode='subsystem' type='usb'>
>     <source>
>       <vendor id='0x090c'/>
>       <product id='0x1000'/>
>     </source>
>   </hostdev>
> 
> [3]: under <devices> added
> 
> <hostdev mode='subsystem' type='usb' managed='yes'>https://egallen.com/openstack-usb-passthrough/
>   <source>
>     <vendor id='0x090c'/>
>     <product id='0x1000'/>
>   </source>
>   <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
> </hostdev>
> 
> [4]: under <devices> added
> 
> <controller type='usb' model='nec-xhci' index='0'/>
>   <hostdev mode='subsystem' type='usb' managed='yes'>
>     <source>
>       <vendor id='0x090c'/>
>       <product id='0x1000'/>
>     </source>
>     <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
>   </hostdev>
> 
> [5]:
> 
> <controller type='usb' index='0'>
>   <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
> </controller>
> <hostdev mode='subsystem' type='usb' managed='yes'>
>   <source>
>     <vendor id='0x090c'/>
>     <product id='0x1000'/>
>   </source>
>   <address type='usb' bus='1' port='2'/>
>   <controller type='usb' index='0'/>
> </hostdev>
> 
> 
> *%Start the VM*
> *expected behavior:*
>           when login to the VM, lsusb or df -h shows the USB
> *what happened:*
>           it wont show the USB from the VM
> 
> *OR *virsh dumpxml instance-0000000a > instance-0000000a.xml
> and then change the configs as above and then
> 
> virsh attach-device instance-0000000a --file
> /path/to/updated-instance-0000000a.xml --config
> 
> 
> *Hot-Plug :*
> *$ lsusb  (on host)*
> Bus 001 Device 014: ID 090c:1000 Silicon Motion >>>> Note Device number
> changed every time I disconnect the device. So it might be different in the
> changed attempt shown below)
> 
> *$ docker exec -it nova_libvirt /bin/bash*
> *# virsh list --all*
>  Id   Name                State
> ---------------------------------------------
>  2    instance-00000002   running
> 19   instance-00000008   running
> 20   instance-0000000a   running
> 
> 
> *#nano USB.xml*
> *%add changes explained in *[1][2][3][4],...
> 
> *$ virsh attach-device  instance-0000000a   /path/to/USB.xml/file*
> 
> *expected behavior:*
>           lsusb or df -h shows the USB
> *what happened:*
>           it wont show the USB from the VM
> 
> 
> 
> 
> *Can you please guide me through this? Any recommendation would be much
> appreciated!Any custom changes comes to your mind ( Reply it) would be
> solution for this problem /;*
as noted above this is not a supported feature of nova.
there is no offical way to do usb passthough.
the unoffical way to do this is https://egallen.com/openstack-usb-passthrough/

> Thanks
> Best regards




More information about the openstack-discuss mailing list