mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-03 07:33:50 +00:00
virsh: pool-list: introduce --uuid for printing pool's UUID only
This patch will introduce option --uuid. If specified, only UUID of pools will be printed out. Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
This commit is contained in:
parent
666bee3973
commit
3fe791f8c9
@ -1060,6 +1060,10 @@ static const vshCmdOptDef opts_pool_list[] = {
|
||||
.type = VSH_OT_BOOL,
|
||||
.help = N_("display extended details for pools")
|
||||
},
|
||||
{.name = "uuid",
|
||||
.type = VSH_OT_BOOL,
|
||||
.help = N_("list UUID of active pools only")
|
||||
},
|
||||
{.name = NULL}
|
||||
};
|
||||
|
||||
@ -1087,6 +1091,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
|
||||
const char *type = NULL;
|
||||
bool details = vshCommandOptBool(cmd, "details");
|
||||
bool inactive, all;
|
||||
bool uuid = false;
|
||||
char *outputStr = NULL;
|
||||
|
||||
inactive = vshCommandOptBool(cmd, "inactive");
|
||||
@ -1111,9 +1116,14 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
|
||||
if (vshCommandOptBool(cmd, "transient"))
|
||||
flags |= VIR_CONNECT_LIST_STORAGE_POOLS_TRANSIENT;
|
||||
|
||||
if (vshCommandOptBool(cmd, "uuid"))
|
||||
uuid = true;
|
||||
|
||||
if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0)
|
||||
return false;
|
||||
|
||||
VSH_EXCLUSIVE_OPTIONS("details", "uuid");
|
||||
|
||||
if (type) {
|
||||
int poolType = -1;
|
||||
char **poolTypes = NULL;
|
||||
@ -1297,6 +1307,16 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
|
||||
|
||||
/* Output basic info then return if --details option not selected */
|
||||
if (!details) {
|
||||
if (uuid) {
|
||||
for (i = 0; i < list->npools; i++) {
|
||||
char uuid_str[VIR_UUID_STRING_BUFLEN];
|
||||
virStoragePoolGetUUIDString(list->pools[i], uuid_str);
|
||||
vshPrint(ctl, "%-36s\n", uuid_str);
|
||||
}
|
||||
ret = true;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Output old style header */
|
||||
vshPrintExtra(ctl, " %-20s %-10s %-10s\n", _("Name"), _("State"),
|
||||
_("Autostart"));
|
||||
|
@ -3621,7 +3621,7 @@ of basic info are not converted to human friendly units.
|
||||
=item B<pool-list> [I<--inactive>] [I<--all>]
|
||||
[I<--persistent>] [I<--transient>]
|
||||
[I<--autostart>] [I<--no-autostart>]
|
||||
[[I<--details>] [<type>]
|
||||
[[I<--details>] [I<--uuid>] [<type>]
|
||||
|
||||
List pool objects known to libvirt. By default, only active pools
|
||||
are listed; I<--inactive> lists just the inactive pools, and I<--all>
|
||||
@ -3630,7 +3630,7 @@ lists all pools.
|
||||
In addition, there are several sets of filtering flags. I<--persistent> is to
|
||||
list the persistent pools, I<--transient> is to list the transient pools.
|
||||
I<--autostart> lists the autostarting pools, I<--no-autostart> lists the pools
|
||||
with autostarting disabled.
|
||||
with autostarting disabled. If I<--uuid> is specified only pool's UUIDs are printed.
|
||||
|
||||
You may also want to list pools with specified types using I<type>, the
|
||||
pool types must be separated by comma, e.g. --type dir,disk. The valid pool
|
||||
|
Loading…
x
Reference in New Issue
Block a user