summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorRyan England <rcengland@gmail.com>2019-06-03 20:16:08 -0700
committerJoshua M. Clulow <josh@sysmgr.org>2019-06-04 13:46:34 -0700
commit0222d5accac6e2a33600db46cd235825f511de93 (patch)
tree643655b883a9129ab21356b93abc9fdbf04d8a81 /usr/src
parent9d48b35be7d9e9a048cb0083d02dfca25362e44e (diff)
downloadillumos-gate-0222d5accac6e2a33600db46cd235825f511de93.tar.gz
6143 Want zoneadm list option for non-global zones only
Reviewed by: Andy Fiddaman <omnios@citrus-it.co.uk> Reviewed by: Joshua M. Clulow <josh@sysmgr.org> Approved by: Joshua M. Clulow <josh@sysmgr.org>
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/zoneadm/zoneadm.c25
-rw-r--r--usr/src/man/man1m/zoneadm.1m14
2 files changed, 29 insertions, 10 deletions
diff --git a/usr/src/cmd/zoneadm/zoneadm.c b/usr/src/cmd/zoneadm/zoneadm.c
index 21bc9248f4..53bfe08855 100644
--- a/usr/src/cmd/zoneadm/zoneadm.c
+++ b/usr/src/cmd/zoneadm/zoneadm.c
@@ -134,7 +134,7 @@ struct cmd {
#define SHELP_READY "ready"
#define SHELP_SHUTDOWN "shutdown [-r [-- boot_arguments]]"
#define SHELP_REBOOT "reboot [-- boot_arguments]"
-#define SHELP_LIST "list [-cipv]"
+#define SHELP_LIST "list [-cinpv]"
#define SHELP_VERIFY "verify"
#define SHELP_INSTALL "install [brand-specific args]"
#define SHELP_UNINSTALL "uninstall [-F] [brand-specific args]"
@@ -254,7 +254,7 @@ long_help(int cmd_num)
"option. When used with the general -z <zone> and/or -u "
"<uuid-match>\n\toptions, lists only the specified "
"matching zone, but lists it\n\tregardless of its state, "
- "and the -i and -c options are disallowed. The\n\t-v "
+ "and the -i, -c, and -n options are disallowed. The\n\t-v "
"option can be used to display verbose information: zone "
"name, id,\n\tcurrent state, root directory and options. "
"The -p option can be used\n\tto request machine-parsable "
@@ -714,7 +714,8 @@ again:
}
static int
-zone_print_list(zone_state_t min_state, boolean_t verbose, boolean_t parsable)
+zone_print_list(zone_state_t min_state, boolean_t verbose, boolean_t parsable,
+ boolean_t exclude_global)
{
int i;
zone_entry_t zent;
@@ -732,8 +733,11 @@ zone_print_list(zone_state_t min_state, boolean_t verbose, boolean_t parsable)
*/
return (i);
}
- for (i = 0; i < nzents; i++)
+ for (i = 0; i < nzents; i++) {
+ if (exclude_global && zents[i].zid == GLOBAL_ZONEID)
+ continue;
zone_print(&zents[i], verbose, parsable);
+ }
if (min_state >= ZONE_STATE_RUNNING)
return (Z_OK);
/*
@@ -1369,14 +1373,15 @@ list_func(int argc, char *argv[])
{
zone_entry_t *zentp, zent;
int arg, retv;
- boolean_t output = B_FALSE, verbose = B_FALSE, parsable = B_FALSE;
+ boolean_t output = B_FALSE, verbose = B_FALSE, parsable = B_FALSE,
+ exclude_global = B_FALSE;
zone_state_t min_state = ZONE_STATE_RUNNING;
zoneid_t zone_id = getzoneid();
if (target_zone == NULL) {
/* all zones: default view to running but allow override */
optind = 0;
- while ((arg = getopt(argc, argv, "?cipv")) != EOF) {
+ while ((arg = getopt(argc, argv, "?cinpv")) != EOF) {
switch (arg) {
case '?':
sub_usage(SHELP_LIST, CMD_LIST);
@@ -1397,6 +1402,9 @@ list_func(int argc, char *argv[])
min_state);
break;
+ case 'n':
+ exclude_global = B_TRUE;
+ break;
case 'p':
parsable = B_TRUE;
break;
@@ -1414,7 +1422,8 @@ list_func(int argc, char *argv[])
return (Z_ERR);
}
if (zone_id == GLOBAL_ZONEID || is_system_labeled()) {
- retv = zone_print_list(min_state, verbose, parsable);
+ retv = zone_print_list(min_state, verbose, parsable,
+ exclude_global);
} else {
fake_up_local_zone(zone_id, &zent);
retv = Z_OK;
@@ -1424,7 +1433,7 @@ list_func(int argc, char *argv[])
}
/*
- * Specific target zone: disallow -i/-c suboptions.
+ * Specific target zone: disallow -i/-c/-n suboptions.
*/
optind = 0;
while ((arg = getopt(argc, argv, "?pv")) != EOF) {
diff --git a/usr/src/man/man1m/zoneadm.1m b/usr/src/man/man1m/zoneadm.1m
index c689dcbb05..e5f406a1be 100644
--- a/usr/src/man/man1m/zoneadm.1m
+++ b/usr/src/man/man1m/zoneadm.1m
@@ -306,8 +306,8 @@ By default, all running zones are listed. If you use this subcommand with the
regardless of its state. In this case, the \fB-i\fR and \fB-c\fR options are
disallowed.
.sp
-If neither the \fB-i\fR or \fB-c\fR options are given, all running zones are
-listed.
+If neither the \fB-i\fR, \fB-c\fR, or \fB-n\fR options are given, all running
+zones are listed.
.sp
The following \fIlist_options\fR are supported:
.sp
@@ -333,6 +333,16 @@ Expand the display to all installed zones.
.sp
.ne 2
.na
+\fB\fB-n\fR\fR
+.ad
+.sp .6
+.RS 4n
+Do not include the global zone in the list of zones returned.
+.RE
+
+.sp
+.ne 2
+.na
\fB\fB-p\fR\fR
.ad
.sp .6