Mercurial > illumos > illumos-gate
changeset 10796:c03a117618e2
6874636 RFE: zoneadmd should mount cluster branded zones as native in alternate roots.
author | Steve Lawrence <Stephen.Lawrence@Sun.COM> |
---|---|
date | Wed, 14 Oct 2009 11:48:20 -0700 |
parents | a68a30d0a8d6 |
children | 8e4cf0dbd8ca |
files | usr/src/cmd/zlogin/zlogin.c usr/src/cmd/zoneadm/zoneadm.c usr/src/cmd/zoneadmd/vplat.c usr/src/cmd/zoneadmd/zoneadmd.c usr/src/cmd/zoneadmd/zoneadmd.h |
diffstat | 5 files changed, 72 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/zlogin/zlogin.c Wed Oct 14 11:32:21 2009 -0700 +++ b/usr/src/cmd/zlogin/zlogin.c Wed Oct 14 11:48:20 2009 -0700 @@ -113,6 +113,8 @@ #define DEFAULTSHELL "/sbin/sh" #define DEF_PATH "/usr/sbin:/usr/bin" +#define CLUSTER_BRAND_NAME "cluster" + /* * The ZLOGIN_BUFSIZ is larger than PIPE_BUF so we can be sure we're clearing * out the pipe when the child is exiting. The ZLOGIN_RDBUFSIZ must be less @@ -1894,12 +1896,28 @@ return (1); } - /* Get a handle to the brand info for this zone */ - if ((zone_get_brand(zonename, zonebrand, sizeof (zonebrand)) != Z_OK) || - ((bh = brand_open(zonebrand)) == NULL)) { + if (zone_get_brand(zonename, zonebrand, sizeof (zonebrand)) != Z_OK) { zerror(gettext("could not get brand for zone %s"), zonename); return (1); } + /* + * In the alternate root environment, the only supported + * operations are mount and unmount. In this case, just treat + * the zone as native if it is cluster. Cluster zones can be + * native for the purpose of LU or upgrade, and the cluster + * brand may not exist in the miniroot (such as in net install + * upgrade). + */ + if (zonecfg_in_alt_root() && + strcmp(zonebrand, CLUSTER_BRAND_NAME) == 0) { + (void) strlcpy(zonebrand, NATIVE_BRAND_NAME, + sizeof (zonebrand)); + } + if ((bh = brand_open(zonebrand)) == NULL) { + zerror(gettext("could not open brand for zone %s"), zonename); + return (1); + } + if ((new_args = prep_args(bh, login, proc_args)) == NULL) { zperror(gettext("could not assemble new arguments")); brand_close(bh);
--- a/usr/src/cmd/zoneadm/zoneadm.c Wed Oct 14 11:32:21 2009 -0700 +++ b/usr/src/cmd/zoneadm/zoneadm.c Wed Oct 14 11:48:20 2009 -0700 @@ -5662,6 +5662,20 @@ zerror(gettext("missing or invalid brand")); exit(Z_ERR); } + /* + * In the alternate root environment, the only supported + * operations are mount and unmount. In this case, just treat + * the zone as native if it is cluster. Cluster zones can be + * native for the purpose of LU or upgrade, and the cluster + * brand may not exist in the miniroot (such as in net install + * upgrade). + */ + if (strcmp(target_brand, CLUSTER_BRAND_NAME) == 0) { + if (zonecfg_in_alt_root()) { + (void) strlcpy(target_brand, NATIVE_BRAND_NAME, + sizeof (target_brand)); + } + } } err = parse_and_run(argc - optind, &argv[optind]);
--- a/usr/src/cmd/zoneadmd/vplat.c Wed Oct 14 11:32:21 2009 -0700 +++ b/usr/src/cmd/zoneadmd/vplat.c Wed Oct 14 11:48:20 2009 -0700 @@ -1091,11 +1091,7 @@ if (ALT_MOUNT(mount_cmd)) { (void) strlcpy(brand, NATIVE_BRAND_NAME, sizeof (brand)); } else { - if (zone_get_brand(zone_name, brand, sizeof (brand)) != Z_OK) { - zerror(zlogp, B_FALSE, - "unable to determine zone brand"); - goto cleanup; - } + (void) strlcpy(brand, brand_name, sizeof (brand)); } if ((bh = brand_open(brand)) == NULL) { @@ -1769,12 +1765,7 @@ if (ALT_MOUNT(mount_cmd)) { (void) strlcpy(brand, NATIVE_BRAND_NAME, sizeof (brand)); } else { - if (zone_get_brand(zone_name, brand, sizeof (brand)) != Z_OK) { - zerror(zlogp, B_FALSE, - "unable to determine zone brand"); - zonecfg_fini_handle(handle); - return (-1); - } + (void) strlcpy(brand, brand_name, sizeof (brand)); } /* Get a handle to the brand info for this zone */ @@ -4143,16 +4134,14 @@ if (setup_zone_hostid(zlogp, zone_name, zoneid) != Z_OK) goto error; - if ((zone_get_brand(zone_name, attr.ba_brandname, - MAXNAMELEN) != Z_OK) || - (bh = brand_open(attr.ba_brandname)) == NULL) { + if ((bh = brand_open(brand_name)) == NULL) { zerror(zlogp, B_FALSE, "unable to determine brand name"); goto error; } if (!is_system_labeled() && - (strcmp(attr.ba_brandname, LABELED_BRAND_NAME) == 0)) { + (strcmp(brand_name, LABELED_BRAND_NAME) == 0)) { brand_close(bh); zerror(zlogp, B_FALSE, "cannot boot labeled zone on unlabeled system"); @@ -4172,7 +4161,10 @@ brand_close(bh); if (strlen(modname) > 0) { - (void) strlcpy(attr.ba_modname, modname, MAXPATHLEN); + (void) strlcpy(attr.ba_brandname, brand_name, + sizeof (attr.ba_brandname)); + (void) strlcpy(attr.ba_modname, modname, + sizeof (attr.ba_modname)); if (zone_setattr(zoneid, ZONE_ATTR_BRAND, &attr, sizeof (attr) != 0)) { zerror(zlogp, B_TRUE, @@ -4421,7 +4413,6 @@ char pool_err[128]; char zpath[MAXPATHLEN]; char cmdbuf[MAXPATHLEN]; - char brand[MAXNAMELEN]; brand_handle_t bh = NULL; dladm_status_t status; char errmsg[DLADM_STRSIZE]; @@ -4465,8 +4456,7 @@ } /* Get a handle to the brand info for this zone */ - if ((zone_get_brand(zone_name, brand, sizeof (brand)) != Z_OK) || - (bh = brand_open(brand)) == NULL) { + if ((bh = brand_open(brand_name)) == NULL) { zerror(zlogp, B_FALSE, "unable to determine zone brand"); return (-1); }
--- a/usr/src/cmd/zoneadmd/zoneadmd.c Wed Oct 14 11:32:21 2009 -0700 +++ b/usr/src/cmd/zoneadmd/zoneadmd.c Wed Oct 14 11:48:20 2009 -0700 @@ -95,6 +95,7 @@ #include <sys/brand.h> #include <libcontract.h> #include <libcontract_priv.h> +#include <sys/brand.h> #include <sys/contract/process.h> #include <sys/ctfs.h> #include <libdladm.h> @@ -1747,15 +1748,37 @@ } /* Get a handle to the brand info for this zone */ - if ((zone_get_brand(zone_name, brand_name, sizeof (brand_name)) - != Z_OK) || (bh = brand_open(brand_name)) == NULL) { + if (zone_get_brand(zone_name, brand_name, sizeof (brand_name)) + != Z_OK) { zerror(zlogp, B_FALSE, "unable to determine zone brand"); return (1); } - zone_isnative = brand_is_native(bh); - zone_iscluster = (strcmp(brand_name, CLUSTER_BRAND_NAME) == 0); + zone_isnative = (strcmp(brand_name, NATIVE_BRAND_NAME) == 0); zone_islabeled = (strcmp(brand_name, LABELED_BRAND_NAME) == 0); + /* + * In the alternate root environment, the only supported + * operations are mount and unmount. In this case, just treat + * the zone as native if it is cluster. Cluster zones can be + * native for the purpose of LU or upgrade, and the cluster + * brand may not exist in the miniroot (such as in net install + * upgrade). + */ + if (strcmp(brand_name, CLUSTER_BRAND_NAME) == 0) { + zone_iscluster = B_TRUE; + if (zonecfg_in_alt_root()) { + (void) strlcpy(brand_name, NATIVE_BRAND_NAME, + sizeof (brand_name)); + } + } else { + zone_iscluster = B_FALSE; + } + + if ((bh = brand_open(brand_name)) == NULL) { + zerror(zlogp, B_FALSE, "unable to open zone brand"); + return (1); + } + /* Get state change brand hooks. */ if (brand_callback_init(bh, zone_name) == -1) { zerror(zlogp, B_TRUE,
--- a/usr/src/cmd/zoneadmd/zoneadmd.h Wed Oct 14 11:32:21 2009 -0700 +++ b/usr/src/cmd/zoneadmd/zoneadmd.h Wed Oct 14 11:48:20 2009 -0700 @@ -86,6 +86,7 @@ extern boolean_t in_death_throes; extern boolean_t bringup_failure_recovery; extern char *zone_name; +extern char brand_name[MAXNAMELEN]; extern char boot_args[BOOTARGS_MAX]; extern char bad_boot_arg[BOOTARGS_MAX]; extern boolean_t zone_isnative;