4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
37 #include <sys/types.h>
38 #include <sys/param.h>
39 #include <uuid/uuid.h>
41 #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
42 #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it wasn't */
47 char *options
= "acdpstu";
52 (void) fprintf(stderr
, gettext("usage: %s [-%s]\n"), cmdname
, options
);
57 virtinfo_cap_to_impl(int cap
)
59 if (cap
& V12N_CAP_IMPL_LDOMS
)
66 main(int argc
, char *argv
[])
73 int aflg
= 0, cflg
= 0, dflg
= 0, pflg
= 0, sflg
= 0, tflg
= 0,
76 /* Set locale environment variables local definitions */
77 (void) setlocale(LC_ALL
, "");
78 (void) textdomain(TEXT_DOMAIN
);
80 cmdname
= basename(argv
[0]);
82 /* disable getopt error messages */
85 while ((opt
= getopt(argc
, argv
, options
)) != EOF
) {
116 if (errflg
|| optind
!= argc
)
120 /* aflg -> set all flags except -p */
121 cflg
= dflg
= sflg
= tflg
= uflg
= 1;
122 } else if (cflg
== 0 && dflg
== 0 && sflg
== 0 && tflg
== 0 &&
124 /* no flag set, default to '-t' */
128 if (getzoneid() != GLOBAL_ZONEID
) {
129 (void) printf(gettext(
130 "%s can only be run from the global zone\n"), cmdname
);
134 cap
= v12n_capabilities();
135 if ((cap
& V12N_CAP_SUPPORTED
) == 0) {
136 (void) printf(gettext("Virtual machines are not supported\n"));
138 } else if ((cap
& V12N_CAP_ENABLED
) == 0) {
139 (void) printf(gettext(
140 "Virtual machines (%s) are supported but not enabled\n"),
141 virtinfo_cap_to_impl(cap
));
146 (void) printf("VERSION 1.0\n");
150 char *impl
= "", *role
= "", *io
= "", *service
= "",
153 roles
= v12n_domain_roles();
155 if (roles
== -1 || (cap
& V12N_CAP_IMPL_LDOMS
) == 0) {
157 impl
= "impl=Unknown";
162 role
= (roles
& V12N_ROLE_CONTROL
) ?
163 "|control=true" : "|control=false";
164 io
= (roles
& V12N_ROLE_IO
) ?
165 "|io=true" : "|io=false";
166 service
= (roles
& V12N_ROLE_SERVICE
) ?
167 "|service=true" : "|service=false";
168 root
= (roles
& V12N_ROLE_ROOT
) ?
169 "|root=true" : "|root=false";
172 role
= (roles
& V12N_ROLE_CONTROL
) ?
173 " control" : " guest";
174 io
= (roles
& V12N_ROLE_IO
) ?
176 service
= (roles
& V12N_ROLE_SERVICE
) ?
178 root
= (roles
& V12N_ROLE_ROOT
) ?
181 (void) printf("%s%s%s%s%s%s\n", pflg
? "DOMAINROLE|" :
182 gettext("Domain role: "), impl
, role
, io
, service
, root
);
186 char domain_name
[V12N_NAME_MAX
];
188 rv
= v12n_domain_name(domain_name
, sizeof (domain_name
));
189 if (rv
== (size_t)(-1)) {
190 (void) strcpy(domain_name
, "Unknown");
192 (void) printf("%s%s\n", pflg
? "DOMAINNAME|name=" :
193 gettext("Domain name: "), domain_name
);
198 char uuid_str
[UUID_PRINTABLE_STRING_LENGTH
];
200 rv
= v12n_domain_uuid(uuid
);
202 if (rv
== (size_t)(-1)) {
203 (void) strcpy(uuid_str
, "Unknown");
205 uuid_unparse(uuid
, uuid_str
);
207 (void) printf("%s%s\n", pflg
? "DOMAINUUID|uuid=" :
208 gettext("Domain UUID: "), uuid_str
);
212 char ctrl_name
[V12N_NAME_MAX
];
214 rv
= v12n_ctrl_domain(ctrl_name
, sizeof (ctrl_name
));
216 if (rv
== (size_t)(-1)) {
217 (void) strcpy(ctrl_name
, "Unknown");
219 (void) printf("%s%s\n", pflg
? "DOMAINCONTROL|name=" :
220 gettext("Control domain: "), ctrl_name
);
224 char serial_no
[V12N_NAME_MAX
];
226 rv
= v12n_chassis_serialno(serial_no
, sizeof (serial_no
));
228 if (rv
== (size_t)(-1)) {
229 (void) strcpy(serial_no
, "Unknown");
231 (void) printf("%s%s\n", pflg
? "DOMAINCHASSIS|serialno=" :
232 gettext("Chassis serial#: "), serial_no
);