diff --git a/lib/constants.py b/lib/constants.py index a5a758d4ce0379a1b79dd4ba5c58142e07d51ecd..13449519529cfb218e739ebeebd0109ef670f49b 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -831,6 +831,7 @@ HV_CPU_CORES = "cpu_cores" HV_CPU_THREADS = "cpu_threads" HV_CPU_SOCKETS = "cpu_sockets" HV_SOUNDHW = "soundhw" +HV_USB_DEVICES = "usb_devices" HVS_PARAMETER_TYPES = { @@ -895,6 +896,7 @@ HVS_PARAMETER_TYPES = { HV_CPU_THREADS: VTYPE_INT, HV_CPU_SOCKETS: VTYPE_INT, HV_SOUNDHW: VTYPE_STRING, + HV_USB_DEVICES: VTYPE_STRING, } HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys()) @@ -1963,6 +1965,7 @@ HVC_DEFAULTS = { HV_CPU_THREADS: 0, HV_CPU_SOCKETS: 0, HV_SOUNDHW: "", + HV_USB_DEVICES: "", }, HT_FAKE: {}, HT_CHROOT: { diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py index aa629b5c7efd443d3a44dcff21b19ce5ebb7235c..47b033058539b1eaa682314d9ca7f308e9a2447b 100644 --- a/lib/hypervisor/hv_kvm.py +++ b/lib/hypervisor/hv_kvm.py @@ -536,6 +536,7 @@ class KVMHypervisor(hv_base.BaseHypervisor): constants.HV_CPU_THREADS: hv_base.OPT_NONNEGATIVE_INT_CHECK, constants.HV_CPU_SOCKETS: hv_base.OPT_NONNEGATIVE_INT_CHECK, constants.HV_SOUNDHW: hv_base.NO_CHECK, + constants.HV_USB_DEVICES: hv_base.NO_CHECK, } _MIGRATION_STATUS_RE = re.compile("Migration\s+status:\s+(\w+)", @@ -1339,6 +1340,11 @@ class KVMHypervisor(hv_base.BaseHypervisor): if hvp[constants.HV_SOUNDHW]: kvm_cmd.extend(["-soundhw", hvp[constants.HV_SOUNDHW]]) + # Various types of usb devices, comma separated + if hvp[constants.HV_USB_DEVICES]: + for dev in hvp[constants.HV_USB_DEVICES].split(","): + kvm_cmd.extend(["-usbdevice", dev]) + # Save the current instance nics, but defer their expansion as parameters, # as we'll need to generate executable temp files for them. kvm_nics = instance.nics diff --git a/man/gnt-instance.rst b/man/gnt-instance.rst index 9837e5cccc002c8b956b8a1babb0980982ec596f..276c824a665584cb7fbfc3de5e4fd963ccb7e3c1 100644 --- a/man/gnt-instance.rst +++ b/man/gnt-instance.rst @@ -655,6 +655,14 @@ soundhw Comma separated list of emulated sounds cards, or "all" to enable all the available ones. +usb\_devices + Valid for the KVM hypervisor. + + Comma separated list of usb devices. These can be emulated devices + or passthrough ones, and each one gets passed to kvm with its own + ``-usbdevice`` option. See the **qemu**\(1) manpage for the syntax + of the possible components. + The ``-O (--os-parameters)`` option allows customisation of the OS parameters. The actual parameter names and values depends on the OS