aboutsummaryrefslogtreecommitdiff
path: root/qga/commands.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2017-04-28 16:12:11 +0100
committerStefan Hajnoczi <stefanha@redhat.com>2017-04-28 16:12:19 +0100
commit7ad691ec988dd0ca1c3674018f6aede8ed18128b (patch)
tree9ea5883ab18b0a0e4389875840057519bb364e1e /qga/commands.c
parent81b2d5ceb0cfb4cdc2163492e3169ed714b0cda9 (diff)
parent53c58e64d0a27c59d763778faa2b5a522c544719 (diff)
Merge remote-tracking branch 'mdroth/tags/qga-pull-2017-04-25-v2-tag' into staging
qemu-ga patch queue * new commands: guest-get-timezone, guest-get-users, guest-get-host-name * fix hang on w32 when stopping qemu-ga service while fs frozen * fix missing setting of can-offline in guest-get-vcpus * make qemu-ga VSS w32 service on-demand rather than on-startup * fix unecessary errors to EventLog on w32 * improvements to fsfreeze documentation v2: * document 'zone' field of guest-get-timezone as informational-only (Daniel, Eric) * fix build error for glib < 2.32 (Peter) # gpg: Signature made Thu 27 Apr 2017 06:43:42 AM BST # gpg: using RSA key 0x3353C9CEF108B584 # gpg: Good signature from "Michael Roth <flukshun@gmail.com>" # gpg: aka "Michael Roth <mdroth@utexas.edu>" # gpg: aka "Michael Roth <mdroth@linux.vnet.ibm.com>" # Primary key fingerprint: CEAC C9E1 5534 EBAB B82D 3FA0 3353 C9CE F108 B584 * mdroth/tags/qga-pull-2017-04-25-v2-tag: qga: Add `guest-get-timezone` command qga: Add 'guest-get-users' command qga: improve fsfreeze documentations qga: Add 'guest-get-host-name' command qga-win: Fix Event Viewer errors caused by qemu-ga qga-win: Fix a bug where qemu-ga service is stuck during stop operation qga-win: Enable 'can-offline' field in 'guest-get-vcpus' reply qemu-ga: Make QGA VSS provider service run only when needed Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'qga/commands.c')
-rw-r--r--qga/commands.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/qga/commands.c b/qga/commands.c
index 4d92946820..3333ed50b2 100644
--- a/qga/commands.c
+++ b/qga/commands.c
@@ -499,3 +499,52 @@ int ga_parse_whence(GuestFileWhence *whence, Error **errp)
error_setg(errp, "invalid whence code %"PRId64, whence->u.value);
return -1;
}
+
+GuestHostName *qmp_guest_get_host_name(Error **err)
+{
+ GuestHostName *result = NULL;
+ gchar const *hostname = g_get_host_name();
+ if (hostname != NULL) {
+ result = g_new0(GuestHostName, 1);
+ result->host_name = g_strdup(hostname);
+ }
+ return result;
+}
+
+GuestTimezone *qmp_guest_get_timezone(Error **errp)
+{
+#if GLIB_CHECK_VERSION(2, 28, 0)
+ GuestTimezone *info = NULL;
+ GTimeZone *tz = NULL;
+ gint64 now = 0;
+ gint32 intv = 0;
+ gchar const *name = NULL;
+
+ info = g_new0(GuestTimezone, 1);
+ tz = g_time_zone_new_local();
+ if (tz == NULL) {
+ error_setg(errp, QERR_QGA_COMMAND_FAILED,
+ "Couldn't retrieve local timezone");
+ goto error;
+ }
+
+ now = g_get_real_time() / G_USEC_PER_SEC;
+ intv = g_time_zone_find_interval(tz, G_TIME_TYPE_UNIVERSAL, now);
+ info->offset = g_time_zone_get_offset(tz, intv);
+ name = g_time_zone_get_abbreviation(tz, intv);
+ if (name != NULL) {
+ info->has_zone = true;
+ info->zone = g_strdup(name);
+ }
+ g_time_zone_unref(tz);
+
+ return info;
+
+error:
+ g_free(info);
+ return NULL;
+#else
+ error_setg(errp, QERR_UNSUPPORTED);
+ return NULL;
+#endif
+}