[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] [XEN] localtime support for paravirtualized guests
# HG changeset patch # User kaf24@xxxxxxxxxxxxxxxxxxxx # Node ID 12aaf4a2486b1cd1bce78292491258ef170970ba # Parent 79ea1d8a5bb210f8b0b258fdc72229450b417507 [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@xxxxxxxxxx> --- tools/libxc/xc_domain.c | 11 +++++++++++ tools/libxc/xenctrl.h | 4 ++++ tools/python/xen/lowlevel/xc/xc.c | 31 +++++++++++++++++++++++++++++++ tools/python/xen/xend/XendDomainInfo.py | 5 +++++ tools/python/xen/xm/create.py | 2 ++ xen/arch/x86/time.c | 2 +- xen/common/dom0_ops.c | 15 +++++++++++++++ xen/include/public/dom0_ops.h | 9 +++++++++ xen/include/xen/sched.h | 1 + 9 files changed, 79 insertions(+), 1 deletion(-) diff -r 79ea1d8a5bb2 -r 12aaf4a2486b tools/libxc/xc_domain.c --- a/tools/libxc/xc_domain.c Wed Jun 21 16:55:25 2006 +0100 +++ b/tools/libxc/xc_domain.c Wed Jun 21 17:09:14 2006 +0100 @@ -283,6 +283,17 @@ int xc_domain_setmaxmem(int xc_handle, op.cmd = DOM0_SETDOMAINMAXMEM; op.u.setdomainmaxmem.domain = (domid_t)domid; op.u.setdomainmaxmem.max_memkb = max_memkb; + return do_dom0_op(xc_handle, &op); +} + +int xc_domain_set_time_offset(int xc_handle, + uint32_t domid, + int32_t time_offset_seconds) +{ + DECLARE_DOM0_OP; + op.cmd = DOM0_SETTIMEOFFSET; + op.u.settimeoffset.domain = (domid_t)domid; + op.u.settimeoffset.time_offset_seconds = time_offset_seconds; return do_dom0_op(xc_handle, &op); } diff -r 79ea1d8a5bb2 -r 12aaf4a2486b tools/libxc/xenctrl.h --- a/tools/libxc/xenctrl.h Wed Jun 21 16:55:25 2006 +0100 +++ b/tools/libxc/xenctrl.h Wed Jun 21 17:09:14 2006 +0100 @@ -410,6 +410,10 @@ int xc_domain_setmaxmem(int xc_handle, uint32_t domid, unsigned int max_memkb); +int xc_domain_set_time_offset(int xc_handle, + uint32_t domid, + int32_t time_offset_seconds); + int xc_domain_memory_increase_reservation(int xc_handle, uint32_t domid, unsigned long nr_extents, diff -r 79ea1d8a5bb2 -r 12aaf4a2486b tools/python/xen/lowlevel/xc/xc.c --- a/tools/python/xen/lowlevel/xc/xc.c Wed Jun 21 16:55:25 2006 +0100 +++ b/tools/python/xen/lowlevel/xc/xc.c Wed Jun 21 17:09:14 2006 +0100 @@ -869,6 +869,30 @@ static PyObject *pyxc_domain_iomem_permi 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)) @@ -1207,6 +1231,13 @@ static PyMethodDef pyxc_methods[] = { METH_VARARGS, "\n" "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 } }; diff -r 79ea1d8a5bb2 -r 12aaf4a2486b tools/python/xen/xend/XendDomainInfo.py --- a/tools/python/xen/xend/XendDomainInfo.py Wed Jun 21 16:55:25 2006 +0100 +++ b/tools/python/xen/xend/XendDomainInfo.py Wed Jun 21 17:09:14 2006 +0100 @@ -135,6 +135,7 @@ ROUNDTRIPPING_CONFIG_ENTRIES = [ ('bootloader', str), ('bootloader_args', str), ('features', str), + ('localtime', int), ] ROUNDTRIPPING_CONFIG_ENTRIES += VM_CONFIG_PARAMS @@ -1259,6 +1260,10 @@ class XendDomainInfo: self.image = image.create(self, 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']) diff -r 79ea1d8a5bb2 -r 12aaf4a2486b tools/python/xen/xm/create.py --- a/tools/python/xen/xm/create.py Wed Jun 21 16:55:25 2006 +0100 +++ b/tools/python/xen/xm/create.py Wed Jun 21 17:09:14 2006 +0100 @@ -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: diff -r 79ea1d8a5bb2 -r 12aaf4a2486b xen/arch/x86/time.c --- a/xen/arch/x86/time.c Wed Jun 21 16:55:25 2006 +0100 +++ b/xen/arch/x86/time.c Wed Jun 21 17:09:14 2006 +0100 @@ -699,7 +699,7 @@ void update_domain_wallclock_time(struct { spin_lock(&wc_lock); version_update_begin(&d->shared_info->wc_version); - d->shared_info->wc_sec = wc_sec; + d->shared_info->wc_sec = wc_sec + d->time_offset_seconds; d->shared_info->wc_nsec = wc_nsec; version_update_end(&d->shared_info->wc_version); spin_unlock(&wc_lock); diff -r 79ea1d8a5bb2 -r 12aaf4a2486b xen/common/dom0_ops.c --- a/xen/common/dom0_ops.c Wed Jun 21 16:55:25 2006 +0100 +++ b/xen/common/dom0_ops.c Wed Jun 21 17:09:14 2006 +0100 @@ -693,6 +693,21 @@ long do_dom0_op(XEN_GUEST_HANDLE(dom0_op break; #endif + case DOM0_SETTIMEOFFSET: + { + struct domain *d; + + ret = -ESRCH; + d = find_domain_by_id(op->u.settimeoffset.domain); + if ( d != NULL ) + { + d->time_offset_seconds = op->u.settimeoffset.time_offset_seconds; + put_domain(d); + ret = 0; + } + } + break; + default: ret = arch_do_dom0_op(op, u_dom0_op); break; diff -r 79ea1d8a5bb2 -r 12aaf4a2486b xen/include/public/dom0_ops.h --- a/xen/include/public/dom0_ops.h Wed Jun 21 16:55:25 2006 +0100 +++ b/xen/include/public/dom0_ops.h Wed Jun 21 17:09:14 2006 +0100 @@ -526,6 +526,14 @@ typedef struct dom0_domain_setup { #endif } dom0_domain_setup_t; DEFINE_XEN_GUEST_HANDLE(dom0_domain_setup_t); + +#define DOM0_SETTIMEOFFSET 50 +struct dom0_settimeoffset { + domid_t domain; + int32_t time_offset_seconds; /* applied to domain wallclock time */ +}; +typedef struct dom0_settimeoffset dom0_settimeoffset_t; +DEFINE_XEN_GUEST_HANDLE(dom0_settimeoffset_t); struct dom0_op { uint32_t cmd; @@ -569,6 +577,7 @@ struct dom0_op { struct dom0_iomem_permission iomem_permission; struct dom0_hypercall_init hypercall_init; struct dom0_domain_setup domain_setup; + struct dom0_settimeoffset settimeoffset; uint8_t pad[128]; } u; }; diff -r 79ea1d8a5bb2 -r 12aaf4a2486b xen/include/xen/sched.h --- a/xen/include/xen/sched.h Wed Jun 21 16:55:25 2006 +0100 +++ b/xen/include/xen/sched.h Wed Jun 21 17:09:14 2006 +0100 @@ -159,6 +159,7 @@ struct domain /* OProfile support. */ struct xenoprof *xenoprof; + int32_t time_offset_seconds; }; struct domain_setup_info _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |