[dbus PATCH 3/8] Implement LibVersion property for Connect Interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx>
---
 data/org.libvirt.Connect.xml |  4 ++++
 src/connect.c                | 19 +++++++++++++++++++
 test/test_connect.py         |  1 +
 3 files changed, 24 insertions(+)

diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index 264f84c..5548820 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -11,6 +11,10 @@
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-host.html#virConnectGetHostname"/>
     </property>
+    <property name="LibVersion" type="t" access="read">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-host.html#virConnectGetLibVersion"/>
+    </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"/>
diff --git a/src/connect.c b/src/connect.c
index b34cd95..3fbb770 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -129,6 +129,24 @@ virtDBusConnectGetHostname(const gchar *objectPath G_GNUC_UNUSED,
     *value = g_variant_new("s", hostname);
 }
 
+static void
+virtDBusConnectGetLibVersion(const gchar *objectPath G_GNUC_UNUSED,
+                             gpointer userData,
+                             GVariant **value,
+                             GError **error)
+{
+    virtDBusConnect *connect = userData;
+    gulong libVer;
+
+    if (!virtDBusConnectOpen(connect, error))
+        return;
+
+    if (virConnectGetLibVersion(connect->connection, &libVer) < 0)
+        return virtDBusUtilSetLastVirtError(error);
+
+    *value = g_variant_new("t", libVer);
+}
+
 static void
 virtDBusConnectGetVersion(const gchar *objectPath G_GNUC_UNUSED,
                           gpointer userData,
@@ -483,6 +501,7 @@ virtDBusNetworkLookupByUUID(GVariant *inArgs,
 static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = {
     { "Capabilities", virtDBusConnectGetCapabilities, NULL },
     { "Hostname", virtDBusConnectGetHostname, NULL },
+    { "LibVersion", virtDBusConnectGetLibVersion, NULL },
     { "Version", virtDBusConnectGetVersion, NULL },
     { 0 }
 };
diff --git a/test/test_connect.py b/test/test_connect.py
index 75a955e..f544f76 100755
--- a/test/test_connect.py
+++ b/test/test_connect.py
@@ -83,6 +83,7 @@ class TestConnect(libvirttest.BaseTestClass):
     @pytest.mark.parametrize("property_name,expected_type", [
         ("Capabilities", dbus.String),
         ("Hostname", dbus.String),
+        ("LibVersion", dbus.UInt64),
         ("Version", dbus.UInt64),
     ])
     def test_connect_properties_return_type(self, property_name, expected_type):
-- 
2.15.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux