mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 10:40:03 +01:00
[XEN] localtime support for paravirtualized guests
It is quite minimal in its approach, satisfying the purposes of the paravirtualized NetWare operating system as well as any others that expect the time base to be provided in localtime. Signed-off-by: Bruce Rogers <brogers@novell.com>
This commit is contained in:
1 parent
060b6f6d38
commit
42fae7ae02
9 files changed
+79
-1
No files matched your search
@@ -869,6 +869,30 @@ static PyObject *pyxc_domain_iomem_permission(PyObject *self,
|
||||
return zero;
|
||||
}
|
||||
|
||||
static PyObject *pyxc_domain_set_time_offset(XcObject *self, PyObject *args)
|
||||
{
|
||||
uint32_t dom;
|
||||
int32_t time_offset_seconds;
|
||||
time_t calendar_time;
|
||||
struct tm local_time;
|
||||
struct tm utc_time;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i", &dom))
|
||||
return NULL;
|
||||
|
||||
calendar_time = time(NULL);
|
||||
localtime_r(&calendar_time, &local_time);
|
||||
gmtime_r(&calendar_time, &utc_time);
|
||||
/* set up to get calendar time based on utc_time, with local dst setting */
|
||||
utc_time.tm_isdst = local_time.tm_isdst;
|
||||
time_offset_seconds = (int32_t)difftime(calendar_time, mktime(&utc_time));
|
||||
|
||||
if (xc_domain_set_time_offset(self->xc_handle, dom, time_offset_seconds) != 0)
|
||||
return NULL;
|
||||
|
||||
Py_INCREF(zero);
|
||||
return zero;
|
||||
}
|
||||
|
||||
static PyObject *dom_op(XcObject *self, PyObject *args,
|
||||
int (*fn)(int, uint32_t))
|
||||
@@ -1208,6 +1232,13 @@ static PyMethodDef pyxc_methods[] = {
|
||||
"Returns: [int]: The size in KiB of memory spanning the given number "
|
||||
"of pages.\n" },
|
||||
|
||||
{ "domain_set_time_offset",
|
||||
(PyCFunction)pyxc_domain_set_time_offset,
|
||||
METH_VARARGS, "\n"
|
||||
"Set a domain's time offset to Dom0's localtime\n"
|
||||
" dom [int]: Domain whose time offset is being set.\n"
|
||||
"Returns: [int] 0 on success; -1 on error.\n" },
|
||||
|
||||
{ NULL, NULL, 0, NULL }
|
||||
};
|
||||
|
||||
|
||||
@@ -135,6 +135,7 @@ ROUNDTRIPPING_CONFIG_ENTRIES = [
|
||||
('bootloader', str),
|
||||
('bootloader_args', str),
|
||||
('features', str),
|
||||
('localtime', int),
|
||||
]
|
||||
|
||||
ROUNDTRIPPING_CONFIG_ENTRIES += VM_CONFIG_PARAMS
|
||||
@@ -1260,6 +1261,10 @@ class XendDomainInfo:
|
||||
self.info['image'],
|
||||
self.info['device'])
|
||||
|
||||
localtime = self.info['localtime']
|
||||
if localtime is not None and localtime == 1:
|
||||
xc.domain_set_time_offset(self.domid)
|
||||
|
||||
xc.domain_setcpuweight(self.domid, self.info['cpu_weight'])
|
||||
|
||||
# repin domain vcpus if a restricted cpus list is provided
|
||||
|
||||
@@ -672,6 +672,8 @@ def make_config(vals):
|
||||
config.append(['backend', ['netif']])
|
||||
if vals.tpmif:
|
||||
config.append(['backend', ['tpmif']])
|
||||
if vals.localtime:
|
||||
config.append(['localtime', vals.localtime])
|
||||
|
||||
config_image = configure_image(vals)
|
||||
if vals.bootloader:
|
||||
|
||||