From: Ian Campbell Subject: Re: [PATCH v2] libxl: support for "rtc_timeoffset" and "localtime" Date: Mon, 19 Mar 2012 15:40:47 +0000 Message-ID: <1332171647.9223.106.camel@zakaz.uk.xensource.com> References: <1332162123-3975-1-git-send-email-mlin@ss.pku.edu.cn> <1332163187.9223.69.camel@zakaz.uk.xensource.com> <1332171078.8074.11.camel@hp6530s> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1332171078.8074.11.camel@hp6530s> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Lin Ming Cc: Teck Choon Giam , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On Mon, 2012-03-19 at 15:31 +0000, Lin Ming wrote: > From 0614ad85fc5956d95d988b88689cc4967b4d8af8 Mon Sep 17 00:00:00 2001 > From: Lin Ming > Date: Sun, 18 Mar 2012 13:14:32 +0800 > Subject: [PATCH] libxl: support for "rtc_timeoffset" and "localtime" > > Implement "rtc_timeoffset" and "localtime" options compatible as xm. > > rtc_timeoffset is the offset between host time and guest time. > localtime means to specify whether the emulted RTC appears as UTC or is > offset by the host. > > Signed-off-by: Lin Ming Looks good to me, thanks! Acked-by: Ian Campbell Although when you repost please can you fix the following: > [...] > @@ -767,6 +767,14 @@ Set mode for Virtual Timers XXX ??? should be an enum of particular > values. See C in > F. The is the end of a sub section entitled "Unclassified HVM Specific Options". I think these new options belong in the "Guest Virtual Time Controls" subsection or perhaps "Miscellaneous Emulated Hardware". Ian. > > +=item B > + > +Set the real time clock to local time or to UTC. 0 by default, i.e. set to UTC. > + > +=item B > + > +Set the real time clock offset in seconds. 0 by default. > + > =back > > =head2 Device-Model Options > diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c > index 8417661..d39ecbe 100644 > --- a/tools/libxl/libxl_create.c > +++ b/tools/libxl/libxl_create.c > @@ -124,6 +124,17 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, > if (b_info->target_memkb == LIBXL_MEMKB_DEFAULT) > b_info->target_memkb = b_info->max_memkb; > > + libxl_defbool_setdefault(&b_info->localtime, false); > + if (libxl_defbool_val(b_info->localtime)) { > + time_t t; > + struct tm *tm; > + > + t = time(NULL); > + tm = localtime(&t); > + > + b_info->rtc_timeoffset += tm->tm_gmtoff; > + } > + > libxl_defbool_setdefault(&b_info->disable_migrate, false); > > switch (b_info->type) { > diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c > index 9b33267..0bdd654 100644 > --- a/tools/libxl/libxl_dom.c > +++ b/tools/libxl/libxl_dom.c > @@ -91,6 +91,9 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid, > if (libxl_defbool_val(info->disable_migrate)) > xc_domain_disable_migrate(ctx->xch, domid); > > + if (info->rtc_timeoffset) > + xc_domain_set_time_offset(ctx->xch, domid, info->rtc_timeoffset); > + > if (info->type == LIBXL_DOMAIN_TYPE_HVM) { > unsigned long shadow; > shadow = (info->shadow_memkb + 1023) / 1024; > diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl > index 413a1a6..09089b2 100644 > --- a/tools/libxl/libxl_types.idl > +++ b/tools/libxl/libxl_types.idl > @@ -238,6 +238,8 @@ libxl_domain_build_info = Struct("domain_build_info",[ > ("target_memkb", MemKB), > ("video_memkb", MemKB), > ("shadow_memkb", MemKB), > + ("rtc_timeoffset", uint32), > + ("localtime", libxl_defbool), > ("disable_migrate", libxl_defbool), > ("cpuid", libxl_cpuid_policy_list), > > diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c > index 1d59b89..0736357 100644 > --- a/tools/libxl/xl_cmdimpl.c > +++ b/tools/libxl/xl_cmdimpl.c > @@ -697,6 +697,11 @@ static void parse_config_data(const char *configfile_filename_report, > } > } > > + if (!xlu_cfg_get_long(config, "rtc_timeoffset", &l, 0)) > + b_info->rtc_timeoffset = l; > + > + xlu_cfg_get_defbool(config, "localtime", &b_info->localtime, 0); > + > if (!xlu_cfg_get_long (config, "videoram", &l, 0)) > b_info->video_memkb = l * 1024; >