diff --git a/lib/constants.py b/lib/constants.py index 91b5a7c18ad60bff0744b3a31e7db239ba4c2d1e..abfb1eafa687457cadaf9dee78f212e0805a2cc2 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -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: { }, diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py index df83538e293c9543abc1bdd1db1b19e6e7c655ee..964fe9c03674d0efc33498b4a8fa162dc09525c0 100644 --- a/lib/hypervisor/hv_kvm.py +++ b/lib/hypervisor/hv_kvm.py @@ -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.