Print this page
OS-192 zone_create() warning on headnode

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/zoneadmd/zoneadmd.c
          +++ new/usr/src/cmd/zoneadmd/zoneadmd.c
↓ open down ↓ 15 lines elided ↑ open up ↑
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
  25   25   * Copyright (c) 2016 by Delphix. All rights reserved.
       26 + * Copyright (c) 2011, Joyent Inc. All rights reserved.
  26   27   */
  27   28  
  28   29  /*
  29   30   * zoneadmd manages zones; one zoneadmd process is launched for each
  30   31   * non-global zone on the system.  This daemon juggles four jobs:
  31   32   *
  32   33   * - Implement setup and teardown of the zone "virtual platform": mount and
  33   34   *   unmount filesystems; create and destroy network interfaces; communicate
  34   35   *   with devfsadmd to lay out devices for the zone; instantiate the zone
  35   36   *   console device; configure process runtime attributes such as resource
↓ open down ↓ 74 lines elided ↑ open up ↑
 110  111  static char *progname;
 111  112  char *zone_name;        /* zone which we are managing */
 112  113  char pool_name[MAXNAMELEN];
 113  114  char default_brand[MAXNAMELEN];
 114  115  char brand_name[MAXNAMELEN];
 115  116  boolean_t zone_isnative;
 116  117  boolean_t zone_iscluster;
 117  118  boolean_t zone_islabeled;
 118  119  boolean_t shutdown_in_progress;
 119  120  static zoneid_t zone_id;
      121 +static zoneid_t zone_did = 0;
 120  122  dladm_handle_t dld_handle = NULL;
 121  123  
 122  124  static char pre_statechg_hook[2 * MAXPATHLEN];
 123  125  static char post_statechg_hook[2 * MAXPATHLEN];
 124  126  char query_hook[2 * MAXPATHLEN];
 125  127  
 126  128  zlog_t logsys;
 127  129  
 128  130  mutex_t lock = DEFAULTMUTEX;    /* to serialize stuff */
 129  131  mutex_t msglock = DEFAULTMUTEX; /* for calling setlocale() */
↓ open down ↓ 410 lines elided ↑ open up ↑
 540  542  
 541  543          if (brand_prestatechg(zlogp, zstate, Z_READY) != 0)
 542  544                  return (-1);
 543  545  
 544  546          if ((err = zonecfg_create_snapshot(zone_name)) != Z_OK) {
 545  547                  zerror(zlogp, B_FALSE, "unable to create snapshot: %s",
 546  548                      zonecfg_strerror(err));
 547  549                  goto bad;
 548  550          }
 549  551  
 550      -        if ((zone_id = vplat_create(zlogp, mount_cmd)) == -1) {
      552 +        if (zone_did == 0)
      553 +                zone_did = zone_get_did(zone_name);
      554 +
      555 +        if ((zone_id = vplat_create(zlogp, mount_cmd, zone_did)) == -1) {
 551  556                  if ((err = zonecfg_destroy_snapshot(zone_name)) != Z_OK)
 552  557                          zerror(zlogp, B_FALSE, "destroying snapshot: %s",
 553  558                              zonecfg_strerror(err));
 554  559                  goto bad;
 555  560          }
 556  561          if (vplat_bringup(zlogp, mount_cmd, zone_id) != 0) {
 557  562                  bringup_failure_recovery = B_TRUE;
 558  563                  (void) vplat_teardown(NULL, (mount_cmd != Z_MNT_BOOT), B_FALSE);
 559  564                  if ((err = zonecfg_destroy_snapshot(zone_name)) != Z_OK)
 560  565                          zerror(zlogp, B_FALSE, "destroying snapshot: %s",
↓ open down ↓ 787 lines elided ↑ open up ↑
1348 1353          case ZONE_STATE_INSTALLED:
1349 1354                  switch (cmd) {
1350 1355                  case Z_READY:
1351 1356                          rval = zone_ready(zlogp, Z_MNT_BOOT, zstate);
1352 1357                          if (rval == 0)
1353 1358                                  eventstream_write(Z_EVT_ZONE_READIED);
1354 1359                          break;
1355 1360                  case Z_BOOT:
1356 1361                  case Z_FORCEBOOT:
1357 1362                          eventstream_write(Z_EVT_ZONE_BOOTING);
1358      -                        if ((rval = zone_ready(zlogp, Z_MNT_BOOT, zstate))
1359      -                            == 0) {
     1363 +                        if ((rval = zone_ready(zlogp, Z_MNT_BOOT,
     1364 +                            zstate)) == 0) {
1360 1365                                  rval = zone_bootup(zlogp, zargp->bootbuf,
1361 1366                                      zstate);
1362 1367                          }
1363 1368                          audit_put_record(zlogp, uc, rval, "boot");
1364 1369                          if (rval != 0) {
1365 1370                                  bringup_failure_recovery = B_TRUE;
1366 1371                                  (void) zone_halt(zlogp, B_FALSE, B_FALSE,
1367 1372                                      zstate);
1368 1373                                  eventstream_write(Z_EVT_ZONE_BOOTFAILED);
1369 1374                          }
↓ open down ↓ 167 lines elided ↑ open up ↑
1537 1542                  break;
1538 1543  
1539 1544          case ZONE_STATE_RUNNING:
1540 1545          case ZONE_STATE_SHUTTING_DOWN:
1541 1546          case ZONE_STATE_DOWN:
1542 1547                  switch (cmd) {
1543 1548                  case Z_READY:
1544 1549                          if ((rval = zone_halt(zlogp, B_FALSE, B_TRUE, zstate))
1545 1550                              != 0)
1546 1551                                  break;
1547      -                        if ((rval = zone_ready(zlogp, Z_MNT_BOOT, zstate)) == 0)
     1552 +                        if ((rval = zone_ready(zlogp, Z_MNT_BOOT, zstate))
     1553 +                            == 0)
1548 1554                                  eventstream_write(Z_EVT_ZONE_READIED);
1549 1555                          else
1550 1556                                  eventstream_write(Z_EVT_ZONE_HALTED);
1551 1557                          break;
1552 1558                  case Z_BOOT:
1553 1559                          /*
1554 1560                           * We could have two clients racing to boot this
1555 1561                           * zone; the second client loses, but its request
1556 1562                           * doesn't fail, since the zone is now in the desired
1557 1563                           * state.
↓ open down ↓ 741 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX