Commit 14fd6c81 authored by Guido Trotter's avatar Guido Trotter
Browse files

kvm: add serial console speed



The serial port speed changed between versions of qemu (what didn't?), so
the old hardcoded default doesn't do anymore. Upgrade it to a parameter.
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 83951b04
......@@ -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: "",
......
......@@ -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]):
......
......@@ -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.
......
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