xen/dom0: set wallclock time in Xen
authorJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Fri, 26 Mar 2010 18:21:22 +0000 (11:21 -0700)
committerJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Mon, 26 Sep 2011 18:04:39 +0000 (11:04 -0700)
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
arch/x86/xen/time.c

index 5158c50..8c9cdfa 100644 (file)
@@ -200,8 +200,22 @@ static unsigned long xen_get_wallclock(void)
 
 static int xen_set_wallclock(unsigned long now)
 {
+       struct xen_platform_op op;
+       int rc;
+
        /* do nothing for domU */
-       return -1;
+       if (!xen_initial_domain())
+               return -1;
+
+       op.cmd = XENPF_settime;
+       op.u.settime.secs = now;
+       op.u.settime.nsecs = 0;
+       op.u.settime.system_time = xen_clocksource_read();
+
+       rc = HYPERVISOR_dom0_op(&op);
+       WARN(rc != 0, "XENPF_settime failed: now=%ld\n", now);
+
+       return rc;
 }
 
 static struct clocksource xen_clocksource __read_mostly = {