Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx> --- data/org.libvirt.StoragePool.xml | 5 +++++ src/storagepool.c | 28 ++++++++++++++++++++++++++++ tests/test_storage.py | 7 +++++++ 3 files changed, 40 insertions(+) diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePool.xml index ed03474..29d501b 100644 --- a/data/org.libvirt.StoragePool.xml +++ b/data/org.libvirt.StoragePool.xml @@ -27,5 +27,10 @@ <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolDestroy"/> </method> + <method name="GetInfo"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetInfo"/> + <arg name="info" type="(uttt)" direction="out"/> + </method> </interface> </node> diff --git a/src/storagepool.c b/src/storagepool.c index 515b38c..a7bcc94 100644 --- a/src/storagepool.c +++ b/src/storagepool.c @@ -138,6 +138,33 @@ virtDBusStoragePoolDestroy(GVariant *inArgs G_GNUC_UNUSED, virtDBusUtilSetLastVirtError(error); } +static void +virtDBusStoragePoolGetInfo(GVariant *inArgs G_GNUC_UNUSED, + 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 virStoragePoolInfoPtr info = NULL; + + storagePool = virtDBusStoragePoolGetVirStoragePool(connect, objectPath, + error); + if (!storagePool) + return; + + info = g_new0(virStoragePoolInfo, 1); + if (virStoragePoolGetInfo(storagePool, info) < 0) + return virtDBusUtilSetLastVirtError(error); + + *outArgs = g_variant_new("((uttt))", info->state, + info->capacity, info->allocation, + info->available); +} + static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] = { { "Autostart", virtDBusStoragePoolGetAutostart, NULL }, { 0 } @@ -148,6 +175,7 @@ static virtDBusGDBusMethodTable virtDBusStoragePoolMethodTable[] = { { "Create", virtDBusStoragePoolCreate }, { "Delete", virtDBusStoragePoolDelete }, { "Destroy", virtDBusStoragePoolDestroy }, + { "GetInfo", virtDBusStoragePoolGetInfo }, { 0 } }; diff --git a/tests/test_storage.py b/tests/test_storage.py index 0aa75e3..116385b 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -51,6 +51,13 @@ class TestStoragePool(libvirttest.BaseTestClass): self.main_loop() + def test_storage_pool_get_info(self): + _, test_storage_pool = self.test_storage_pool() + interface_obj = dbus.Interface(test_storage_pool, + 'org.libvirt.StoragePool') + info = interface_obj.GetInfo() + assert isinstance(info, dbus.Struct) + def test_storage_pool_properties_type(self): _, obj = self.test_storage_pool() -- 2.15.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list