diff options
author | <gerald.jelinek@sun.com> | 2010-02-26 06:50:49 -0700 |
---|---|---|
committer | <gerald.jelinek@sun.com> | 2010-02-26 06:50:49 -0700 |
commit | ab5dfd5e82c7de6e8a7172573741f3c5890a82fa (patch) | |
tree | cccf9c63eac36f78344145aeae41fd63352e57a3 /usr/src | |
parent | 7706a9bf5155da553880e1d88bef039daa6fc46c (diff) | |
download | illumos-gate-ab5dfd5e82c7de6e8a7172573741f3c5890a82fa.tar.gz |
6914369 enable s10brand on system booted under xvm
6925770 add service tag when installing solaris10 branded zone
6926946 preuninstall hook uses wrong buffer
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/cmd/zoneadm/zoneadm.c | 4 | ||||
-rw-r--r-- | usr/src/lib/brand/solaris10/s10_support/s10_support.c | 42 | ||||
-rw-r--r-- | usr/src/lib/brand/solaris10/zone/Makefile | 6 | ||||
-rw-r--r-- | usr/src/lib/brand/solaris10/zone/clone.ksh | 5 | ||||
-rw-r--r-- | usr/src/lib/brand/solaris10/zone/common.ksh | 86 | ||||
-rw-r--r-- | usr/src/lib/brand/solaris10/zone/config.xml | 4 | ||||
-rw-r--r-- | usr/src/lib/brand/solaris10/zone/detach.ksh | 5 | ||||
-rw-r--r-- | usr/src/lib/brand/solaris10/zone/image_install.ksh | 3 | ||||
-rw-r--r-- | usr/src/lib/brand/solaris10/zone/postattach.ksh | 79 | ||||
-rw-r--r-- | usr/src/lib/brand/solaris10/zone/preuninstall.ksh | 72 | ||||
-rw-r--r-- | usr/src/lib/brand/solaris10/zone/uninstall.ksh | 14 | ||||
-rw-r--r-- | usr/src/pkgdefs/SUNWs10brandu/prototype_com | 4 |
12 files changed, 287 insertions, 37 deletions
diff --git a/usr/src/cmd/zoneadm/zoneadm.c b/usr/src/cmd/zoneadm/zoneadm.c index af08db8d70..be0a8e1bc1 100644 --- a/usr/src/cmd/zoneadm/zoneadm.c +++ b/usr/src/cmd/zoneadm/zoneadm.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -5017,7 +5017,7 @@ uninstall_func(int argc, char *argv[]) /* If we have a brand preuninstall hook, run it. */ if (!brand_help && precmdbuf[0] != '\0') { - status = do_subproc(cmdbuf); + status = do_subproc(precmdbuf); if (subproc_status(gettext("brand-specific preuninstall"), status, B_FALSE) != ZONE_SUBPROC_OK) { zonecfg_release_lock_file(target_zone, lockfd); diff --git a/usr/src/lib/brand/solaris10/s10_support/s10_support.c b/usr/src/lib/brand/solaris10/s10_support/s10_support.c index e8a640b6e0..e05aed8253 100644 --- a/usr/src/lib/brand/solaris10/s10_support/s10_support.c +++ b/usr/src/lib/brand/solaris10/s10_support/s10_support.c @@ -280,14 +280,15 @@ have_valid_ku(char *zonename) char *lastp; char *pstr; char *patchlist = NULL; - int i; char zonepath[MAXPATHLEN]; char sanity_skip[MAXPATHLEN]; struct stat64 buf; + boolean_t is_xpv = B_FALSE; + char platform[80]; + char *xpv_vers = "142910"; char *vers_table[] = { "141444-09", - "141445-09", - NULL}; + "141445-09"}; if (zone_get_zonepath(zonename, zonepath, sizeof (zonepath)) != Z_OK) s10_err(gettext("error getting zone's path")); @@ -306,15 +307,33 @@ have_valid_ku(char *zonename) if (get_ku_patchlist(zonepath, &patchlist) != 0 || patchlist == NULL) return (B_FALSE); + /* + * Check if we're running on the i86xpv platform. If so, the zone + * needs a different ku patch to work properly. + */ + if (sysinfo(SI_PLATFORM, platform, sizeof (platform)) != -1 && + strcmp(platform, "i86xpv") == 0) + is_xpv = B_TRUE; + pstr = patchlist; while ((p = strtok_r(pstr, " ", &lastp)) != NULL) { - for (i = 0; vers_table[i] != NULL; i++) - if (strcmp(p, vers_table[i]) == 0) + if (is_xpv) { + if (strncmp(p, xpv_vers, 6) == 0) return (B_TRUE); + } else { + if (strcmp(p, vers_table[0]) == 0 || + strcmp(p, vers_table[1]) == 0) + return (B_TRUE); + } pstr = NULL; } + if (is_xpv) + s10_err(gettext("the zone must have patch 142910 installed " + "when running in a paravirtualized domain")); + + return (B_FALSE); } @@ -404,17 +423,6 @@ set_zone_emul_bitmap(char *zonename) s10_err(gettext("error setting zone's emulation bitmap")); } -static void -fail_xvm() -{ - char buf[80]; - - if (sysinfo(SI_PLATFORM, buf, sizeof (buf)) != -1 && - strcmp(buf, "i86xpv") == 0 && !override) - s10_err(gettext("running the solaris10 brand " - "in a paravirtualized\ndomain is currently not supported")); -} - static int s10_boot(char *zonename) { @@ -424,8 +432,6 @@ s10_boot(char *zonename) set_zone_emul_bitmap(zonename); - fail_xvm(); - return (0); } diff --git a/usr/src/lib/brand/solaris10/zone/Makefile b/usr/src/lib/brand/solaris10/zone/Makefile index e3463d849b..b15fa490eb 100644 --- a/usr/src/lib/brand/solaris10/zone/Makefile +++ b/usr/src/lib/brand/solaris10/zone/Makefile @@ -20,12 +20,12 @@ # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Copyright 2010 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -PROGS = attach clone detach image_install p2v poststate prestate \ - s10_boot uninstall +PROGS = attach clone detach image_install p2v postattach poststate \ + prestate preuninstall s10_boot uninstall XMLDOCS= config.xml platform.xml smf_disable.lst pkgrm.lst common.ksh \ version USERFILES= smf_disable.conf pkgrm.conf diff --git a/usr/src/lib/brand/solaris10/zone/clone.ksh b/usr/src/lib/brand/solaris10/zone/clone.ksh index 9f5052b112..b6c10c6d19 100644 --- a/usr/src/lib/brand/solaris10/zone/clone.ksh +++ b/usr/src/lib/brand/solaris10/zone/clone.ksh @@ -20,7 +20,7 @@ # CDDL HEADER END # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Copyright 2010 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # @@ -134,4 +134,7 @@ if [[ ! -f $ZONEROOT/etc/.UNCONFIGURED ]]; then /usr/sbin/zoneadm -z $ZONENAME halt fi +# Add a service tag for this zone. +add_svc_tag "$ZONENAME" "clone $sourcezone" + exit $ZONE_SUBPROC_OK diff --git a/usr/src/lib/brand/solaris10/zone/common.ksh b/usr/src/lib/brand/solaris10/zone/common.ksh index 32a7358c32..50d134ef21 100644 --- a/usr/src/lib/brand/solaris10/zone/common.ksh +++ b/usr/src/lib/brand/solaris10/zone/common.ksh @@ -19,7 +19,7 @@ # CDDL HEADER END # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Copyright 2010 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # @@ -32,6 +32,12 @@ export PATH # Use the ipkg-brand ZFS property for denoting the zone root's active dataset. PROP_ACTIVE="org.opensolaris.libbe:active" +# Values for service tags. +STCLIENT=/usr/bin/stclient +ST_PRODUCT_NAME="Solaris 10 Containers" +ST_PRODUCT_REV="1.0" +ST_PRODUCT_UUID="urn:uuid:2f459121-dec7-11de-9af7-080020a9ed93" + w_sanity_detail=$(gettext " WARNING: Skipping image sanity checks.") f_sanity_detail=$(gettext "Missing %s at %s") f_sanity_sparse=$(gettext "Is this a sparse zone image? The image must be whole-root.") @@ -56,6 +62,12 @@ e_nosingleuser=$(gettext "ERROR: zone did not finish booting to single-user.") e_unconfig=$(gettext "sys-unconfig failed") v_unconfig=$(gettext "Performing zone sys-unconfig") +v_no_tags=$(gettext "Service tags facility not present.") +e_bad_uuid=$(gettext "Failed to get zone UUID") +v_addtag=$(gettext "Adding service tag: %s") +v_deltag=$(gettext "Removing service tag: %s") +e_addtag_fail=$(gettext "Adding service tag failed (error: %s)") + sanity_check() { typeset dir="$1" @@ -342,3 +354,75 @@ sysunconfig_zone() { return 0 } + +# +# Get zone's uuid for service tag. +# +get_inst_uuid() +{ + typeset ZONENAME="$1" + + ZONEUUID=`zoneadm -z $ZONENAME list -p | nawk -F: '{print $5}'` + [[ $? -ne 0 || -z $ZONEUUID ]] && return 1 + + INSTANCE_UUID="urn:st:${ZONEUUID}" + return 0 +} + +# +# Add a service tag for a given zone. We use two UUIDs-- the first, +# the Product UUID, comes from the Sun swoRDFish ontology. The second +# is the UUID of the zone itself, which forms the instance UUID. +# +add_svc_tag() +{ + typeset ZONENAME="$1" + typeset SOURCE="$2" + + if [ ! -x $STCLIENT ]; then + vlog "$v_no_tags" + return 0 + fi + + get_inst_uuid "$ZONENAME" || (error "$e_bad_uuid"; return 1) + + vlog "$v_addtag" "$INSTANCE_UUID" + $STCLIENT -a \ + -p "$ST_PRODUCT_NAME" \ + -e "$ST_PRODUCT_REV" \ + -t "$ST_PRODUCT_UUID" \ + -i "$INSTANCE_UUID" \ + -P "none" \ + -m "Sun" \ + -A `uname -p` \ + -z "$ZONENAME" \ + -S "$SOURCE" >/dev/null 2>&1 + + err=$? + + # 226 means "duplicate record," which we can ignore. + if [[ $err -ne 0 && $err -ne 226 ]]; then + error "$e_addtag_fail" "$err" + return 1 + fi + return 0 +} + +# +# Remove a service tag for a given zone. +# +del_svc_tag() +{ + typeset ZONENAME="$1" + + if [ ! -x $STCLIENT ]; then + vlog "$v_no_tags" + return 0 + fi + + get_inst_uuid "$ZONENAME" || (error "$e_bad_uuid"; return 1) + + vlog "$v_deltag" "$INSTANCE_UUID" + $STCLIENT -d -i "$INSTANCE_UUID" >/dev/null 2>&1 + return 0 +} diff --git a/usr/src/lib/brand/solaris10/zone/config.xml b/usr/src/lib/brand/solaris10/zone/config.xml index 0a4967fcd2..f128b9ed30 100644 --- a/usr/src/lib/brand/solaris10/zone/config.xml +++ b/usr/src/lib/brand/solaris10/zone/config.xml @@ -20,7 +20,7 @@ CDDL HEADER END - Copyright 2009 Sun Microsystems, Inc. All rights reserved. + Copyright 2010 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. DO NOT EDIT THIS FILE. @@ -42,9 +42,11 @@ <halt></halt> <verify_cfg>/usr/lib/brand/solaris10/s10_support verify</verify_cfg> <verify_adm></verify_adm> + <postattach>/usr/lib/brand/solaris10/postattach %z %R</postattach> <attach>/usr/lib/brand/solaris10/attach %z %R</attach> <detach>/usr/lib/brand/solaris10/detach %z %R</detach> <clone>/usr/lib/brand/solaris10/clone -z %z -R %R</clone> + <preuninstall>/usr/lib/brand/solaris10/preuninstall %z %R</preuninstall> <uninstall>/usr/lib/brand/solaris10/uninstall %z %R</uninstall> <prestatechange>/usr/lib/brand/solaris10/prestate %z %R</prestatechange> <poststatechange>/usr/lib/brand/solaris10/poststate %z %R</poststatechange> diff --git a/usr/src/lib/brand/solaris10/zone/detach.ksh b/usr/src/lib/brand/solaris10/zone/detach.ksh index ae28857062..27b55556ba 100644 --- a/usr/src/lib/brand/solaris10/zone/detach.ksh +++ b/usr/src/lib/brand/solaris10/zone/detach.ksh @@ -20,7 +20,7 @@ # CDDL HEADER END # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Copyright 2010 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # @@ -62,4 +62,7 @@ fi cp /etc/zones/$ZONENAME.xml $ZONEPATH/SUNWdetached.xml +# Remove the service tag for this zone. +del_svc_tag "$ZONENAME" + exit $ZONE_SUBPROC_OK diff --git a/usr/src/lib/brand/solaris10/zone/image_install.ksh b/usr/src/lib/brand/solaris10/zone/image_install.ksh index 8cf238a16b..86b9345d27 100644 --- a/usr/src/lib/brand/solaris10/zone/image_install.ksh +++ b/usr/src/lib/brand/solaris10/zone/image_install.ksh @@ -244,6 +244,9 @@ else exit $ZONE_SUBPROC_FATAL fi +# Add a service tag for this zone. +add_svc_tag "$ZONENAME" "install $inst_type `basename $install_media`" + log "" log "$install_good" "$ZONENAME" diff --git a/usr/src/lib/brand/solaris10/zone/postattach.ksh b/usr/src/lib/brand/solaris10/zone/postattach.ksh new file mode 100644 index 0000000000..9d6d6f1df8 --- /dev/null +++ b/usr/src/lib/brand/solaris10/zone/postattach.ksh @@ -0,0 +1,79 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2010 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# This postattach hook adds the service tag for the zone. +# We need this in a postattach hook since the zone doesn't have +# a UUID when the attach hook is run. +# + +. /usr/lib/brand/solaris10/common.ksh + +install_media="-" + +# If we weren't passed at least two arguments, exit now. +(( $# < 2 )) && exit $ZONE_SUBPROC_OK + +ZONENAME="$1" +ZONEPATH="$2" + +shift 2 + +noexecute=0 +unset inst_type + +# +# This hook will see the same options as the attach hook, so make sure +# we accept all of these. +# +while getopts "a:d:nr:" opt; do + case $opt in + a) + inst_type="archive" + install_media="$OPTARG" + ;; + d) + inst_type="directory" + install_media="$OPTARG" + ;; + n) noexecute=1 ;; + r) + inst_type="stdin" + install_media="$OPTARG" + ;; + ?) exit $ZONE_SUBPROC_OK;; + *) exit $ZONE_SUBPROC_OK;; + esac +done +shift $((OPTIND-1)) + +[ $noexecute -eq 1 ] && exit $ZONE_SUBPROC_OK +[[ -z "$inst_type" ]] && inst_type="directory" + +# Add a service tag for this zone. +add_svc_tag "$ZONENAME" "attach $inst_type `basename $install_media`" + +exit $ZONE_SUBPROC_OK diff --git a/usr/src/lib/brand/solaris10/zone/preuninstall.ksh b/usr/src/lib/brand/solaris10/zone/preuninstall.ksh new file mode 100644 index 0000000000..244fae731d --- /dev/null +++ b/usr/src/lib/brand/solaris10/zone/preuninstall.ksh @@ -0,0 +1,72 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2010 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# This preuninstall hook removes the service tag for the zone. +# We need this in a preuninstall hook since once the zone state is +# changed to 'incomplete' (which happens before we run the uninstall hook) +# then the zone gets a new UUID and we can no longer figure out which +# service tag instance to delete. +# + +# +# common shell script functions +# +. /usr/lib/brand/solaris10/common.ksh + +# If we weren't passed at least two arguments, exit now. +(( $# < 2 )) && exit $ZONE_SUBPROC_USAGE + +ZONENAME=$1 +ZONEPATH=$2 + +shift 2 + +# +# This hook will see the same options as the uninstall hook, so make sure +# we accept these even though all but -n are ignored. +# +options="FhHnv" +nop="" + +# process options +OPTIND=1 +while getopts :$options OPT ; do +case $OPT in + F ) ;; + h|H ) exit $ZONE_SUBPROC_OK ;; + n ) nop="echo" ;; + v ) ;; +esac +done +shift `expr $OPTIND - 1` + +[ $# -gt 0 ] && exit $ZONE_SUBPROC_OK + +# Remove the service tag for this zone. +$nop del_svc_tag "$ZONENAME" + +exit $ZONE_SUBPROC_OK diff --git a/usr/src/lib/brand/solaris10/zone/uninstall.ksh b/usr/src/lib/brand/solaris10/zone/uninstall.ksh index cd1f02671d..e77a2c0ddc 100644 --- a/usr/src/lib/brand/solaris10/zone/uninstall.ksh +++ b/usr/src/lib/brand/solaris10/zone/uninstall.ksh @@ -20,7 +20,7 @@ # CDDL HEADER END # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Copyright 2010 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # @@ -33,16 +33,12 @@ # # options processing # +# If we weren't passed at least two arguments, exit now. +(( $# < 2 )) && exit $ZONE_SUBPROC_USAGE + zonename=$1 -if [ -z "$zonename" ]; then - printf "$f_abort\n" >&2 - exit $ZONE_SUBPROC_FATAL -fi zonepath=$2 -if [ -z "$zonepath" ]; then - printf "$f_abort" >&2 - exit $ZONE_SUBPROC_FATAL -fi + shift 2 options="FhHnv" diff --git a/usr/src/pkgdefs/SUNWs10brandu/prototype_com b/usr/src/pkgdefs/SUNWs10brandu/prototype_com index c3d6015c07..a6a6bffc93 100644 --- a/usr/src/pkgdefs/SUNWs10brandu/prototype_com +++ b/usr/src/pkgdefs/SUNWs10brandu/prototype_com @@ -19,7 +19,7 @@ # CDDL HEADER END # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Copyright 2010 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # @@ -42,8 +42,10 @@ f none usr/lib/brand/solaris10/image_install 755 root bin f none usr/lib/brand/solaris10/p2v 755 root bin f none usr/lib/brand/solaris10/pkgrm.lst 444 root bin f none usr/lib/brand/solaris10/platform.xml 444 root bin +f none usr/lib/brand/solaris10/postattach 755 root bin f none usr/lib/brand/solaris10/poststate 755 root bin f none usr/lib/brand/solaris10/prestate 755 root bin +f none usr/lib/brand/solaris10/preuninstall 755 root bin f none usr/lib/brand/solaris10/s10_automount 755 root bin f none usr/lib/brand/solaris10/s10_automountd 755 root bin f none usr/lib/brand/solaris10/s10_boot 755 root bin |