diff --git a/lib/constants.py b/lib/constants.py index 0ce3927d05bcad42f46ce378ba7dc78fb1935589..759ab3e01ad303fe3c8cba7a25eb0f64edbbab25 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -748,6 +748,27 @@ ENFORCEABLE_TYPES = compat.UniqueFrozenset([ # Constant representing that the user does not specify any IP version IFACE_NO_IP_VERSION_SPECIFIED = 0 +VALID_SERIAL_SPEEDS = compat.UniqueFrozenset([ + 75, + 110, + 300, + 600, + 1200, + 1800, + 2400, + 4800, + 9600, + 14400, + 19200, + 28800, + 38400, + 57600, + 115200, + 230400, + 345600, + 460800, + ]) + # HV parameter names (global namespace) HV_BOOT_ORDER = "boot_order" HV_CDROM_IMAGE_PATH = "cdrom_image_path" @@ -782,6 +803,7 @@ HV_KERNEL_PATH = "kernel_path" HV_INITRD_PATH = "initrd_path" HV_ROOT_PATH = "root_path" HV_SERIAL_CONSOLE = "serial_console" +HV_SERIAL_SPEED = "serial_speed" HV_USB_MOUSE = "usb_mouse" HV_KEYMAP = "keymap" HV_DEVICE_MODEL = "device_model" @@ -841,6 +863,7 @@ HVS_PARAMETER_TYPES = { HV_INITRD_PATH: VTYPE_STRING, HV_ROOT_PATH: VTYPE_MAYBE_STRING, HV_SERIAL_CONSOLE: VTYPE_BOOL, + HV_SERIAL_SPEED: VTYPE_INT, HV_USB_MOUSE: VTYPE_STRING, HV_KEYMAP: VTYPE_STRING, HV_DEVICE_MODEL: VTYPE_STRING, @@ -1887,6 +1910,7 @@ HVC_DEFAULTS = { HV_ROOT_PATH: "/dev/vda1", HV_ACPI: True, HV_SERIAL_CONSOLE: True, + HV_SERIAL_SPEED: 38400, HV_VNC_BIND_ADDRESS: "", HV_VNC_TLS: False, HV_VNC_X509: "", diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py index 2fd3684e5cd1cf905a6badf448c812691b68da6e..e77d1c27dfd9ec04149a94cc76f09fbe0cfa1455 100644 --- a/lib/hypervisor/hv_kvm.py +++ b/lib/hypervisor/hv_kvm.py @@ -466,6 +466,7 @@ class KVMHypervisor(hv_base.BaseHypervisor): constants.HV_KERNEL_ARGS: hv_base.NO_CHECK, constants.HV_ACPI: hv_base.NO_CHECK, constants.HV_SERIAL_CONSOLE: hv_base.NO_CHECK, + constants.HV_SERIAL_SPEED: hv_base.NO_CHECK, constants.HV_VNC_BIND_ADDRESS: (False, lambda x: (netutils.IP4Address.IsValid(x) or utils.IsNormAbsPath(x)), @@ -1135,7 +1136,8 @@ class KVMHypervisor(hv_base.BaseHypervisor): root_append = ["root=%s" % hvp[constants.HV_ROOT_PATH], hvp[constants.HV_KERNEL_ARGS]] if hvp[constants.HV_SERIAL_CONSOLE]: - root_append.append("console=ttyS0,38400") + serial_speed = hvp[constants.HV_SERIAL_SPEED] + root_append.append("console=ttyS0,%s" % serial_speed) kvm_cmd.extend(["-append", " ".join(root_append)]) mem_path = hvp[constants.HV_MEM_PATH] @@ -1949,6 +1951,14 @@ class KVMHypervisor(hv_base.BaseHypervisor): (constants.HV_VNC_X509, constants.HV_VNC_X509_VERIFY)) + if hvparams[constants.HV_SERIAL_CONSOLE]: + serial_speed = hvparams[constants.HV_SERIAL_SPEED] + valid_speeds = constants.VALID_SERIAL_SPEEDS + if not serial_speed or serial_speed not in valid_speeds: + raise errors.HypervisorError("Invalid serial console speed, must be" + " one of: %s" % + utils.CommaJoin(valid_speeds)) + boot_order = hvparams[constants.HV_BOOT_ORDER] if (boot_order == constants.HT_BO_CDROM and not hvparams[constants.HV_CDROM_IMAGE_PATH]): diff --git a/man/gnt-instance.rst b/man/gnt-instance.rst index 23526d27081abfc73896c38f23dfa219c3b0b82a..f22ee5d2ff4fcd5b34f84d72fadc8bebee51082c 100644 --- a/man/gnt-instance.rst +++ b/man/gnt-instance.rst @@ -473,6 +473,14 @@ serial\_console This boolean option specifies whether to emulate a serial console for the instance. +serial\_speed + Valid for the KVM hypervisor. + + This integer option specifies the speed of the serial console. + Common values are 9600, 19200, 38400, 57600 and 115200: choose the + one which works on your system. (The default is 38400 for historical + reasons, but newer versions of kvm/qemu work with 115200) + disk\_cache Valid for the KVM hypervisor.