[dbus PATCH v2 09/17] Implement GetXMLDesc 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 +++++++++++++++++++++++++++++
 tests/test_storage.py           |  7 +++++++
 3 files changed, 42 insertions(+)

diff --git a/data/org.libvirt.StorageVol.xml b/data/org.libvirt.StorageVol.xml
index 03c15c2..c1fecf3 100644
--- a/data/org.libvirt.StorageVol.xml
+++ b/data/org.libvirt.StorageVol.xml
@@ -18,5 +18,11 @@
           value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolGetPath"/>
       <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
     </property>
+    <method name="GetXMLDesc">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolGetXMLDesc"/>
+      <arg name="flags" type="u" direction="in"/>
+      <arg name="xml" type="s" direction="out"/>
+    </method>
   </interface>
 </node>
diff --git a/src/storagevol.c b/src/storagevol.c
index 7f33de8..fb66dd0 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
+virtDBusStorageVolGetXMLDesc(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;
+    g_autofree gchar *xml = NULL;
+    guint flags;
+
+    g_variant_get(inArgs, "(u)", &flags);
+
+    storageVol = virtDBusStorageVolGetVirStorageVol(connect, objectPath,
+                                                    error);
+    if (!storageVol)
+        return;
+
+    xml = virStorageVolGetXMLDesc(storageVol, flags);
+    if (!xml)
+        return virtDBusUtilSetLastVirtError(error);
+
+    *outArgs = g_variant_new("(s)", xml);
+}
+
 static virtDBusGDBusPropertyTable virtDBusStorageVolPropertyTable[] = {
     { "Name", virtDBusStorageVolGetName, NULL },
     { "Key", virtDBusStorageVolGetKey, NULL },
@@ -98,6 +126,7 @@ static virtDBusGDBusPropertyTable virtDBusStorageVolPropertyTable[] = {
 };
 
 static virtDBusGDBusMethodTable virtDBusStorageVolMethodTable[] = {
+    { "GetXMLDesc", virtDBusStorageVolGetXMLDesc },
     { 0 }
 };
 
diff --git a/tests/test_storage.py b/tests/test_storage.py
index d3a8701..3f15fe0 100755
--- a/tests/test_storage.py
+++ b/tests/test_storage.py
@@ -142,6 +142,13 @@ class TestStorageVolume(libvirttest.BaseTestClass):
         assert isinstance(props['Name'], dbus.String)
         assert isinstance(props['Path'], dbus.String)
 
+    def test_storage_vol_get_xml_description(self):
+        _, test_storage_vol = self.get_test_storage_volume()
+        interface_obj = dbus.Interface(test_storage_vol,
+                                       'org.libvirt.StorageVol')
+        xml = interface_obj.GetXMLDesc(0)
+        assert isinstance(xml, dbus.String)
+
 
 if __name__ == '__main__':
     libvirttest.run()
-- 
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