|
|
46bd62 |
From c3d3a693c4bb181f6673071de95e79fd97eda526 Mon Sep 17 00:00:00 2001
|
|
|
46bd62 |
From: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
46bd62 |
Date: Thu, 19 Apr 2018 12:33:44 -0300
|
|
|
46bd62 |
Subject: [PATCH 3/7] qga: Add `guest-get-timezone` command
|
|
|
46bd62 |
MIME-Version: 1.0
|
|
|
46bd62 |
Content-Type: text/plain; charset=UTF-8
|
|
|
46bd62 |
Content-Transfer-Encoding: 8bit
|
|
|
46bd62 |
|
|
|
46bd62 |
RH-Author: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
46bd62 |
Message-id: <605280b778254624582ec8aa72c72155d2206948.1524139831.git.mrezanin@redhat.com>
|
|
|
46bd62 |
Patchwork-id: 79705
|
|
|
46bd62 |
O-Subject: [RHEL-7.5.z qemu-guest-agent PATCH 3/7] qga: Add `guest-get-timezone` command
|
|
|
46bd62 |
Bugzilla: 1598210
|
|
|
46bd62 |
RH-Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
46bd62 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
46bd62 |
RH-Acked-by: Tomáš Golembiovský <tgolembi@redhat.com>
|
|
|
46bd62 |
|
|
|
46bd62 |
From: Vinzenz Feenstra <vfeenstr@redhat.com>
|
|
|
46bd62 |
|
|
|
46bd62 |
Adds a new command `guest-get-timezone` reporting the currently
|
|
|
46bd62 |
configured timezone on the system. The information on what timezone is
|
|
|
46bd62 |
currently is configured is useful in case of Windows VMs where the
|
|
|
46bd62 |
offset of the hardware clock is required to have the same offset. This
|
|
|
46bd62 |
can be used for management systems like `oVirt` to detect the timezone
|
|
|
46bd62 |
difference and warn administrators of the misconfiguration.
|
|
|
46bd62 |
|
|
|
46bd62 |
Signed-off-by: Vinzenz Feenstra <vfeenstr@redhat.com>
|
|
|
46bd62 |
Reviewed-by: Sameeh Jubran <sameeh@daynix.com>
|
|
|
46bd62 |
Tested-by: Sameeh Jubran <sameeh@daynix.com>
|
|
|
46bd62 |
* moved stub implementation to end of function for consistency
|
|
|
46bd62 |
* document that timezone names are for informational use only.
|
|
|
46bd62 |
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
|
|
|
46bd62 |
(cherry picked from commit 53c58e64d0a27c59d763778faa2b5a522c544719)
|
|
|
46bd62 |
Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
|
|
|
46bd62 |
---
|
|
|
46bd62 |
qga/commands.c | 38 ++++++++++++++++++++++++++++++++++++++
|
|
|
46bd62 |
qga/qapi-schema.json | 25 +++++++++++++++++++++++++
|
|
|
46bd62 |
2 files changed, 63 insertions(+)
|
|
|
46bd62 |
|
|
|
46bd62 |
diff --git a/qga/commands.c b/qga/commands.c
|
|
|
46bd62 |
index 8c09938e28..5b73cd0e4d 100644
|
|
|
46bd62 |
--- a/qga/commands.c
|
|
|
46bd62 |
+++ b/qga/commands.c
|
|
|
46bd62 |
@@ -510,3 +510,41 @@ GuestHostName *qmp_guest_get_host_name(Error **err)
|
|
|
46bd62 |
}
|
|
|
46bd62 |
return result;
|
|
|
46bd62 |
}
|
|
|
46bd62 |
+
|
|
|
46bd62 |
+GuestTimezone *qmp_guest_get_timezone(Error **errp)
|
|
|
46bd62 |
+{
|
|
|
46bd62 |
+#if GLIB_CHECK_VERSION(2, 28, 0)
|
|
|
46bd62 |
+ GuestTimezone *info = NULL;
|
|
|
46bd62 |
+ GTimeZone *tz = NULL;
|
|
|
46bd62 |
+ gint64 now = 0;
|
|
|
46bd62 |
+ gint32 intv = 0;
|
|
|
46bd62 |
+ gchar const *name = NULL;
|
|
|
46bd62 |
+
|
|
|
46bd62 |
+ info = g_new0(GuestTimezone, 1);
|
|
|
46bd62 |
+ tz = g_time_zone_new_local();
|
|
|
46bd62 |
+ if (tz == NULL) {
|
|
|
46bd62 |
+ error_setg(errp, QERR_QGA_COMMAND_FAILED,
|
|
|
46bd62 |
+ "Couldn't retrieve local timezone");
|
|
|
46bd62 |
+ goto error;
|
|
|
46bd62 |
+ }
|
|
|
46bd62 |
+
|
|
|
46bd62 |
+ now = g_get_real_time() / G_USEC_PER_SEC;
|
|
|
46bd62 |
+ intv = g_time_zone_find_interval(tz, G_TIME_TYPE_UNIVERSAL, now);
|
|
|
46bd62 |
+ info->offset = g_time_zone_get_offset(tz, intv);
|
|
|
46bd62 |
+ name = g_time_zone_get_abbreviation(tz, intv);
|
|
|
46bd62 |
+ if (name != NULL) {
|
|
|
46bd62 |
+ info->has_zone = true;
|
|
|
46bd62 |
+ info->zone = g_strdup(name);
|
|
|
46bd62 |
+ }
|
|
|
46bd62 |
+ g_time_zone_unref(tz);
|
|
|
46bd62 |
+
|
|
|
46bd62 |
+ return info;
|
|
|
46bd62 |
+
|
|
|
46bd62 |
+error:
|
|
|
46bd62 |
+ g_free(info);
|
|
|
46bd62 |
+ return NULL;
|
|
|
46bd62 |
+#else
|
|
|
46bd62 |
+ error_setg(errp, QERR_UNSUPPORTED);
|
|
|
46bd62 |
+ return NULL;
|
|
|
46bd62 |
+#endif
|
|
|
46bd62 |
+}
|
|
|
46bd62 |
diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
|
|
|
46bd62 |
index 1695afe3a9..5af73fedae 100644
|
|
|
46bd62 |
--- a/qga/qapi-schema.json
|
|
|
46bd62 |
+++ b/qga/qapi-schema.json
|
|
|
46bd62 |
@@ -1079,3 +1079,28 @@
|
|
|
46bd62 |
##
|
|
|
46bd62 |
{ 'command': 'guest-get-users',
|
|
|
46bd62 |
'returns': ['GuestUser'] }
|
|
|
46bd62 |
+
|
|
|
46bd62 |
+##
|
|
|
46bd62 |
+# @GuestTimezone:
|
|
|
46bd62 |
+#
|
|
|
46bd62 |
+# @zone: Timezone name. These values may differ depending on guest/OS and
|
|
|
46bd62 |
+# should only be used for informational purposes.
|
|
|
46bd62 |
+# @offset: Offset to UTC in seconds, negative numbers for time zones west of
|
|
|
46bd62 |
+# GMT, positive numbers for east
|
|
|
46bd62 |
+#
|
|
|
46bd62 |
+# Since: 2.10
|
|
|
46bd62 |
+##
|
|
|
46bd62 |
+{ 'struct': 'GuestTimezone',
|
|
|
46bd62 |
+ 'data': { '*zone': 'str', 'offset': 'int' } }
|
|
|
46bd62 |
+
|
|
|
46bd62 |
+##
|
|
|
46bd62 |
+# @guest-get-timezone:
|
|
|
46bd62 |
+#
|
|
|
46bd62 |
+# Retrieves the timezone information from the guest.
|
|
|
46bd62 |
+#
|
|
|
46bd62 |
+# Returns: A GuestTimezone dictionary.
|
|
|
46bd62 |
+#
|
|
|
46bd62 |
+# Since: 2.10
|
|
|
46bd62 |
+##
|
|
|
46bd62 |
+{ 'command': 'guest-get-timezone',
|
|
|
46bd62 |
+ 'returns': 'GuestTimezone' }
|
|
|
46bd62 |
--
|
|
|
46bd62 |
2.13.6
|
|
|
46bd62 |
|