]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tools: add switches persistent and transient to nodedev-list
authorBoris Fiuczynski <fiuczy@linux.ibm.com>
Thu, 22 Feb 2024 13:02:04 +0000 (14:02 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 26 Feb 2024 10:02:44 +0000 (11:02 +0100)
Now that we can filter persistent and transient node devices in
virConnectListAllNodeDevices(), add these switches also to the
virsh nodedev-list command.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
docs/manpages/virsh.rst
tools/virsh-nodedev.c

index 3a814dccd2c53f87645a2cd8dfea4ffe137b6bc0..248807d0e9766920b6aec78b1f68bfac173ea1a5 100644 (file)
@@ -5461,7 +5461,7 @@ nodedev-list
 
 ::
 
-   nodedev-list [--cap capability] [--tree] [--inactive | --all]
+   nodedev-list [--cap capability] [--tree] [--inactive | --all] [--persistent | --transient]
 
 List all of the devices available on the node that are known by libvirt.
 *cap* is used to filter the list by capability types, the types must be
@@ -5470,7 +5470,11 @@ separated by comma, e.g. --cap pci,scsi. Valid capability types include
 'scsi', 'storage', 'fc_host', 'vports', 'scsi_generic', 'drm', 'mdev',
 'mdev_types', 'ccw', 'css', 'ap_card', 'ap_queue', 'ap_matrix'. By default,
 only active devices are listed. *--inactive* is used to list only inactive
-devices, and *-all* is used to list both active and inactive devices.
+devices, and *--all* is used to list both active and inactive devices.
+*--persistent* is used to list only persistent devices, and *--transient* is
+used to list only transient devices. Not providing *--persistent* or
+*--transient* will list all devices unless filtered otherwise. *--transient*
+is mutually exclusive with *--persistent* and *--inactive*.
 If *--tree* is used, the output is formatted in a tree representing parents of
 each node.  *--tree* is mutually exclusive with all other options.
 
index aeb3685acaf6924438090339090701d67c333b9e..5942c4368992d1129aeb54fd1c19f2b48d0394a3 100644 (file)
@@ -390,6 +390,14 @@ static const vshCmdOptDef opts_node_list_devices[] = {
      .type = VSH_OT_BOOL,
      .help = N_("list inactive & active devices")
     },
+    {.name = "persistent",
+     .type = VSH_OT_BOOL,
+     .help = N_("list persistent devices")
+    },
+    {.name = "transient",
+     .type = VSH_OT_BOOL,
+     .help = N_("list transient devices")
+    },
     {.name = NULL}
 };
 
@@ -407,6 +415,8 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
     int cap_type = -1;
     bool inactive = vshCommandOptBool(cmd, "inactive");
     bool all = vshCommandOptBool(cmd, "all");
+    bool persistent = vshCommandOptBool(cmd, "persistent");
+    bool transient = vshCommandOptBool(cmd, "transient");
 
     ignore_value(vshCommandOptStringQuiet(ctl, cmd, "cap", &cap_str));
 
@@ -420,8 +430,13 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
         return false;
     }
 
-    if (tree && (cap_str || inactive)) {
-        vshError(ctl, "%s", _("Option --tree is incompatible with --cap and --inactive"));
+    if (transient && (persistent || inactive)) {
+        vshError(ctl, "%s", _("Option --transient is incompatible with --persistent and --inactive"));
+        return false;
+    }
+
+    if (tree && (cap_str || inactive || persistent || transient)) {
+        vshError(ctl, "%s", _("Option --tree is incompatible with --cap, --inactive, --persistent and --transient"));
         return false;
     }
 
@@ -509,6 +524,11 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
     if (!inactive)
         flags |= VIR_CONNECT_LIST_NODE_DEVICES_ACTIVE;
 
+    if (persistent)
+        flags |= VIR_CONNECT_LIST_NODE_DEVICES_PERSISTENT;
+    if (transient)
+        flags |= VIR_CONNECT_LIST_NODE_DEVICES_TRANSIENT;
+
     if (!(list = virshNodeDeviceListCollect(ctl, caps, ncaps, flags))) {
         ret = false;
         goto cleanup;