9.18.12.2. Connecting a USB device to a virtual machine
You can configure virtual machine (VM) access to a USB device. This configuration enables the VM to connect to USB hardware that is attached to an OpenShift Container Platform node, as if the hardware and the VM are physically connected.
Prerequisites
-
You have installed the OpenShift CLI (
oc). - You have attached the required USB device as a resource at the cluster level.
Procedure
In the
HyperConvergedcustom resource (CR), find the assigned resource name of the USB device:$ oc get hyperconverged kubevirt-hyperconverged -n openshift-cnvExample output
# ... spec: permittedHostDevices: usbHostDevices: - resourceName: kubevirt.io/peripherals selectors: - vendor: "045e" product: "07a5" - vendor: "062a" product: "4102" - vendor: "072f" product: "b100"Open the VM instance CR:
$ oc edit vmi <vmi_usb>where:
<vmi_usb>-
Specifies the name of the
VirtualMachineInstanceCR.
Edit the CR by adding the USB device, as shown in the following example:
Example configuration
apiVersion: kubevirt.io/v1 kind: VirtualMachineInstance metadata: labels: special: vmi-usb name: vmi-usb spec: domain: devices: hostDevices: - deviceName: kubevirt.io/peripherals name: local-peripherals # ...-
spec.domain.devices.hostDevices.namedefines the name of the USB device.
-
Apply the modifications to the VM configurations:
$ oc apply -f <filename>.yamlwhere:
- <filename>
-
Specifies the name of the
VirtualMachineInstancemanifest YAML file.