Commit 6b970cef authored by Jun Futagawa's avatar Jun Futagawa Committed by Iustin Pop

Add use_localtime parameter for xen-hvm and kvm

Currently xen-hvm and kvm use different real time clock by default. To
reduce confusion, this patch adds an optional use_localtime parameter.

If the real time clock on the instance is set to local time, the
parameter use_localtime should be True. The default is False. Note that
the real time clock changes from local to UTC in xen-hvm with the
default parameter.
Signed-off-by: default avatarJun Futagawa <jfut@integ.jp>
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent e8a3bf18
......@@ -391,6 +391,7 @@ HV_USB_MOUSE = "usb_mouse"
HV_DEVICE_MODEL = "device_model"
HV_INIT_SCRIPT = "init_script"
HV_MIGRATION_PORT = "migration_port"
HV_USE_LOCALTIME = "use_localtime"
HVS_PARAMETER_TYPES = {
HV_BOOT_ORDER: VTYPE_STRING,
......@@ -416,6 +417,7 @@ HVS_PARAMETER_TYPES = {
HV_DEVICE_MODEL: VTYPE_STRING,
HV_INIT_SCRIPT: VTYPE_STRING,
HV_MIGRATION_PORT: VTYPE_INT,
HV_USE_LOCALTIME: VTYPE_BOOL,
}
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
......@@ -623,6 +625,7 @@ HVC_DEFAULTS = {
HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm",
HV_MIGRATION_PORT: 8002,
HV_USE_LOCALTIME: False,
},
HT_KVM: {
HV_KERNEL_PATH: "/boot/vmlinuz-2.6-kvmU",
......@@ -642,6 +645,7 @@ HVC_DEFAULTS = {
HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
HV_USB_MOUSE: '',
HV_MIGRATION_PORT: 8102,
HV_USE_LOCALTIME: False,
},
HT_FAKE: {
},
......
......@@ -73,6 +73,7 @@ class KVMHypervisor(hv_base.BaseHypervisor):
constants.HV_USB_MOUSE:
hv_base.ParamInSet(False, constants.HT_KVM_VALID_MOUSE_TYPES),
constants.HV_MIGRATION_PORT: hv_base.NET_PORT_CHECK,
constants.HV_USE_LOCALTIME: hv_base.NO_CHECK,
}
_MIGRATION_STATUS_RE = re.compile('Migration\s+status:\s+(\w+)',
......@@ -402,6 +403,9 @@ class KVMHypervisor(hv_base.BaseHypervisor):
else:
kvm_cmd.extend(['-serial', 'none'])
if hvp[constants.HV_USE_LOCALTIME]:
kvm_cmd.extend(['-localtime'])
# 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
......
......@@ -551,6 +551,7 @@ class XenHvmHypervisor(XenHypervisor):
constants.HV_DEVICE_MODEL: hv_base.REQ_FILE_CHECK,
constants.HV_VNC_PASSWORD_FILE: hv_base.REQ_FILE_CHECK,
constants.HV_MIGRATION_PORT: hv_base.NET_PORT_CHECK,
constants.HV_USE_LOCALTIME: hv_base.NO_CHECK,
}
@classmethod
......@@ -609,7 +610,8 @@ class XenHvmHypervisor(XenHypervisor):
config.write("vncpasswd = '%s'\n" % password.rstrip())
config.write("serial = 'pty'\n")
config.write("localtime = 1\n")
if hvp[constants.HV_USE_LOCALTIME]:
config.write("localtime = 1\n")
vif_data = []
nic_type = hvp[constants.HV_NIC_TYPE]
......
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