[dbus PATCH 07/19] Implement Delete method for StoragePool Interface

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

 



VIR_STORAGE_POOL_EVENT_DELETED event was added in 3.1.
Test should be fixed later on to use signal handler.

Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx>
---
 data/org.libvirt.StoragePool.xml |  5 +++++
 src/storagepool.c                | 25 +++++++++++++++++++++++++
 tests/test_storage.py            |  7 +++++++
 3 files changed, 37 insertions(+)

diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePool.xml
index 7e837c0..fb21e59 100644
--- a/data/org.libvirt.StoragePool.xml
+++ b/data/org.libvirt.StoragePool.xml
@@ -13,6 +13,11 @@
         value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolCreate"/>
       <arg name="flags" type="u" direction="in"/>
     </method>
+    <method name="Delete">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolDelete"/>
+      <arg name="flags" type="u" direction="in"/>
+    </method>
     <method name="Destroy">
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolDestroy"/>
diff --git a/src/storagepool.c b/src/storagepool.c
index d4cd7a7..bf1fd3f 100644
--- a/src/storagepool.c
+++ b/src/storagepool.c
@@ -72,6 +72,30 @@ virtDBusStoragePoolCreate(GVariant *inArgs,
         virtDBusUtilSetLastVirtError(error);
 }
 
+static void
+virtDBusStoragePoolDelete(GVariant *inArgs,
+                          GUnixFDList *inFDs G_GNUC_UNUSED,
+                          const gchar *objectPath,
+                          gpointer userData,
+                          GVariant **outArgs G_GNUC_UNUSED,
+                          GUnixFDList **outFDs G_GNUC_UNUSED,
+                          GError **error)
+{
+    virtDBusConnect *connect = userData;
+    g_autoptr(virStoragePool) storagePool = NULL;
+    guint flags;
+
+    g_variant_get(inArgs, "(u)", &flags);
+
+    storagePool = virtDBusStoragePoolGetVirStoragePool(connect, objectPath,
+                                                       error);
+    if (!storagePool)
+        return;
+
+    if (virStoragePoolDelete(storagePool, flags) < 0)
+        virtDBusUtilSetLastVirtError(error);
+}
+
 static void
 virtDBusStoragePoolDestroy(GVariant *inArgs G_GNUC_UNUSED,
                            GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -100,6 +124,7 @@ static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] = {
 static virtDBusGDBusMethodTable virtDBusStoragePoolMethodTable[] = {
     { "Build", virtDBusStoragePoolBuild },
     { "Create", virtDBusStoragePoolCreate },
+    { "Delete", virtDBusStoragePoolDelete },
     { "Destroy", virtDBusStoragePoolDestroy },
     { 0 }
 };
diff --git a/tests/test_storage.py b/tests/test_storage.py
index b1927cb..c4c7cf1 100755
--- a/tests/test_storage.py
+++ b/tests/test_storage.py
@@ -28,6 +28,13 @@ class TestStoragePool(libvirttest.BaseTestClass):
 
         self.main_loop()
 
+    def test_storage_pool_delete(self):
+        _, test_storage_pool = self.test_storage_pool()
+        interface_obj = dbus.Interface(test_storage_pool,
+                                       'org.libvirt.StoragePool')
+        interface_obj.Destroy()
+        interface_obj.Delete(0)
+
     def test_storage_pool_destroy(self):
         def storage_pool_destroyed(path, event, _detail):
             if event != libvirttest.StoragePoolEvent.STOPPED:
-- 
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