Print this page
14019 Allow more control over zone init exit actions (fix mismerge)
14019 Allow more control over zone init exit actions
Portions contributed by: Joshua M. Clulow <jmc@joyent.com>
Portions contributed by: Andy Fiddaman <andy@omnios.org>
Reviewed by: C Fraire <cfraire@me.com>
Reviewed by: Gordon Ross <Gordon.W.Ross@gmail.com>
Approved by: Robert Mustacchi <rm@fingolfin.org>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/zoneadmd/zoneadmd.c
          +++ new/usr/src/cmd/zoneadmd/zoneadmd.c
↓ open down ↓ 1284 lines elided ↑ open up ↑
1285 1285          struct stat st;
1286 1286          char rpath[MAXPATHLEN], initpath[MAXPATHLEN], init_file[MAXPATHLEN];
1287 1287          char nbootargs[BOOTARGS_MAX];
1288 1288          char cmdbuf[MAXPATHLEN];
1289 1289          fs_callback_t cb;
1290 1290          brand_handle_t bh;
1291 1291          zone_iptype_t iptype;
1292 1292          dladm_status_t status;
1293 1293          char errmsg[DLADM_STRSIZE];
1294 1294          int err;
1295      -        boolean_t restart_init;
1296 1295          boolean_t app_svc_dep;
     1296 +        boolean_t restart_init, restart_init0, restart_initreboot;
1297 1297  
1298 1298          if (brand_prestatechg(zlogp, zstate, Z_BOOT, debug) != 0)
1299 1299                  return (-1);
1300 1300  
1301 1301          if ((zoneid = getzoneidbyname(zone_name)) == -1) {
1302 1302                  zerror(zlogp, B_TRUE, "unable to get zoneid");
1303 1303                  goto bad;
1304 1304          }
1305 1305  
1306 1306          cb.zlogp = zlogp;
↓ open down ↓ 31 lines elided ↑ open up ↑
1338 1338          }
1339 1339  
1340 1340          /* Get the path for this zone's init(1M) (or equivalent) process.  */
1341 1341          if (get_initname(bh, init_file, MAXPATHLEN) != 0) {
1342 1342                  zerror(zlogp, B_FALSE,
1343 1343                      "unable to determine zone's init(1M) location");
1344 1344                  brand_close(bh);
1345 1345                  goto bad;
1346 1346          }
1347 1347  
1348      -        /* See if we should restart init if it dies. */
     1348 +        /* See if this zone's brand should restart init if it dies. */
1349 1349          restart_init = restartinit(bh);
     1350 +        restart_init0 = brand_restartinit0(bh);
     1351 +        restart_initreboot = brand_restartinitreboot(bh);
1350 1352  
1351 1353          /*
1352 1354           * See if we need to setup contract dependencies between the zone's
1353 1355           * primary application and any of its services.
1354 1356           */
1355 1357          app_svc_dep = is_app_svc_dep();
1356 1358  
1357 1359          brand_close(bh);
1358 1360  
1359 1361          err = filter_bootargs(zlogp, bootargs, nbootargs, init_file);
↓ open down ↓ 60 lines elided ↑ open up ↑
1420 1422          if (zone_setattr(zoneid, ZONE_ATTR_BOOTARGS, nbootargs, 0) == -1) {
1421 1423                  zerror(zlogp, B_TRUE, "could not set zone boot arguments");
1422 1424                  goto bad;
1423 1425          }
1424 1426  
1425 1427          if (!restart_init && zone_setattr(zoneid, ZONE_ATTR_INITNORESTART,
1426 1428              NULL, 0) == -1) {
1427 1429                  zerror(zlogp, B_TRUE, "could not set zone init-no-restart");
1428 1430                  goto bad;
1429 1431          }
     1432 +        if (restart_init0 && zone_setattr(zoneid, ZONE_ATTR_INITRESTART0,
     1433 +            NULL, 0) == -1) {
     1434 +                zerror(zlogp, B_TRUE,
     1435 +                    "could not set zone init-restart-on-exit-0");
     1436 +                goto bad;
     1437 +        }
     1438 +        if (restart_initreboot && zone_setattr(zoneid, ZONE_ATTR_INITREBOOT,
     1439 +            NULL, 0) == -1) {
     1440 +                zerror(zlogp, B_TRUE, "could not set zone reboot-on-init-exit");
     1441 +                goto bad;
     1442 +        }
1430 1443  
1431 1444          if (app_svc_dep && zone_setattr(zoneid, ZONE_ATTR_APP_SVC_CT,
1432 1445              (void *)B_TRUE, sizeof (boolean_t)) == -1) {
1433 1446                  zerror(zlogp, B_TRUE, "could not set zone app-die");
1434 1447                  goto bad;
1435 1448          }
1436 1449  
1437 1450          /*
1438 1451           * Inform zonestatd of a new zone so that it can install a door for
1439 1452           * the zone to contact it.
↓ open down ↓ 1496 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX