Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx> --- data/org.libvirt.StoragePool.xml | 5 +++++ src/storagepool.c | 22 ++++++++++++++++++++++ tests/test_storage.py | 1 + 3 files changed, 28 insertions(+) diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePool.xml index 8bc90b7..a60ef84 100644 --- a/data/org.libvirt.StoragePool.xml +++ b/data/org.libvirt.StoragePool.xml @@ -12,6 +12,11 @@ <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetName"/> </property> + <property name="UUID" type="s" access="read"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetUUIDString"/> + <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/> + </property> <method name="Build"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolBuild"/> diff --git a/src/storagepool.c b/src/storagepool.c index f81a670..43e8040 100644 --- a/src/storagepool.c +++ b/src/storagepool.c @@ -67,6 +67,27 @@ virtDBusStoragePoolGetName(const gchar *objectPath, *value = g_variant_new("s", name); } +static void +virtDBusStoragePoolGetUUID(const gchar *objectPath, + gpointer userData, + GVariant **value, + GError **error) +{ + virtDBusConnect *connect = userData; + g_autoptr(virStoragePool) storagePool = NULL; + gchar uuid[VIR_UUID_STRING_BUFLEN] = ""; + + storagePool = virtDBusStoragePoolGetVirStoragePool(connect, objectPath, + error); + if (!storagePool) + return; + + if (virStoragePoolGetUUIDString(storagePool, uuid) < 0) + return virtDBusUtilSetLastVirtError(error); + + *value = g_variant_new("s", uuid); +} + static void virtDBusStoragePoolBuild(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -190,6 +211,7 @@ virtDBusStoragePoolGetInfo(GVariant *inArgs G_GNUC_UNUSED, static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] = { { "Autostart", virtDBusStoragePoolGetAutostart, NULL }, { "Name", virtDBusStoragePoolGetName, NULL }, + { "UUID", virtDBusStoragePoolGetUUID, NULL }, { 0 } }; diff --git a/tests/test_storage.py b/tests/test_storage.py index 8e73228..3e67633 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -65,6 +65,7 @@ class TestStoragePool(libvirttest.BaseTestClass): dbus_interface=dbus.PROPERTIES_IFACE) assert isinstance(props['Autostart'], dbus.Boolean) assert isinstance(props['Name'], dbus.String) + assert isinstance(props['UUID'], dbus.String) if __name__ == '__main__': -- 2.15.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list