[dbus PATCH v2 11/17] Implement StorageVolLookupByName method for StoragePool Interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx>
Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 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 cde9ec3..ee2862b 100644
--- a/src/storagepool.c
+++ b/src/storagepool.c
@@ -400,6 +400,39 @@ virtDBusStoragePoolStorageVolCreateXML(GVariant *inArgs,
     *outArgs = g_variant_new("(o)", path);
 }
 
+static void
+virtDBusStoragePoolStorageVolLookupByName(GVariant *inArgs,
+                                          GUnixFDList *inFDs G_GNUC_UNUSED,
+                                          const gchar *objectPath,
+                                          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,
@@ -441,6 +474,7 @@ static virtDBusGDBusMethodTable virtDBusStoragePoolMethodTable[] = {
     { "ListStorageVolumes", virtDBusStoragePoolListStorageVolumes },
     { "Refresh", virtDBusStoragePoolRefresh },
     { "StorageVolCreateXML", virtDBusStoragePoolStorageVolCreateXML },
+    { "StorageVolLookupByName", virtDBusStoragePoolStorageVolLookupByName },
     { "Undefine", virtDBusStoragePoolUndefine },
     { 0 }
 };
-- 
2.15.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux