/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
*/
#include <mdb/mdb_param.h>
#include <mdb/mdb_modapi.h>
#include "zone.h"
#include <stddef.h>
#ifdef _LP64
#else
#endif
/*
*/
char *zone_status_names[] = {
"uninitialized", /* ZONE_IS_UNINITIALIZED */
"initialized", /* ZONE_IS_INITIALIZED */
"ready", /* ZONE_IS_READY */
"booting", /* ZONE_IS_BOOTING */
"running", /* ZONE_IS_RUNNING */
"shutting_down", /* ZONE_IS_SHUTTING_DOWN */
"empty", /* ZONE_IS_EMPTY */
"down", /* ZONE_IS_DOWN */
"dying", /* ZONE_IS_DYING */
"dead" /* ZONE_IS_DEAD */
};
static int
{
return (WALK_NEXT);
}
/*ARGSUSED*/
int
{
return (DCMD_USAGE);
mdb_warn("failed to walk zone");
return (DCMD_ERR);
}
return (DCMD_OK);
}
int
{
int len;
if (argc > 2)
return (DCMD_USAGE);
if (!(flags & DCMD_ADDRSPEC)) {
mdb_warn("can't walk zones");
return (DCMD_ERR);
}
return (DCMD_OK);
}
/*
* Get the optional -r (reference counts) and -v (verbose output)
* arguments.
*/
vopt_given = FALSE;
ropt_given = FALSE;
return (DCMD_USAGE);
/*
* -v can only be specified with -r.
*/
return (DCMD_USAGE);
/*
* Print a table header, if necessary.
*/
if (DCMD_HDRSPEC(flags)) {
if (ropt_given == FALSE)
mdb_printf("%<u>%?s %6s %-13s %-20s %-s%</u>\n",
"ADDR", "ID", "STATUS", "NAME", "PATH");
else
mdb_printf("%<u>%?s %6s %10s %10s %-20s%</u>\n",
"ADDR", "ID", "REFS", "CREFS", "NAME");
}
/*
* Read the zone_t structure at the given address and read its name.
*/
return (DCMD_ERR);
}
if (len > 0) {
if (len == ZONE_NAMELEN)
} else {
}
if (ropt_given == FALSE) {
char *statusp;
/*
* Default display
* Fetch the zone's path and print the results.
*/
if (len > 0) {
if (len == ZONE_PATHLEN)
} else {
}
else
statusp = "???";
} else {
/*
* Display the zone's reference counts.
* Display the zone's subsystem-specific reference counts if
* the user specified the '-v' option.
*/
if (vopt_given == TRUE) {
uint_t n;
/*
* Read zone_ref_subsys_names from the kernel image.
*/
if (mdb_lookup_by_name("zone_ref_subsys_names",
&subsys_names_sym) != 0) {
mdb_warn("can't find zone_ref_subsys_names");
return (DCMD_ERR);
}
sizeof (char *)) {
mdb_warn("number of subsystems in target "
"differs from what mdb expects (mismatched"
" kernel versions?)");
if (subsys_names_sym.st_size <
ZONE_REF_NUM_SUBSYS * sizeof (char *))
sizeof (char *);
else
} else {
}
if ((zone_ref_subsys_names = mdb_alloc(
mdb_warn("out of memory");
return (DCMD_ERR);
}
"zone_ref_subsys_names") == -1) {
mdb_warn("can't find zone_ref_subsys_names");
return (DCMD_ERR);
}
/*
* Display each subsystem's reference count if it's
* nonzero.
*/
mdb_inc_indent(7);
for (n = 0; n < num_subsys; ++n) {
/*
* Skip subsystems lacking outstanding
* references.
*/
if (zn.zone_subsys_ref[n] == 0)
continue;
/*
* Each subsystem's name must be read from
* the target's image.
*/
if (mdb_readstr(subsys_name,
sizeof (subsys_name),
(uintptr_t)zone_ref_subsys_names[n]) ==
-1) {
mdb_warn("unable to read subsystem name"
" from zone_ref_subsys_names[%u]",
n);
return (DCMD_ERR);
}
zn.zone_subsys_ref[n]);
}
mdb_dec_indent(7);
}
}
return (DCMD_OK);
}
int
{
mdb_warn("failed to find 'zone_active'");
return (WALK_ERR);
}
}
mdb_warn("couldn't walk 'list'");
return (WALK_ERR);
}
return (WALK_NEXT);
}
int
{
wsp->walk_cbdata));
}
int
{
mdb_warn("global walk not supported\n");
return (WALK_ERR);
}
mdb_warn("couldn't walk 'list'");
return (WALK_ERR);
}
return (WALK_NEXT);
}
int
{
wsp->walk_cbdata));
}
/*
* Helper structure used when walking ZSD entries via zsd().
*/
struct zsd_cb_data {
/* searching for a specific ZSD */
/* entry)? */
};
/*
* Helper function for zsd() that displays information from a single ZSD struct.
* 'datap' must point to a valid zsd_cb_data struct.
*/
/* ARGSUSED */
static int
{
return (WALK_ERR);
}
/*
* Are we looking for a single entry specified by a key? Then make sure
* that the current ZSD's key is what we're looking for.
*/
return (WALK_NEXT);
mdb_printf(" Create CB: %a\n Shutdown CB: %a\n"
return (WALK_DONE);
}
return (WALK_NEXT);
}
int
{
int argcindex;
int len;
/*
* Walk all zones if necessary.
*/
if (argc > 2)
return (DCMD_USAGE);
if ((flags & DCMD_ADDRSPEC) == 0) {
mdb_warn("failed to walk zone\n");
return (DCMD_ERR);
}
return (DCMD_OK);
}
/*
* Make sure a zone_t can be read from the specified address.
*/
return (DCMD_ERR);
}
/*
* Get the optional arguments (key or -v or both). Note that
* mdb_getopts() will not parse a key argument because it is not
* preceded by an option letter. We'll get around this by requiring
* that all options precede the optional key argument.
*/
/*
* No options may appear after the key.
*/
return (DCMD_USAGE);
/*
* The missed argument should be a key.
*/
else
}
/*
* Prepare to output the specified zone's ZSD information.
*/
if (DCMD_HDRSPEC(flags))
"VALUE", "FLAGS");
if (len > 0) {
if (len == ZONE_NAMELEN)
} else {
}
/*
* Display the requested ZSD entries.
*/
mdb_inc_indent(21);
mdb_warn("failed to walk zsd\n");
mdb_dec_indent(21);
return (DCMD_ERR);
}
mdb_printf("no corresponding ZSD entry found\n");
mdb_dec_indent(21);
return (DCMD_ERR);
}
mdb_dec_indent(21);
return (DCMD_OK);
}