From: "Bruce Rogers" <BROGERS@novell.com>
To: xen-devel@lists.xensource.com
Cc: Ian Pratt <m+Ian.Pratt@cl.cam.ac.uk>
Subject: Re: [PATCHl] localtime basis for paravirtualized guests
Date: Tue, 20 Jun 2006 17:20:43 -0600 [thread overview]
Message-ID: <44982E5D.092E.0048.1@novell.com> (raw)
In-Reply-To: <268cbf4ac7bb43efa0994df4a124a19d@cl.cam.ac.uk>
[-- Attachment #1: Type: text/plain, Size: 1964 bytes --]
Attached please find a patch (against unstable tree) which provides
some 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.
I should point out however that this by itself does not allow a
localtime
time base to be used for xenolinux. That support would require
additional
changes to Linux (eg a Xen aware implementation of /dev/rtc & etc.),
and
should probably be based on a more flexible and thorough implementation
of
non-UTC guest time bases than what this patch provides. Nevertheless,
this patch is functionaly equivalent to what is being done SLES 10's
Xen
implementation (but with SLES10 being based on testing tree), so I felt
it
should be submitted as is, with a more comprehensive approach
submitted
separately.
Signed-off-by: Bruce Rogers <brogers@novell.com>
- Bruce
>>> On 4/5/2006 at 8:03 AM, in message
<268cbf4ac7bb43efa0994df4a124a19d@cl.cam.ac.uk>, Keir Fraser
<Keir.Fraser@cl.cam.ac.uk> wrote:
> On 31 Mar 2006, at 21:22, Bruce Rogers wrote:
>
>> This patch allows the localtime parameter to be used for
>> para-virtualized guests.
>> Some paravirtualized guests may need to start with a local time
basis
>> instead of UTC.
>> This patch provides for that need. Please review and apply.
>
> I've just checked in a patch to provide a clean wallclock update
> interface from common Xen code. Please re-send based on that patch.
> Your dom0_op implementation should modify d->time_offset_seconds
> directly and then call update_domain_wallclock_time(d).
>
> Apart from that, the time_offset_seconds field in dom0_op.h should be
> type int32_t (we don't use s32 in public headers).
>
> -- Keir
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
[-- Attachment #2: xen-localtime.diff --]
[-- Type: application/octet-stream, Size: 6168 bytes --]
--- xen-unstable.orig/tools/libxc/xc_domain.c
+++ xen-unstable/tools/libxc/xc_domain.c
@@ -286,6 +286,17 @@ int xc_domain_setmaxmem(int xc_handle,
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);
+}
+
int xc_domain_memory_increase_reservation(int xc_handle,
uint32_t domid,
unsigned long nr_extents,
--- xen-unstable.orig/tools/libxc/xenctrl.h
+++ xen-unstable/tools/libxc/xenctrl.h
@@ -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,
--- xen-unstable.orig/tools/python/xen/xend/XendDomainInfo.py
+++ xen-unstable/tools/python/xen/xend/XendDomainInfo.py
@@ -135,6 +135,7 @@
('bootloader', str),
('bootloader_args', str),
('features', str),
+ ('localtime', int),
]
ROUNDTRIPPING_CONFIG_ENTRIES += VM_CONFIG_PARAMS
@@ -1260,6 +1261,10 @@
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
--- xen-unstable.orig/tools/python/xen/xm/create.py
+++ xen-unstable/tools/python/xen/xm/create.py
@@ -672,6 +672,8 @@
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:
--- xen-unstable.orig/xen/arch/x86/time.c
+++ xen-unstable/xen/arch/x86/time.c
@@ -699,7 +699,7 @@
{
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);
--- xen-unstable.orig/xen/common/dom0_ops.c
+++ xen-unstable/xen/common/dom0_ops.c
@@ -693,6 +693,21 @@ long do_dom0_op(GUEST_HANDLE(dom0_op_t)
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;
--- xen-unstable.orig/xen/include/public/dom0_ops.h
+++ xen-unstable/xen/include/public/dom0_ops.h
@@ -514,6 +514,14 @@
typedef struct dom0_hypercall_init dom0_hypercall_init_t;
DEFINE_XEN_GUEST_HANDLE(dom0_hypercall_init_t);
+#define DOM0_SETTIMEOFFSET 49
+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;
uint32_t interface_version; /* DOM0_INTERFACE_VERSION */
@@ -555,6 +563,7 @@
struct dom0_irq_permission irq_permission;
struct dom0_iomem_permission iomem_permission;
struct dom0_hypercall_init hypercall_init;
+ struct dom0_settimeoffset settimeoffset;
uint8_t pad[128];
} u;
};
--- xen-unstable.orig/xen/include/xen/sched.h
+++ xen-unstable/xen/include/xen/sched.h
@@ -159,6 +159,7 @@
/* OProfile support. */
struct xenoprof *xenoprof;
+ int32_t time_offset_seconds;
};
struct domain_setup_info
--- xen-unstable.orig/tools/python/xen/lowlevel/xc/xc.c
+++ xen-unstable/tools/python/xen/lowlevel/xc/xc.c
@@ -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))
@@ -1208,6 +1208,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 }
};
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next prev parent reply other threads:[~2006-06-20 23:20 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-28 3:40 wallclock time for paravirtualized guests Ian Pratt
2006-03-28 15:28 ` Bruce Rogers
2006-03-28 15:33 ` Keir Fraser
2006-03-31 20:22 ` [PATCHl] localtime basis " Bruce Rogers
2006-03-31 20:30 ` Muli Ben-Yehuda
2006-03-31 20:41 ` Bruce Rogers
2006-04-05 14:03 ` Keir Fraser
2006-04-05 14:30 ` Bruce Rogers
2006-06-20 23:20 ` Bruce Rogers [this message]
2006-06-21 15:29 ` B Thomas
2006-06-21 15:49 ` Keir Fraser
2006-06-21 16:01 ` Keir Fraser
2006-06-21 16:59 ` B Thomas
2006-06-21 16:11 ` Keir Fraser
2006-06-21 21:23 ` Bruce Rogers
2006-06-21 21:45 ` Keir Fraser
2006-06-21 22:16 ` Bruce Rogers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44982E5D.092E.0048.1@novell.com \
--to=brogers@novell.com \
--cc=m+Ian.Pratt@cl.cam.ac.uk \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.