[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 14/22] virsh: add option to detach entire group of devices



The nodedev-detach command gains a "--group" option, which will
instruct libvirt to detach all devices in the same group as the
specified device. This option requires the recently added
virNodeDeviceDetachFlags() API in libvirtd.
---
 tools/virsh-nodedev.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
index da93b8e..39f74f2 100644
--- a/tools/virsh-nodedev.c
+++ b/tools/virsh-nodedev.c
@@ -607,6 +607,10 @@ static const vshCmdOptDef opts_node_device_detach[] = {
      .type = VSH_OT_STRING,
      .help = N_("pci device assignment backend driver (e.g. 'vfio' or 'kvm'")
     },
+    {.name = "group",
+     .type = VSH_OT_BOOL,
+     .help = N_("detach all devices in the same IOMMU group")
+    },
     {.name = NULL}
 };
 
@@ -616,6 +620,7 @@ cmdNodeDeviceDetach(vshControl *ctl, const vshCmd *cmd)
     const char *name = NULL;
     const char *driverName = NULL;
     virNodeDevicePtr device;
+    bool group = vshCommandOptBool(cmd, "group");
     bool ret = true;
 
     if (vshCommandOptStringReq(ctl, cmd, "device", &name) < 0)
@@ -628,9 +633,13 @@ cmdNodeDeviceDetach(vshControl *ctl, const vshCmd *cmd)
         return false;
     }
 
-    if (driverName) {
+    if (driverName || group) {
         /* we must use the newer API that accepts a driverName */
-        if (virNodeDeviceDetachFlags(device, driverName, 0) < 0)
+        unsigned int flags = 0;
+
+        if (group)
+            flags |= VIR_NODE_DEVICE_DETACH_GROUP;
+        if (virNodeDeviceDetachFlags(device, driverName, flags) < 0)
             ret = false;
     } else {
         /* Yes, our (old) public API is misspelled.  At least virsh
-- 
1.7.11.7


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]