From: marcandre.lureau@redhat.com
To: qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>, "Marek Vasut" <marex@denx.de>,
"Thomas Huth" <thuth@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
qemu-block@nongnu.org, "David Hildenbrand" <david@redhat.com>,
"Laurent Vivier" <lvivier@redhat.com>,
"Michael Roth" <michael.roth@amd.com>,
"Chris Wulff" <crwulff@gmail.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Konstantin Kostiuk" <kkostiuk@redhat.com>,
"Hanna Reitz" <hreitz@redhat.com>,
qemu-ppc@nongnu.org,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Stefan Weil" <sw@weilnetz.de>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Laurent Vivier" <laurent@vivier.eu>
Subject: [PATCH v2 3/5] qga: replace qemu_gettimeofday() with g_get_real_time()
Date: Sat, 5 Mar 2022 01:16:16 +0400 [thread overview]
Message-ID: <20220304211618.3715999-4-marcandre.lureau@redhat.com> (raw)
In-Reply-To: <20220304211618.3715999-1-marcandre.lureau@redhat.com>
From: Marc-André Lureau <marcandre.lureau@redhat.com>
GLib g_get_real_time() is an alternative to gettimeofday() which allows
to simplify our code.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
---
qga/commands-posix.c | 14 --------------
qga/commands-win32.c | 19 -------------------
qga/commands.c | 5 +++++
3 files changed, 5 insertions(+), 33 deletions(-)
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 75dbaab68ea9..1e7b4656edd1 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -136,20 +136,6 @@ void qmp_guest_shutdown(bool has_mode, const char *mode, Error **errp)
/* succeeded */
}
-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;
-}
-
void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)
{
int ret;
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 4fbbad793f2e..ce0af5ba45fc 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -1751,25 +1751,6 @@ static int64_t filetime_to_ns(const FILETIME *tf)
- W32_FT_OFFSET) * 100;
}
-int64_t qmp_guest_get_time(Error **errp)
-{
- SYSTEMTIME ts = {0};
- FILETIME tf;
-
- GetSystemTime(&ts);
- if (ts.wYear < 1601 || ts.wYear > 30827) {
- error_setg(errp, "Failed to get time");
- return -1;
- }
-
- if (!SystemTimeToFileTime(&ts, &tf)) {
- error_setg(errp, "Failed to convert system time: %d", (int)GetLastError());
- return -1;
- }
-
- return filetime_to_ns(&tf);
-}
-
void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)
{
Error *local_err = NULL;
diff --git a/qga/commands.c b/qga/commands.c
index 80501e4a737c..653ba3061e24 100644
--- a/qga/commands.c
+++ b/qga/commands.c
@@ -585,3 +585,8 @@ GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count,
return read_data;
}
+
+int64_t qmp_guest_get_time(Error **errp)
+{
+ return g_get_real_time() * 1000;
+}
--
2.35.1.273.ge6ebfd0e8cbb
next prev parent reply other threads:[~2022-03-04 21:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-04 21:16 [PATCH v2 0/5] Remove qemu_gettimeofday() marcandre.lureau
2022-03-04 21:16 ` [PATCH v2 1/5] m68k/nios2-semi: fix gettimeofday() result check marcandre.lureau
2022-03-04 21:16 ` [PATCH v2 2/5] qtest: replace gettimeofday with GTimer marcandre.lureau
2022-03-04 21:16 ` marcandre.lureau [this message]
2022-03-04 21:16 ` [PATCH v2 4/5] Replace qemu_gettimeofday() with g_get_real_time() marcandre.lureau
2022-03-05 19:17 ` Marc-André Lureau
2022-03-07 10:02 ` Laurent Vivier
2022-03-07 10:35 ` Marc-André Lureau
2022-03-07 11:36 ` Laurent Vivier
2022-03-04 21:16 ` [PATCH v2 5/5] oslib: drop qemu_gettimeofday() marcandre.lureau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220304211618.3715999-4-marcandre.lureau@redhat.com \
--to=marcandre.lureau@redhat.com \
--cc=armbru@redhat.com \
--cc=crwulff@gmail.com \
--cc=david@redhat.com \
--cc=hreitz@redhat.com \
--cc=kkostiuk@redhat.com \
--cc=kwolf@redhat.com \
--cc=laurent@vivier.eu \
--cc=lvivier@redhat.com \
--cc=marex@denx.de \
--cc=michael.roth@amd.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=sw@weilnetz.de \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).