Blame SOURCES/qemuga-qga-Add-guest-get-host-name-command.patch

46bd62
From 1878782a30dac5279c050a381015d9590d96a22e Mon Sep 17 00:00:00 2001
46bd62
From: Miroslav Rezanina <mrezanin@redhat.com>
46bd62
Date: Thu, 19 Apr 2018 12:33:42 -0300
46bd62
Subject: [PATCH 1/7] qga: Add 'guest-get-host-name' 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: <a597a6984027d2276a75bd08d3d10ed43d0807a8.1524139831.git.mrezanin@redhat.com>
46bd62
Patchwork-id: 79710
46bd62
O-Subject: [RHEL-7.5.z qemu-guest-agent PATCH 1/7] qga: Add 'guest-get-host-name' 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
Retrieving the guest host name is a very useful feature for virtual management
46bd62
systems. This information can help to have more user friendly VM access
46bd62
details, instead of an IP there would be the host name. Also the host name
46bd62
reported can be used to have automated checks for valid SSL certificates.
46bd62
46bd62
virsh # qemu-agent-command F25 '{ "execute": "guest-get-host-name" }'
46bd62
{"return":{"host-name":"F25.lab.evilissimo.net"}}
46bd62
46bd62
Signed-off-by: Vinzenz Feenstra <vfeenstr@redhat.com>
46bd62
* minor whitespace fix-ups
46bd62
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
46bd62
(cherry picked from commit 0a3d197a71b0508f5ca066488fbbbe45a61c44fe)
46bd62
Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
46bd62
---
46bd62
 qga/commands.c       | 11 +++++++++++
46bd62
 qga/qapi-schema.json | 26 ++++++++++++++++++++++++++
46bd62
 2 files changed, 37 insertions(+)
46bd62
46bd62
diff --git a/qga/commands.c b/qga/commands.c
46bd62
index edd3e830e6..8c09938e28 100644
46bd62
--- a/qga/commands.c
46bd62
+++ b/qga/commands.c
46bd62
@@ -499,3 +499,14 @@ int ga_parse_whence(GuestFileWhence *whence, Error **errp)
46bd62
     error_setg(errp, "invalid whence code %"PRId64, whence->u.value);
46bd62
     return -1;
46bd62
 }
46bd62
+
46bd62
+GuestHostName *qmp_guest_get_host_name(Error **err)
46bd62
+{
46bd62
+    GuestHostName *result = NULL;
46bd62
+    gchar const *hostname = g_get_host_name();
46bd62
+    if (hostname != NULL) {
46bd62
+        result = g_new0(GuestHostName, 1);
46bd62
+        result->host_name = g_strdup(hostname);
46bd62
+    }
46bd62
+    return result;
46bd62
+}
46bd62
diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
46bd62
index 94c03128fd..8271c1eb84 100644
46bd62
--- a/qga/qapi-schema.json
46bd62
+++ b/qga/qapi-schema.json
46bd62
@@ -1028,3 +1028,29 @@
46bd62
   'data':    { 'path': 'str', '*arg': ['str'], '*env': ['str'],
46bd62
                '*input-data': 'str', '*capture-output': 'bool' },
46bd62
   'returns': 'GuestExec' }
46bd62
+
46bd62
+
46bd62
+##
46bd62
+# @GuestHostName:
46bd62
+# @host-name: Fully qualified domain name of the guest OS
46bd62
+#
46bd62
+# Since: 2.10
46bd62
+##
46bd62
+{ 'struct': 'GuestHostName',
46bd62
+  'data':   { 'host-name': 'str' } }
46bd62
+
46bd62
+##
46bd62
+# @guest-get-host-name:
46bd62
+#
46bd62
+# Return a name for the machine.
46bd62
+#
46bd62
+# The returned name is not necessarily a fully-qualified domain name, or even
46bd62
+# present in DNS or some other name service at all. It need not even be unique
46bd62
+# on your local network or site, but usually it is.
46bd62
+#
46bd62
+# Returns: the host name of the machine on success
46bd62
+#
46bd62
+# Since: 2.10
46bd62
+##
46bd62
+{ 'command': 'guest-get-host-name',
46bd62
+  'returns': 'GuestHostName' }
46bd62
-- 
46bd62
2.13.6
46bd62