Commit 156681c1 authored by Guido Trotter's avatar Guido Trotter
Browse files

kvm: support usb devices



All in one go, comma separated usb devices of all types.
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 2fddb144
......@@ -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: {
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment