qga/commands.c | 19 +++++++++++++++++++ qga/qapi-schema.json | 25 +++++++++++++++++++++++++ 2 files changed, 44 insertions(+)
From: Vinzenz Feenstra <vfeenstr@redhat.com>
Adds a new command `guest-get-timezone` reporting the currently
configured timezone on the system. The information on what timezone is
currently is configured is useful in case of Windows VMs where the
offset of the hardware clock is required to have the same offset. This
can be used for management systems like `oVirt` to detect the timezone
difference and warn administrators of the misconfiguration.
Signed-off-by: Vinzenz Feenstra <vfeenstr@redhat.com>
---
qga/commands.c | 19 +++++++++++++++++++
qga/qapi-schema.json | 25 +++++++++++++++++++++++++
2 files changed, 44 insertions(+)
diff --git a/qga/commands.c b/qga/commands.c
index 4d92946..83d7f99 100644
--- a/qga/commands.c
+++ b/qga/commands.c
@@ -499,3 +499,22 @@ int ga_parse_whence(GuestFileWhence *whence, Error **errp)
error_setg(errp, "invalid whence code %"PRId64, whence->u.value);
return -1;
}
+
+GuestTimezone *qmp_guest_get_timezone(Error **errp)
+{
+ GuestTimezone *info = g_new0(GuestTimezone, 1);
+ GTimeZone *tz = g_time_zone_new_local();
+ gint32 interval = g_time_zone_find_interval(tz, G_TIME_TYPE_STANDARD, 0);
+ gchar const *name = g_time_zone_get_abbreviation(tz, interval);
+ if (name != NULL) {
+ info->offset = g_time_zone_get_offset(tz, interval) / 60;
+ info->zone = g_strdup(name);
+ } else {
+ error_setg(errp, "Timezone lookup failed");
+ g_free(info);
+ info = NULL;
+ }
+ g_time_zone_unref(tz);
+ return info;
+}
+
diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
index a02dbf2..6683aae 100644
--- a/qga/qapi-schema.json
+++ b/qga/qapi-schema.json
@@ -1042,3 +1042,28 @@
'data': { 'path': 'str', '*arg': ['str'], '*env': ['str'],
'*input-data': 'str', '*capture-output': 'bool' },
'returns': 'GuestExec' }
+
+
+##
+# @GuestTimezone:
+#
+# @zone: Timezone name
+# @offset: Offset to UTC in minutes
+#
+# Since: 2.10
+##
+{ 'struct': 'GuestTimezone',
+ 'data': { 'zone': 'str', 'offset': 'int' } }
+
+
+##
+# @guest-get-timezone:
+#
+# Retrieves the timezone information from the guest.
+#
+# Returns: The guest timezone GuestTimezone information on success.
+#
+# Since: 2.10
+##
+{ 'command': 'guest-get-timezone',
+ 'returns': 'GuestTimezone' }
--
2.9.3
Sorry I meant to add you Michael not Paolo -_- > On Mar 22, 2017, at 4:46 PM, Vinzenz 'evilissimo' Feenstra <vfeenstr@redhat.com> wrote: > > From: Vinzenz Feenstra <vfeenstr@redhat.com> > > Adds a new command `guest-get-timezone` reporting the currently > configured timezone on the system. The information on what timezone is > currently is configured is useful in case of Windows VMs where the > offset of the hardware clock is required to have the same offset. This > can be used for management systems like `oVirt` to detect the timezone > difference and warn administrators of the misconfiguration. > > Signed-off-by: Vinzenz Feenstra <vfeenstr@redhat.com> > --- > qga/commands.c | 19 +++++++++++++++++++ > qga/qapi-schema.json | 25 +++++++++++++++++++++++++ > 2 files changed, 44 insertions(+) > > diff --git a/qga/commands.c b/qga/commands.c > index 4d92946..83d7f99 100644 > --- a/qga/commands.c > +++ b/qga/commands.c > @@ -499,3 +499,22 @@ int ga_parse_whence(GuestFileWhence *whence, Error **errp) > error_setg(errp, "invalid whence code %"PRId64, whence->u.value); > return -1; > } > + > +GuestTimezone *qmp_guest_get_timezone(Error **errp) > +{ > + GuestTimezone *info = g_new0(GuestTimezone, 1); > + GTimeZone *tz = g_time_zone_new_local(); > + gint32 interval = g_time_zone_find_interval(tz, G_TIME_TYPE_STANDARD, 0); > + gchar const *name = g_time_zone_get_abbreviation(tz, interval); > + if (name != NULL) { > + info->offset = g_time_zone_get_offset(tz, interval) / 60; > + info->zone = g_strdup(name); > + } else { > + error_setg(errp, "Timezone lookup failed"); > + g_free(info); > + info = NULL; > + } > + g_time_zone_unref(tz); > + return info; > +} > + > diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json > index a02dbf2..6683aae 100644 > --- a/qga/qapi-schema.json > +++ b/qga/qapi-schema.json > @@ -1042,3 +1042,28 @@ > 'data': { 'path': 'str', '*arg': ['str'], '*env': ['str'], > '*input-data': 'str', '*capture-output': 'bool' }, > 'returns': 'GuestExec' } > + > + > +## > +# @GuestTimezone: > +# > +# @zone: Timezone name > +# @offset: Offset to UTC in minutes > +# > +# Since: 2.10 > +## > +{ 'struct': 'GuestTimezone', > + 'data': { 'zone': 'str', 'offset': 'int' } } > + > + > +## > +# @guest-get-timezone: > +# > +# Retrieves the timezone information from the guest. > +# > +# Returns: The guest timezone GuestTimezone information on success. > +# > +# Since: 2.10 > +## > +{ 'command': 'guest-get-timezone', > + 'returns': 'GuestTimezone' } > -- > 2.9.3 >
On 03/22/2017 10:46 AM, Vinzenz 'evilissimo' Feenstra wrote: > From: Vinzenz Feenstra <vfeenstr@redhat.com> This is not a trivial patch (it is adding a new feature), so including qemu-trivial is not necessary, and it should be merged through the qga maintainer. > > Adds a new command `guest-get-timezone` reporting the currently > configured timezone on the system. The information on what timezone is > currently is configured is useful in case of Windows VMs where the > offset of the hardware clock is required to have the same offset. This > can be used for management systems like `oVirt` to detect the timezone > difference and warn administrators of the misconfiguration. > > Signed-off-by: Vinzenz Feenstra <vfeenstr@redhat.com> > --- > qga/commands.c | 19 +++++++++++++++++++ > qga/qapi-schema.json | 25 +++++++++++++++++++++++++ > 2 files changed, 44 insertions(+) > > +++ b/qga/qapi-schema.json > @@ -1042,3 +1042,28 @@ > 'data': { 'path': 'str', '*arg': ['str'], '*env': ['str'], > '*input-data': 'str', '*capture-output': 'bool' }, > 'returns': 'GuestExec' } > + > + > +## > +# @GuestTimezone: > +# > +# @zone: Timezone name > +# @offset: Offset to UTC in minutes > +# Is it worth clarifying that negative numbers imply west of UTC? (There are some places that get offsets backwards from the usual POSIX notation, so it never hurts to be specific which direction is intended). > +## > +# @guest-get-timezone: > +# > +# Retrieves the timezone information from the guest. > +# > +# Returns: The guest timezone GuestTimezone information on success. Sounds rather repetitive; and a struct return is implicitly only possible on success. Perhaps it could be shortened to: # Retrieves timezone information from the guest. # # Returns: A GuestTimezone dictionary. > +# > +# Since: 2.10 > +## > +{ 'command': 'guest-get-timezone', > + 'returns': 'GuestTimezone' } > But the overall idea makes sense to me, so whether or not you wordsmith the documentation in the .json file, Reviewed-by: Eric Blake <eblake@redhat.com> -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
© 2016 - 2024 Red Hat, Inc.