mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-09-09 17:44:57 +03:00
virsh: Add --inactive, --all to nodedev-list
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@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
@@ -378,6 +378,14 @@ static const vshCmdOptDef opts_node_list_devices[] = {
|
|||||||
.completer = virshNodeDeviceCapabilityNameCompleter,
|
.completer = virshNodeDeviceCapabilityNameCompleter,
|
||||||
.help = N_("capability names, separated by comma")
|
.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}
|
{.name = NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -393,18 +401,26 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
|
|||||||
int ncaps = 0;
|
int ncaps = 0;
|
||||||
virshNodeDeviceListPtr list = NULL;
|
virshNodeDeviceListPtr list = NULL;
|
||||||
int cap_type = -1;
|
int cap_type = -1;
|
||||||
|
bool inactive = vshCommandOptBool(cmd, "inactive");
|
||||||
|
bool all = vshCommandOptBool(cmd, "all");
|
||||||
|
|
||||||
ignore_value(vshCommandOptStringQuiet(ctl, cmd, "cap", &cap_str));
|
ignore_value(vshCommandOptStringQuiet(ctl, cmd, "cap", &cap_str));
|
||||||
|
|
||||||
if (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)
|
if ((ncaps = vshStringToArray(cap_str, &caps)) < 0)
|
||||||
return false;
|
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++) {
|
for (i = 0; i < ncaps; i++) {
|
||||||
if ((cap_type = virNodeDevCapTypeFromString(caps[i])) < 0) {
|
if ((cap_type = virNodeDevCapTypeFromString(caps[i])) < 0) {
|
||||||
vshError(ctl, "%s", _("Invalid capability type"));
|
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))) {
|
if (!(list = virshNodeDeviceListCollect(ctl, caps, ncaps, flags))) {
|
||||||
ret = false;
|
ret = false;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
Reference in New Issue
Block a user