[dbus PATCH v2 15/17] Implement GetInfo method for StorageVol 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.StorageVol.xml |  6 ++++++
 src/storagevol.c                | 29 +++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/data/org.libvirt.StorageVol.xml b/data/org.libvirt.StorageVol.xml
index aed3f7a..8a4eab2 100644
--- a/data/org.libvirt.StorageVol.xml
+++ b/data/org.libvirt.StorageVol.xml
@@ -18,6 +18,12 @@
           value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolGetPath"/>
       <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
     </property>
+    <method name="GetInfo">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolGetInfoFlags"/>
+      <arg name="flags" type="u" direction="in"/>
+      <arg name="info" type="(itt)" direction="out"/>
+    </method>
     <method name="GetXMLDesc">
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolGetXMLDesc"/>
diff --git a/src/storagevol.c b/src/storagevol.c
index 7bfe39e..022ce37 100644
--- a/src/storagevol.c
+++ b/src/storagevol.c
@@ -90,6 +90,34 @@ virtDBusStorageVolGetPath(const gchar *objectPath,
     *value = g_variant_new("s", path);
 }
 
+static void
+virtDBusStorageVolGetInfo(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(virStorageVol) storageVol = NULL;
+    virStorageVolInfo info;
+    guint flags;
+
+    g_variant_get(inArgs, "(u)", &flags);
+
+    storageVol = virtDBusStorageVolGetVirStorageVol(connect, objectPath,
+                                                    error);
+    if (!storageVol)
+        return;
+
+    if (virStorageVolGetInfoFlags(storageVol, &info, flags) < 0)
+        return virtDBusUtilSetLastVirtError(error);
+
+    *outArgs = g_variant_new("((itt))", info.type, info.capacity,
+                             info.allocation);
+}
+
 static void
 virtDBusStorageVolGetXMLDesc(GVariant *inArgs,
                              GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -176,6 +204,7 @@ static virtDBusGDBusPropertyTable virtDBusStorageVolPropertyTable[] = {
 };
 
 static virtDBusGDBusMethodTable virtDBusStorageVolMethodTable[] = {
+    { "GetInfo", virtDBusStorageVolGetInfo },
     { "GetXMLDesc", virtDBusStorageVolGetXMLDesc },
     { "Resize", virtDBusStorageVolResize },
     { "Wipe", virtDBusStorageVolWipe },
-- 
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