Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
data/org.libvirt.NodeDevice.xml | 5 +++++
src/nodedev.c | 25 +++++++++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/data/org.libvirt.NodeDevice.xml b/data/org.libvirt.NodeDevice.xml
index 4ca2e11..ea9bd7c 100644
--- a/data/org.libvirt.NodeDevice.xml
+++ b/data/org.libvirt.NodeDevice.xml
@@ -7,5 +7,10 @@
<annotation name="org.gtk.GDBus.DocString"
value="See
https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceDestro...
</method>
+ <method name="Detach">
+ <annotation name="org.gtk.GDBus.DocString"
+ value="See
https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceDetach...
+ <arg name="flags" type="u" direction="in"/>
+ </method>
</interface>
</node>
diff --git a/src/nodedev.c b/src/nodedev.c
index ec87bd8..e8551b8 100644
--- a/src/nodedev.c
+++ b/src/nodedev.c
@@ -44,12 +44,37 @@ virtDBusNodeDeviceDestroy(GVariant *inArgs G_GNUC_UNUSED,
virtDBusUtilSetLastVirtError(error);
}
+static void
+virtDBusNodeDeviceDetach(GVariant *inArgs,
+ GUnixFDList *inFDs G_GNUC_UNUSED,
+ const gchar *objectPath,
+ gpointer userData,
+ GVariant **outArgs G_GNUC_UNUSED,
+ GUnixFDList **outFDs G_GNUC_UNUSED,
+ GError **error)
+{
+ virtDBusConnect *connect = userData;
+ g_autoptr(virNodeDevice) dev = NULL;
+ const gchar *driverName;
+ guint flags;
+
+ g_variant_get(inArgs, "(&su)", &driverName, &flags);
+
+ dev = virtDBusNodeDeviceGetVirNodeDevice(connect, objectPath, error);
+ if (!dev)
+ return;
+
+ if (virNodeDeviceDetachFlags(dev, driverName, flags) < 0)
+ virtDBusUtilSetLastVirtError(error);
+}
+
static virtDBusGDBusPropertyTable virtDBusNodeDevicePropertyTable[] = {
{ 0 }
};
static virtDBusGDBusMethodTable virtDBusNodeDeviceMethodTable[] = {
{ "Destroy", virtDBusNodeDeviceDestroy },
+ { "Detach", virtDBusNodeDeviceDetach },
{ 0 }
};
--
2.15.0