Print this page
OS-3342+co


2235         /*
2236          * The global zone is fully initialized (except for zone_rootvp which
2237          * will be set when the root filesystem is mounted).
2238          */
2239         global_zone = &zone0;
2240 
2241         /*
2242          * Setup an event channel to send zone status change notifications on
2243          */
2244         res = sysevent_evc_bind(ZONE_EVENT_CHANNEL, &zone_event_chan,
2245             EVCH_CREAT);
2246 
2247         if (res)
2248                 panic("Sysevent_evc_bind failed during zone setup.\n");
2249 
2250 }
2251 
2252 static void
2253 zone_free(zone_t *zone)
2254 {


2255         ASSERT(zone != global_zone);
2256         ASSERT(zone->zone_ntasks == 0);
2257         ASSERT(zone->zone_nlwps == 0);
2258         ASSERT(zone->zone_nprocs == 0);
2259         ASSERT(zone->zone_cred_ref == 0);
2260         ASSERT(zone->zone_kcred == NULL);
2261         ASSERT(zone_status_get(zone) == ZONE_IS_DEAD ||
2262             zone_status_get(zone) == ZONE_IS_UNINITIALIZED);
2263         ASSERT(list_is_empty(&zone->zone_ref_list));
2264 
2265         /*
2266          * Remove any zone caps.
2267          */
2268         cpucaps_zone_remove(zone);
2269 
2270         ASSERT(zone->zone_cpucap == NULL);
2271 
2272         /* remove from deathrow list */
2273         if (zone_status_get(zone) == ZONE_IS_DEAD) {
2274                 ASSERT(zone->zone_ref == 0);
2275                 mutex_enter(&zone_deathrow_lock);
2276                 list_remove(&zone_deathrow, zone);
2277                 mutex_exit(&zone_deathrow_lock);
2278         }
2279 
2280         list_destroy(&zone->zone_ref_list);
2281         zone_free_zsd(zone);
2282         zone_free_datasets(zone);













2283         list_destroy(&zone->zone_dl_list);
2284 
2285         if (zone->zone_rootvp != NULL)
2286                 VN_RELE(zone->zone_rootvp);
2287         if (zone->zone_rootpath)
2288                 kmem_free(zone->zone_rootpath, zone->zone_rootpathlen);
2289         if (zone->zone_name != NULL)
2290                 kmem_free(zone->zone_name, ZONENAME_MAX);
2291         if (zone->zone_slabel != NULL)
2292                 label_rele(zone->zone_slabel);
2293         if (zone->zone_nodename != NULL)
2294                 kmem_free(zone->zone_nodename, _SYS_NMLN);
2295         if (zone->zone_domain != NULL)
2296                 kmem_free(zone->zone_domain, _SYS_NMLN);
2297         if (zone->zone_privset != NULL)
2298                 kmem_free(zone->zone_privset, sizeof (priv_set_t));
2299         if (zone->zone_rctls != NULL)
2300                 rctl_set_free(zone->zone_rctls);
2301         if (zone->zone_bootargs != NULL)
2302                 strfree(zone->zone_bootargs);




2235         /*
2236          * The global zone is fully initialized (except for zone_rootvp which
2237          * will be set when the root filesystem is mounted).
2238          */
2239         global_zone = &zone0;
2240 
2241         /*
2242          * Setup an event channel to send zone status change notifications on
2243          */
2244         res = sysevent_evc_bind(ZONE_EVENT_CHANNEL, &zone_event_chan,
2245             EVCH_CREAT);
2246 
2247         if (res)
2248                 panic("Sysevent_evc_bind failed during zone setup.\n");
2249 
2250 }
2251 
2252 static void
2253 zone_free(zone_t *zone)
2254 {
2255         zone_dl_t *zdl;
2256 
2257         ASSERT(zone != global_zone);
2258         ASSERT(zone->zone_ntasks == 0);
2259         ASSERT(zone->zone_nlwps == 0);
2260         ASSERT(zone->zone_nprocs == 0);
2261         ASSERT(zone->zone_cred_ref == 0);
2262         ASSERT(zone->zone_kcred == NULL);
2263         ASSERT(zone_status_get(zone) == ZONE_IS_DEAD ||
2264             zone_status_get(zone) == ZONE_IS_UNINITIALIZED);
2265         ASSERT(list_is_empty(&zone->zone_ref_list));
2266 
2267         /*
2268          * Remove any zone caps.
2269          */
2270         cpucaps_zone_remove(zone);
2271 
2272         ASSERT(zone->zone_cpucap == NULL);
2273 
2274         /* remove from deathrow list */
2275         if (zone_status_get(zone) == ZONE_IS_DEAD) {
2276                 ASSERT(zone->zone_ref == 0);
2277                 mutex_enter(&zone_deathrow_lock);
2278                 list_remove(&zone_deathrow, zone);
2279                 mutex_exit(&zone_deathrow_lock);
2280         }
2281 
2282         list_destroy(&zone->zone_ref_list);
2283         zone_free_zsd(zone);
2284         zone_free_datasets(zone);
2285 
2286         /*
2287          * While dlmgmtd should have removed all of these, it could have left
2288          * something behind or crashed. In which case it's not safe for us to
2289          * assume that the list is empty which list_destroy() will ASSERT. We
2290          * clean up for our userland comrades which may have crashed, or worse,
2291          * been disabled by SMF.
2292          */
2293         while ((zdl = list_remove_head(&zone->zone_dl_list)) != NULL) {
2294                 if (zdl->zdl_net != NULL)
2295                         nvlist_free(zdl->zdl_net);
2296                 kmem_free(zdl, sizeof (zone_dl_t));
2297         }
2298         list_destroy(&zone->zone_dl_list);
2299 
2300         if (zone->zone_rootvp != NULL)
2301                 VN_RELE(zone->zone_rootvp);
2302         if (zone->zone_rootpath)
2303                 kmem_free(zone->zone_rootpath, zone->zone_rootpathlen);
2304         if (zone->zone_name != NULL)
2305                 kmem_free(zone->zone_name, ZONENAME_MAX);
2306         if (zone->zone_slabel != NULL)
2307                 label_rele(zone->zone_slabel);
2308         if (zone->zone_nodename != NULL)
2309                 kmem_free(zone->zone_nodename, _SYS_NMLN);
2310         if (zone->zone_domain != NULL)
2311                 kmem_free(zone->zone_domain, _SYS_NMLN);
2312         if (zone->zone_privset != NULL)
2313                 kmem_free(zone->zone_privset, sizeof (priv_set_t));
2314         if (zone->zone_rctls != NULL)
2315                 rctl_set_free(zone->zone_rctls);
2316         if (zone->zone_bootargs != NULL)
2317                 strfree(zone->zone_bootargs);