[libvirt PATCH v6 17/30] virsh: Add --inactive, --all to nodedev-list

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

 



Now that we can filter active and inactive node devices in
virConnectListAllNodeDevices(), add these switches to the virsh command.

Eventual output (once everything is hooked up):

    virsh # nodedev-list --cap mdev
    mdev_bd2ea955_3402_4252_8c17_7468083a0f26

    virsh # nodedev-list --inactive --cap mdev
    mdev_07d8b8b0_7e04_4c0f_97ed_9214ce12723c
    mdev_927c040f_ae7d_4a35_966e_286ba6ebbe1c

    virsh # nodedev-list --all --cap mdev
    mdev_07d8b8b0_7e04_4c0f_97ed_9214ce12723c
    mdev_927c040f_ae7d_4a35_966e_286ba6ebbe1c
    mdev_bd2ea955_3402_4252_8c17_7468083a0f26

Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
Reviewed-by: Erik Skultety <eskultet@xxxxxxxxxx>
---
 tools/virsh-nodedev.c | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
index b9fe9b8be1..7ab5b264fc 100644
--- a/tools/virsh-nodedev.c
+++ b/tools/virsh-nodedev.c
@@ -378,6 +378,14 @@ static const vshCmdOptDef opts_node_list_devices[] = {
      .completer = virshNodeDeviceCapabilityNameCompleter,
      .help = N_("capability names, separated by comma")
     },
+    {.name = "inactive",
+     .type = VSH_OT_BOOL,
+     .help = N_("list inactive devices")
+    },
+    {.name = "all",
+     .type = VSH_OT_BOOL,
+     .help = N_("list inactive & active devices")
+    },
     {.name = NULL}
 };
 
@@ -393,18 +401,26 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
     int ncaps = 0;
     virshNodeDeviceListPtr list = NULL;
     int cap_type = -1;
+    bool inactive = vshCommandOptBool(cmd, "inactive");
+    bool all = vshCommandOptBool(cmd, "all");
 
     ignore_value(vshCommandOptStringQuiet(ctl, cmd, "cap", &cap_str));
 
     if (cap_str) {
-        if (tree) {
-            vshError(ctl, "%s", _("Options --tree and --cap are incompatible"));
-            return false;
-        }
         if ((ncaps = vshStringToArray(cap_str, &caps)) < 0)
             return false;
     }
 
+    if (all && inactive) {
+        vshError(ctl, "%s", _("Option --all is incompatible with --inactive"));
+        return false;
+    }
+
+    if (tree && (cap_str || inactive || all)) {
+        vshError(ctl, "%s", _("Option --tree is incompatible with other options"));
+        return false;
+    }
+
     for (i = 0; i < ncaps; i++) {
         if ((cap_type = virNodeDevCapTypeFromString(caps[i])) < 0) {
             vshError(ctl, "%s", _("Invalid capability type"));
@@ -481,6 +497,11 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
         }
     }
 
+    if (inactive || all)
+        flags |= VIR_CONNECT_LIST_NODE_DEVICES_INACTIVE;
+    if (!inactive)
+        flags |= VIR_CONNECT_LIST_NODE_DEVICES_ACTIVE;
+
     if (!(list = virshNodeDeviceListCollect(ctl, caps, ncaps, flags))) {
         ret = false;
         goto cleanup;
-- 
2.26.3




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux