Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
data/org.libvirt.Connect.xml | 4 ++++
src/connect.c | 20 ++++++++++++++++++++
test/test_connect.py | 1 +
3 files changed, 25 insertions(+)
diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index caf0a47..264f84c 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -7,6 +7,10 @@
<annotation name="org.gtk.GDBus.DocString"
value="See
https://libvirt.org/html/libvirt-libvirt-host.html#virConnectGetCapabilit...
</property>
+ <property name="Hostname" type="s"
access="read">
+ <annotation name="org.gtk.GDBus.DocString"
+ value="See
https://libvirt.org/html/libvirt-libvirt-host.html#virConnectGetHostname&...
+ </property>
<property name="Version" type="t" access="read">
<annotation name="org.gtk.GDBus.DocString"
value="See
https://libvirt.org/html/libvirt-libvirt-host.html#virConnectGetVersion&q...
diff --git a/src/connect.c b/src/connect.c
index af61cc8..b34cd95 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -110,6 +110,25 @@ virtDBusConnectGetCapabilities(const gchar *objectPath
G_GNUC_UNUSED,
*value = g_variant_new("s", capabilities);
}
+static void
+virtDBusConnectGetHostname(const gchar *objectPath G_GNUC_UNUSED,
+ gpointer userData,
+ GVariant **value,
+ GError **error)
+{
+ virtDBusConnect *connect = userData;
+ g_autofree gchar * hostname = NULL;
+
+ if (!virtDBusConnectOpen(connect, error))
+ return;
+
+ hostname = virConnectGetHostname(connect->connection);
+ if (!hostname)
+ return virtDBusUtilSetLastVirtError(error);
+
+ *value = g_variant_new("s", hostname);
+}
+
static void
virtDBusConnectGetVersion(const gchar *objectPath G_GNUC_UNUSED,
gpointer userData,
@@ -463,6 +482,7 @@ virtDBusNetworkLookupByUUID(GVariant *inArgs,
static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = {
{ "Capabilities", virtDBusConnectGetCapabilities, NULL },
+ { "Hostname", virtDBusConnectGetHostname, NULL },
{ "Version", virtDBusConnectGetVersion, NULL },
{ 0 }
};
diff --git a/test/test_connect.py b/test/test_connect.py
index d7c1e20..75a955e 100755
--- a/test/test_connect.py
+++ b/test/test_connect.py
@@ -82,6 +82,7 @@ class TestConnect(libvirttest.BaseTestClass):
@pytest.mark.parametrize("property_name,expected_type", [
("Capabilities", dbus.String),
+ ("Hostname", dbus.String),
("Version", dbus.UInt64),
])
def test_connect_properties_return_type(self, property_name, expected_type):
--
2.15.0