Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx> --- data/org.libvirt.Connect.xml | 6 ++++++ src/connect.c | 31 +++++++++++++++++++++++++++++++ tests/test_connect.py | 1 + 3 files changed, 38 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 55c0883..0c009cd 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -223,6 +223,12 @@ <arg name="name" type="s" direction="in"/> <arg name="storagePool" type="o" direction="out"/> </method> + <method name="StoragePoolLookupByUUID"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolLookupByUUIDString"/> + <arg name="uuid" type="s" direction="in"/> + <arg name="storagePool" type="o" direction="out"/> + </method> <signal name="DomainEvent"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectDomainEventCallback"/> diff --git a/src/connect.c b/src/connect.c index fa4078f..43013a2 100644 --- a/src/connect.c +++ b/src/connect.c @@ -1133,6 +1133,36 @@ virtDBusConnectStoragePoolLookupByName(GVariant *inArgs, *outArgs = g_variant_new("(o)", path); } +static void +virtDBusConnectStoragePoolLookupByUUID(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect = userData; + g_autoptr(virStoragePool) storagePool = NULL; + g_autofree gchar *path = NULL; + const gchar *uuidstr; + + g_variant_get(inArgs, "(s)", &uuidstr); + + if (!virtDBusConnectOpen(connect, error)) + return; + + storagePool = virStoragePoolLookupByUUIDString(connect->connection, + uuidstr); + if (!storagePool) + return virtDBusUtilSetLastVirtError(error); + + path = virtDBusUtilBusPathForVirStoragePool(storagePool, + connect->storagePoolPath); + + *outArgs = g_variant_new("(o)", path); +} + static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = { { "Encrypted", virtDBusConnectGetEncrypted, NULL }, { "Hostname", virtDBusConnectGetHostname, NULL }, @@ -1173,6 +1203,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "NodeGetSecurityModel", virtDBusConnectNodeGetSecurityModel }, { "NodeSetMemoryParameters", virtDBusConnectNodeSetMemoryParameters }, { "StoragePoolLookupByName", virtDBusConnectStoragePoolLookupByName }, + { "StoragePoolLookupByUUID", virtDBusConnectStoragePoolLookupByUUID }, { 0 } }; diff --git a/tests/test_connect.py b/tests/test_connect.py index 2e0cd7f..c0365ae 100755 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -192,6 +192,7 @@ class TestConnect(libvirttest.BaseTestClass): @pytest.mark.parametrize("lookup_method_name,lookup_item", [ ("StoragePoolLookupByName", 'Name'), + ("StoragePoolLookupByUUID", 'UUID'), ]) def test_connect_network_lookup_by_property( self, -- 2.15.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list