From f793dde0914ae7f2605ee22c5bbc81dc79e23eee Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Mon, 7 Mar 2022 11:04:00 +0400 Subject: 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 Reviewed-by: Laurent Vivier Message-Id: <20220307070401.171986-5-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- blockdev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'blockdev.c') diff --git a/blockdev.c b/blockdev.c index e46e831212..9230888e34 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1258,7 +1258,7 @@ static void internal_snapshot_prepare(BlkActionState *common, BlockDriverState *bs; QEMUSnapshotInfo old_sn, *sn; bool ret; - qemu_timeval tv; + int64_t rt; BlockdevSnapshotInternal *internal; InternalSnapshotState *state; AioContext *aio_context; @@ -1328,9 +1328,9 @@ static void internal_snapshot_prepare(BlkActionState *common, /* 3. take the snapshot */ sn = &state->sn; pstrcpy(sn->name, sizeof(sn->name), 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; sn->vm_clock_nsec = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); if (replay_mode != REPLAY_MODE_NONE) { sn->icount = replay_get_current_icount(); -- cgit v1.2.3-55-g7522