summaryrefslogtreecommitdiff
path: root/usr
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2011-07-20 08:43:44 -0700
committerJerry Jelinek <jerry.jelinek@joyent.com>2011-07-20 08:43:44 -0700
commitc169e3f410e52ad753c783d87600dd4a6e9adb22 (patch)
treea62deeaa1a1e736ba2bbabd9d1cb4c1f42afd6be /usr
parentd64d613cdc671a93417a930933f6ca71c3b1e0de (diff)
downloadillumos-joyent-c169e3f410e52ad753c783d87600dd4a6e9adb22.tar.gz
OS-505 Create zone brand option that allows a brand to specify that when init fails, it should not be restarted
Diffstat (limited to 'usr')
-rw-r--r--usr/src/cmd/zoneadmd/zoneadmd.c10
-rw-r--r--usr/src/lib/brand/kvm/zone/config.xml1
-rw-r--r--usr/src/lib/libbrand/common/libbrand.c17
-rw-r--r--usr/src/lib/libbrand/common/libbrand.h2
-rw-r--r--usr/src/lib/libbrand/common/mapfile-vers2
-rw-r--r--usr/src/lib/libbrand/dtd/brand.dtd.118
-rw-r--r--usr/src/uts/common/os/zone.c4
-rw-r--r--usr/src/uts/common/sys/zone.h1
8 files changed, 53 insertions, 2 deletions
diff --git a/usr/src/cmd/zoneadmd/zoneadmd.c b/usr/src/cmd/zoneadmd/zoneadmd.c
index 53926a307a..96249c65a6 100644
--- a/usr/src/cmd/zoneadmd/zoneadmd.c
+++ b/usr/src/cmd/zoneadmd/zoneadmd.c
@@ -915,6 +915,7 @@ zone_bootup(zlog_t *zlogp, const char *bootargs, int zstate, boolean_t debug)
dladm_status_t status;
char errmsg[DLADM_STRSIZE];
int err;
+ boolean_t restart_init;
if (brand_prestatechg(zlogp, zstate, Z_BOOT, debug) != 0)
return (-1);
@@ -971,6 +972,9 @@ zone_bootup(zlog_t *zlogp, const char *bootargs, int zstate, boolean_t debug)
goto bad;
}
+ /* See if this zone's brand should restart init if it dies. */
+ restart_init = brand_restartinit(bh);
+
brand_close(bh);
err = filter_bootargs(zlogp, bootargs, nbootargs, init_file,
@@ -1037,6 +1041,12 @@ zone_bootup(zlog_t *zlogp, const char *bootargs, int zstate, boolean_t debug)
goto bad;
}
+ if (!restart_init && zone_setattr(zoneid, ZONE_ATTR_INITNORESTART,
+ NULL, 0) == -1) {
+ zerror(zlogp, B_TRUE, "could not set zone init-no-restart");
+ goto bad;
+ }
+
/*
* Inform zonestatd of a new zone so that it can install a door for
* the zone to contact it.
diff --git a/usr/src/lib/brand/kvm/zone/config.xml b/usr/src/lib/brand/kvm/zone/config.xml
index 7bbe728bd9..ee26d52b89 100644
--- a/usr/src/lib/brand/kvm/zone/config.xml
+++ b/usr/src/lib/brand/kvm/zone/config.xml
@@ -33,6 +33,7 @@
<modname></modname>
<initname>/startvm</initname>
+ <restartinit>false</restartinit>
<login_cmd>/usr/bin/login -z %Z %u</login_cmd>
<forcedlogin_cmd>/usr/bin/login -z %Z -f %u</forcedlogin_cmd>
<user_cmd>/usr/bin/getent passwd %u</user_cmd>
diff --git a/usr/src/lib/libbrand/common/libbrand.c b/usr/src/lib/libbrand/common/libbrand.c
index bc2fa50328..baaaf33120 100644
--- a/usr/src/lib/libbrand/common/libbrand.c
+++ b/usr/src/lib/libbrand/common/libbrand.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, Joyent, Inc. All rights reserved.
*/
#include <assert.h>
@@ -60,6 +61,7 @@
#define DTD_ELEM_FORCELOGIN_CMD ((const xmlChar *) "forcedlogin_cmd")
#define DTD_ELEM_MODNAME ((const xmlChar *) "modname")
#define DTD_ELEM_MOUNT ((const xmlChar *) "mount")
+#define DTD_ELEM_RESTARTINIT ((const xmlChar *) "restartinit")
#define DTD_ELEM_POSTATTACH ((const xmlChar *) "postattach")
#define DTD_ELEM_POSTCLONE ((const xmlChar *) "postclone")
#define DTD_ELEM_POSTINSTALL ((const xmlChar *) "postinstall")
@@ -517,6 +519,21 @@ brand_get_initname(brand_handle_t bh, char *buf, size_t len)
buf, len, DTD_ELEM_INITNAME, B_FALSE, B_FALSE));
}
+boolean_t
+brand_restartinit(brand_handle_t bh)
+{
+ struct brand_handle *bhp = (struct brand_handle *)bh;
+ char val[80];
+
+ if (brand_get_value(bhp, NULL, NULL, NULL, NULL,
+ val, 80, DTD_ELEM_RESTARTINIT, B_FALSE, B_FALSE) != 0)
+ return (B_TRUE);
+
+ if (strcmp(val, "false") == 0)
+ return (B_FALSE);
+ return (B_TRUE);
+}
+
int
brand_get_login_cmd(brand_handle_t bh, const char *username,
char *buf, size_t len)
diff --git a/usr/src/lib/libbrand/common/libbrand.h b/usr/src/lib/libbrand/common/libbrand.h
index 19231604a5..1ca9e9f36d 100644
--- a/usr/src/lib/libbrand/common/libbrand.h
+++ b/usr/src/lib/libbrand/common/libbrand.h
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, Joyent, Inc. All rights reserved.
*/
#ifndef _LIBBRAND_H
@@ -57,6 +58,7 @@ extern int brand_get_detach(brand_handle_t, const char *, const char *,
extern int brand_get_halt(brand_handle_t, const char *, const char *,
char *, size_t);
extern int brand_get_initname(brand_handle_t, char *, size_t);
+extern boolean_t brand_restartinit(brand_handle_t);
extern int brand_get_install(brand_handle_t, const char *, const char *,
char *, size_t);
extern int brand_get_installopts(brand_handle_t, char *, size_t);
diff --git a/usr/src/lib/libbrand/common/mapfile-vers b/usr/src/lib/libbrand/common/mapfile-vers
index 7b961c3c18..9bf21d2d26 100644
--- a/usr/src/lib/libbrand/common/mapfile-vers
+++ b/usr/src/lib/libbrand/common/mapfile-vers
@@ -20,6 +20,7 @@
#
#
# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, Joyent, Inc. All rights reserved.
#
#
@@ -76,6 +77,7 @@ SYMBOL_VERSION SUNWprivate {
brand_platform_iter_gmounts;
brand_platform_iter_link;
brand_platform_iter_mounts;
+ brand_restartinit;
local:
*;
};
diff --git a/usr/src/lib/libbrand/dtd/brand.dtd.1 b/usr/src/lib/libbrand/dtd/brand.dtd.1
index 15542102db..89719a6ae6 100644
--- a/usr/src/lib/libbrand/dtd/brand.dtd.1
+++ b/usr/src/lib/libbrand/dtd/brand.dtd.1
@@ -21,6 +21,7 @@
CDDL HEADER END
Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2011, Joyent, Inc. All rights reserved.
DO NOT EDIT THIS FILE.
-->
@@ -188,6 +189,19 @@
<!ATTLIST initname>
<!--
+ restartinit
+
+ Boolean indicating that the program specified by the initname attr
+ should be restarted, or not, if it exits. By default, the init program
+ will be restarted if this attribute is not provided. Specifying false
+ for this attr will prevent that.
+
+ It has no attributes.
+-->
+<!ELEMENT restartinit (#PCDATA) >
+<!ATTLIST restartinit>
+
+<!--
login_cmd
Path to the initial login binary that should be executed when
@@ -605,8 +619,8 @@
directory in which the configuration file is stored.
-->
-<!ELEMENT brand (modname?, initname, login_cmd, forcedlogin_cmd,
- user_cmd, install,
+<!ELEMENT brand (modname?, initname, restartinit?, login_cmd,
+ forcedlogin_cmd, user_cmd, install,
installopts?, boot?, sysboot?, halt?, verify_cfg?,
verify_adm?, postattach?, postclone?, postinstall?,
predetach?, attach?, detach?, clone?,
diff --git a/usr/src/uts/common/os/zone.c b/usr/src/uts/common/os/zone.c
index 2ad2d3c3a9..a9bd61f05c 100644
--- a/usr/src/uts/common/os/zone.c
+++ b/usr/src/uts/common/os/zone.c
@@ -5909,6 +5909,10 @@ zone_setattr(zoneid_t zoneid, int attr, void *buf, size_t bufsize)
case ZONE_ATTR_INITNAME:
err = zone_set_initname(zone, (const char *)buf);
break;
+ case ZONE_ATTR_INITNORESTART:
+ zone->zone_restart_init = B_FALSE;
+ err = 0;
+ break;
case ZONE_ATTR_BOOTARGS:
err = zone_set_bootargs(zone, (const char *)buf);
break;
diff --git a/usr/src/uts/common/sys/zone.h b/usr/src/uts/common/sys/zone.h
index 32c80691df..08677a2f65 100644
--- a/usr/src/uts/common/sys/zone.h
+++ b/usr/src/uts/common/sys/zone.h
@@ -103,6 +103,7 @@ extern "C" {
#define ZONE_ATTR_NETWORK 17
#define ZONE_ATTR_DID 18
#define ZONE_ATTR_PMCAP_PAGEOUT 19
+#define ZONE_ATTR_INITNORESTART 20
/* Start of the brand-specific attribute namespace */
#define ZONE_ATTR_BRAND_ATTRS 32768