[libvirt] [dbus PATCH 06/14] Implement Detach method for NodeDevice Interface

Katerina Koukiou posted 14 patches 7 years ago
[libvirt] [dbus PATCH 06/14] Implement Detach method for NodeDevice Interface
Posted by Katerina Koukiou 7 years ago
Signed-off-by: Katerina Koukiou <kkoukiou@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#virNodeDeviceDestroy"/>
     </method>
+    <method name="Detach">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceDetachFlags"/>
+      <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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [dbus PATCH 06/14] Implement Detach method for NodeDevice Interface
Posted by Pavel Hrdina 7 years ago
On Fri, Jun 15, 2018 at 07:03:42PM +0200, Katerina Koukiou wrote:
> Signed-off-by: Katerina Koukiou <kkoukiou@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#virNodeDeviceDestroy"/>
>      </method>
> +    <method name="Detach">
> +      <annotation name="org.gtk.GDBus.DocString"
> +        value="See https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceDetachFlags"/>
> +      <arg name="flags" type="u" direction="in"/>

Missing driverName argument.

> +    </method>
>    </interface>
>  </node>

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list