Comments
Patch
@@ -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' */
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(-)