Problem
Virtual machines (VMs) with connected USB devices do not start automatically after the hypervisor reboot. They can be started only after physically reconnecting the devices to the server USB ports.
Cause
The configuration uses a strict binding of the USB device to a specific device ID. For example, bus='1' device='6'. After a reboot or reconnection, the device gets a new identifier. Libvirt cannot find the device by the old ID and blocks the VM start.
Diagnostics
To confirm the cause:
- Connect to the target cluster node via SSH. For more information about SSH connection, see the article Workstation setup.
- Open the USB device configuration XML file that you created when attaching the device. For example, /opt/USB/usb_device.xml:
cat /opt/USB/usb_device.xmlIn the example, the device is strictly bound to a specific deviceExample output<source> <address bus='1' device='6'/> </source>ID. This means that libvirt will look for the USB device with exactly this identifier. - Reboot the cluster node or reconnect the USB device.
- Determine the current USB device parameters:
lsusbExample outputBus 001 Device 003: ID 1234:5678 Some_USB_DeviceIf the
device IDidentifiers do not match, this confirms the cause. In the example, after reboot the device received a newdevice ID(device='3'), while the configuration specifiesdevice='6'.
Solution
To solve the issue, replace the binding by device ID with binding by vendor ID and product ID. These parameters remain unchanged after reboot:
- Connect to the target cluster node via SSH. For more information about SSH connection, see the article Workstation setup.
- Get the device
vendor IDandproduct ID:
lsusbExample outputBus 001 Device 003: ID 1234:5678 Some_USB_DeviceCommand notes:
1234— Vendor ID;5678— Product ID.
- Open the USB device configuration XML file in edit mode. For example, /opt/USB/usb_device.xml.
- Replace the block
<source> <address bus='1' device='6'/> </source>with
<source> <vendor id='0x1234'/> <product id='0x5678'/> </source> - Determine the VM internal name:
sudo virsh list --allIn the output, find the line for the required VM. The internal name usually has the format
ID VM_VM_name. - Detach the device with the old configuration:
virsh detach-device <vm_name> /opt/USB/usb_device.xmlCommand notes:
<vm_name>— the VM internal name.
- Attach the device with the new configuration:
virsh attach-device <vm_name> /opt/USB/usb_device.xml --config --persistentCommand notes:
<vm_name>— the VM internal name.
- Start the VM.
Related topics:
En
Es