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