aboutsummaryrefslogtreecommitdiff
path: root/qemu-img.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2022-03-07 11:04:00 +0400
committerPaolo Bonzini <pbonzini@redhat.com>2022-04-06 10:50:37 +0200
commitf793dde0914ae7f2605ee22c5bbc81dc79e23eee (patch)
treeaf62c611c5d4f73d9a87bc8ec84d2ae5265e9d8d /qemu-img.c
parent287698e50fb2340d9f6436976ac701512cb7c383 (diff)
Replace qemu_gettimeofday() with g_get_real_time()
GLib g_get_real_time() is an alternative to gettimeofday() which allows to simplify our code. For semihosting, a few bits are lost on POSIX host, but this shouldn't be a big concern. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20220307070401.171986-5-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'qemu-img.c')
-rw-r--r--qemu-img.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/qemu-img.c b/qemu-img.c
index 1caddfb23a..cf63db7655 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -3305,11 +3305,11 @@ static int img_snapshot(int argc, char **argv)
char *filename, *snapshot_name = NULL;
int c, ret = 0, bdrv_oflags;
int action = 0;
- qemu_timeval tv;
bool quiet = false;
Error *err = NULL;
bool image_opts = false;
bool force_share = false;
+ int64_t rt;
bdrv_oflags = BDRV_O_RDWR;
/* Parse commandline parameters */
@@ -3406,9 +3406,9 @@ static int img_snapshot(int argc, char **argv)
memset(&sn, 0, sizeof(sn));
pstrcpy(sn.name, sizeof(sn.name), snapshot_name);
- qemu_gettimeofday(&tv);
- sn.date_sec = tv.tv_sec;
- sn.date_nsec = tv.tv_usec * 1000;
+ rt = g_get_real_time();
+ sn.date_sec = rt / G_USEC_PER_SEC;
+ sn.date_nsec = (rt % G_USEC_PER_SEC) * 1000;
ret = bdrv_snapshot_create(bs, &sn);
if (ret) {