[libvirt] [dbus PATCH 10/19] Implement Name property for StoragePool Interface

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


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

diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePool.xml
index 29d501b..8bc90b7 100644
--- a/data/org.libvirt.StoragePool.xml
+++ b/data/org.libvirt.StoragePool.xml
@@ -8,6 +8,10 @@
       <annotation name="org.gtk.GDBus.DocString"
           value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetAutostart"/>
     </property>
+    <property name="Name" type="s" access="read">
+      <annotation name="org.gtk.GDBus.DocString"
+          value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetName"/>
+    </property>
     <method name="Build">
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolBuild"/>
diff --git a/src/storagepool.c b/src/storagepool.c
index a7bcc94..f81a670 100644
--- a/src/storagepool.c
+++ b/src/storagepool.c
@@ -45,6 +45,28 @@ virtDBusStoragePoolGetAutostart(const gchar *objectPath,
     *value = g_variant_new("b", !!autostart);
 }
 
+static void
+virtDBusStoragePoolGetName(const gchar *objectPath,
+                           gpointer userData,
+                           GVariant **value,
+                           GError **error)
+{
+    virtDBusConnect *connect = userData;
+    g_autoptr(virStoragePool) storagePool = NULL;
+    const gchar *name;
+
+    storagePool = virtDBusStoragePoolGetVirStoragePool(connect, objectPath,
+                                                       error);
+    if (!storagePool)
+        return;
+
+    name = virStoragePoolGetName(storagePool);
+    if (!name)
+        return virtDBusUtilSetLastVirtError(error);
+
+    *value = g_variant_new("s", name);
+}
+
 static void
 virtDBusStoragePoolBuild(GVariant *inArgs,
                          GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -167,6 +189,7 @@ virtDBusStoragePoolGetInfo(GVariant *inArgs G_GNUC_UNUSED,
 
 static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] = {
     { "Autostart", virtDBusStoragePoolGetAutostart, NULL },
+    { "Name", virtDBusStoragePoolGetName, NULL },
     { 0 }
 };
 
diff --git a/tests/test_storage.py b/tests/test_storage.py
index 116385b..8e73228 100755
--- a/tests/test_storage.py
+++ b/tests/test_storage.py
@@ -64,6 +64,7 @@ class TestStoragePool(libvirttest.BaseTestClass):
         props = obj.GetAll('org.libvirt.StoragePool',
                            dbus_interface=dbus.PROPERTIES_IFACE)
         assert isinstance(props['Autostart'], dbus.Boolean)
+        assert isinstance(props['Name'], dbus.String)
 
 
 if __name__ == '__main__':
-- 
2.15.0




More information about the libvir-list mailing list