Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/x86/x86 synchronize the guest clock with the host o...



details:   https://anonhg.NetBSD.org/src/rev/7973f186cc63
branches:  trunk
changeset: 770543:7973f186cc63
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Fri Oct 21 10:10:28 2011 +0000

description:
synchronize the guest clock with the host on attach and resume

diffstat:

 sys/arch/x86/x86/vmt.c |  56 ++++++++++++++++---------------------------------
 1 files changed, 18 insertions(+), 38 deletions(-)

diffs (122 lines):

diff -r f4250cb25014 -r 7973f186cc63 sys/arch/x86/x86/vmt.c
--- a/sys/arch/x86/x86/vmt.c    Fri Oct 21 02:26:09 2011 +0000
+++ b/sys/arch/x86/x86/vmt.c    Fri Oct 21 10:10:28 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vmt.c,v 1.6 2011/10/20 20:13:55 jmcneill Exp $ */
+/* $NetBSD: vmt.c,v 1.7 2011/10/21 10:10:28 jmcneill Exp $ */
 /* $OpenBSD: vmt.c,v 1.11 2011/01/27 21:29:25 dtucker Exp $ */
 
 /*
@@ -34,6 +34,7 @@
 #include <sys/syslog.h>
 #include <sys/proc.h>
 #include <sys/socket.h>
+#include <sys/timetc.h>
 #include <sys/module.h>
 
 #include <net/if.h>
@@ -191,10 +192,6 @@
 
        struct callout          sc_tick;
        struct callout          sc_tclo_tick;
-#if notyet
-       struct ksensordev       sc_sensordev;
-       struct ksensor          sc_sensor;
-#endif
 
        struct vmt_event        sc_ev_power;
        struct vmt_event        sc_ev_reset;
@@ -229,6 +226,7 @@
 
 static void vmt_update_guest_info(struct vmt_softc *);
 static void vmt_update_guest_uptime(struct vmt_softc *);
+static void vmt_sync_guest_clock(struct vmt_softc *);
 
 static void vmt_tick(void *);
 static void vmt_tclo_tick(void *);
@@ -325,17 +323,6 @@
 
        pmf_device_register1(self, NULL, NULL, vmt_shutdown);
 
-#if notyet
-       strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname,
-           sizeof(sc->sc_sensordev.xname));
-
-       sc->sc_sensor.type = SENSOR_TIMEDELTA;
-       sc->sc_sensor.status = SENSOR_S_UNKNOWN;
-
-       sensor_attach(&sc->sc_sensordev, &sc->sc_sensor);
-       sensordev_install(&sc->sc_sensordev);
-#endif
-
        sysmon_task_queue_init();
 
        sc->sc_ev_power.ev_smpsw.smpsw_type = PSWITCH_TYPE_POWER;
@@ -359,6 +346,8 @@
        callout_schedule(&sc->sc_tclo_tick, hz);
        sc->sc_tclo_ping = 1;
 
+       vmt_sync_guest_clock(sc);
+
        return;
 
 free:
@@ -444,16 +433,10 @@
 }
 
 static void
-vmt_tick(void *xarg)
+vmt_sync_guest_clock(struct vmt_softc *sc)
 {
-       struct vmt_softc *sc = xarg;
        struct vm_backdoor frame;
-#if notyet
-       struct timeval *guest = &sc->sc_sensor.tv;
-       struct timeval host, diff;
-
-       microtime(guest);
-#endif
+       struct timespec ts;
 
        memset(&frame, 0, sizeof(frame));
        frame.eax.word = VM_MAGIC;
@@ -462,21 +445,16 @@
        vm_cmd(&frame);
 
        if (frame.eax.word != 0xffffffff) {
-#if notyet
-               host.tv_sec = ((uint64_t)frame.esi.word << 32) | frame.edx.word;
-               host.tv_usec = frame.ebx.word;
-
-               timersub(guest, &host, &diff);
+               ts.tv_sec = ((uint64_t)frame.esi.word << 32) | frame.edx.word;
+               ts.tv_nsec = frame.ebx.word * 1000;
+               tc_setclock(&ts);
+       }
+}
 
-               sc->sc_sensor.value = (u_int64_t)diff.tv_sec * 1000000000LL +
-                   (u_int64_t)diff.tv_usec * 1000LL;
-               sc->sc_sensor.status = SENSOR_S_OK;
-#endif
-       } else {
-#if notyet
-               sc->sc_sensor.status = SENSOR_S_UNKNOWN;
-#endif
-       }
+static void
+vmt_tick(void *xarg)
+{
+       struct vmt_softc *sc = xarg;
 
        vmt_update_guest_info(sc);
        vmt_update_guest_uptime(sc);
@@ -519,6 +497,8 @@
 {
        device_printf(sc->sc_dev, "guest resuming from suspended state\n");
 
+       vmt_sync_guest_clock(sc);
+
        /* force guest info update */
        sc->sc_hostname[0] = '\0';
        sc->sc_set_guest_os = 0;



Home | Main Index | Thread Index | Old Index