[dbus PATCH v2 1/8] Implement GetCapabilities method 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 |  5 +++++
 src/connect.c                | 23 +++++++++++++++++++++++
 test/test_connect.py         |  3 +++
 3 files changed, 31 insertions(+)

diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index e36b7f6..91faa73 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -44,6 +44,11 @@
       <arg name="uuid" type="s" direction="in"/>
       <arg name="domain" type="o" direction="out"/>
     </method>
+    <method name="GetCapabilities">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-host.html#virConnectGetCapabilities"/>
+      <arg name="capabilities" type="s" direction="out"/>
+    </method>
     <method name="ListNetworks">
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-network.html#virConnectListAllNetworks"/>
diff --git a/src/connect.c b/src/connect.c
index ce9055a..6c2f910 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -109,6 +109,28 @@ virtDBusConnectGetVersion(const gchar *objectPath G_GNUC_UNUSED,
     *value = g_variant_new("t", hvVer);
 }
 
+static void
+virtDBusConnectGetCapabilities(GVariant *inArgs G_GNUC_UNUSED,
+                               GUnixFDList *inFDs G_GNUC_UNUSED,
+                               const gchar *objectPath G_GNUC_UNUSED,
+                               gpointer userData,
+                               GVariant **outArgs,
+                               GUnixFDList **outFDs G_GNUC_UNUSED,
+                               GError **error)
+{
+    virtDBusConnect *connect = userData;
+    g_autofree gchar *capabilities = NULL;
+
+    if (!virtDBusConnectOpen(connect, error))
+        return;
+
+    capabilities = virConnectGetCapabilities(connect->connection);
+    if (!capabilities)
+        return virtDBusUtilSetLastVirtError(error);
+
+    *outArgs = g_variant_new("(s)", capabilities);
+}
+
 static void
 virtDBusConnectListDomains(GVariant *inArgs,
                            GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -454,6 +476,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
     { "DomainLookupByID", virtDBusDomainLookupByID },
     { "DomainLookupByName", virtDBusDomainLookupByName },
     { "DomainLookupByUUID", virtDBusDomainLookupByUUID },
+    { "GetCapabilities", virtDBusConnectGetCapabilities },
     { "ListNetworks", virtDBusConnectListNetworks },
     { "NetworkCreateXML", virtDBusConnectNetworkCreateXML },
     { "NetworkDefineXML", virtDBusConnectNetworkDefineXML },
diff --git a/test/test_connect.py b/test/test_connect.py
index c411eeb..0571cae 100755
--- a/test/test_connect.py
+++ b/test/test_connect.py
@@ -100,6 +100,9 @@ class TestConnect(libvirttest.BaseTestClass):
             # ensure the path exists by calling Introspect on it
             network.Introspect(dbus_interface=dbus.INTROSPECTABLE_IFACE)
 
+    def test_connect_get_capabilities(self):
+        assert isinstance(self.connect.GetCapabilities(), dbus.String)
+
     def test_connect_network_create_xml(self):
         def network_started(path, _event):
             assert isinstance(path, dbus.ObjectPath)
-- 
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