Commit 11344a50 authored by Guido Trotter's avatar Guido Trotter
Browse files

KVM: Add usb mouse type parameter

In some cases 'mouse' may work better than 'tablet', so we'll handle
both by allowing the user to specify a parameter. By default no mouse is
used.

Reviewed-by: iustinp
parent 8745c3d7
......@@ -292,6 +292,7 @@ HV_KERNEL_PATH = "kernel_path"
HV_INITRD_PATH = "initrd_path"
HV_ROOT_PATH = "root_path"
HV_SERIAL_CONSOLE = "serial_console"
HV_USB_MOUSE = "usb_mouse"
HVS_PARAMETERS = frozenset([
HV_BOOT_ORDER,
......@@ -308,6 +309,7 @@ HVS_PARAMETERS = frozenset([
HV_INITRD_PATH,
HV_ROOT_PATH,
HV_SERIAL_CONSOLE,
HV_USB_MOUSE,
])
# BE parameter names
......@@ -481,6 +483,7 @@ HVC_DEFAULTS = {
HV_BOOT_ORDER: "disk",
HV_NIC_TYPE: HT_NIC_PARAVIRTUAL,
HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
HV_USB_MOUSE: None,
},
HT_FAKE: {
},
......
......@@ -62,6 +62,7 @@ class KVMHypervisor(hv_base.BaseHypervisor):
constants.HV_BOOT_ORDER,
constants.HV_NIC_TYPE,
constants.HV_DISK_TYPE,
constants.HV_USB_MOUSE,
]
_MIGRATION_STATUS_RE = re.compile('Migration\s+status:\s+(\w+)',
......@@ -285,10 +286,14 @@ class KVMHypervisor(hv_base.BaseHypervisor):
else:
kvm_cmd.extend(['-append', root_append])
mouse_type = instance.hvparams[constants.HV_USB_MOUSE]
if mouse_type:
kvm_cmd.extend(['-usb'])
kvm_cmd.extend(['-usbdevice', mouse_type])
# FIXME: handle vnc password
vnc_bind_address = instance.hvparams[constants.HV_VNC_BIND_ADDRESS]
if vnc_bind_address:
kvm_cmd.extend(['-usbdevice', 'tablet'])
if utils.IsValidIP(vnc_bind_address):
if instance.network_port > constants.VNC_BASE_PORT:
display = instance.network_port - constants.VNC_BASE_PORT
......@@ -784,6 +789,12 @@ class KVMHypervisor(hv_base.BaseHypervisor):
(disk_type,
constants.HT_KVM_VALID_DISK_TYPES))
mouse_type = hvparams[constants.HV_USB_MOUSE]
if mouse_type and mouse_type not in ('mouse', 'tablet'):
raise errors.HypervisorError("Invalid usb mouse type %s specified for"
" the KVM hyervisor. Please choose"
" 'mouse' or 'tablet'" % mouse_type)
def ValidateParameters(self, hvparams):
"""Check the given parameters for validity.
......
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