17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 545916cd2Sjpk * Common Development and Distribution License (the "License"). 645916cd2Sjpk * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22134a1f4eSCasper H.S. Dik * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 237c478bd9Sstevel@tonic-gate */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate #ifndef _SYS_ZONE_H 267c478bd9Sstevel@tonic-gate #define _SYS_ZONE_H 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #include <sys/types.h> 297c478bd9Sstevel@tonic-gate #include <sys/mutex.h> 307c478bd9Sstevel@tonic-gate #include <sys/param.h> 317c478bd9Sstevel@tonic-gate #include <sys/rctl.h> 32824c205fSml93401 #include <sys/ipc_rctl.h> 337c478bd9Sstevel@tonic-gate #include <sys/pset.h> 3445916cd2Sjpk #include <sys/tsol/label.h> 35f4b3ec61Sdh155122 #include <sys/cred.h> 36f4b3ec61Sdh155122 #include <sys/netstack.h> 373f2f09c1Sdp #include <sys/uadmin.h> 38835ee219SRobert Harris #include <sys/ksynch.h> 39*550b6e40SSowmini Varadhan #include <sys/socket_impl.h> 40*550b6e40SSowmini Varadhan #include <netinet/in.h> 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate #ifdef __cplusplus 437c478bd9Sstevel@tonic-gate extern "C" { 447c478bd9Sstevel@tonic-gate #endif 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate /* 477c478bd9Sstevel@tonic-gate * NOTE 487c478bd9Sstevel@tonic-gate * 497c478bd9Sstevel@tonic-gate * The contents of this file are private to the implementation of 507c478bd9Sstevel@tonic-gate * Solaris and are subject to change at any time without notice. 517c478bd9Sstevel@tonic-gate * Applications and drivers using these interfaces may fail to 527c478bd9Sstevel@tonic-gate * run on future releases. 537c478bd9Sstevel@tonic-gate */ 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate /* Available both in kernel and for user space */ 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate /* zone id restrictions and special ids */ 587c478bd9Sstevel@tonic-gate #define MAX_ZONEID 9999 597c478bd9Sstevel@tonic-gate #define MIN_USERZONEID 1 /* lowest user-creatable zone ID */ 607c478bd9Sstevel@tonic-gate #define MIN_ZONEID 0 /* minimum zone ID on system */ 617c478bd9Sstevel@tonic-gate #define GLOBAL_ZONEID 0 627c478bd9Sstevel@tonic-gate #define ZONEID_WIDTH 4 /* for printf */ 637c478bd9Sstevel@tonic-gate 6445916cd2Sjpk /* 6545916cd2Sjpk * Special zoneid_t token to refer to all zones. 6645916cd2Sjpk */ 6745916cd2Sjpk #define ALL_ZONES (-1) 6845916cd2Sjpk 697c478bd9Sstevel@tonic-gate /* system call subcodes */ 707c478bd9Sstevel@tonic-gate #define ZONE_CREATE 0 717c478bd9Sstevel@tonic-gate #define ZONE_DESTROY 1 727c478bd9Sstevel@tonic-gate #define ZONE_GETATTR 2 737c478bd9Sstevel@tonic-gate #define ZONE_ENTER 3 747c478bd9Sstevel@tonic-gate #define ZONE_LIST 4 757c478bd9Sstevel@tonic-gate #define ZONE_SHUTDOWN 5 767c478bd9Sstevel@tonic-gate #define ZONE_LOOKUP 6 777c478bd9Sstevel@tonic-gate #define ZONE_BOOT 7 78821c4a97Sdp #define ZONE_VERSION 8 793f2f09c1Sdp #define ZONE_SETATTR 9 80f4b3ec61Sdh155122 #define ZONE_ADD_DATALINK 10 81f4b3ec61Sdh155122 #define ZONE_DEL_DATALINK 11 82f4b3ec61Sdh155122 #define ZONE_CHECK_DATALINK 12 83f4b3ec61Sdh155122 #define ZONE_LIST_DATALINK 13 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate /* zone attributes */ 867c478bd9Sstevel@tonic-gate #define ZONE_ATTR_ROOT 1 877c478bd9Sstevel@tonic-gate #define ZONE_ATTR_NAME 2 887c478bd9Sstevel@tonic-gate #define ZONE_ATTR_STATUS 3 897c478bd9Sstevel@tonic-gate #define ZONE_ATTR_PRIVSET 4 907c478bd9Sstevel@tonic-gate #define ZONE_ATTR_UNIQID 5 917c478bd9Sstevel@tonic-gate #define ZONE_ATTR_POOLID 6 927c478bd9Sstevel@tonic-gate #define ZONE_ATTR_INITPID 7 9345916cd2Sjpk #define ZONE_ATTR_SLBL 8 943f2f09c1Sdp #define ZONE_ATTR_INITNAME 9 953f2f09c1Sdp #define ZONE_ATTR_BOOTARGS 10 969acbbeafSnn35248 #define ZONE_ATTR_BRAND 11 970209230bSgjelinek #define ZONE_ATTR_PHYS_MCAP 12 980209230bSgjelinek #define ZONE_ATTR_SCHED_CLASS 13 99f4b3ec61Sdh155122 #define ZONE_ATTR_FLAGS 14 1005679c89fSjv227347 #define ZONE_ATTR_HOSTID 15 1010fbb751dSJohn Levon #define ZONE_ATTR_FS_ALLOWED 16 102*550b6e40SSowmini Varadhan #define ZONE_ATTR_NETWORK 17 1039acbbeafSnn35248 1049acbbeafSnn35248 /* Start of the brand-specific attribute namespace */ 1059acbbeafSnn35248 #define ZONE_ATTR_BRAND_ATTRS 32768 1067c478bd9Sstevel@tonic-gate 1070fbb751dSJohn Levon #define ZONE_FS_ALLOWED_MAX 1024 1080fbb751dSJohn Levon 109cf8f45c7Sdstaff #define ZONE_EVENT_CHANNEL "com.sun:zones:status" 110cf8f45c7Sdstaff #define ZONE_EVENT_STATUS_CLASS "status" 111cf8f45c7Sdstaff #define ZONE_EVENT_STATUS_SUBCLASS "change" 112cf8f45c7Sdstaff 113cf8f45c7Sdstaff #define ZONE_EVENT_UNINITIALIZED "uninitialized" 114bd41d0a8Snordmark #define ZONE_EVENT_INITIALIZED "initialized" 115cf8f45c7Sdstaff #define ZONE_EVENT_READY "ready" 116cf8f45c7Sdstaff #define ZONE_EVENT_RUNNING "running" 117cf8f45c7Sdstaff #define ZONE_EVENT_SHUTTING_DOWN "shutting_down" 118cf8f45c7Sdstaff 119cf8f45c7Sdstaff #define ZONE_CB_NAME "zonename" 120cf8f45c7Sdstaff #define ZONE_CB_NEWSTATE "newstate" 121cf8f45c7Sdstaff #define ZONE_CB_OLDSTATE "oldstate" 122cf8f45c7Sdstaff #define ZONE_CB_TIMESTAMP "when" 123cf8f45c7Sdstaff #define ZONE_CB_ZONEID "zoneid" 124cf8f45c7Sdstaff 1259acbbeafSnn35248 /* 1269acbbeafSnn35248 * Exit values that may be returned by scripts or programs invoked by various 1279acbbeafSnn35248 * zone commands. 1289acbbeafSnn35248 * 1299acbbeafSnn35248 * These are defined as: 1309acbbeafSnn35248 * 1319acbbeafSnn35248 * ZONE_SUBPROC_OK 1329acbbeafSnn35248 * =============== 1339acbbeafSnn35248 * The subprocess completed successfully. 1349acbbeafSnn35248 * 1359acbbeafSnn35248 * ZONE_SUBPROC_USAGE 1369acbbeafSnn35248 * ================== 1379acbbeafSnn35248 * The subprocess failed with a usage message, or a usage message should 1389acbbeafSnn35248 * be output in its behalf. 1399acbbeafSnn35248 * 1409acbbeafSnn35248 * ZONE_SUBPROC_NOTCOMPLETE 1419acbbeafSnn35248 * ======================== 1429acbbeafSnn35248 * The subprocess did not complete, but the actions performed by the 1439acbbeafSnn35248 * subprocess require no recovery actions by the user. 1449acbbeafSnn35248 * 1459acbbeafSnn35248 * For example, if the subprocess were called by "zoneadm install," the 1469acbbeafSnn35248 * installation of the zone did not succeed but the user need not perform 1479acbbeafSnn35248 * a "zoneadm uninstall" before attempting another install. 1489acbbeafSnn35248 * 1499acbbeafSnn35248 * ZONE_SUBPROC_FATAL 1509acbbeafSnn35248 * ================== 1519acbbeafSnn35248 * The subprocess failed in a fatal manner, usually one that will require 1529acbbeafSnn35248 * some type of recovery action by the user. 1539acbbeafSnn35248 * 1549acbbeafSnn35248 * For example, if the subprocess were called by "zoneadm install," the 1559acbbeafSnn35248 * installation of the zone did not succeed and the user will need to 1569acbbeafSnn35248 * perform a "zoneadm uninstall" before another install attempt is 1579acbbeafSnn35248 * possible. 1589acbbeafSnn35248 * 1599acbbeafSnn35248 * The non-success exit values are large to avoid accidental collision 1609acbbeafSnn35248 * with values used internally by some commands (e.g. "Z_ERR" and 1619acbbeafSnn35248 * "Z_USAGE" as used by zoneadm.) 1629acbbeafSnn35248 */ 1639acbbeafSnn35248 #define ZONE_SUBPROC_OK 0 1649acbbeafSnn35248 #define ZONE_SUBPROC_USAGE 253 1659acbbeafSnn35248 #define ZONE_SUBPROC_NOTCOMPLETE 254 1669acbbeafSnn35248 #define ZONE_SUBPROC_FATAL 255 1679acbbeafSnn35248 1687c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32 1697c478bd9Sstevel@tonic-gate typedef struct { 1707c478bd9Sstevel@tonic-gate caddr32_t zone_name; 1717c478bd9Sstevel@tonic-gate caddr32_t zone_root; 1727c478bd9Sstevel@tonic-gate caddr32_t zone_privs; 173821c4a97Sdp size32_t zone_privssz; 1747c478bd9Sstevel@tonic-gate caddr32_t rctlbuf; 1757c478bd9Sstevel@tonic-gate size32_t rctlbufsz; 1767c478bd9Sstevel@tonic-gate caddr32_t extended_error; 177fa9e4066Sahrens caddr32_t zfsbuf; 178fa9e4066Sahrens size32_t zfsbufsz; 17942bc57c4Srica int match; /* match level */ 18042bc57c4Srica uint32_t doi; /* DOI for label */ 18142bc57c4Srica caddr32_t label; /* label associated with zone */ 182f4b3ec61Sdh155122 int flags; 1837c478bd9Sstevel@tonic-gate } zone_def32; 1847c478bd9Sstevel@tonic-gate #endif 1857c478bd9Sstevel@tonic-gate typedef struct { 1867c478bd9Sstevel@tonic-gate const char *zone_name; 1877c478bd9Sstevel@tonic-gate const char *zone_root; 1887c478bd9Sstevel@tonic-gate const struct priv_set *zone_privs; 189821c4a97Sdp size_t zone_privssz; 1907c478bd9Sstevel@tonic-gate const char *rctlbuf; 1917c478bd9Sstevel@tonic-gate size_t rctlbufsz; 1927c478bd9Sstevel@tonic-gate int *extended_error; 193fa9e4066Sahrens const char *zfsbuf; 194fa9e4066Sahrens size_t zfsbufsz; 19545916cd2Sjpk int match; /* match level */ 19642bc57c4Srica uint32_t doi; /* DOI for label */ 19745916cd2Sjpk const bslabel_t *label; /* label associated with zone */ 198f4b3ec61Sdh155122 int flags; 1997c478bd9Sstevel@tonic-gate } zone_def; 2007c478bd9Sstevel@tonic-gate 2017c478bd9Sstevel@tonic-gate /* extended error information */ 2027c478bd9Sstevel@tonic-gate #define ZE_UNKNOWN 0 /* No extended error info */ 2037c478bd9Sstevel@tonic-gate #define ZE_CHROOTED 1 /* tried to zone_create from chroot */ 2047c478bd9Sstevel@tonic-gate #define ZE_AREMOUNTS 2 /* there are mounts within the zone */ 2058c55461bSton #define ZE_LABELINUSE 3 /* label is already in use by some other zone */ 2067c478bd9Sstevel@tonic-gate 2077c478bd9Sstevel@tonic-gate /* zone_status */ 2087c478bd9Sstevel@tonic-gate typedef enum { 2097c478bd9Sstevel@tonic-gate ZONE_IS_UNINITIALIZED = 0, 210bd41d0a8Snordmark ZONE_IS_INITIALIZED, 2117c478bd9Sstevel@tonic-gate ZONE_IS_READY, 2127c478bd9Sstevel@tonic-gate ZONE_IS_BOOTING, 2137c478bd9Sstevel@tonic-gate ZONE_IS_RUNNING, 2147c478bd9Sstevel@tonic-gate ZONE_IS_SHUTTING_DOWN, 2157c478bd9Sstevel@tonic-gate ZONE_IS_EMPTY, 2167c478bd9Sstevel@tonic-gate ZONE_IS_DOWN, 2177c478bd9Sstevel@tonic-gate ZONE_IS_DYING, 2187c478bd9Sstevel@tonic-gate ZONE_IS_DEAD 2197c478bd9Sstevel@tonic-gate } zone_status_t; 2207c478bd9Sstevel@tonic-gate #define ZONE_MIN_STATE ZONE_IS_UNINITIALIZED 2217c478bd9Sstevel@tonic-gate #define ZONE_MAX_STATE ZONE_IS_DEAD 2227c478bd9Sstevel@tonic-gate 2237c478bd9Sstevel@tonic-gate /* 2247c478bd9Sstevel@tonic-gate * Valid commands which may be issued by zoneadm to zoneadmd. The kernel also 2257c478bd9Sstevel@tonic-gate * communicates with zoneadmd, but only uses Z_REBOOT and Z_HALT. 2267c478bd9Sstevel@tonic-gate */ 2277c478bd9Sstevel@tonic-gate typedef enum zone_cmd { 2289acbbeafSnn35248 Z_READY, Z_BOOT, Z_FORCEBOOT, Z_REBOOT, Z_HALT, Z_NOTE_UNINSTALLING, 2299acbbeafSnn35248 Z_MOUNT, Z_FORCEMOUNT, Z_UNMOUNT 2307c478bd9Sstevel@tonic-gate } zone_cmd_t; 2317c478bd9Sstevel@tonic-gate 2327c478bd9Sstevel@tonic-gate /* 2337c478bd9Sstevel@tonic-gate * The structure of a request to zoneadmd. 2347c478bd9Sstevel@tonic-gate */ 2357c478bd9Sstevel@tonic-gate typedef struct zone_cmd_arg { 2367c478bd9Sstevel@tonic-gate uint64_t uniqid; /* unique "generation number" */ 2377c478bd9Sstevel@tonic-gate zone_cmd_t cmd; /* requested action */ 2383f2f09c1Sdp uint32_t _pad; /* need consistent 32/64 bit alignmt */ 2397c478bd9Sstevel@tonic-gate char locale[MAXPATHLEN]; /* locale in which to render messages */ 2403f2f09c1Sdp char bootbuf[BOOTARGS_MAX]; /* arguments passed to zone_boot() */ 2417c478bd9Sstevel@tonic-gate } zone_cmd_arg_t; 2427c478bd9Sstevel@tonic-gate 2437c478bd9Sstevel@tonic-gate /* 2447c478bd9Sstevel@tonic-gate * Structure of zoneadmd's response to a request. A NULL return value means 2457c478bd9Sstevel@tonic-gate * the caller should attempt to restart zoneadmd and retry. 2467c478bd9Sstevel@tonic-gate */ 2477c478bd9Sstevel@tonic-gate typedef struct zone_cmd_rval { 2487c478bd9Sstevel@tonic-gate int rval; /* return value of request */ 2497c478bd9Sstevel@tonic-gate char errbuf[1]; /* variable-sized buffer containing error messages */ 2507c478bd9Sstevel@tonic-gate } zone_cmd_rval_t; 2517c478bd9Sstevel@tonic-gate 2527c478bd9Sstevel@tonic-gate /* 2537c478bd9Sstevel@tonic-gate * The zone support infrastructure uses the zone name as a component 2547c478bd9Sstevel@tonic-gate * of unix domain (AF_UNIX) sockets, which are limited to 108 characters 2557c478bd9Sstevel@tonic-gate * in length, so ZONENAME_MAX is limited by that. 2567c478bd9Sstevel@tonic-gate */ 2577c478bd9Sstevel@tonic-gate #define ZONENAME_MAX 64 2587c478bd9Sstevel@tonic-gate 2597c478bd9Sstevel@tonic-gate #define GLOBAL_ZONENAME "global" 2607c478bd9Sstevel@tonic-gate 2617c478bd9Sstevel@tonic-gate /* 2627c478bd9Sstevel@tonic-gate * Extended Regular expression (see regex(5)) which matches all valid zone 2637c478bd9Sstevel@tonic-gate * names. 2647c478bd9Sstevel@tonic-gate */ 2657c478bd9Sstevel@tonic-gate #define ZONENAME_REGEXP "[a-zA-Z0-9][-_.a-zA-Z0-9]{0,62}" 2667c478bd9Sstevel@tonic-gate 2677c478bd9Sstevel@tonic-gate /* 2687c478bd9Sstevel@tonic-gate * Where the zones support infrastructure places temporary files. 2697c478bd9Sstevel@tonic-gate */ 2707c478bd9Sstevel@tonic-gate #define ZONES_TMPDIR "/var/run/zones" 2717c478bd9Sstevel@tonic-gate 2727c478bd9Sstevel@tonic-gate /* 2737c478bd9Sstevel@tonic-gate * The path to the door used by clients to communicate with zoneadmd. 2747c478bd9Sstevel@tonic-gate */ 2757c478bd9Sstevel@tonic-gate #define ZONE_DOOR_PATH ZONES_TMPDIR "/%s.zoneadmd_door" 2767c478bd9Sstevel@tonic-gate 277f4b3ec61Sdh155122 /* zone_flags */ 278f4b3ec61Sdh155122 #define ZF_HASHED_LABEL 0x2 /* zone has a unique label */ 279f4b3ec61Sdh155122 #define ZF_IS_SCRATCH 0x4 /* scratch zone */ 280f4b3ec61Sdh155122 #define ZF_NET_EXCL 0x8 /* Zone has an exclusive IP stack */ 281f4b3ec61Sdh155122 282f4b3ec61Sdh155122 /* zone_create flags */ 283f4b3ec61Sdh155122 #define ZCF_NET_EXCL 0x1 /* Create a zone with exclusive IP */ 284f4b3ec61Sdh155122 285*550b6e40SSowmini Varadhan /* zone network properties */ 286*550b6e40SSowmini Varadhan #define ZONE_NETWORK_ADDRESS 1 287*550b6e40SSowmini Varadhan #define ZONE_NETWORK_DEFROUTER 2 288*550b6e40SSowmini Varadhan 289*550b6e40SSowmini Varadhan #define ZONE_NET_ADDRNAME "address" 290*550b6e40SSowmini Varadhan #define ZONE_NET_RTRNAME "route" 291*550b6e40SSowmini Varadhan 292*550b6e40SSowmini Varadhan typedef struct zone_net_data { 293*550b6e40SSowmini Varadhan int zn_type; 294*550b6e40SSowmini Varadhan int zn_len; 295*550b6e40SSowmini Varadhan datalink_id_t zn_linkid; 296*550b6e40SSowmini Varadhan uint8_t zn_val[1]; 297*550b6e40SSowmini Varadhan } zone_net_data_t; 298*550b6e40SSowmini Varadhan 299*550b6e40SSowmini Varadhan 3007c478bd9Sstevel@tonic-gate #ifdef _KERNEL 3017c478bd9Sstevel@tonic-gate /* 3027c478bd9Sstevel@tonic-gate * We need to protect the definition of 'list_t' from userland applications and 3037c478bd9Sstevel@tonic-gate * libraries which may be defining ther own versions. 3047c478bd9Sstevel@tonic-gate */ 3057c478bd9Sstevel@tonic-gate #include <sys/list.h> 3067c478bd9Sstevel@tonic-gate 3077c478bd9Sstevel@tonic-gate #define GLOBAL_ZONEUNIQID 0 /* uniqid of the global zone */ 3087c478bd9Sstevel@tonic-gate 3097c478bd9Sstevel@tonic-gate struct pool; 3109acbbeafSnn35248 struct brand; 3117c478bd9Sstevel@tonic-gate 312fa9e4066Sahrens /* 313fa9e4066Sahrens * Structure to record list of ZFS datasets exported to a zone. 314fa9e4066Sahrens */ 315fa9e4066Sahrens typedef struct zone_dataset { 316fa9e4066Sahrens char *zd_dataset; 317fa9e4066Sahrens list_node_t zd_linkage; 318fa9e4066Sahrens } zone_dataset_t; 319fa9e4066Sahrens 3200209230bSgjelinek /* 3210209230bSgjelinek * structure for zone kstats 3220209230bSgjelinek */ 3230209230bSgjelinek typedef struct zone_kstat { 3240209230bSgjelinek kstat_named_t zk_zonename; 3250209230bSgjelinek kstat_named_t zk_usage; 3260209230bSgjelinek kstat_named_t zk_value; 3270209230bSgjelinek } zone_kstat_t; 3280209230bSgjelinek 329c97ad5cdSakolb struct cpucap; 330c97ad5cdSakolb 3317c478bd9Sstevel@tonic-gate typedef struct zone { 3327c478bd9Sstevel@tonic-gate /* 3337c478bd9Sstevel@tonic-gate * zone_name is never modified once set. 3347c478bd9Sstevel@tonic-gate */ 3357c478bd9Sstevel@tonic-gate char *zone_name; /* zone's configuration name */ 3367c478bd9Sstevel@tonic-gate /* 3377c478bd9Sstevel@tonic-gate * zone_nodename and zone_domain are never freed once allocated. 3387c478bd9Sstevel@tonic-gate */ 3397c478bd9Sstevel@tonic-gate char *zone_nodename; /* utsname.nodename equivalent */ 3407c478bd9Sstevel@tonic-gate char *zone_domain; /* srpc_domain equivalent */ 3417c478bd9Sstevel@tonic-gate /* 3425679c89fSjv227347 * zone_hostid is used for per-zone hostid emulation. 3435679c89fSjv227347 * Currently it isn't modified after it's set (so no locks protect 3445679c89fSjv227347 * accesses), but that might have to change when we allow 3455679c89fSjv227347 * administrators to change running zones' properties. 3465679c89fSjv227347 * 3475679c89fSjv227347 * The global zone's zone_hostid must always be HW_INVALID_HOSTID so 3485679c89fSjv227347 * that zone_get_hostid() will function correctly. 3495679c89fSjv227347 */ 3505679c89fSjv227347 uint32_t zone_hostid; /* zone's hostid, HW_INVALID_HOSTID */ 3515679c89fSjv227347 /* if not emulated */ 3525679c89fSjv227347 /* 3537c478bd9Sstevel@tonic-gate * zone_lock protects the following fields of a zone_t: 3547c478bd9Sstevel@tonic-gate * zone_ref 3557c478bd9Sstevel@tonic-gate * zone_cred_ref 3567c478bd9Sstevel@tonic-gate * zone_ntasks 3577c478bd9Sstevel@tonic-gate * zone_flags 3587c478bd9Sstevel@tonic-gate * zone_zsd 359134a1f4eSCasper H.S. Dik * zone_pfexecd 3607c478bd9Sstevel@tonic-gate */ 3617c478bd9Sstevel@tonic-gate kmutex_t zone_lock; 3627c478bd9Sstevel@tonic-gate /* 3637c478bd9Sstevel@tonic-gate * zone_linkage is the zone's linkage into the active or 3647c478bd9Sstevel@tonic-gate * death-row list. The field is protected by zonehash_lock. 3657c478bd9Sstevel@tonic-gate */ 3667c478bd9Sstevel@tonic-gate list_node_t zone_linkage; 3677c478bd9Sstevel@tonic-gate zoneid_t zone_id; /* ID of zone */ 3687c478bd9Sstevel@tonic-gate uint_t zone_ref; /* count of zone_hold()s on zone */ 3697c478bd9Sstevel@tonic-gate uint_t zone_cred_ref; /* count of zone_hold_cred()s on zone */ 3707c478bd9Sstevel@tonic-gate /* 3717c478bd9Sstevel@tonic-gate * zone_rootvp and zone_rootpath can never be modified once set. 3727c478bd9Sstevel@tonic-gate */ 3737c478bd9Sstevel@tonic-gate struct vnode *zone_rootvp; /* zone's root vnode */ 3747c478bd9Sstevel@tonic-gate char *zone_rootpath; /* Path to zone's root + '/' */ 3757c478bd9Sstevel@tonic-gate ushort_t zone_flags; /* misc flags */ 3767c478bd9Sstevel@tonic-gate zone_status_t zone_status; /* protected by zone_status_lock */ 3777c478bd9Sstevel@tonic-gate uint_t zone_ntasks; /* number of tasks executing in zone */ 3787c478bd9Sstevel@tonic-gate kmutex_t zone_nlwps_lock; /* protects zone_nlwps, and *_nlwps */ 3797c478bd9Sstevel@tonic-gate /* counters in projects and tasks */ 3807c478bd9Sstevel@tonic-gate /* that are within the zone */ 3817c478bd9Sstevel@tonic-gate rctl_qty_t zone_nlwps; /* number of lwps in zone */ 3827c478bd9Sstevel@tonic-gate rctl_qty_t zone_nlwps_ctl; /* protected by zone_rctls->rcs_lock */ 383824c205fSml93401 rctl_qty_t zone_shmmax; /* System V shared memory usage */ 384824c205fSml93401 ipc_rqty_t zone_ipc; /* System V IPC id resource usage */ 3857c478bd9Sstevel@tonic-gate 3867c478bd9Sstevel@tonic-gate uint_t zone_rootpathlen; /* strlen(zone_rootpath) + 1 */ 3877c478bd9Sstevel@tonic-gate uint32_t zone_shares; /* FSS shares allocated to zone */ 3887c478bd9Sstevel@tonic-gate rctl_set_t *zone_rctls; /* zone-wide (zone.*) rctls */ 3890209230bSgjelinek kmutex_t zone_mem_lock; /* protects zone_locked_mem and */ 390c6939658Ssl108498 /* kpd_locked_mem for all */ 3910209230bSgjelinek /* projects in zone. */ 3920209230bSgjelinek /* Also protects zone_max_swap */ 393c6939658Ssl108498 /* grab after p_lock, before rcs_lock */ 3940209230bSgjelinek rctl_qty_t zone_locked_mem; /* bytes of locked memory in */ 3950209230bSgjelinek /* zone */ 3960209230bSgjelinek rctl_qty_t zone_locked_mem_ctl; /* Current locked memory */ 397c6939658Ssl108498 /* limit. Protected by */ 398c6939658Ssl108498 /* zone_rctls->rcs_lock */ 3990209230bSgjelinek rctl_qty_t zone_max_swap; /* bytes of swap reserved by zone */ 4000209230bSgjelinek rctl_qty_t zone_max_swap_ctl; /* current swap limit. */ 4010209230bSgjelinek /* Protected by */ 4020209230bSgjelinek /* zone_rctls->rcs_lock */ 4030fbb751dSJohn Levon kmutex_t zone_rctl_lock; /* protects zone_max_lofi */ 4040fbb751dSJohn Levon rctl_qty_t zone_max_lofi; /* lofi devs for zone */ 4050fbb751dSJohn Levon rctl_qty_t zone_max_lofi_ctl; /* current lofi limit. */ 4060fbb751dSJohn Levon /* Protected by */ 4070fbb751dSJohn Levon /* zone_rctls->rcs_lock */ 4087c478bd9Sstevel@tonic-gate list_t zone_zsd; /* list of Zone-Specific Data values */ 4097c478bd9Sstevel@tonic-gate kcondvar_t zone_cv; /* used to signal state changes */ 4107c478bd9Sstevel@tonic-gate struct proc *zone_zsched; /* Dummy kernel "zsched" process */ 4117c478bd9Sstevel@tonic-gate pid_t zone_proc_initpid; /* pid of "init" for this zone */ 4123f2f09c1Sdp char *zone_initname; /* fs path to 'init' */ 4137c478bd9Sstevel@tonic-gate int zone_boot_err; /* for zone_boot() if boot fails */ 4147c478bd9Sstevel@tonic-gate char *zone_bootargs; /* arguments passed via zone_boot() */ 4150209230bSgjelinek uint64_t zone_phys_mcap; /* physical memory cap */ 4167c478bd9Sstevel@tonic-gate /* 4177c478bd9Sstevel@tonic-gate * zone_kthreads is protected by zone_status_lock. 4187c478bd9Sstevel@tonic-gate */ 4197c478bd9Sstevel@tonic-gate kthread_t *zone_kthreads; /* kernel threads in zone */ 4207c478bd9Sstevel@tonic-gate struct priv_set *zone_privset; /* limit set for zone */ 4217c478bd9Sstevel@tonic-gate /* 4227c478bd9Sstevel@tonic-gate * zone_vfslist is protected by vfs_list_lock(). 4237c478bd9Sstevel@tonic-gate */ 4247c478bd9Sstevel@tonic-gate struct vfs *zone_vfslist; /* list of FS's mounted in zone */ 4257c478bd9Sstevel@tonic-gate uint64_t zone_uniqid; /* unique zone generation number */ 4267c478bd9Sstevel@tonic-gate struct cred *zone_kcred; /* kcred-like, zone-limited cred */ 4277c478bd9Sstevel@tonic-gate /* 4287c478bd9Sstevel@tonic-gate * zone_pool is protected by pool_lock(). 4297c478bd9Sstevel@tonic-gate */ 4307c478bd9Sstevel@tonic-gate struct pool *zone_pool; /* pool the zone is bound to */ 4317c478bd9Sstevel@tonic-gate hrtime_t zone_pool_mod; /* last pool bind modification time */ 4327c478bd9Sstevel@tonic-gate /* zone_psetid is protected by cpu_lock */ 4337c478bd9Sstevel@tonic-gate psetid_t zone_psetid; /* pset the zone is bound to */ 4347c478bd9Sstevel@tonic-gate /* 4357c478bd9Sstevel@tonic-gate * The following two can be read without holding any locks. They are 4367c478bd9Sstevel@tonic-gate * updated under cpu_lock. 4377c478bd9Sstevel@tonic-gate */ 4387c478bd9Sstevel@tonic-gate int zone_ncpus; /* zone's idea of ncpus */ 4397c478bd9Sstevel@tonic-gate int zone_ncpus_online; /* zone's idea of ncpus_online */ 440fa9e4066Sahrens /* 441fa9e4066Sahrens * List of ZFS datasets exported to this zone. 442fa9e4066Sahrens */ 443fa9e4066Sahrens list_t zone_datasets; /* list of datasets */ 44445916cd2Sjpk 44542bc57c4Srica ts_label_t *zone_slabel; /* zone sensitivity label */ 44642bc57c4Srica int zone_match; /* require label match for packets */ 44745916cd2Sjpk tsol_mlp_list_t zone_mlps; /* MLPs on zone-private addresses */ 4483f2f09c1Sdp 4499acbbeafSnn35248 boolean_t zone_restart_init; /* Restart init if it dies? */ 4509acbbeafSnn35248 struct brand *zone_brand; /* zone's brand */ 451319378d9Seh208807 void *zone_brand_data; /* store brand specific data */ 4520209230bSgjelinek id_t zone_defaultcid; /* dflt scheduling class id */ 4530209230bSgjelinek kstat_t *zone_swapresv_kstat; 4540209230bSgjelinek kstat_t *zone_lockedmem_kstat; 455f4b3ec61Sdh155122 /* 456f4b3ec61Sdh155122 * zone_dl_list is protected by zone_lock 457f4b3ec61Sdh155122 */ 4582b24ab6bSSebastien Roy list_t zone_dl_list; 459f4b3ec61Sdh155122 netstack_t *zone_netstack; 460c97ad5cdSakolb struct cpucap *zone_cpucap; /* CPU caps data */ 4619e9e6ab8Spaulson /* 4629e9e6ab8Spaulson * Solaris Auditing per-zone audit context 4639e9e6ab8Spaulson */ 4649e9e6ab8Spaulson struct au_kcontext *zone_audit_kctxt; 465835ee219SRobert Harris /* 466835ee219SRobert Harris * For private use by mntfs. 467835ee219SRobert Harris */ 468835ee219SRobert Harris struct mntelem *zone_mntfs_db; 469835ee219SRobert Harris krwlock_t zone_mntfs_db_lock; 470134a1f4eSCasper H.S. Dik 471134a1f4eSCasper H.S. Dik struct klpd_reg *zone_pfexecd; 4720fbb751dSJohn Levon 4730fbb751dSJohn Levon char *zone_fs_allowed; 474ff19e029SMenno Lageman rctl_qty_t zone_nprocs; /* number of processes in the zone */ 475ff19e029SMenno Lageman rctl_qty_t zone_nprocs_ctl; /* current limit protected by */ 476ff19e029SMenno Lageman /* zone_rctls->rcs_lock */ 477ff19e029SMenno Lageman kstat_t *zone_nprocs_kstat; 4787c478bd9Sstevel@tonic-gate } zone_t; 4797c478bd9Sstevel@tonic-gate 4807c478bd9Sstevel@tonic-gate /* 4817c478bd9Sstevel@tonic-gate * Special value of zone_psetid to indicate that pools are disabled. 4827c478bd9Sstevel@tonic-gate */ 4837c478bd9Sstevel@tonic-gate #define ZONE_PS_INVAL PS_MYID 4847c478bd9Sstevel@tonic-gate 485f4b3ec61Sdh155122 4867c478bd9Sstevel@tonic-gate extern zone_t zone0; 4877c478bd9Sstevel@tonic-gate extern zone_t *global_zone; 4887c478bd9Sstevel@tonic-gate extern uint_t maxzones; 4897c478bd9Sstevel@tonic-gate extern rctl_hndl_t rc_zone_nlwps; 490ff19e029SMenno Lageman extern rctl_hndl_t rc_zone_nprocs; 4917c478bd9Sstevel@tonic-gate 492fa9e4066Sahrens extern long zone(int, void *, void *, void *, void *); 4937c478bd9Sstevel@tonic-gate extern void zone_zsd_init(void); 4947c478bd9Sstevel@tonic-gate extern void zone_init(void); 4957c478bd9Sstevel@tonic-gate extern void zone_hold(zone_t *); 4967c478bd9Sstevel@tonic-gate extern void zone_rele(zone_t *); 4977c478bd9Sstevel@tonic-gate extern void zone_cred_hold(zone_t *); 4987c478bd9Sstevel@tonic-gate extern void zone_cred_rele(zone_t *); 4997c478bd9Sstevel@tonic-gate extern void zone_task_hold(zone_t *); 5007c478bd9Sstevel@tonic-gate extern void zone_task_rele(zone_t *); 5017c478bd9Sstevel@tonic-gate extern zone_t *zone_find_by_id(zoneid_t); 50245916cd2Sjpk extern zone_t *zone_find_by_label(const ts_label_t *); 5037c478bd9Sstevel@tonic-gate extern zone_t *zone_find_by_name(char *); 50445916cd2Sjpk extern zone_t *zone_find_by_any_path(const char *, boolean_t); 50548451833Scarlsonj extern zone_t *zone_find_by_path(const char *); 5067c478bd9Sstevel@tonic-gate extern zoneid_t getzoneid(void); 507f4b3ec61Sdh155122 extern zone_t *zone_find_by_id_nolock(zoneid_t); 5082b24ab6bSSebastien Roy extern int zone_datalink_walk(zoneid_t, int (*)(datalink_id_t, void *), void *); 5092b24ab6bSSebastien Roy extern int zone_check_datalink(zoneid_t *, datalink_id_t); 5107c478bd9Sstevel@tonic-gate 5117c478bd9Sstevel@tonic-gate /* 5127c478bd9Sstevel@tonic-gate * Zone-specific data (ZSD) APIs 5137c478bd9Sstevel@tonic-gate */ 5147c478bd9Sstevel@tonic-gate /* 5157c478bd9Sstevel@tonic-gate * The following is what code should be initializing its zone_key_t to if it 5167c478bd9Sstevel@tonic-gate * calls zone_getspecific() without necessarily knowing that zone_key_create() 5177c478bd9Sstevel@tonic-gate * has been called on the key. 5187c478bd9Sstevel@tonic-gate */ 5197c478bd9Sstevel@tonic-gate #define ZONE_KEY_UNINITIALIZED 0 5207c478bd9Sstevel@tonic-gate 5217c478bd9Sstevel@tonic-gate typedef uint_t zone_key_t; 5227c478bd9Sstevel@tonic-gate 5237c478bd9Sstevel@tonic-gate extern void zone_key_create(zone_key_t *, void *(*)(zoneid_t), 5247c478bd9Sstevel@tonic-gate void (*)(zoneid_t, void *), void (*)(zoneid_t, void *)); 5257c478bd9Sstevel@tonic-gate extern int zone_key_delete(zone_key_t); 5267c478bd9Sstevel@tonic-gate extern void *zone_getspecific(zone_key_t, zone_t *); 5277c478bd9Sstevel@tonic-gate extern int zone_setspecific(zone_key_t, zone_t *, const void *); 5287c478bd9Sstevel@tonic-gate 5297c478bd9Sstevel@tonic-gate /* 5307c478bd9Sstevel@tonic-gate * The definition of a zsd_entry is truly private to zone.c and is only 5317c478bd9Sstevel@tonic-gate * placed here so it can be shared with mdb. 532bd41d0a8Snordmark * 533bd41d0a8Snordmark * State maintained for each zone times each registered key, which tracks 534bd41d0a8Snordmark * the state of the create, shutdown and destroy callbacks. 535bd41d0a8Snordmark * 536bd41d0a8Snordmark * zsd_flags is used to keep track of pending actions to avoid holding locks 537bd41d0a8Snordmark * when calling the create/shutdown/destroy callbacks, since doing so 538bd41d0a8Snordmark * could lead to deadlocks. 5397c478bd9Sstevel@tonic-gate */ 5407c478bd9Sstevel@tonic-gate struct zsd_entry { 5417c478bd9Sstevel@tonic-gate zone_key_t zsd_key; /* Key used to lookup value */ 5427c478bd9Sstevel@tonic-gate void *zsd_data; /* Caller-managed value */ 5437c478bd9Sstevel@tonic-gate /* 5447c478bd9Sstevel@tonic-gate * Callbacks to be executed when a zone is created, shutdown, and 5457c478bd9Sstevel@tonic-gate * destroyed, respectively. 5467c478bd9Sstevel@tonic-gate */ 5477c478bd9Sstevel@tonic-gate void *(*zsd_create)(zoneid_t); 5487c478bd9Sstevel@tonic-gate void (*zsd_shutdown)(zoneid_t, void *); 5497c478bd9Sstevel@tonic-gate void (*zsd_destroy)(zoneid_t, void *); 5507c478bd9Sstevel@tonic-gate list_node_t zsd_linkage; 551bd41d0a8Snordmark uint16_t zsd_flags; /* See below */ 552bd41d0a8Snordmark kcondvar_t zsd_cv; 5537c478bd9Sstevel@tonic-gate }; 5547c478bd9Sstevel@tonic-gate 5557c478bd9Sstevel@tonic-gate /* 556bd41d0a8Snordmark * zsd_flags 557bd41d0a8Snordmark */ 558bd41d0a8Snordmark #define ZSD_CREATE_NEEDED 0x0001 559bd41d0a8Snordmark #define ZSD_CREATE_INPROGRESS 0x0002 560bd41d0a8Snordmark #define ZSD_CREATE_COMPLETED 0x0004 561bd41d0a8Snordmark #define ZSD_SHUTDOWN_NEEDED 0x0010 562bd41d0a8Snordmark #define ZSD_SHUTDOWN_INPROGRESS 0x0020 563bd41d0a8Snordmark #define ZSD_SHUTDOWN_COMPLETED 0x0040 564bd41d0a8Snordmark #define ZSD_DESTROY_NEEDED 0x0100 565bd41d0a8Snordmark #define ZSD_DESTROY_INPROGRESS 0x0200 566bd41d0a8Snordmark #define ZSD_DESTROY_COMPLETED 0x0400 567bd41d0a8Snordmark 568bd41d0a8Snordmark #define ZSD_CREATE_ALL \ 569bd41d0a8Snordmark (ZSD_CREATE_NEEDED|ZSD_CREATE_INPROGRESS|ZSD_CREATE_COMPLETED) 570bd41d0a8Snordmark #define ZSD_SHUTDOWN_ALL \ 571bd41d0a8Snordmark (ZSD_SHUTDOWN_NEEDED|ZSD_SHUTDOWN_INPROGRESS|ZSD_SHUTDOWN_COMPLETED) 572bd41d0a8Snordmark #define ZSD_DESTROY_ALL \ 573bd41d0a8Snordmark (ZSD_DESTROY_NEEDED|ZSD_DESTROY_INPROGRESS|ZSD_DESTROY_COMPLETED) 574bd41d0a8Snordmark 575bd41d0a8Snordmark #define ZSD_ALL_INPROGRESS \ 576bd41d0a8Snordmark (ZSD_CREATE_INPROGRESS|ZSD_SHUTDOWN_INPROGRESS|ZSD_DESTROY_INPROGRESS) 577bd41d0a8Snordmark 578bd41d0a8Snordmark /* 5797c478bd9Sstevel@tonic-gate * Macros to help with zone visibility restrictions. 5807c478bd9Sstevel@tonic-gate */ 5817c478bd9Sstevel@tonic-gate 5827c478bd9Sstevel@tonic-gate /* 5837c478bd9Sstevel@tonic-gate * Is process in the global zone? 5847c478bd9Sstevel@tonic-gate */ 5857c478bd9Sstevel@tonic-gate #define INGLOBALZONE(p) \ 5867c478bd9Sstevel@tonic-gate ((p)->p_zone == global_zone) 5877c478bd9Sstevel@tonic-gate 5887c478bd9Sstevel@tonic-gate /* 5897c478bd9Sstevel@tonic-gate * Can process view objects in given zone? 5907c478bd9Sstevel@tonic-gate */ 5917c478bd9Sstevel@tonic-gate #define HASZONEACCESS(p, zoneid) \ 5927c478bd9Sstevel@tonic-gate ((p)->p_zone->zone_id == (zoneid) || INGLOBALZONE(p)) 5937c478bd9Sstevel@tonic-gate 5947c478bd9Sstevel@tonic-gate /* 5957c478bd9Sstevel@tonic-gate * Convenience macro to see if a resolved path is visible from within a 5967c478bd9Sstevel@tonic-gate * given zone. 5977c478bd9Sstevel@tonic-gate * 5987c478bd9Sstevel@tonic-gate * The basic idea is that the first (zone_rootpathlen - 1) bytes of the 5997c478bd9Sstevel@tonic-gate * two strings must be equal. Since the rootpathlen has a trailing '/', 6007c478bd9Sstevel@tonic-gate * we want to skip everything in the path up to (but not including) the 6017c478bd9Sstevel@tonic-gate * trailing '/'. 6027c478bd9Sstevel@tonic-gate */ 6037c478bd9Sstevel@tonic-gate #define ZONE_PATH_VISIBLE(path, zone) \ 6047c478bd9Sstevel@tonic-gate (strncmp((path), (zone)->zone_rootpath, \ 6057c478bd9Sstevel@tonic-gate (zone)->zone_rootpathlen - 1) == 0) 6067c478bd9Sstevel@tonic-gate 6077c478bd9Sstevel@tonic-gate /* 6087c478bd9Sstevel@tonic-gate * Convenience macro to go from the global view of a path to that seen 6097c478bd9Sstevel@tonic-gate * from within said zone. It is the responsibility of the caller to 6107c478bd9Sstevel@tonic-gate * ensure that the path is a resolved one (ie, no '..'s or '.'s), and is 6117c478bd9Sstevel@tonic-gate * in fact visible from within the zone. 6127c478bd9Sstevel@tonic-gate */ 6137c478bd9Sstevel@tonic-gate #define ZONE_PATH_TRANSLATE(path, zone) \ 6147c478bd9Sstevel@tonic-gate (ASSERT(ZONE_PATH_VISIBLE(path, zone)), \ 6157c478bd9Sstevel@tonic-gate (path) + (zone)->zone_rootpathlen - 2) 6167c478bd9Sstevel@tonic-gate 6177c478bd9Sstevel@tonic-gate /* 6187c478bd9Sstevel@tonic-gate * Special processes visible in all zones. 6197c478bd9Sstevel@tonic-gate */ 6207c478bd9Sstevel@tonic-gate #define ZONE_SPECIALPID(x) ((x) == 0 || (x) == 1) 6217c478bd9Sstevel@tonic-gate 6227c478bd9Sstevel@tonic-gate /* 6237c478bd9Sstevel@tonic-gate * Zone-safe version of thread_create() to be used when the caller wants to 6247c478bd9Sstevel@tonic-gate * create a kernel thread to run within the current zone's context. 6257c478bd9Sstevel@tonic-gate */ 6267c478bd9Sstevel@tonic-gate extern kthread_t *zthread_create(caddr_t, size_t, void (*)(), void *, size_t, 6277c478bd9Sstevel@tonic-gate pri_t); 6287c478bd9Sstevel@tonic-gate extern void zthread_exit(void); 6297c478bd9Sstevel@tonic-gate 6307c478bd9Sstevel@tonic-gate /* 6317c478bd9Sstevel@tonic-gate * Functions for an external observer to register interest in a zone's status 6327c478bd9Sstevel@tonic-gate * change. Observers will be woken up when the zone status equals the status 6337c478bd9Sstevel@tonic-gate * argument passed in (in the case of zone_status_timedwait, the function may 6347c478bd9Sstevel@tonic-gate * also return because of a timeout; zone_status_wait_sig may return early due 6357c478bd9Sstevel@tonic-gate * to a signal being delivered; zone_status_timedwait_sig may return for any of 6367c478bd9Sstevel@tonic-gate * the above reasons). 6377c478bd9Sstevel@tonic-gate * 6387c478bd9Sstevel@tonic-gate * Otherwise these behave identically to cv_timedwait(), cv_wait(), and 6397c478bd9Sstevel@tonic-gate * cv_wait_sig() respectively. 6407c478bd9Sstevel@tonic-gate */ 6417c478bd9Sstevel@tonic-gate extern clock_t zone_status_timedwait(zone_t *, clock_t, zone_status_t); 6427c478bd9Sstevel@tonic-gate extern clock_t zone_status_timedwait_sig(zone_t *, clock_t, zone_status_t); 6437c478bd9Sstevel@tonic-gate extern void zone_status_wait(zone_t *, zone_status_t); 6447c478bd9Sstevel@tonic-gate extern int zone_status_wait_sig(zone_t *, zone_status_t); 6457c478bd9Sstevel@tonic-gate 6467c478bd9Sstevel@tonic-gate /* 6477c478bd9Sstevel@tonic-gate * Get the status of the zone (at the time it was called). The state may 6487c478bd9Sstevel@tonic-gate * have progressed by the time it is returned. 6497c478bd9Sstevel@tonic-gate */ 6507c478bd9Sstevel@tonic-gate extern zone_status_t zone_status_get(zone_t *); 6517c478bd9Sstevel@tonic-gate 6527c478bd9Sstevel@tonic-gate /* 6535679c89fSjv227347 * Safely get the hostid of the specified zone (defaults to machine's hostid 6545679c89fSjv227347 * if the specified zone doesn't emulate a hostid). Passing NULL retrieves 6555679c89fSjv227347 * the global zone's (i.e., physical system's) hostid. 6565679c89fSjv227347 */ 6575679c89fSjv227347 extern uint32_t zone_get_hostid(zone_t *); 6585679c89fSjv227347 6595679c89fSjv227347 /* 6607c478bd9Sstevel@tonic-gate * Get the "kcred" credentials corresponding to the given zone. 6617c478bd9Sstevel@tonic-gate */ 6627c478bd9Sstevel@tonic-gate extern struct cred *zone_get_kcred(zoneid_t); 6637c478bd9Sstevel@tonic-gate 6647c478bd9Sstevel@tonic-gate /* 6657c478bd9Sstevel@tonic-gate * Get/set the pool the zone is currently bound to. 6667c478bd9Sstevel@tonic-gate */ 6677c478bd9Sstevel@tonic-gate extern struct pool *zone_pool_get(zone_t *); 6687c478bd9Sstevel@tonic-gate extern void zone_pool_set(zone_t *, struct pool *); 6697c478bd9Sstevel@tonic-gate 6707c478bd9Sstevel@tonic-gate /* 6717c478bd9Sstevel@tonic-gate * Get/set the pset the zone is currently using. 6727c478bd9Sstevel@tonic-gate */ 6737c478bd9Sstevel@tonic-gate extern psetid_t zone_pset_get(zone_t *); 6747c478bd9Sstevel@tonic-gate extern void zone_pset_set(zone_t *, psetid_t); 6757c478bd9Sstevel@tonic-gate 6767c478bd9Sstevel@tonic-gate /* 6777c478bd9Sstevel@tonic-gate * Get the number of cpus/online-cpus visible from the given zone. 6787c478bd9Sstevel@tonic-gate */ 6797c478bd9Sstevel@tonic-gate extern int zone_ncpus_get(zone_t *); 6807c478bd9Sstevel@tonic-gate extern int zone_ncpus_online_get(zone_t *); 6817c478bd9Sstevel@tonic-gate 6827c478bd9Sstevel@tonic-gate /* 683fa9e4066Sahrens * Returns true if the named pool/dataset is visible in the current zone. 684fa9e4066Sahrens */ 685fa9e4066Sahrens extern int zone_dataset_visible(const char *, int *); 686fa9e4066Sahrens 687fa9e4066Sahrens /* 6883f2f09c1Sdp * zone version of kadmin() 6897c478bd9Sstevel@tonic-gate */ 6903f2f09c1Sdp extern int zone_kadmin(int, int, const char *, cred_t *); 6917c478bd9Sstevel@tonic-gate extern void zone_shutdown_global(void); 6927c478bd9Sstevel@tonic-gate 6937c478bd9Sstevel@tonic-gate extern void mount_in_progress(void); 6947c478bd9Sstevel@tonic-gate extern void mount_completed(void); 6957c478bd9Sstevel@tonic-gate 6967c478bd9Sstevel@tonic-gate extern int zone_walk(int (*)(zone_t *, void *), void *); 6977c478bd9Sstevel@tonic-gate 698c6939658Ssl108498 extern rctl_hndl_t rc_zone_locked_mem; 6990209230bSgjelinek extern rctl_hndl_t rc_zone_max_swap; 7000fbb751dSJohn Levon extern rctl_hndl_t rc_zone_max_lofi; 701c6939658Ssl108498 7027c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 7037c478bd9Sstevel@tonic-gate 7047c478bd9Sstevel@tonic-gate #ifdef __cplusplus 7057c478bd9Sstevel@tonic-gate } 7067c478bd9Sstevel@tonic-gate #endif 7077c478bd9Sstevel@tonic-gate 7087c478bd9Sstevel@tonic-gate #endif /* _SYS_ZONE_H */ 709