3 *
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.
7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
24 * Copyright 2014 Igor Kozhukhov <ikozhukhov@gmail.com>.
25 * Copyright 2016, Joyent, Inc.
26 */
27
28 #ifndef _SYS_ZONE_H
29 #define _SYS_ZONE_H
30
31 #include <sys/types.h>
32 #include <sys/mutex.h>
33 #include <sys/param.h>
34 #include <sys/rctl.h>
35 #include <sys/ipc_rctl.h>
36 #include <sys/pset.h>
37 #include <sys/tsol/label.h>
38 #include <sys/cred.h>
39 #include <sys/netstack.h>
40 #include <sys/uadmin.h>
41 #include <sys/ksynch.h>
42 #include <sys/socket_impl.h>
173 #define ZONE_SUBPROC_OK 0
174 #define ZONE_SUBPROC_USAGE 253
175 #define ZONE_SUBPROC_NOTCOMPLETE 254
176 #define ZONE_SUBPROC_FATAL 255
177
178 #ifdef _SYSCALL32
179 typedef struct {
180 caddr32_t zone_name;
181 caddr32_t zone_root;
182 caddr32_t zone_privs;
183 size32_t zone_privssz;
184 caddr32_t rctlbuf;
185 size32_t rctlbufsz;
186 caddr32_t extended_error;
187 caddr32_t zfsbuf;
188 size32_t zfsbufsz;
189 int match; /* match level */
190 uint32_t doi; /* DOI for label */
191 caddr32_t label; /* label associated with zone */
192 int flags;
193 zoneid_t zoneid; /* requested zoneid */
194 } zone_def32;
195 #endif
196 typedef struct {
197 const char *zone_name;
198 const char *zone_root;
199 const struct priv_set *zone_privs;
200 size_t zone_privssz;
201 const char *rctlbuf;
202 size_t rctlbufsz;
203 int *extended_error;
204 const char *zfsbuf;
205 size_t zfsbufsz;
206 int match; /* match level */
207 uint32_t doi; /* DOI for label */
208 const bslabel_t *label; /* label associated with zone */
209 int flags;
210 zoneid_t zoneid; /* requested zoneid */
211 } zone_def;
212
213 /* extended error information */
214 #define ZE_UNKNOWN 0 /* No extended error info */
215 #define ZE_CHROOTED 1 /* tried to zone_create from chroot */
216 #define ZE_AREMOUNTS 2 /* there are mounts within the zone */
217 #define ZE_LABELINUSE 3 /* label is already in use by some other zone */
218
219 /*
220 * zone_status values
221 *
222 * You must modify zone_status_names in mdb(1M)'s genunix module
223 * (genunix/zone.c) when you modify this enum.
224 */
225 typedef enum {
226 ZONE_IS_UNINITIALIZED = 0,
227 ZONE_IS_INITIALIZED,
228 ZONE_IS_READY,
229 ZONE_IS_BOOTING,
230 ZONE_IS_RUNNING,
366
367 /*
368 * zone_ref represents a general-purpose references to a zone. Each zone's
369 * references are linked into the zone's zone_t::zone_ref_list. This allows
370 * debuggers to walk zones' references.
371 */
372 typedef struct zone_ref {
373 struct zone *zref_zone; /* the zone to which the reference refers */
374 list_node_t zref_linkage; /* linkage for zone_t::zone_ref_list */
375 } zone_ref_t;
376
377 /*
378 * Structure to record list of ZFS datasets exported to a zone.
379 */
380 typedef struct zone_dataset {
381 char *zd_dataset;
382 list_node_t zd_linkage;
383 } zone_dataset_t;
384
385 /*
386 * structure for rctl zone kstats
387 */
388 typedef struct zone_kstat {
389 kstat_named_t zk_zonename;
390 kstat_named_t zk_usage;
391 kstat_named_t zk_value;
392 } zone_kstat_t;
393
394 struct cpucap;
395
396 typedef struct {
397 hrtime_t cycle_start;
398 uint_t cycle_cnt;
399 hrtime_t zone_avg_cnt;
400 } sys_zio_cntr_t;
401
402 typedef struct {
403 kstat_named_t zv_zonename;
404 kstat_named_t zv_nread;
405 kstat_named_t zv_reads;
406 kstat_named_t zv_rtime;
442 kstat_named_t zm_anonpgin;
443 kstat_named_t zm_execpgin;
444 kstat_named_t zm_fspgin;
445 kstat_named_t zm_anon_alloc_fail;
446 kstat_named_t zm_pf_throttle;
447 kstat_named_t zm_pf_throttle_usec;
448 } zone_mcap_kstat_t;
449
450 typedef struct {
451 kstat_named_t zm_zonename; /* full name, kstat truncates name */
452 kstat_named_t zm_utime;
453 kstat_named_t zm_stime;
454 kstat_named_t zm_wtime;
455 kstat_named_t zm_avenrun1;
456 kstat_named_t zm_avenrun5;
457 kstat_named_t zm_avenrun15;
458 kstat_named_t zm_ffcap;
459 kstat_named_t zm_ffnoproc;
460 kstat_named_t zm_ffnomem;
461 kstat_named_t zm_ffmisc;
462 kstat_named_t zm_mfseglim;
463 kstat_named_t zm_nested_intp;
464 kstat_named_t zm_init_pid;
465 kstat_named_t zm_boot_time;
466 } zone_misc_kstat_t;
467
468 typedef struct zone {
469 /*
470 * zone_name is never modified once set.
471 */
472 char *zone_name; /* zone's configuration name */
473 /*
474 * zone_nodename and zone_domain are never freed once allocated.
475 */
476 char *zone_nodename; /* utsname.nodename equivalent */
477 char *zone_domain; /* srpc_domain equivalent */
478 /*
479 * zone_hostid is used for per-zone hostid emulation.
480 * Currently it isn't modified after it's set (so no locks protect
481 * accesses), but that might have to change when we allow
482 * administrators to change running zones' properties.
487 uint32_t zone_hostid; /* zone's hostid, HW_INVALID_HOSTID */
488 /* if not emulated */
489 /*
490 * zone_lock protects the following fields of a zone_t:
491 * zone_ref
492 * zone_cred_ref
493 * zone_subsys_ref
494 * zone_ref_list
495 * zone_ntasks
496 * zone_flags
497 * zone_zsd
498 * zone_pfexecd
499 */
500 kmutex_t zone_lock;
501 /*
502 * zone_linkage is the zone's linkage into the active or
503 * death-row list. The field is protected by zonehash_lock.
504 */
505 list_node_t zone_linkage;
506 zoneid_t zone_id; /* ID of zone */
507 zoneid_t zone_did; /* persistent debug ID of zone */
508 uint_t zone_ref; /* count of zone_hold()s on zone */
509 uint_t zone_cred_ref; /* count of zone_hold_cred()s on zone */
510 /*
511 * Fixed-sized array of subsystem-specific reference counts
512 * The sum of all of the counts must be less than or equal to zone_ref.
513 * The array is indexed by the counts' subsystems' zone_ref_subsys_t
514 * constants.
515 */
516 uint_t zone_subsys_ref[ZONE_REF_NUM_SUBSYS];
517 list_t zone_ref_list; /* list of zone_ref_t structs */
518 /*
519 * zone_rootvp and zone_rootpath can never be modified once set.
520 */
521 struct vnode *zone_rootvp; /* zone's root vnode */
522 char *zone_rootpath; /* Path to zone's root + '/' */
523 ushort_t zone_flags; /* misc flags */
524 zone_status_t zone_status; /* protected by zone_status_lock */
525 uint_t zone_ntasks; /* number of tasks executing in zone */
526 kmutex_t zone_nlwps_lock; /* protects zone_nlwps, and *_nlwps */
527 /* counters in projects and tasks */
612 */
613 list_t zone_dl_list;
614 netstack_t *zone_netstack;
615 struct cpucap *zone_cpucap; /* CPU caps data */
616
617 /*
618 * Data and counters used for ZFS fair-share disk IO.
619 */
620 rctl_qty_t zone_zfs_io_pri; /* ZFS IO priority */
621 uint_t zone_zfs_queued[2]; /* sync I/O enqueued count */
622 uint64_t zone_zfs_weight; /* used to prevent starvation */
623 uint64_t zone_io_util; /* IO utilization metric */
624 boolean_t zone_io_util_above_avg; /* IO util percent > avg. */
625 uint16_t zone_io_delay; /* IO delay on logical r/w */
626 kmutex_t zone_stg_io_lock; /* protects IO window data */
627 sys_zio_cntr_t zone_rd_ops; /* Counters for ZFS reads, */
628 sys_zio_cntr_t zone_wr_ops; /* writes and */
629 sys_zio_cntr_t zone_lwr_ops; /* logical writes. */
630
631 /*
632 * kstats and counters for VFS ops and bytes.
633 */
634 kmutex_t zone_vfs_lock; /* protects VFS statistics */
635 kstat_t *zone_vfs_ksp;
636 kstat_io_t zone_vfs_rwstats;
637 zone_vfs_kstat_t *zone_vfs_stats;
638
639 /*
640 * kstats for ZFS I/O ops and bytes.
641 */
642 kmutex_t zone_zfs_lock; /* protects ZFS statistics */
643 kstat_t *zone_zfs_ksp;
644 kstat_io_t zone_zfs_rwstats;
645 zone_zfs_kstat_t *zone_zfs_stats;
646
647 /*
648 * Solaris Auditing per-zone audit context
649 */
650 struct au_kcontext *zone_audit_kctxt;
651 /*
652 * For private use by mntfs.
653 */
654 struct mntelem *zone_mntfs_db;
655 krwlock_t zone_mntfs_db_lock;
656
657 struct klpd_reg *zone_pfexecd;
658
659 char *zone_fs_allowed;
660 rctl_qty_t zone_nprocs; /* number of processes in the zone */
661 rctl_qty_t zone_nprocs_ctl; /* current limit protected by */
662 /* zone_rctls->rcs_lock */
663 kstat_t *zone_nprocs_kstat;
690 * This is tracked in msacct.c as threads change state.
691 * The zone_stime is the sum of the LMS_SYSTEM times.
692 * The zone_utime is the sum of the LMS_USER times.
693 * The zone_wtime is the sum of the LMS_WAIT_CPU times.
694 * As with per-thread micro-state accounting values, these values are
695 * not scaled to nanosecs. The scaling is done by the
696 * zone_misc_kstat_update function when kstats are requested.
697 */
698 kmutex_t zone_misc_lock; /* protects misc statistics */
699 kstat_t *zone_misc_ksp;
700 zone_misc_kstat_t *zone_misc_stats;
701 uint64_t zone_stime; /* total system time */
702 uint64_t zone_utime; /* total user time */
703 uint64_t zone_wtime; /* total time waiting in runq */
704 /* fork-fail kstat tracking */
705 uint32_t zone_ffcap; /* hit an rctl cap */
706 uint32_t zone_ffnoproc; /* get proc/lwp error */
707 uint32_t zone_ffnomem; /* as_dup/memory error */
708 uint32_t zone_ffmisc; /* misc. other error */
709
710 uint32_t zone_mfseglim; /* map failure (# segs limit) */
711
712 uint32_t zone_nested_intp; /* nested interp. kstat */
713
714 struct loadavg_s zone_loadavg; /* loadavg for this zone */
715 uint64_t zone_hp_avenrun[3]; /* high-precision avenrun */
716 int zone_avenrun[3]; /* FSCALED avg. run queue len */
717
718 /*
719 * FSS stats updated once per second by fss_decay_usage.
720 */
721 uint32_t zone_fss_gen; /* FSS generation cntr */
722 uint64_t zone_run_ticks; /* tot # of ticks running */
723
724 /*
725 * DTrace-private per-zone state
726 */
727 int zone_dtrace_getf; /* # of unprivileged getf()s */
728
729 /*
730 * Synchronization primitives used to synchronize between mounts and
731 * zone creation/destruction.
748 extern rctl_hndl_t rc_zone_nprocs;
749
750 extern long zone(int, void *, void *, void *, void *);
751 extern void zone_zsd_init(void);
752 extern void zone_init(void);
753 extern void zone_hold(zone_t *);
754 extern void zone_rele(zone_t *);
755 extern void zone_init_ref(zone_ref_t *);
756 extern void zone_hold_ref(zone_t *, zone_ref_t *, zone_ref_subsys_t);
757 extern void zone_rele_ref(zone_ref_t *, zone_ref_subsys_t);
758 extern void zone_cred_hold(zone_t *);
759 extern void zone_cred_rele(zone_t *);
760 extern void zone_task_hold(zone_t *);
761 extern void zone_task_rele(zone_t *);
762 extern zone_t *zone_find_by_id(zoneid_t);
763 extern zone_t *zone_find_by_label(const ts_label_t *);
764 extern zone_t *zone_find_by_name(char *);
765 extern zone_t *zone_find_by_any_path(const char *, boolean_t);
766 extern zone_t *zone_find_by_path(const char *);
767 extern zoneid_t getzoneid(void);
768 extern zoneid_t getzonedid(void);
769 extern zone_t *zone_find_by_id_nolock(zoneid_t);
770 extern int zone_datalink_walk(zoneid_t, int (*)(datalink_id_t, void *), void *);
771 extern int zone_check_datalink(zoneid_t *, datalink_id_t);
772 extern void zone_loadavg_update();
773
774 /*
775 * Zone-specific data (ZSD) APIs
776 */
777 /*
778 * The following is what code should be initializing its zone_key_t to if it
779 * calls zone_getspecific() without necessarily knowing that zone_key_create()
780 * has been called on the key.
781 */
782 #define ZONE_KEY_UNINITIALIZED 0
783
784 typedef uint_t zone_key_t;
785
786 extern void zone_key_create(zone_key_t *, void *(*)(zoneid_t),
787 void (*)(zoneid_t, void *), void (*)(zoneid_t, void *));
788 extern int zone_key_delete(zone_key_t);
|
3 *
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.
7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2015 Joyent, Inc. All rights reserved.
24 * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
25 * Copyright 2014 Igor Kozhukhov <ikozhukhov@gmail.com>.
26 * Copyright 2016, Joyent, Inc.
27 */
28
29 #ifndef _SYS_ZONE_H
30 #define _SYS_ZONE_H
31
32 #include <sys/types.h>
33 #include <sys/mutex.h>
34 #include <sys/param.h>
35 #include <sys/rctl.h>
36 #include <sys/ipc_rctl.h>
37 #include <sys/pset.h>
38 #include <sys/tsol/label.h>
39 #include <sys/cred.h>
40 #include <sys/netstack.h>
41 #include <sys/uadmin.h>
42 #include <sys/ksynch.h>
43 #include <sys/socket_impl.h>
174 #define ZONE_SUBPROC_OK 0
175 #define ZONE_SUBPROC_USAGE 253
176 #define ZONE_SUBPROC_NOTCOMPLETE 254
177 #define ZONE_SUBPROC_FATAL 255
178
179 #ifdef _SYSCALL32
180 typedef struct {
181 caddr32_t zone_name;
182 caddr32_t zone_root;
183 caddr32_t zone_privs;
184 size32_t zone_privssz;
185 caddr32_t rctlbuf;
186 size32_t rctlbufsz;
187 caddr32_t extended_error;
188 caddr32_t zfsbuf;
189 size32_t zfsbufsz;
190 int match; /* match level */
191 uint32_t doi; /* DOI for label */
192 caddr32_t label; /* label associated with zone */
193 int flags;
194 } zone_def32;
195 #endif
196 typedef struct {
197 const char *zone_name;
198 const char *zone_root;
199 const struct priv_set *zone_privs;
200 size_t zone_privssz;
201 const char *rctlbuf;
202 size_t rctlbufsz;
203 int *extended_error;
204 const char *zfsbuf;
205 size_t zfsbufsz;
206 int match; /* match level */
207 uint32_t doi; /* DOI for label */
208 const bslabel_t *label; /* label associated with zone */
209 int flags;
210 } zone_def;
211
212 /* extended error information */
213 #define ZE_UNKNOWN 0 /* No extended error info */
214 #define ZE_CHROOTED 1 /* tried to zone_create from chroot */
215 #define ZE_AREMOUNTS 2 /* there are mounts within the zone */
216 #define ZE_LABELINUSE 3 /* label is already in use by some other zone */
217
218 /*
219 * zone_status values
220 *
221 * You must modify zone_status_names in mdb(1M)'s genunix module
222 * (genunix/zone.c) when you modify this enum.
223 */
224 typedef enum {
225 ZONE_IS_UNINITIALIZED = 0,
226 ZONE_IS_INITIALIZED,
227 ZONE_IS_READY,
228 ZONE_IS_BOOTING,
229 ZONE_IS_RUNNING,
365
366 /*
367 * zone_ref represents a general-purpose references to a zone. Each zone's
368 * references are linked into the zone's zone_t::zone_ref_list. This allows
369 * debuggers to walk zones' references.
370 */
371 typedef struct zone_ref {
372 struct zone *zref_zone; /* the zone to which the reference refers */
373 list_node_t zref_linkage; /* linkage for zone_t::zone_ref_list */
374 } zone_ref_t;
375
376 /*
377 * Structure to record list of ZFS datasets exported to a zone.
378 */
379 typedef struct zone_dataset {
380 char *zd_dataset;
381 list_node_t zd_linkage;
382 } zone_dataset_t;
383
384 /*
385 * structure for zone kstats
386 */
387 typedef struct zone_kstat {
388 kstat_named_t zk_zonename;
389 kstat_named_t zk_usage;
390 kstat_named_t zk_value;
391 } zone_kstat_t;
392
393 struct cpucap;
394
395 typedef struct {
396 hrtime_t cycle_start;
397 uint_t cycle_cnt;
398 hrtime_t zone_avg_cnt;
399 } sys_zio_cntr_t;
400
401 typedef struct {
402 kstat_named_t zv_zonename;
403 kstat_named_t zv_nread;
404 kstat_named_t zv_reads;
405 kstat_named_t zv_rtime;
441 kstat_named_t zm_anonpgin;
442 kstat_named_t zm_execpgin;
443 kstat_named_t zm_fspgin;
444 kstat_named_t zm_anon_alloc_fail;
445 kstat_named_t zm_pf_throttle;
446 kstat_named_t zm_pf_throttle_usec;
447 } zone_mcap_kstat_t;
448
449 typedef struct {
450 kstat_named_t zm_zonename; /* full name, kstat truncates name */
451 kstat_named_t zm_utime;
452 kstat_named_t zm_stime;
453 kstat_named_t zm_wtime;
454 kstat_named_t zm_avenrun1;
455 kstat_named_t zm_avenrun5;
456 kstat_named_t zm_avenrun15;
457 kstat_named_t zm_ffcap;
458 kstat_named_t zm_ffnoproc;
459 kstat_named_t zm_ffnomem;
460 kstat_named_t zm_ffmisc;
461 kstat_named_t zm_nested_intp;
462 kstat_named_t zm_init_pid;
463 kstat_named_t zm_boot_time;
464 } zone_misc_kstat_t;
465
466 typedef struct zone {
467 /*
468 * zone_name is never modified once set.
469 */
470 char *zone_name; /* zone's configuration name */
471 /*
472 * zone_nodename and zone_domain are never freed once allocated.
473 */
474 char *zone_nodename; /* utsname.nodename equivalent */
475 char *zone_domain; /* srpc_domain equivalent */
476 /*
477 * zone_hostid is used for per-zone hostid emulation.
478 * Currently it isn't modified after it's set (so no locks protect
479 * accesses), but that might have to change when we allow
480 * administrators to change running zones' properties.
485 uint32_t zone_hostid; /* zone's hostid, HW_INVALID_HOSTID */
486 /* if not emulated */
487 /*
488 * zone_lock protects the following fields of a zone_t:
489 * zone_ref
490 * zone_cred_ref
491 * zone_subsys_ref
492 * zone_ref_list
493 * zone_ntasks
494 * zone_flags
495 * zone_zsd
496 * zone_pfexecd
497 */
498 kmutex_t zone_lock;
499 /*
500 * zone_linkage is the zone's linkage into the active or
501 * death-row list. The field is protected by zonehash_lock.
502 */
503 list_node_t zone_linkage;
504 zoneid_t zone_id; /* ID of zone */
505 uint_t zone_ref; /* count of zone_hold()s on zone */
506 uint_t zone_cred_ref; /* count of zone_hold_cred()s on zone */
507 /*
508 * Fixed-sized array of subsystem-specific reference counts
509 * The sum of all of the counts must be less than or equal to zone_ref.
510 * The array is indexed by the counts' subsystems' zone_ref_subsys_t
511 * constants.
512 */
513 uint_t zone_subsys_ref[ZONE_REF_NUM_SUBSYS];
514 list_t zone_ref_list; /* list of zone_ref_t structs */
515 /*
516 * zone_rootvp and zone_rootpath can never be modified once set.
517 */
518 struct vnode *zone_rootvp; /* zone's root vnode */
519 char *zone_rootpath; /* Path to zone's root + '/' */
520 ushort_t zone_flags; /* misc flags */
521 zone_status_t zone_status; /* protected by zone_status_lock */
522 uint_t zone_ntasks; /* number of tasks executing in zone */
523 kmutex_t zone_nlwps_lock; /* protects zone_nlwps, and *_nlwps */
524 /* counters in projects and tasks */
609 */
610 list_t zone_dl_list;
611 netstack_t *zone_netstack;
612 struct cpucap *zone_cpucap; /* CPU caps data */
613
614 /*
615 * Data and counters used for ZFS fair-share disk IO.
616 */
617 rctl_qty_t zone_zfs_io_pri; /* ZFS IO priority */
618 uint_t zone_zfs_queued[2]; /* sync I/O enqueued count */
619 uint64_t zone_zfs_weight; /* used to prevent starvation */
620 uint64_t zone_io_util; /* IO utilization metric */
621 boolean_t zone_io_util_above_avg; /* IO util percent > avg. */
622 uint16_t zone_io_delay; /* IO delay on logical r/w */
623 kmutex_t zone_stg_io_lock; /* protects IO window data */
624 sys_zio_cntr_t zone_rd_ops; /* Counters for ZFS reads, */
625 sys_zio_cntr_t zone_wr_ops; /* writes and */
626 sys_zio_cntr_t zone_lwr_ops; /* logical writes. */
627
628 /*
629 * kstats and counters for I/O ops and bytes.
630 */
631 kmutex_t zone_io_lock; /* protects I/O statistics */
632 kstat_t *zone_io_ksp;
633 kstat_io_t *zone_io_kiop;
634
635 /*
636 * kstats and counters for VFS ops and bytes.
637 */
638 kmutex_t zone_vfs_lock; /* protects VFS statistics */
639 kstat_t *zone_vfs_ksp;
640 kstat_io_t zone_vfs_rwstats;
641 zone_vfs_kstat_t *zone_vfs_stats;
642
643 /*
644 * kstats for ZFS I/O ops and bytes.
645 */
646 kmutex_t zone_zfs_lock; /* protects ZFS statistics */
647 kstat_io_t zone_zfs_rwstats;
648 zone_zfs_kstat_t *zone_zfs_stats;
649
650 /*
651 * Solaris Auditing per-zone audit context
652 */
653 struct au_kcontext *zone_audit_kctxt;
654 /*
655 * For private use by mntfs.
656 */
657 struct mntelem *zone_mntfs_db;
658 krwlock_t zone_mntfs_db_lock;
659
660 struct klpd_reg *zone_pfexecd;
661
662 char *zone_fs_allowed;
663 rctl_qty_t zone_nprocs; /* number of processes in the zone */
664 rctl_qty_t zone_nprocs_ctl; /* current limit protected by */
665 /* zone_rctls->rcs_lock */
666 kstat_t *zone_nprocs_kstat;
693 * This is tracked in msacct.c as threads change state.
694 * The zone_stime is the sum of the LMS_SYSTEM times.
695 * The zone_utime is the sum of the LMS_USER times.
696 * The zone_wtime is the sum of the LMS_WAIT_CPU times.
697 * As with per-thread micro-state accounting values, these values are
698 * not scaled to nanosecs. The scaling is done by the
699 * zone_misc_kstat_update function when kstats are requested.
700 */
701 kmutex_t zone_misc_lock; /* protects misc statistics */
702 kstat_t *zone_misc_ksp;
703 zone_misc_kstat_t *zone_misc_stats;
704 uint64_t zone_stime; /* total system time */
705 uint64_t zone_utime; /* total user time */
706 uint64_t zone_wtime; /* total time waiting in runq */
707 /* fork-fail kstat tracking */
708 uint32_t zone_ffcap; /* hit an rctl cap */
709 uint32_t zone_ffnoproc; /* get proc/lwp error */
710 uint32_t zone_ffnomem; /* as_dup/memory error */
711 uint32_t zone_ffmisc; /* misc. other error */
712
713 uint32_t zone_nested_intp; /* nested interp. kstat */
714
715 struct loadavg_s zone_loadavg; /* loadavg for this zone */
716 uint64_t zone_hp_avenrun[3]; /* high-precision avenrun */
717 int zone_avenrun[3]; /* FSCALED avg. run queue len */
718
719 /*
720 * FSS stats updated once per second by fss_decay_usage.
721 */
722 uint32_t zone_fss_gen; /* FSS generation cntr */
723 uint64_t zone_run_ticks; /* tot # of ticks running */
724
725 /*
726 * DTrace-private per-zone state
727 */
728 int zone_dtrace_getf; /* # of unprivileged getf()s */
729
730 /*
731 * Synchronization primitives used to synchronize between mounts and
732 * zone creation/destruction.
749 extern rctl_hndl_t rc_zone_nprocs;
750
751 extern long zone(int, void *, void *, void *, void *);
752 extern void zone_zsd_init(void);
753 extern void zone_init(void);
754 extern void zone_hold(zone_t *);
755 extern void zone_rele(zone_t *);
756 extern void zone_init_ref(zone_ref_t *);
757 extern void zone_hold_ref(zone_t *, zone_ref_t *, zone_ref_subsys_t);
758 extern void zone_rele_ref(zone_ref_t *, zone_ref_subsys_t);
759 extern void zone_cred_hold(zone_t *);
760 extern void zone_cred_rele(zone_t *);
761 extern void zone_task_hold(zone_t *);
762 extern void zone_task_rele(zone_t *);
763 extern zone_t *zone_find_by_id(zoneid_t);
764 extern zone_t *zone_find_by_label(const ts_label_t *);
765 extern zone_t *zone_find_by_name(char *);
766 extern zone_t *zone_find_by_any_path(const char *, boolean_t);
767 extern zone_t *zone_find_by_path(const char *);
768 extern zoneid_t getzoneid(void);
769 extern zone_t *zone_find_by_id_nolock(zoneid_t);
770 extern int zone_datalink_walk(zoneid_t, int (*)(datalink_id_t, void *), void *);
771 extern int zone_check_datalink(zoneid_t *, datalink_id_t);
772 extern void zone_loadavg_update();
773
774 /*
775 * Zone-specific data (ZSD) APIs
776 */
777 /*
778 * The following is what code should be initializing its zone_key_t to if it
779 * calls zone_getspecific() without necessarily knowing that zone_key_create()
780 * has been called on the key.
781 */
782 #define ZONE_KEY_UNINITIALIZED 0
783
784 typedef uint_t zone_key_t;
785
786 extern void zone_key_create(zone_key_t *, void *(*)(zoneid_t),
787 void (*)(zoneid_t, void *), void (*)(zoneid_t, void *));
788 extern int zone_key_delete(zone_key_t);
|