[libvirt] [dbus PATCH 13/14] Implement ReAttach method for NodeDevice Interface

Katerina Koukiou kkoukiou at redhat.com
Fri Jun 15 17:03:49 UTC 2018


Signed-off-by: Katerina Koukiou <kkoukiou at redhat.com>
---
 data/org.libvirt.NodeDevice.xml |  4 ++++
 src/nodedev.c                   | 21 +++++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/data/org.libvirt.NodeDevice.xml b/data/org.libvirt.NodeDevice.xml
index bf85958..56deee3 100644
--- a/data/org.libvirt.NodeDevice.xml
+++ b/data/org.libvirt.NodeDevice.xml
@@ -33,5 +33,9 @@
         value="See https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceListCaps"/>
       <arg name="names" type="as" direction="out"/>
     </method>
+    <method name="ReAttach">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceReAttach"/>
+    </method>
   </interface>
 </node>
diff --git a/src/nodedev.c b/src/nodedev.c
index 01fcd35..1d15d79 100644
--- a/src/nodedev.c
+++ b/src/nodedev.c
@@ -173,6 +173,26 @@ virtDBusNodeDeviceListCaps(GVariant *inArgs G_GNUC_UNUSED,
     *outArgs = g_variant_new_tuple(&gret, 1);
 }
 
+static void
+virtDBusNodeDeviceReAttach(GVariant *inArgs G_GNUC_UNUSED,
+                           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;
+
+    dev = virtDBusNodeDeviceGetVirNodeDevice(connect, objectPath, error);
+    if (!dev)
+        return;
+
+    if (virNodeDeviceReAttach(dev) < 0)
+        virtDBusUtilSetLastVirtError(error);
+}
+
 static virtDBusGDBusPropertyTable virtDBusNodeDevicePropertyTable[] = {
     { "Name", virtDBusNodeDeviceGetName, NULL },
     { "Parent", virtDBusNodeDeviceGetParent, NULL },
@@ -184,6 +204,7 @@ static virtDBusGDBusMethodTable virtDBusNodeDeviceMethodTable[] = {
     { "Detach", virtDBusNodeDeviceDetach },
     { "GetXMLDesc", virtDBusNodeDeviceGetXMLDesc },
     { "ListCaps", virtDBusNodeDeviceListCaps },
+    { "ReAttach", virtDBusNodeDeviceReAttach },
     { 0 }
 };
 
-- 
2.15.0




More information about the libvir-list mailing list