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 91faa73..d754235 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -3,6 +3,10 @@
<node name="/org/libvirt/connect">
<interface name="org.libvirt.Connect">
+ <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 6c2f910..27de019 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -91,6 +91,25 @@ virtDBusConnectOpen(virtDBusConnect *connect,
return TRUE;
}
+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,
@@ -465,6 +484,7 @@ virtDBusNetworkLookupByUUID(GVariant *inArgs,
}
static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = {
+ { "Hostname", virtDBusConnectGetHostname, NULL },
{ "Version", virtDBusConnectGetVersion, NULL },
{ 0 }
};
diff --git a/test/test_connect.py b/test/test_connect.py
index 0571cae..05d7bd8 100755
--- a/test/test_connect.py
+++ b/test/test_connect.py
@@ -81,6 +81,7 @@ class TestConnect(libvirttest.BaseTestClass):
assert original_path == path
@pytest.mark.parametrize("property_name,expected_type", [
+ ("Hostname", dbus.String),
("Version", dbus.UInt64),
])
def test_connect_properties_return_type(self, property_name, expected_type):
--
2.15.0