Commit eeb049a1 authored by Katerina Koukiou's avatar Katerina Koukiou

Implement Name property for StorageVol Interface

Signed-off-by: default avatarKaterina Koukiou <kkoukiou@redhat.com>
Reviewed-by: Jano Tomko's avatarJán Tomko <jtomko@redhat.com>
parent 4c15fbce
......@@ -3,5 +3,10 @@
<node name="/org/libvirt/storagevol">
<interface name="org.libvirt.StorageVol">
<property name="Name" type="s" access="read">
<annotation name="org.gtk.GDBus.DocString"
value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolGetName"/>
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
</interface>
</node>
......@@ -3,7 +3,51 @@
#include <libvirt/libvirt.h>
static virStorageVolPtr
virtDBusStorageVolGetVirStorageVol(virtDBusConnect *connect,
const gchar *objectPath,
GError **error)
{
virStorageVolPtr storageVol;
if (virtDBusConnectOpen(connect, error) < 0)
return NULL;
storageVol = virtDBusUtilVirStorageVolFromBusPath(connect->connection,
objectPath,
connect->storageVolPath);
if (!storageVol) {
virtDBusUtilSetLastVirtError(error);
return NULL;
}
return storageVol;
}
static void
virtDBusStorageVolGetName(const gchar *objectPath,
gpointer userData,
GVariant **value,
GError **error)
{
virtDBusConnect *connect = userData;
g_autoptr(virStorageVol) storageVol = NULL;
const gchar *name;
storageVol = virtDBusStorageVolGetVirStorageVol(connect, objectPath,
error);
if (!storageVol)
return;
name = virStorageVolGetName(storageVol);
if (!name)
return virtDBusUtilSetLastVirtError(error);
*value = g_variant_new("s", name);
}
static virtDBusGDBusPropertyTable virtDBusStorageVolPropertyTable[] = {
{ "Name", virtDBusStorageVolGetName, NULL },
{ 0 }
};
......
......@@ -2,6 +2,7 @@
import dbus
import libvirttest
import pytest
class TestStoragePool(libvirttest.BaseTestClass):
def test_storage_pool_autostart(self):
......@@ -130,5 +131,15 @@ class TestStoragePool(libvirttest.BaseTestClass):
assert isinstance(storage_volume_create, dbus.ObjectPath)
@pytest.mark.usefixtures('storage_volume_create')
class TestStorageVolume(libvirttest.BaseTestClass):
def test_storage_vol_properties_type(self):
_, obj = self.get_test_storage_volume()
props = obj.GetAll('org.libvirt.StorageVol',
dbus_interface=dbus.PROPERTIES_IFACE)
assert isinstance(props['Name'], dbus.String)
if __name__ == '__main__':
libvirttest.run()
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