qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 3/4] Replace qemu_gettimeofday() with g_get_real_time()


From: Laurent Vivier
Subject: Re: [PATCH 3/4] Replace qemu_gettimeofday() with g_get_real_time()
Date: Fri, 4 Mar 2022 17:13:20 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0

Le 04/03/2022 à 17:08, Laurent Vivier a écrit :
Le 04/03/2022 à 16:27, marcandre.lureau@redhat.com a écrit :
From: Marc-André Lureau <marcandre.lureau@redhat.com>

GLib g_get_real_time() is an alternative to gettimeofday().

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>
---
  blockdev.c                 |  8 ++++----
  hw/rtc/m41t80.c            |  6 +++---
  hw/virtio/virtio-balloon.c |  9 +--------
  qapi/qmp-event.c           | 12 +++++-------
  qemu-img.c                 |  8 ++++----
  qga/commands-posix.c       | 11 +----------
  target/m68k/m68k-semi.c    | 22 ++++++++++------------
  target/nios2/nios2-semi.c  | 24 +++++++++++-------------
  8 files changed, 39 insertions(+), 61 deletions(-)

...
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 75dbaab68ea9..3311a4ca0167 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -138,16 +138,7 @@ void qmp_guest_shutdown(bool has_mode, const char *mode, 
Error **errp)
  int64_t qmp_guest_get_time(Error **errp)
  {
-   int ret;
-   qemu_timeval tq;
-
-   ret = qemu_gettimeofday(&tq);
-   if (ret < 0) {
-       error_setg_errno(errp, errno, "Failed to get time");
-       return -1;
-   }
-
-   return tq.tv_sec * 1000000000LL + tq.tv_usec * 1000;
+    return g_get_real_time();

now you return microseconds, before it was nanoseconds.

qga/qapi-schema.json:

##
# @guest-get-time:
#
# Get the information about guest's System Time relative to
# the Epoch of 1970-01-01 in UTC.
#
# Returns: Time in nanoseconds.
#
# Since: 1.5
##
{ 'command': 'guest-get-time',
   'returns': 'int' }

Except this problem:

Reviewed-by: Laurent Vivier <laurent@vivier.eu>

Perhaps you can also remove the windows version from qga/commands-win32.c and move the function to qga/commands.c ?

Thanks,
Laurent




reply via email to

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