summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Zezeski <rpz@joyent.com>2016-09-16 09:50:24 -0400
committerRyan Zezeski <rpz@joyent.com>2016-09-21 22:03:51 -0400
commit09b9f0e78b5878f94478446e2b0d61b0cf5a6577 (patch)
tree4ce2f7cb13fd9973e0f616849ea6465696b1e65a
parent5cf554af1079ca06b1b977788f9c0fb796f68945 (diff)
downloadillumos-joyent-09b9f0e78b5878f94478446e2b0d61b0cf5a6577.tar.gz
OS-5330 zoneadm mounting an lx or joyent branded zone fails
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com> Approved by: Jerry Jelinek <jerry.jelinek@joyent.com>
-rw-r--r--usr/src/cmd/zoneadmd/vplat.c49
-rw-r--r--usr/src/cmd/zoneadmd/zoneadmd.c24
-rw-r--r--usr/src/cmd/zoneadmd/zoneadmd.h3
3 files changed, 53 insertions, 23 deletions
diff --git a/usr/src/cmd/zoneadmd/vplat.c b/usr/src/cmd/zoneadmd/vplat.c
index cdfa7a8785..238157f2f9 100644
--- a/usr/src/cmd/zoneadmd/vplat.c
+++ b/usr/src/cmd/zoneadmd/vplat.c
@@ -136,8 +136,6 @@
#define DFSTYPES "/etc/dfs/fstypes"
#define MAXTNZLEN 2048
-#define ALT_MOUNT(mount_cmd) ((mount_cmd) != Z_MNT_BOOT)
-
/* Number of times to retry unmounting if it fails */
#define UMOUNT_RETRIES 30
@@ -1812,23 +1810,40 @@ mount_filesystems(zlog_t *zlogp, zone_mnt_t mount_cmd)
qsort(fs_ptr, num_fs, sizeof (*fs_ptr), fs_compare);
for (i = 0; i < num_fs; i++) {
- if (ALT_MOUNT(mount_cmd) &&
- strcmp(fs_ptr[i].zone_fs_dir, "/dev") == 0) {
- size_t slen = strlen(rootpath) - 2;
+ if (ALT_MOUNT(mount_cmd)) {
+ if (strcmp(fs_ptr[i].zone_fs_dir, "/dev") == 0) {
+ size_t slen = strlen(rootpath) - 2;
- /*
- * By default we'll try to mount /dev as /a/dev
- * but /dev is special and always goes at the top
- * so strip the trailing '/a' from the rootpath.
- */
- assert(strcmp(&rootpath[slen], "/a") == 0);
- rootpath[slen] = '\0';
- if (mount_one(zlogp, &fs_ptr[i], rootpath, mount_cmd)
- != 0)
- goto bad;
- rootpath[slen] = '/';
- continue;
+ /*
+ * By default we'll try to mount /dev
+ * as /a/dev but /dev is special and
+ * always goes at the top so strip the
+ * trailing '/a' from the rootpath.
+ */
+ assert(strcmp(&rootpath[slen], "/a") == 0);
+ rootpath[slen] = '\0';
+ if (mount_one(zlogp, &fs_ptr[i], rootpath,
+ mount_cmd) != 0)
+ goto bad;
+ rootpath[slen] = '/';
+ continue;
+ } else if (strcmp(brand_name, default_brand) != 0) {
+ /*
+ * If mounting non-native brand, skip
+ * mounting global mounts and
+ * filesystem entries since they are
+ * only needed for native pkg upgrade
+ * tools.
+ *
+ * The only exception right now is
+ * /dev (handled above), which is
+ * needed in the luroot in order to
+ * zlogin -S into the zone.
+ */
+ continue;
+ }
}
+
if (mount_one(zlogp, &fs_ptr[i], rootpath, mount_cmd) != 0)
goto bad;
}
diff --git a/usr/src/cmd/zoneadmd/zoneadmd.c b/usr/src/cmd/zoneadmd/zoneadmd.c
index 576b6e8c8f..884ebf2fd9 100644
--- a/usr/src/cmd/zoneadmd/zoneadmd.c
+++ b/usr/src/cmd/zoneadmd/zoneadmd.c
@@ -535,6 +535,9 @@ notify_zonestatd(zoneid_t zoneid)
* Bring a zone up to the pre-boot "ready" stage. The mount_cmd argument is
* 'true' if this is being invoked as part of the processing for the "mount"
* subcommand.
+ *
+ * If a scratch zone mount (ALT_MOUNT) is being performed then do not
+ * call the state change hooks.
*/
static int
zone_ready(zlog_t *zlogp, zone_mnt_t mount_cmd, int zstate, boolean_t debug)
@@ -561,7 +564,8 @@ zone_ready(zlog_t *zlogp, zone_mnt_t mount_cmd, int zstate, boolean_t debug)
if (zone_did == 0)
zone_did = zone_get_did(zone_name);
- if (brand_prestatechg(zlogp, zstate, Z_READY, debug) != 0)
+ if (!ALT_MOUNT(mount_cmd) &&
+ brand_prestatechg(zlogp, zstate, Z_READY, debug) != 0)
goto bad;
if ((zone_id = vplat_create(zlogp, mount_cmd, zone_did)) == -1)
@@ -574,7 +578,8 @@ zone_ready(zlog_t *zlogp, zone_mnt_t mount_cmd, int zstate, boolean_t debug)
goto bad;
}
- if (brand_poststatechg(zlogp, zstate, Z_READY, debug) != 0)
+ if (!ALT_MOUNT(mount_cmd) &&
+ brand_poststatechg(zlogp, zstate, Z_READY, debug) != 0)
goto bad;
return (0);
@@ -584,7 +589,10 @@ bad:
* If something goes wrong, we up the zones's state to the target
* state, READY, and then invoke the hook as if we're halting.
*/
- (void) brand_poststatechg(zlogp, ZONE_STATE_READY, Z_HALT, debug);
+ if (!ALT_MOUNT(mount_cmd))
+ (void) brand_poststatechg(zlogp, ZONE_STATE_READY, Z_HALT,
+ debug);
+
if (snapped)
if ((err = zonecfg_destroy_snapshot(zone_name)) != Z_OK)
zerror(zlogp, B_FALSE, "destroying snapshot: %s",
@@ -1242,7 +1250,12 @@ zone_halt(zlog_t *zlogp, boolean_t unmount_cmd, boolean_t rebooting, int zstate,
{
int err;
- if (brand_prestatechg(zlogp, zstate, Z_HALT, debug) != 0)
+ /*
+ * If performing a scratch zone unmount then do not call the
+ * state change hooks.
+ */
+ if (unmount_cmd == B_FALSE &&
+ brand_prestatechg(zlogp, zstate, Z_HALT, debug) != 0)
return (-1);
/* Shutting down, stop the memcap thread */
@@ -1258,7 +1271,8 @@ zone_halt(zlog_t *zlogp, boolean_t unmount_cmd, boolean_t rebooting, int zstate,
/* Shut down is done, stop the log thread */
destroy_log_thread();
- if (brand_poststatechg(zlogp, zstate, Z_HALT, debug) != 0)
+ if (unmount_cmd == B_FALSE &&
+ brand_poststatechg(zlogp, zstate, Z_HALT, debug) != 0)
return (-1);
if ((err = zonecfg_destroy_snapshot(zone_name)) != Z_OK)
diff --git a/usr/src/cmd/zoneadmd/zoneadmd.h b/usr/src/cmd/zoneadmd/zoneadmd.h
index 7e5dcea432..864c8ea8da 100644
--- a/usr/src/cmd/zoneadmd/zoneadmd.h
+++ b/usr/src/cmd/zoneadmd/zoneadmd.h
@@ -22,7 +22,7 @@
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2014 Nexenta Systems, Inc. All rights reserved.
- * Copyright 2014, Joyent, Inc. All rights reserved.
+ * Copyright 2016 Joyent, Inc.
*/
#ifndef _ZONEADMD_H
@@ -70,6 +70,7 @@ extern "C" {
#define DEFAULT_DIR_USER -1 /* user ID for chown: -1 means don't change */
#define DEFAULT_DIR_GROUP -1 /* grp ID for chown: -1 means don't change */
+#define ALT_MOUNT(mount_cmd) ((mount_cmd) != Z_MNT_BOOT)
typedef struct zlog {
FILE *logfile; /* file to log to */