Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
data/org.libvirt.NodeDevice.xml | 6 ++++++
src/nodedev.c | 28 ++++++++++++++++++++++++++++
tests/test_nodedev.py | 6 ++++++
3 files changed, 40 insertions(+)
diff --git a/data/org.libvirt.NodeDevice.xml b/data/org.libvirt.NodeDevice.xml
index c4b4075..1185bca 100644
--- a/data/org.libvirt.NodeDevice.xml
+++ b/data/org.libvirt.NodeDevice.xml
@@ -22,5 +22,11 @@
value="See
https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceDetach...
<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#virNodeDeviceGetXML...
+ <arg name="flags" type="u" direction="in"/>
+ <arg name="xml" type="s" direction="out"/>
+ </method>
</interface>
</node>
diff --git a/src/nodedev.c b/src/nodedev.c
index c597411..e61242d 100644
--- a/src/nodedev.c
+++ b/src/nodedev.c
@@ -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 }
};
diff --git a/tests/test_nodedev.py b/tests/test_nodedev.py
index 39343ae..64c97b2 100755
--- a/tests/test_nodedev.py
+++ b/tests/test_nodedev.py
@@ -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
"""
--
2.15.0