[dbus PATCH 02/22] Implement StoragePoolDefineXML 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 |  7 +++++++
 src/connect.c                | 31 +++++++++++++++++++++++++++++++
 tests/test_connect.py        | 15 +++++++++++++++
 3 files changed, 53 insertions(+)

diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index 2f88d42..7b0a73e 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -258,6 +258,13 @@
       <arg name="flags" type="u" direction="in"/>
       <arg name="storagePool" type="o" direction="out"/>
     </method>
+    <method name="StoragePoolDefineXML">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolDefineXML"/>
+      <arg name="xml" type="s" direction="in"/>
+      <arg name="flags" type="u" direction="in"/>
+      <arg name="storagePool" type="o" direction="out"/>
+    </method>
     <method name="StoragePoolLookupByName">
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolLookupByName"/>
diff --git a/src/connect.c b/src/connect.c
index a6163d2..0ee532e 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -1306,6 +1306,36 @@ virtDBusConnectStoragePoolCreateXML(GVariant *inArgs,
     *outArgs = g_variant_new("(o)", path);
 }
 
+static void
+virtDBusConnectStoragePoolDefineXML(GVariant *inArgs,
+                                    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_autoptr(virStoragePool) storagePool = NULL;
+    g_autofree gchar *path = NULL;
+    gchar *xml;
+    guint flags;
+
+    g_variant_get(inArgs, "(&su)", &xml, &flags);
+
+    if (!virtDBusConnectOpen(connect, error))
+        return;
+
+    storagePool = virStoragePoolDefineXML(connect->connection, xml, flags);
+    if (!storagePool)
+        return virtDBusUtilSetLastVirtError(error);
+
+    path = virtDBusUtilBusPathForVirStoragePool(storagePool,
+                                                connect->storagePoolPath);
+
+    *outArgs = g_variant_new("(o)", path);
+}
+
 static void
 virtDBusConnectStoragePoolLookupByName(GVariant *inArgs,
                                        GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -1410,6 +1440,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
     { "SecretLookupByUUID", virtDBusConnectSecretLookupByUUID },
     { "SecretLookupByUsage", virtDBusConnectSecretLookupByUsage },
     { "StoragePoolCreateXML", virtDBusConnectStoragePoolCreateXML },
+    { "StoragePoolDefineXML", virtDBusConnectStoragePoolDefineXML },
     { "StoragePoolLookupByName", virtDBusConnectStoragePoolLookupByName },
     { "StoragePoolLookupByUUID", virtDBusConnectStoragePoolLookupByUUID },
     { 0 }
diff --git a/tests/test_connect.py b/tests/test_connect.py
index 6e28b81..4becf4e 100755
--- a/tests/test_connect.py
+++ b/tests/test_connect.py
@@ -223,6 +223,21 @@ class TestConnect(libvirttest.BaseTestClass):
 
         self.main_loop()
 
+    def test_connect_storage_pool_define_xml(self):
+        def storage_pool_defined(path, event, _detail):
+            if event != libvirttest.StoragePoolEvent.DEFINED:
+                return
+            assert isinstance(path, dbus.ObjectPath)
+            self.loop.quit()
+
+        self.connect.connect_to_signal('StoragePoolEvent', storage_pool_defined)
+
+        path = self.connect.StoragePoolDefineXML(
+            self.minimal_storage_pool_xml, 0)
+        assert isinstance(path, dbus.ObjectPath)
+
+        self.main_loop()
+
     @pytest.mark.parametrize("lookup_method_name,lookup_item", [
         ("StoragePoolLookupByName", 'Name'),
         ("StoragePoolLookupByUUID", 'UUID'),
-- 
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