[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 03/53] qga: replace qemu_gettimeofday() with g_get_real_time()
From: |
Paolo Bonzini |
Subject: |
[PULL 03/53] qga: replace qemu_gettimeofday() with g_get_real_time() |
Date: |
Tue, 19 Apr 2022 07:50:19 +0200 |
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>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20220307070401.171986-4-marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
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 75dbaab68e..1e7b4656ed 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 3c428213db..15b451f0a4 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 72e6022207..4e9ce25b2e 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
- [PULL 24/53] include: move coroutine IO functions to coroutine.h, (continued)
- [PULL 24/53] include: move coroutine IO functions to coroutine.h, Paolo Bonzini, 2022/04/19
- [PULL 27/53] include: move cpu_exec* declarations to cpu-common.h, Paolo Bonzini, 2022/04/19
- [PULL 37/53] build-sys: drop ntddscsi.h check, Paolo Bonzini, 2022/04/19
- [PULL 38/53] build-sys: simplify AF_VSOCK check, Paolo Bonzini, 2022/04/19
- [PULL 41/53] thread-posix: use monotonic clock for QemuCond and QemuSemaphore, Paolo Bonzini, 2022/04/19
- [PULL 40/53] thread-posix: remove the posix semaphore support, Paolo Bonzini, 2022/04/19
- [PULL 44/53] hyperv: SControl is optional to enable SynIc, Paolo Bonzini, 2022/04/19
- [PULL 52/53] target/i386: do not access beyond the low 128 bits of SSE registers, Paolo Bonzini, 2022/04/19
- [PULL 30/53] include: move qemu_get_vm_name() to sysemu.h, Paolo Bonzini, 2022/04/19
- [PULL 05/53] oslib: drop qemu_gettimeofday(), Paolo Bonzini, 2022/04/19
- [PULL 03/53] qga: replace qemu_gettimeofday() with g_get_real_time(),
Paolo Bonzini <=
- [PULL 04/53] Replace qemu_gettimeofday() with g_get_real_time(), Paolo Bonzini, 2022/04/19
- [PULL 13/53] osdep: poison {HOST,TARGET}_WORDS_BIGENDIAN, Paolo Bonzini, 2022/04/19
- [PULL 09/53] meson: remove test-qdev-global-props dependency on testqapi, Paolo Bonzini, 2022/04/19
- [PULL 10/53] char: move qemu_openpty_raw from util/ to char/, Paolo Bonzini, 2022/04/19
- [PULL 17/53] qga: replace deprecated g_get_current_time(), Paolo Bonzini, 2022/04/19
- [PULL 12/53] Replace TARGET_WORDS_BIGENDIAN, Paolo Bonzini, 2022/04/19
- [PULL 02/53] qtest: replace gettimeofday with GTimer, Paolo Bonzini, 2022/04/19
- [PULL 15/53] tests: replace free_all() usage with g_auto, Paolo Bonzini, 2022/04/19
- [PULL 31/53] include: move os_*() to os-foo.h, Paolo Bonzini, 2022/04/19
- [PULL 33/53] Move CPU softfloat unions to cpu-float.h, Paolo Bonzini, 2022/04/19