提交 0d9bcd6f 编写于 作者: C Chen Hanxiao 提交者: John Ferlan

virsh: pool-list: introduce --name for printing pool's name only

This patch will introduce option --name.
If specified, only name of pools will be printed out.
Signed-off-by: NChen Hanxiao <chenhanxiao@gmail.com>
上级 3fe791f8
...@@ -1064,6 +1064,10 @@ static const vshCmdOptDef opts_pool_list[] = { ...@@ -1064,6 +1064,10 @@ static const vshCmdOptDef opts_pool_list[] = {
.type = VSH_OT_BOOL, .type = VSH_OT_BOOL,
.help = N_("list UUID of active pools only") .help = N_("list UUID of active pools only")
}, },
{.name = "name",
.type = VSH_OT_BOOL,
.help = N_("list name of active pools only")
},
{.name = NULL} {.name = NULL}
}; };
...@@ -1092,6 +1096,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) ...@@ -1092,6 +1096,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
bool details = vshCommandOptBool(cmd, "details"); bool details = vshCommandOptBool(cmd, "details");
bool inactive, all; bool inactive, all;
bool uuid = false; bool uuid = false;
bool name = false;
char *outputStr = NULL; char *outputStr = NULL;
inactive = vshCommandOptBool(cmd, "inactive"); inactive = vshCommandOptBool(cmd, "inactive");
...@@ -1119,10 +1124,14 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) ...@@ -1119,10 +1124,14 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if (vshCommandOptBool(cmd, "uuid")) if (vshCommandOptBool(cmd, "uuid"))
uuid = true; uuid = true;
if (vshCommandOptBool(cmd, "name"))
name = true;
if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0) if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0)
return false; return false;
VSH_EXCLUSIVE_OPTIONS("details", "uuid"); VSH_EXCLUSIVE_OPTIONS("details", "uuid");
VSH_EXCLUSIVE_OPTIONS("details", "name");
if (type) { if (type) {
int poolType = -1; int poolType = -1;
...@@ -1317,6 +1326,15 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) ...@@ -1317,6 +1326,15 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
goto cleanup; goto cleanup;
} }
if (name) {
for (i = 0; i < list->npools; i++) {
const char *name_str = virStoragePoolGetName(list->pools[i]);
vshPrint(ctl, "%-20s\n", name_str);
}
ret = true;
goto cleanup;
}
/* Output old style header */ /* Output old style header */
vshPrintExtra(ctl, " %-20s %-10s %-10s\n", _("Name"), _("State"), vshPrintExtra(ctl, " %-20s %-10s %-10s\n", _("Name"), _("State"),
_("Autostart")); _("Autostart"));
...@@ -1324,9 +1342,9 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) ...@@ -1324,9 +1342,9 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
/* Output old style pool info */ /* Output old style pool info */
for (i = 0; i < list->npools; i++) { for (i = 0; i < list->npools; i++) {
const char *name = virStoragePoolGetName(list->pools[i]); const char *name_str = virStoragePoolGetName(list->pools[i]);
vshPrint(ctl, " %-20s %-10s %-10s\n", vshPrint(ctl, " %-20s %-10s %-10s\n",
name, name_str,
poolInfoTexts[i].state, poolInfoTexts[i].state,
poolInfoTexts[i].autostart); poolInfoTexts[i].autostart);
} }
......
...@@ -3621,7 +3621,8 @@ of basic info are not converted to human friendly units. ...@@ -3621,7 +3621,8 @@ of basic info are not converted to human friendly units.
=item B<pool-list> [I<--inactive>] [I<--all>] =item B<pool-list> [I<--inactive>] [I<--all>]
[I<--persistent>] [I<--transient>] [I<--persistent>] [I<--transient>]
[I<--autostart>] [I<--no-autostart>] [I<--autostart>] [I<--no-autostart>]
[[I<--details>] [I<--uuid>] [<type>] [[I<--details>] [I<--uuid>]
[I<--name>] [<type>]
List pool objects known to libvirt. By default, only active pools List pool objects known to libvirt. By default, only active pools
are listed; I<--inactive> lists just the inactive pools, and I<--all> are listed; I<--inactive> lists just the inactive pools, and I<--all>
...@@ -3631,6 +3632,7 @@ In addition, there are several sets of filtering flags. I<--persistent> is to ...@@ -3631,6 +3632,7 @@ 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. list the persistent pools, I<--transient> is to list the transient pools.
I<--autostart> lists the autostarting pools, I<--no-autostart> lists the pools I<--autostart> lists the autostarting pools, I<--no-autostart> lists the pools
with autostarting disabled. If I<--uuid> is specified only pool's UUIDs are printed. with autostarting disabled. If I<--uuid> is specified only pool's UUIDs are printed.
If I<--name> is specified only pool's names are printed.
You may also want to list pools with specified types using I<type>, the 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 pool types must be separated by comma, e.g. --type dir,disk. The valid pool
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册