Commit 36c1f8cd authored by Katerina Koukiou's avatar Katerina Koukiou

Implement StorageVolLookupByPath method for Connect Interface

Signed-off-by: 's avatarKaterina Koukiou <kkoukiou@redhat.com>
Reviewed-by: Jano Tomko's avatarJán Tomko <jtomko@redhat.com>
parent 10f1e1f7
......@@ -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#virStorageVolLookupByPath"/>
<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#virConnectDomainEventCallback"/>
......
......@@ -1573,6 +1573,35 @@ 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;
const gchar *inPath;
g_autofree gchar *path = NULL;
g_variant_get(inArgs, "(&s)", &inPath);
if (!virtDBusConnectOpen(connect, error))
return;
storageVol = virStorageVolLookupByPath(connect->connection, inPath);
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 +1656,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
{ "StoragePoolLookupByName", virtDBusConnectStoragePoolLookupByName },
{ "StoragePoolLookupByUUID", virtDBusConnectStoragePoolLookupByUUID },
{ "StorageVolLookupByKey", virtDBusConnectStorageVolLookupByKey },
{ "StorageVolLookupByPath", virtDBusConnectStorageVolLookupByPath },
{ 0 }
};
......
......@@ -215,6 +215,7 @@ class TestConnect(libvirttest.BaseTestClass):
@pytest.mark.usefixtures("storage_volume_create")
@pytest.mark.parametrize("lookup_method_name,lookup_item", [
("StorageVolLookupByKey", 'Key'),
("StorageVolLookupByPath", 'Path'),
])
def test_connect_storage_vol_lookup_by_property(self,
lookup_method_name,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment