[libvirt] [dbus PATCH 09/15] Implement StorageVolLookupByName method for StoragePool Interface

Katerina Koukiou kkoukiou at redhat.com
Tue Jun 12 09:00:22 UTC 2018


Signed-off-by: Katerina Koukiou <kkoukiou at redhat.com>
---
 data/org.libvirt.StoragePool.xml |  6 ++++++
 src/storagepool.c                | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePool.xml
index 51d65ab..161ade5 100644
--- a/data/org.libvirt.StoragePool.xml
+++ b/data/org.libvirt.StoragePool.xml
@@ -75,6 +75,12 @@
       <arg name="flags" type="u" direction="in"/>
       <arg name="storageVol" type="o" direction="out"/>
     </method>
+    <method name="StorageVolLookupByName">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolLookupByName"/>
+      <arg name="name" type="s" direction="in"/>
+      <arg name="storageVol" type="o" direction="out"/>
+    </method>
     <method name="Undefine">
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolUndefine"/>
diff --git a/src/storagepool.c b/src/storagepool.c
index c3fd0bf..55077ed 100644
--- a/src/storagepool.c
+++ b/src/storagepool.c
@@ -401,6 +401,39 @@ virtDBusStoragePoolStorageVolCreateXML(GVariant *inArgs,
     *outArgs = g_variant_new("(o)", path);
 }
 
+static void
+virtDBusStoragePoolStorageVolLookupByName(GVariant *inArgs,
+                                          GUnixFDList *inFDs G_GNUC_UNUSED,
+                                          const gchar *objectPath G_GNUC_UNUSED,
+                                          gpointer userData,
+                                          GVariant **outArgs,
+                                          GUnixFDList **outFDs G_GNUC_UNUSED,
+                                          GError **error)
+{
+    virtDBusConnect *connect = userData;
+    g_autoptr(virStoragePool) storagePool = NULL;
+    g_autoptr(virStorageVol) storageVol = NULL;
+    g_autofree gchar *path = NULL;
+    const gchar *name;
+
+    g_variant_get(inArgs, "(&s)", &name);
+
+    storagePool = virtDBusStoragePoolGetVirStoragePool(connect, objectPath,
+                                                       error);
+    if (!storagePool)
+        return;
+
+    storageVol = virStorageVolLookupByName(storagePool, name);
+
+    if (!storageVol)
+        return virtDBusUtilSetLastVirtError(error);
+
+    path = virtDBusUtilBusPathForVirStorageVol(storageVol,
+                                               connect->storageVolPath);
+
+    *outArgs = g_variant_new("(o)", path);
+}
+
 static void
 virtDBusStoragePoolUndefine(GVariant *inArgs G_GNUC_UNUSED,
                             GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -442,6 +475,7 @@ static virtDBusGDBusMethodTable virtDBusStoragePoolMethodTable[] = {
     { "ListStorageVolumes", virtDBusStoragePoolListAllVolumes },
     { "Refresh", virtDBusStoragePoolRefresh },
     { "StorageVolCreateXML", virtDBusStoragePoolStorageVolCreateXML },
+    { "StorageVolLookupByName", virtDBusStoragePoolStorageVolLookupByName },
     { "Undefine", virtDBusStoragePoolUndefine },
     { 0 }
 };
-- 
2.15.0




More information about the libvir-list mailing list