Commit 004ff131 authored by Katerina Koukiou's avatar Katerina Koukiou

Implement Name property for NodeDevice Interface

Signed-off-by: 's avatarKaterina Koukiou <kkoukiou@redhat.com>
Reviewed-by: Pavel Hrdina's avatarPavel Hrdina <phrdina@redhat.com>
parent a896b3e4
......@@ -3,6 +3,11 @@
<node name="/org/libvirt/nodedev">
<interface name="org.libvirt.NodeDevice">
<property name="Name" type="s" access="read">
<annotation name="org.gtk.GDBus.DocString"
value="See https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceGetName"/>
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<method name="Destroy">
<annotation name="org.gtk.GDBus.DocString"
value="See https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceDestroy"/>
......
......@@ -24,6 +24,27 @@ virtDBusNodeDeviceGetVirNodeDevice(virtDBusConnect *connect,
return dev;
}
static void
virtDBusNodeDeviceGetName(const gchar *objectPath,
gpointer userData,
GVariant **value,
GError **error)
{
virtDBusConnect *connect = userData;
g_autoptr(virNodeDevice) dev = NULL;
const gchar *name;
dev = virtDBusNodeDeviceGetVirNodeDevice(connect, objectPath, error);
if (!dev)
return;
name = virNodeDeviceGetName(dev);
if (!name)
return virtDBusUtilSetLastVirtError(error);
*value = g_variant_new("s", name);
}
static void
virtDBusNodeDeviceDestroy(GVariant *inArgs G_GNUC_UNUSED,
GUnixFDList *inFDs G_GNUC_UNUSED,
......@@ -69,6 +90,7 @@ virtDBusNodeDeviceDetach(GVariant *inArgs,
}
static virtDBusGDBusPropertyTable virtDBusNodeDevicePropertyTable[] = {
{ "Name", virtDBusNodeDeviceGetName, NULL },
{ 0 }
};
......
......@@ -26,6 +26,14 @@ class TestNodeDevice(libvirttest.BaseTestClass):
self.main_loop()
def test_node_device_properties_type(self):
""" Ensure correct return type for NodeDevice properties
"""
test_node_device_path = self.node_device_create()
obj = self.bus.get_object('org.libvirt', test_node_device_path)
props = obj.GetAll('org.libvirt.NodeDevice', 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