[libvirt] [dbus PATCH 19/19] Implement Undefine method for StoragePool Interface

Katerina Koukiou kkoukiou at redhat.com
Mon May 7 14:41:00 UTC 2018


Signed-off-by: Katerina Koukiou <kkoukiou at redhat.com>
---
 data/org.libvirt.StoragePool.xml |  4 ++++
 src/storagepool.c                | 22 ++++++++++++++++++++++
 tests/test_storage.py            | 18 ++++++++++++++++++
 3 files changed, 44 insertions(+)

diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePool.xml
index 9d59818..d7e19d0 100644
--- a/data/org.libvirt.StoragePool.xml
+++ b/data/org.libvirt.StoragePool.xml
@@ -61,5 +61,9 @@
         value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolRefresh"/>
       <arg name="flags" type="u" direction="in"/>
     </method>
+    <method name="Undefine">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolUndefine"/>
+    </method>
   </interface>
 </node>
diff --git a/src/storagepool.c b/src/storagepool.c
index a40db14..c8b6467 100644
--- a/src/storagepool.c
+++ b/src/storagepool.c
@@ -325,6 +325,27 @@ virtDBusStoragePoolRefresh(GVariant *inArgs,
         virtDBusUtilSetLastVirtError(error);
 }
 
+static void
+virtDBusStoragePoolUndefine(GVariant *inArgs G_GNUC_UNUSED,
+                            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;
+
+    storagePool = virtDBusStoragePoolGetVirStoragePool(connect, objectPath,
+                                                       error);
+    if (!storagePool)
+        return;
+
+    if (virStoragePoolUndefine(storagePool) < 0)
+        virtDBusUtilSetLastVirtError(error);
+}
+
 static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] = {
     { "Active", virtDBusStoragePoolGetActive, NULL },
     { "Autostart", virtDBusStoragePoolGetAutostart,
@@ -343,6 +364,7 @@ static virtDBusGDBusMethodTable virtDBusStoragePoolMethodTable[] = {
     { "GetInfo", virtDBusStoragePoolGetInfo },
     { "GetXMLDesc", virtDBusStoragePoolGetXMLDesc },
     { "Refresh", virtDBusStoragePoolRefresh },
+    { "Undefine", virtDBusStoragePoolUndefine },
     { 0 }
 };
 
diff --git a/tests/test_storage.py b/tests/test_storage.py
index 2d87e08..d2cbbb5 100755
--- a/tests/test_storage.py
+++ b/tests/test_storage.py
@@ -89,6 +89,24 @@ class TestStoragePool(libvirttest.BaseTestClass):
         assert isinstance(props['Persistent'], dbus.Boolean)
         assert isinstance(props['UUID'], dbus.String)
 
+    def test_storage_pool_undefine(self):
+        def storage_pool_undefined(path, event, _detail):
+            if event != libvirttest.StoragePoolEvent.UNDEFINED:
+                return
+            assert isinstance(path, dbus.ObjectPath)
+            self.loop.quit()
+
+        self.connect.connect_to_signal('StoragePoolEvent',
+                                       storage_pool_undefined)
+
+        _, test_storage_pool = self.test_storage_pool()
+        interface_obj = dbus.Interface(test_storage_pool,
+                                       'org.libvirt.StoragePool')
+        interface_obj.Destroy()
+        interface_obj.Undefine()
+
+        self.main_loop()
+
 
 if __name__ == '__main__':
     libvirttest.run()
-- 
2.15.0




More information about the libvir-list mailing list