Patchwork savevm: use qemu_gettimeofday

login
register
mail settings
Submitter Blue Swirl
Date Jan. 5, 2013, 6:32 p.m.
Message ID <b23347024b1d34d8bda0c8521ed5a4b2fd0558f7.1357410707.git.blauwirbel@gmail.com>
Download mbox | patch
Permalink /patch/209690/
State New
Headers show

Comments

Blue Swirl - Jan. 5, 2013, 6:32 p.m.
Use qemu_gettimeofday() instead of _ftime() on Win32.

This fixes build for mingw32:
  CC    sparc-softmmu/savevm.o
/src/qemu/savevm.c: In function 'do_savevm':
/src/qemu/savevm.c:2097: error: storage size of 'tb' isn't known
/src/qemu/savevm.c:2133: warning: implicit declaration of function '_ftime'
/src/qemu/savevm.c:2133: warning: nested extern declaration of '_ftime'
/src/qemu/savevm.c:2097: warning: unused variable 'tb'

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 savevm.c |   14 +++-----------
 1 files changed, 3 insertions(+), 11 deletions(-)

Patch

diff --git a/savevm.c b/savevm.c
index 529d60e..10a52ab 100644
--- a/savevm.c
+++ b/savevm.c
@@ -2093,11 +2093,10 @@  void do_savevm(Monitor *mon, const QDict *qdict)
     QEMUFile *f;
     int saved_vm_running;
     uint64_t vm_state_size;
+    qemu_timeval tv;
 #ifdef _WIN32
-    struct _timeb tb;
     struct tm *ptm;
 #else
-    struct timeval tv;
     struct tm tm;
 #endif
     const char *name = qdict_get_try_str(qdict, "name");
@@ -2129,15 +2128,9 @@  void do_savevm(Monitor *mon, const QDict *qdict)
     memset(sn, 0, sizeof(*sn));
 
     /* fill auxiliary fields */
-#ifdef _WIN32
-    _ftime(&tb);
-    sn->date_sec = tb.time;
-    sn->date_nsec = tb.millitm * 1000000;
-#else
-    gettimeofday(&tv, NULL);
+    qemu_gettimeofday(&tv);
     sn->date_sec = tv.tv_sec;
     sn->date_nsec = tv.tv_usec * 1000;
-#endif
     sn->vm_clock_nsec = qemu_get_clock_ns(vm_clock);
 
     if (name) {
@@ -2150,8 +2143,7 @@  void do_savevm(Monitor *mon, const QDict *qdict)
         }
     } else {
 #ifdef _WIN32
-        time_t t = tb.time;
-        ptm = localtime(&t);
+        ptm = localtime(&tv.tv_sec);
         strftime(sn->name, sizeof(sn->name), "vm-%Y%m%d%H%M%S", ptm);
 #else
         /* cast below needed for OpenBSD where tv_sec is still 'long' */