qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH] savevm: use qemu_gettimeofday


From: Blue Swirl
Subject: [Qemu-devel] [PATCH] savevm: use qemu_gettimeofday
Date: Sat, 5 Jan 2013 18:32:15 +0000

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 <address@hidden>
---
 savevm.c |   14 +++-----------
 1 files changed, 3 insertions(+), 11 deletions(-)

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' */
-- 
1.7.2.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]