Signed-off-by: Katerina Koukiou <kkouk...@redhat.com> --- data/org.libvirt.StoragePool.xml | 6 ++++++ src/storagepool.c | 29 +++++++++++++++++++++++++++++ tests/test_storage.py | 7 +++++++ 3 files changed, 42 insertions(+)
diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePool.xml index a60ef84..50550ee 100644 --- a/data/org.libvirt.StoragePool.xml +++ b/data/org.libvirt.StoragePool.xml @@ -41,5 +41,11 @@ value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetInfo"/> <arg name="info" type="(uttt)" direction="out"/> </method> + <method name="GetXMLDesc"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetXMLDesc"/> + <arg name="flags" type="u" direction="in"/> + <arg name="xml" type="s" direction="out"/> + </method> </interface> </node> diff --git a/src/storagepool.c b/src/storagepool.c index 43e8040..628ad17 100644 --- a/src/storagepool.c +++ b/src/storagepool.c @@ -208,6 +208,34 @@ virtDBusStoragePoolGetInfo(GVariant *inArgs G_GNUC_UNUSED, info->available); } +static void +virtDBusStoragePoolGetXMLDesc(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_autofree gchar *xml = NULL; + guint flags; + + g_variant_get(inArgs, "(u)", &flags); + + storagePool = virtDBusStoragePoolGetVirStoragePool(connect, objectPath, + error); + if (!storagePool) + return; + + xml = virStoragePoolGetXMLDesc(storagePool, flags); + if (!xml) + return virtDBusUtilSetLastVirtError(error); + + *outArgs = g_variant_new("(s)", xml); +} + static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] = { { "Autostart", virtDBusStoragePoolGetAutostart, NULL }, { "Name", virtDBusStoragePoolGetName, NULL }, @@ -221,6 +249,7 @@ static virtDBusGDBusMethodTable virtDBusStoragePoolMethodTable[] = { { "Delete", virtDBusStoragePoolDelete }, { "Destroy", virtDBusStoragePoolDestroy }, { "GetInfo", virtDBusStoragePoolGetInfo }, + { "GetXMLDesc", virtDBusStoragePoolGetXMLDesc }, { 0 } }; diff --git a/tests/test_storage.py b/tests/test_storage.py index 3e67633..1afae2a 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -58,6 +58,13 @@ class TestStoragePool(libvirttest.BaseTestClass): info = interface_obj.GetInfo() assert isinstance(info, dbus.Struct) + def test_storage_pool_get_xml_description(self): + _, test_storage_pool = self.test_storage_pool() + interface_obj = dbus.Interface(test_storage_pool, + 'org.libvirt.StoragePool') + info = interface_obj.GetXMLDesc(0) + assert isinstance(info, dbus.String) + def test_storage_pool_properties_type(self): _, obj = self.test_storage_pool() -- 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list