Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
data/org.libvirt.Connect.xml | 6 ++++++
src/connect.c | 29 +++++++++++++++++++++++++++++
tests/test_connect.py | 1 +
3 files changed, 36 insertions(+)
diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index d3871b3..37daed0 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -314,6 +314,12 @@
<arg name="key" type="s" direction="in"/>
<arg name="storageVol" type="o"
direction="out"/>
</method>
+ <method name="StorageVolLookupByPath">
+ <annotation name="org.gtk.GDBus.DocString"
+ value="See
https://libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolLookup...
+ <arg name="path" type="s" direction="in"/>
+ <arg name="storageVol" type="o"
direction="out"/>
+ </method>
<signal name="DomainEvent">
<annotation name="org.gtk.GDBus.DocString"
value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectDomainEven...
diff --git a/src/connect.c b/src/connect.c
index c526808..157cdb3 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -1573,6 +1573,34 @@ virtDBusConnectStorageVolLookupByKey(GVariant *inArgs,
*outArgs = g_variant_new("(o)", path);
}
+static void
+virtDBusConnectStorageVolLookupByPath(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(virStorageVol) storageVol = NULL;
+ g_autofree gchar *path = NULL;
+
+ g_variant_get(inArgs, "(s)", &path);
+
+ if (!virtDBusConnectOpen(connect, error))
+ return;
+
+ storageVol = virStorageVolLookupByPath(connect->connection, path);
+ if (!storageVol)
+ return virtDBusUtilSetLastVirtError(error);
+
+ path = virtDBusUtilBusPathForVirStorageVol(storageVol,
+ connect->storageVolPath);
+
+ *outArgs = g_variant_new("(o)", path);
+}
+
static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = {
{ "Encrypted", virtDBusConnectGetEncrypted, NULL },
{ "Hostname", virtDBusConnectGetHostname, NULL },
@@ -1627,6 +1655,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
{ "StoragePoolLookupByName", virtDBusConnectStoragePoolLookupByName },
{ "StoragePoolLookupByUUID", virtDBusConnectStoragePoolLookupByUUID },
{ "StorageVolLookupByKey", virtDBusConnectStorageVolLookupByKey },
+ { "StorageVolLookupByPath", virtDBusConnectStorageVolLookupByPath },
{ 0 }
};
diff --git a/tests/test_connect.py b/tests/test_connect.py
index fc4ca78..80bb50b 100755
--- a/tests/test_connect.py
+++ b/tests/test_connect.py
@@ -247,6 +247,7 @@ class TestConnect(libvirttest.BaseTestClass):
@pytest.mark.parametrize("lookup_method_name,lookup_item", [
("StorageVolLookupByKey", 'Key'),
+ ("StorageVolLookupByPath", 'Path'),
])
def test_connect_storage_vol_lookup_by_property(self,
lookup_method_name,
--
2.15.0