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

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


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

diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePool.xml
index f96e676..7e837c0 100644
--- a/data/org.libvirt.StoragePool.xml
+++ b/data/org.libvirt.StoragePool.xml
@@ -8,6 +8,11 @@
         value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolBuild"/>
       <arg name="flags" type="u" direction="in"/>
     </method>
+    <method name="Create">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolCreate"/>
+      <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 d23c847..d4cd7a7 100644
--- a/src/storagepool.c
+++ b/src/storagepool.c
@@ -48,6 +48,30 @@ virtDBusStoragePoolBuild(GVariant *inArgs,
         virtDBusUtilSetLastVirtError(error);
 }
 
+static void
+virtDBusStoragePoolCreate(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 (virStoragePoolCreate(storagePool, flags) < 0)
+        virtDBusUtilSetLastVirtError(error);
+}
+
 static void
 virtDBusStoragePoolDestroy(GVariant *inArgs G_GNUC_UNUSED,
                            GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -75,6 +99,7 @@ static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] = {
 
 static virtDBusGDBusMethodTable virtDBusStoragePoolMethodTable[] = {
     { "Build", virtDBusStoragePoolBuild },
+    { "Create", virtDBusStoragePoolCreate },
     { "Destroy", virtDBusStoragePoolDestroy },
     { 0 }
 };
diff --git a/tests/test_storage.py b/tests/test_storage.py
index cf13024..b1927cb 100755
--- a/tests/test_storage.py
+++ b/tests/test_storage.py
@@ -11,6 +11,23 @@ class TestStoragePool(libvirttest.BaseTestClass):
         interface_obj.Destroy()
         interface_obj.Build(libvirttest.StoragePoolBuildFlags.NEW)
 
+    def test_storage_pool_create(self):
+        def storage_pool_started(path, event, _detail):
+            if event != libvirttest.StoragePoolEvent.STARTED:
+                return
+            assert isinstance(path, dbus.ObjectPath)
+            self.loop.quit()
+
+        self.connect.connect_to_signal('StoragePoolEvent', storage_pool_started)
+
+        _, test_storage_pool = self.test_storage_pool()
+        interface_obj = dbus.Interface(test_storage_pool,
+                                       'org.libvirt.StoragePool')
+        interface_obj.Destroy()
+        interface_obj.Create(0)
+
+        self.main_loop()
+
     def test_storage_pool_destroy(self):
         def storage_pool_destroyed(path, event, _detail):
             if event != libvirttest.StoragePoolEvent.STOPPED:
-- 
2.15.0




More information about the libvir-list mailing list