Jun
22
2012
libvirt hotplug usb device

You need to attach a usb device to a libvirt domain without rebooting the virtual machine.

Lets figure this together:

  1. Locate the usb device:

# lsusb -v

  idVendor           0x0781 SanDisk Corp.
  idProduct          0x5567 Cruzer Blade

  1. Build the below XML:

usb_device.xml


    <hostdev mode='subsystem' type='usb' managed='yes'>
      <source>
        <vendor id='0x0781'/>
        <product id='0x5567'/>
      </source>
    </hostdev>
  1. Attach device

# virsh attach-device VIRTUAL_MACHINE usb_device.xml

and if you want to de-attach:

  1. De-attache device

# virsh detach-device VIRTUAL_MACHINE usb_device.xml
Tag(s): libvirt
  1. Avatar di Boulate Boulate

    Thursday, June 26, 2014 - 14:34:43

    Thank you very much! You really help me!