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

Katerina Koukiou kkoukiou at redhat.com
Mon May 7 14:40:46 UTC 2018


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

Signed-off-by: Katerina Koukiou <kkoukiou at redhat.com>
---
 data/org.libvirt.StoragePool.xml |  5 +++++
 src/storagepool.c                | 25 +++++++++++++++++++++++++
 tests/libvirttest.py             |  8 ++++++++
 tests/test_storage.py            |  8 +++++++-
 4 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePool.xml
index ac628d9..f96e676 100644
--- a/data/org.libvirt.StoragePool.xml
+++ b/data/org.libvirt.StoragePool.xml
@@ -3,6 +3,11 @@
 
 <node name="/org/libvirt/storagepool">
   <interface name="org.libvirt.StoragePool">
+    <method name="Build">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolBuild"/>
+      <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 5202f9e..d23c847 100644
--- a/src/storagepool.c
+++ b/src/storagepool.c
@@ -24,6 +24,30 @@ virtDBusStoragePoolGetVirStoragePool(virtDBusConnect *connect,
     return storagePool;
 }
 
+static void
+virtDBusStoragePoolBuild(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 (virStoragePoolBuild(storagePool, flags) < 0)
+        virtDBusUtilSetLastVirtError(error);
+}
+
 static void
 virtDBusStoragePoolDestroy(GVariant *inArgs G_GNUC_UNUSED,
                            GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -50,6 +74,7 @@ static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] = {
 };
 
 static virtDBusGDBusMethodTable virtDBusStoragePoolMethodTable[] = {
+    { "Build", virtDBusStoragePoolBuild },
     { "Destroy", virtDBusStoragePoolDestroy },
     { 0 }
 };
diff --git a/tests/libvirttest.py b/tests/libvirttest.py
index e88484f..3cd02ef 100644
--- a/tests/libvirttest.py
+++ b/tests/libvirttest.py
@@ -187,6 +187,14 @@ class NetworkEvent(IntEnum):
     STOPPED = 3
 
 
+class StoragePoolBuildFlags(IntEnum):
+    NEW = 0
+    REPAIR = 1
+    RESIZE = 2
+    NO_OVERWRITE = 4
+    OVERWRITE = 8
+
+
 class StoragePoolEvent(IntEnum):
     DEFINED = 0
     UNDEFINED = 1
diff --git a/tests/test_storage.py b/tests/test_storage.py
index 8c5d75f..cf13024 100755
--- a/tests/test_storage.py
+++ b/tests/test_storage.py
@@ -4,6 +4,13 @@ import dbus
 import libvirttest
 
 class TestStoragePool(libvirttest.BaseTestClass):
+    def test_storage_pool_build(self):
+        _, test_storage_pool = self.test_storage_pool()
+        interface_obj = dbus.Interface(test_storage_pool,
+                                       'org.libvirt.StoragePool')
+        interface_obj.Destroy()
+        interface_obj.Build(libvirttest.StoragePoolBuildFlags.NEW)
+
     def test_storage_pool_destroy(self):
         def storage_pool_destroyed(path, event, _detail):
             if event != libvirttest.StoragePoolEvent.STOPPED:
@@ -13,7 +20,6 @@ class TestStoragePool(libvirttest.BaseTestClass):
 
         self.connect.connect_to_signal('StoragePoolEvent',
                                        storage_pool_destroyed)
-
         _, test_storage_pool = self.test_storage_pool()
         interface_obj = dbus.Interface(test_storage_pool,
                                        'org.libvirt.StoragePool')
-- 
2.15.0




More information about the libvir-list mailing list