libxl: support for "rtc_timeoffset" and "localtime"
authorLin Ming <mlin@ss.pku.edu.cn>
Mon, 2 Apr 2012 16:32:39 +0000 (17:32 +0100)
committerLin Ming <mlin@ss.pku.edu.cn>
Mon, 2 Apr 2012 16:32:39 +0000 (17:32 +0100)
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.

Acked-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Lin Ming <mlin@ss.pku.edu.cn>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
---
 docs/man/xl.cfg.pod.5       |    8 ++++++++
 tools/libxl/libxl_create.c  |   11 +++++++++++
 tools/libxl/libxl_dom.c     |    3 +++
 tools/libxl/libxl_types.idl |    2 ++
 tools/libxl/xl_cmdimpl.c    |    5 +++++
 5 files changed, 29 insertions(+), 0 deletions(-)

docs/man/xl.cfg.pod.5
tools/libxl/libxl_create.c
tools/libxl/libxl_dom.c
tools/libxl/libxl_types.idl
tools/libxl/xl_cmdimpl.c

index 55f7e75a16da41b73dcb6221e164dba6176d51c8..b53887cb32f08024ed2633f5112f3cb91060c0a8 100644 (file)
@@ -558,6 +558,14 @@ frequency changes.
 
 Please see F<docs/misc/tscmode.txt> for more information on this option.
 
+=item B<localtime=BOOLEAN>
+
+Set the real time clock to local time or to UTC. 0 by default, i.e. set to UTC.
+
+=item B<rtc_timeoffset=SECONDS>
+
+Set the real time clock offset in seconds. 0 by default.
+
 =head3 Support for Paravirtualisation of HVM Guests
 
 The following options allow Paravirtualised features (such as devices)
index 84176611084b497620799a71484fa4e5ada9a1a2..d39ecbe68710b070736c134b43d5853031935569 100644 (file)
@@ -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) {
index 9b33267353f727d6d73c4f274823e713f22a34c1..0bdd654745b8a7e4b304b160d7dcec20eba1fcac 100644 (file)
@@ -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;
index 413a1a6efc39a06526708a07fd1ece8d2bf5fc6c..09089b219fcb7d292b4f4e3e7de657c8674e9f16 100644 (file)
@@ -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),
     
index 4c1aa41ce3a39a70e405091b749daf4da54087ac..7868ce798c38c42cb88a8f38b5b2a7a5eee0b3f8 100644 (file)
@@ -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;