Commit eeb44488 authored by Katerina Koukiou's avatar Katerina Koukiou

Implement GetXMLDesc property for NodeDevice Interface

Signed-off-by: 's avatarKaterina Koukiou <kkoukiou@redhat.com>
Reviewed-by: Pavel Hrdina's avatarPavel Hrdina <phrdina@redhat.com>
parent 5040f09e
......@@ -23,5 +23,11 @@
<arg name="driverName" type="s" direction="in"/>
<arg name="flags" type="u" direction="in"/>
</method>
<method name="GetXMLDesc">
<annotation name="org.gtk.GDBus.DocString"
value="See https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceGetXMLDesc"/>
<arg name="flags" type="u" direction="in"/>
<arg name="xml" type="s" direction="out"/>
</method>
</interface>
</node>
......@@ -110,6 +110,33 @@ virtDBusNodeDeviceDetach(GVariant *inArgs,
virtDBusUtilSetLastVirtError(error);
}
static void
virtDBusNodeDeviceGetXMLDesc(GVariant *inArgs,
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_autofree gchar *xml = NULL;
guint flags;
g_variant_get(inArgs, "(u)", &flags);
dev = virtDBusNodeDeviceGetVirNodeDevice(connect, objectPath, error);
if (!dev)
return;
xml = virNodeDeviceGetXMLDesc(dev, flags);
if (!xml)
return virtDBusUtilSetLastVirtError(error);
*outArgs = g_variant_new("(s)", xml);
}
static virtDBusGDBusPropertyTable virtDBusNodeDevicePropertyTable[] = {
{ "Name", virtDBusNodeDeviceGetName, NULL },
{ "Parent", virtDBusNodeDeviceGetParent, NULL },
......@@ -119,6 +146,7 @@ static virtDBusGDBusPropertyTable virtDBusNodeDevicePropertyTable[] = {
static virtDBusGDBusMethodTable virtDBusNodeDeviceMethodTable[] = {
{ "Destroy", virtDBusNodeDeviceDestroy },
{ "Detach", virtDBusNodeDeviceDetach },
{ "GetXMLDesc", virtDBusNodeDeviceGetXMLDesc },
{ 0 }
};
......
......@@ -26,6 +26,12 @@ class TestNodeDevice(libvirttest.BaseTestClass):
self.main_loop()
def test_node_device_get_xml_description(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.GetXMLDesc(0), dbus.String)
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