Print this page
OS-208 DTrace needs to use zone_did to match zone-limited enablings
OS-192 zone_create() warning on headnode


 100 /* zone attributes */
 101 #define ZONE_ATTR_ROOT          1
 102 #define ZONE_ATTR_NAME          2
 103 #define ZONE_ATTR_STATUS        3
 104 #define ZONE_ATTR_PRIVSET       4
 105 #define ZONE_ATTR_UNIQID        5
 106 #define ZONE_ATTR_POOLID        6
 107 #define ZONE_ATTR_INITPID       7
 108 #define ZONE_ATTR_SLBL          8
 109 #define ZONE_ATTR_INITNAME      9
 110 #define ZONE_ATTR_BOOTARGS      10
 111 #define ZONE_ATTR_BRAND         11
 112 #define ZONE_ATTR_PHYS_MCAP     12
 113 #define ZONE_ATTR_SCHED_CLASS   13
 114 #define ZONE_ATTR_FLAGS         14
 115 #define ZONE_ATTR_HOSTID        15
 116 #define ZONE_ATTR_FS_ALLOWED    16
 117 #define ZONE_ATTR_NETWORK       17
 118 #define ZONE_ATTR_INITNORESTART 20
 119 #define ZONE_ATTR_SECFLAGS      21

 120 
 121 /* Start of the brand-specific attribute namespace */
 122 #define ZONE_ATTR_BRAND_ATTRS   32768
 123 
 124 #define ZONE_FS_ALLOWED_MAX     1024
 125 
 126 #define ZONE_EVENT_CHANNEL      "com.sun:zones:status"
 127 #define ZONE_EVENT_STATUS_CLASS "status"
 128 #define ZONE_EVENT_STATUS_SUBCLASS      "change"
 129 
 130 #define ZONE_EVENT_UNINITIALIZED        "uninitialized"
 131 #define ZONE_EVENT_INITIALIZED          "initialized"
 132 #define ZONE_EVENT_READY                "ready"
 133 #define ZONE_EVENT_RUNNING              "running"
 134 #define ZONE_EVENT_SHUTTING_DOWN        "shutting_down"
 135 
 136 #define ZONE_CB_NAME            "zonename"
 137 #define ZONE_CB_NEWSTATE        "newstate"
 138 #define ZONE_CB_OLDSTATE        "oldstate"
 139 #define ZONE_CB_TIMESTAMP       "when"


 180 #define ZONE_SUBPROC_OK                 0
 181 #define ZONE_SUBPROC_USAGE              253
 182 #define ZONE_SUBPROC_NOTCOMPLETE        254
 183 #define ZONE_SUBPROC_FATAL              255
 184 
 185 #ifdef _SYSCALL32
 186 typedef struct {
 187         caddr32_t zone_name;
 188         caddr32_t zone_root;
 189         caddr32_t zone_privs;
 190         size32_t zone_privssz;
 191         caddr32_t rctlbuf;
 192         size32_t rctlbufsz;
 193         caddr32_t extended_error;
 194         caddr32_t zfsbuf;
 195         size32_t  zfsbufsz;
 196         int match;                      /* match level */
 197         uint32_t doi;                   /* DOI for label */
 198         caddr32_t label;                /* label associated with zone */
 199         int flags;

 200 } zone_def32;
 201 #endif
 202 typedef struct {
 203         const char *zone_name;
 204         const char *zone_root;
 205         const struct priv_set *zone_privs;
 206         size_t zone_privssz;
 207         const char *rctlbuf;
 208         size_t rctlbufsz;
 209         int *extended_error;
 210         const char *zfsbuf;
 211         size_t zfsbufsz;
 212         int match;                      /* match level */
 213         uint32_t doi;                   /* DOI for label */
 214         const bslabel_t *label;         /* label associated with zone */
 215         int flags;

 216 } zone_def;
 217 
 218 /* extended error information */
 219 #define ZE_UNKNOWN      0       /* No extended error info */
 220 #define ZE_CHROOTED     1       /* tried to zone_create from chroot */
 221 #define ZE_AREMOUNTS    2       /* there are mounts within the zone */
 222 #define ZE_LABELINUSE   3       /* label is already in use by some other zone */
 223 
 224 /*
 225  * zone_status values
 226  *
 227  * You must modify zone_status_names in mdb(1M)'s genunix module
 228  * (genunix/zone.c) when you modify this enum.
 229  */
 230 typedef enum {
 231         ZONE_IS_UNINITIALIZED = 0,
 232         ZONE_IS_INITIALIZED,
 233         ZONE_IS_READY,
 234         ZONE_IS_BOOTING,
 235         ZONE_IS_RUNNING,


 445         uint32_t        zone_hostid;    /* zone's hostid, HW_INVALID_HOSTID */
 446                                         /* if not emulated */
 447         /*
 448          * zone_lock protects the following fields of a zone_t:
 449          *      zone_ref
 450          *      zone_cred_ref
 451          *      zone_subsys_ref
 452          *      zone_ref_list
 453          *      zone_ntasks
 454          *      zone_flags
 455          *      zone_zsd
 456          *      zone_pfexecd
 457          */
 458         kmutex_t        zone_lock;
 459         /*
 460          * zone_linkage is the zone's linkage into the active or
 461          * death-row list.  The field is protected by zonehash_lock.
 462          */
 463         list_node_t     zone_linkage;
 464         zoneid_t        zone_id;        /* ID of zone */

 465         uint_t          zone_ref;       /* count of zone_hold()s on zone */
 466         uint_t          zone_cred_ref;  /* count of zone_hold_cred()s on zone */
 467         /*
 468          * Fixed-sized array of subsystem-specific reference counts
 469          * The sum of all of the counts must be less than or equal to zone_ref.
 470          * The array is indexed by the counts' subsystems' zone_ref_subsys_t
 471          * constants.
 472          */
 473         uint_t          zone_subsys_ref[ZONE_REF_NUM_SUBSYS];
 474         list_t          zone_ref_list;  /* list of zone_ref_t structs */
 475         /*
 476          * zone_rootvp and zone_rootpath can never be modified once set.
 477          */
 478         struct vnode    *zone_rootvp;   /* zone's root vnode */
 479         char            *zone_rootpath; /* Path to zone's root + '/' */
 480         ushort_t        zone_flags;     /* misc flags */
 481         zone_status_t   zone_status;    /* protected by zone_status_lock */
 482         uint_t          zone_ntasks;    /* number of tasks executing in zone */
 483         kmutex_t        zone_nlwps_lock; /* protects zone_nlwps, and *_nlwps */
 484                                         /* counters in projects and tasks */


 647 extern rctl_hndl_t rc_zone_nprocs;
 648 
 649 extern long zone(int, void *, void *, void *, void *);
 650 extern void zone_zsd_init(void);
 651 extern void zone_init(void);
 652 extern void zone_hold(zone_t *);
 653 extern void zone_rele(zone_t *);
 654 extern void zone_init_ref(zone_ref_t *);
 655 extern void zone_hold_ref(zone_t *, zone_ref_t *, zone_ref_subsys_t);
 656 extern void zone_rele_ref(zone_ref_t *, zone_ref_subsys_t);
 657 extern void zone_cred_hold(zone_t *);
 658 extern void zone_cred_rele(zone_t *);
 659 extern void zone_task_hold(zone_t *);
 660 extern void zone_task_rele(zone_t *);
 661 extern zone_t *zone_find_by_id(zoneid_t);
 662 extern zone_t *zone_find_by_label(const ts_label_t *);
 663 extern zone_t *zone_find_by_name(char *);
 664 extern zone_t *zone_find_by_any_path(const char *, boolean_t);
 665 extern zone_t *zone_find_by_path(const char *);
 666 extern zoneid_t getzoneid(void);

 667 extern zone_t *zone_find_by_id_nolock(zoneid_t);
 668 extern int zone_datalink_walk(zoneid_t, int (*)(datalink_id_t, void *), void *);
 669 extern int zone_check_datalink(zoneid_t *, datalink_id_t);
 670 extern void zone_loadavg_update();
 671 
 672 /*
 673  * Zone-specific data (ZSD) APIs
 674  */
 675 /*
 676  * The following is what code should be initializing its zone_key_t to if it
 677  * calls zone_getspecific() without necessarily knowing that zone_key_create()
 678  * has been called on the key.
 679  */
 680 #define ZONE_KEY_UNINITIALIZED  0
 681 
 682 typedef uint_t zone_key_t;
 683 
 684 extern void     zone_key_create(zone_key_t *, void *(*)(zoneid_t),
 685     void (*)(zoneid_t, void *), void (*)(zoneid_t, void *));
 686 extern int      zone_key_delete(zone_key_t);




 100 /* zone attributes */
 101 #define ZONE_ATTR_ROOT          1
 102 #define ZONE_ATTR_NAME          2
 103 #define ZONE_ATTR_STATUS        3
 104 #define ZONE_ATTR_PRIVSET       4
 105 #define ZONE_ATTR_UNIQID        5
 106 #define ZONE_ATTR_POOLID        6
 107 #define ZONE_ATTR_INITPID       7
 108 #define ZONE_ATTR_SLBL          8
 109 #define ZONE_ATTR_INITNAME      9
 110 #define ZONE_ATTR_BOOTARGS      10
 111 #define ZONE_ATTR_BRAND         11
 112 #define ZONE_ATTR_PHYS_MCAP     12
 113 #define ZONE_ATTR_SCHED_CLASS   13
 114 #define ZONE_ATTR_FLAGS         14
 115 #define ZONE_ATTR_HOSTID        15
 116 #define ZONE_ATTR_FS_ALLOWED    16
 117 #define ZONE_ATTR_NETWORK       17
 118 #define ZONE_ATTR_INITNORESTART 20
 119 #define ZONE_ATTR_SECFLAGS      21
 120 #define ZONE_ATTR_DID           22
 121 
 122 /* Start of the brand-specific attribute namespace */
 123 #define ZONE_ATTR_BRAND_ATTRS   32768
 124 
 125 #define ZONE_FS_ALLOWED_MAX     1024
 126 
 127 #define ZONE_EVENT_CHANNEL      "com.sun:zones:status"
 128 #define ZONE_EVENT_STATUS_CLASS "status"
 129 #define ZONE_EVENT_STATUS_SUBCLASS      "change"
 130 
 131 #define ZONE_EVENT_UNINITIALIZED        "uninitialized"
 132 #define ZONE_EVENT_INITIALIZED          "initialized"
 133 #define ZONE_EVENT_READY                "ready"
 134 #define ZONE_EVENT_RUNNING              "running"
 135 #define ZONE_EVENT_SHUTTING_DOWN        "shutting_down"
 136 
 137 #define ZONE_CB_NAME            "zonename"
 138 #define ZONE_CB_NEWSTATE        "newstate"
 139 #define ZONE_CB_OLDSTATE        "oldstate"
 140 #define ZONE_CB_TIMESTAMP       "when"


 181 #define ZONE_SUBPROC_OK                 0
 182 #define ZONE_SUBPROC_USAGE              253
 183 #define ZONE_SUBPROC_NOTCOMPLETE        254
 184 #define ZONE_SUBPROC_FATAL              255
 185 
 186 #ifdef _SYSCALL32
 187 typedef struct {
 188         caddr32_t zone_name;
 189         caddr32_t zone_root;
 190         caddr32_t zone_privs;
 191         size32_t zone_privssz;
 192         caddr32_t rctlbuf;
 193         size32_t rctlbufsz;
 194         caddr32_t extended_error;
 195         caddr32_t zfsbuf;
 196         size32_t  zfsbufsz;
 197         int match;                      /* match level */
 198         uint32_t doi;                   /* DOI for label */
 199         caddr32_t label;                /* label associated with zone */
 200         int flags;
 201         zoneid_t zone_did;              /* zone debug ID */
 202 } zone_def32;
 203 #endif
 204 typedef struct {
 205         const char *zone_name;
 206         const char *zone_root;
 207         const struct priv_set *zone_privs;
 208         size_t zone_privssz;
 209         const char *rctlbuf;
 210         size_t rctlbufsz;
 211         int *extended_error;
 212         const char *zfsbuf;
 213         size_t zfsbufsz;
 214         int match;                      /* match level */
 215         uint32_t doi;                   /* DOI for label */
 216         const bslabel_t *label;         /* label associated with zone */
 217         int flags;
 218         zoneid_t zone_did;              /* zone debug ID */
 219 } zone_def;
 220 
 221 /* extended error information */
 222 #define ZE_UNKNOWN      0       /* No extended error info */
 223 #define ZE_CHROOTED     1       /* tried to zone_create from chroot */
 224 #define ZE_AREMOUNTS    2       /* there are mounts within the zone */
 225 #define ZE_LABELINUSE   3       /* label is already in use by some other zone */
 226 
 227 /*
 228  * zone_status values
 229  *
 230  * You must modify zone_status_names in mdb(1M)'s genunix module
 231  * (genunix/zone.c) when you modify this enum.
 232  */
 233 typedef enum {
 234         ZONE_IS_UNINITIALIZED = 0,
 235         ZONE_IS_INITIALIZED,
 236         ZONE_IS_READY,
 237         ZONE_IS_BOOTING,
 238         ZONE_IS_RUNNING,


 448         uint32_t        zone_hostid;    /* zone's hostid, HW_INVALID_HOSTID */
 449                                         /* if not emulated */
 450         /*
 451          * zone_lock protects the following fields of a zone_t:
 452          *      zone_ref
 453          *      zone_cred_ref
 454          *      zone_subsys_ref
 455          *      zone_ref_list
 456          *      zone_ntasks
 457          *      zone_flags
 458          *      zone_zsd
 459          *      zone_pfexecd
 460          */
 461         kmutex_t        zone_lock;
 462         /*
 463          * zone_linkage is the zone's linkage into the active or
 464          * death-row list.  The field is protected by zonehash_lock.
 465          */
 466         list_node_t     zone_linkage;
 467         zoneid_t        zone_id;        /* ID of zone */
 468         zoneid_t        zone_did;       /* persistent debug ID of zone */
 469         uint_t          zone_ref;       /* count of zone_hold()s on zone */
 470         uint_t          zone_cred_ref;  /* count of zone_hold_cred()s on zone */
 471         /*
 472          * Fixed-sized array of subsystem-specific reference counts
 473          * The sum of all of the counts must be less than or equal to zone_ref.
 474          * The array is indexed by the counts' subsystems' zone_ref_subsys_t
 475          * constants.
 476          */
 477         uint_t          zone_subsys_ref[ZONE_REF_NUM_SUBSYS];
 478         list_t          zone_ref_list;  /* list of zone_ref_t structs */
 479         /*
 480          * zone_rootvp and zone_rootpath can never be modified once set.
 481          */
 482         struct vnode    *zone_rootvp;   /* zone's root vnode */
 483         char            *zone_rootpath; /* Path to zone's root + '/' */
 484         ushort_t        zone_flags;     /* misc flags */
 485         zone_status_t   zone_status;    /* protected by zone_status_lock */
 486         uint_t          zone_ntasks;    /* number of tasks executing in zone */
 487         kmutex_t        zone_nlwps_lock; /* protects zone_nlwps, and *_nlwps */
 488                                         /* counters in projects and tasks */


 651 extern rctl_hndl_t rc_zone_nprocs;
 652 
 653 extern long zone(int, void *, void *, void *, void *);
 654 extern void zone_zsd_init(void);
 655 extern void zone_init(void);
 656 extern void zone_hold(zone_t *);
 657 extern void zone_rele(zone_t *);
 658 extern void zone_init_ref(zone_ref_t *);
 659 extern void zone_hold_ref(zone_t *, zone_ref_t *, zone_ref_subsys_t);
 660 extern void zone_rele_ref(zone_ref_t *, zone_ref_subsys_t);
 661 extern void zone_cred_hold(zone_t *);
 662 extern void zone_cred_rele(zone_t *);
 663 extern void zone_task_hold(zone_t *);
 664 extern void zone_task_rele(zone_t *);
 665 extern zone_t *zone_find_by_id(zoneid_t);
 666 extern zone_t *zone_find_by_label(const ts_label_t *);
 667 extern zone_t *zone_find_by_name(char *);
 668 extern zone_t *zone_find_by_any_path(const char *, boolean_t);
 669 extern zone_t *zone_find_by_path(const char *);
 670 extern zoneid_t getzoneid(void);
 671 extern zoneid_t getzonedid(void);
 672 extern zone_t *zone_find_by_id_nolock(zoneid_t);
 673 extern int zone_datalink_walk(zoneid_t, int (*)(datalink_id_t, void *), void *);
 674 extern int zone_check_datalink(zoneid_t *, datalink_id_t);
 675 extern void zone_loadavg_update();
 676 
 677 /*
 678  * Zone-specific data (ZSD) APIs
 679  */
 680 /*
 681  * The following is what code should be initializing its zone_key_t to if it
 682  * calls zone_getspecific() without necessarily knowing that zone_key_create()
 683  * has been called on the key.
 684  */
 685 #define ZONE_KEY_UNINITIALIZED  0
 686 
 687 typedef uint_t zone_key_t;
 688 
 689 extern void     zone_key_create(zone_key_t *, void *(*)(zoneid_t),
 690     void (*)(zoneid_t, void *), void (*)(zoneid_t, void *));
 691 extern int      zone_key_delete(zone_key_t);