Commit 04b8cdf6 authored by Katerina Koukiou's avatar Katerina Koukiou

Implement ListCaps method for NodeDevicesInterface

Signed-off-by: 's avatarKaterina Koukiou <kkoukiou@redhat.com>
Reviewed-by: Pavel Hrdina's avatarPavel Hrdina <phrdina@redhat.com>
parent eeb44488
......@@ -29,5 +29,10 @@
<arg name="flags" type="u" direction="in"/>
<arg name="xml" type="s" direction="out"/>
</method>
<method name="ListCaps">
<annotation name="org.gtk.GDBus.DocString"
value="See https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceListCaps"/>
<arg name="names" type="as" direction="out"/>
</method>
</interface>
</node>
......@@ -137,6 +137,42 @@ virtDBusNodeDeviceGetXMLDesc(GVariant *inArgs,
*outArgs = g_variant_new("(s)", xml);
}
static void
virtDBusNodeDeviceListCaps(GVariant *inArgs G_GNUC_UNUSED,
GUnixFDList *inFDs G_GNUC_UNUSED,
const gchar *objectPath,
gpointer userData,
GVariant **outArgs,
GUnixFDList **outFDs G_GNUC_UNUSED,
GError **error)
{
virtDBusConnect *connect = userData;
g_autoptr(virNodeDevice) dev = NULL;
g_autoptr(virtDBusCharArray) caps = NULL;
gint ncaps;
GVariant *gret;
GVariantBuilder builder;
dev = virtDBusNodeDeviceGetVirNodeDevice(connect, objectPath, error);
if (!dev)
return;
if ((ncaps = virNodeDeviceNumOfCaps(dev)) < 0)
return virtDBusUtilSetLastVirtError(error);
caps = g_new0(char *, ncaps + 1);
if ((ncaps = virNodeDeviceListCaps(dev, caps, ncaps)) < 0)
return virtDBusUtilSetLastVirtError(error);
g_variant_builder_init(&builder, G_VARIANT_TYPE("as"));
for (gint i = 0; i < ncaps; i++)
g_variant_builder_add(&builder, "s", caps[i]);
gret = g_variant_builder_end(&builder);
*outArgs = g_variant_new_tuple(&gret, 1);
}
static virtDBusGDBusPropertyTable virtDBusNodeDevicePropertyTable[] = {
{ "Name", virtDBusNodeDeviceGetName, NULL },
{ "Parent", virtDBusNodeDeviceGetParent, NULL },
......@@ -147,6 +183,7 @@ static virtDBusGDBusMethodTable virtDBusNodeDeviceMethodTable[] = {
{ "Destroy", virtDBusNodeDeviceDestroy },
{ "Detach", virtDBusNodeDeviceDetach },
{ "GetXMLDesc", virtDBusNodeDeviceGetXMLDesc },
{ "ListCaps", virtDBusNodeDeviceListCaps },
{ 0 }
};
......
......@@ -32,6 +32,12 @@ class TestNodeDevice(libvirttest.BaseTestClass):
interface_obj = dbus.Interface(obj, 'org.libvirt.NodeDevice')
assert isinstance(interface_obj.GetXMLDesc(0), dbus.String)
def test_node_device_list_caps(self):
test_node_device_path = self.node_device_create()
obj = self.bus.get_object('org.libvirt', test_node_device_path)
interface_obj = dbus.Interface(obj, 'org.libvirt.NodeDevice')
assert isinstance(interface_obj.ListCaps(), dbus.Array)
def test_node_device_properties_type(self):
""" Ensure correct return type for NodeDevice properties
"""
......
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