diff options
author | Alexander Eremin <a.eremin@nexenta.com> | 2014-02-24 18:38:06 +0400 |
---|---|---|
committer | Dan McDonald <danmcd@omniti.com> | 2014-02-24 05:43:48 -0500 |
commit | 3c7284bd3243d42a710edac3a15f6019b4c849be (patch) | |
tree | a68127ed38b888e9b111abe0215d3d962053918b /usr/src/lib | |
parent | 97f7c4750238e3c507904468e4e9f17b15a08e2d (diff) | |
download | illumos-joyent-3c7284bd3243d42a710edac3a15f6019b4c849be.tar.gz |
2594 implement graceful shutdown for local zones in zoneadm
Reviewed by: Saso Kiselkov <skiselkov.ml@gmail.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Approved by: Dan McDonald <danmcd@omniti.com>
Diffstat (limited to 'usr/src/lib')
-rw-r--r-- | usr/src/lib/brand/ipkg/zone/config.xml | 2 | ||||
-rw-r--r-- | usr/src/lib/brand/labeled/zone/config.xml | 2 | ||||
-rw-r--r-- | usr/src/lib/brand/solaris10/zone/config.xml | 2 | ||||
-rw-r--r-- | usr/src/lib/libbrand/common/libbrand.c | 11 | ||||
-rw-r--r-- | usr/src/lib/libbrand/common/libbrand.h | 3 | ||||
-rw-r--r-- | usr/src/lib/libbrand/common/mapfile-vers | 2 | ||||
-rw-r--r-- | usr/src/lib/libbrand/dtd/brand.dtd.1 | 29 |
7 files changed, 48 insertions, 3 deletions
diff --git a/usr/src/lib/brand/ipkg/zone/config.xml b/usr/src/lib/brand/ipkg/zone/config.xml index 91f492bdde..e7307bfd8a 100644 --- a/usr/src/lib/brand/ipkg/zone/config.xml +++ b/usr/src/lib/brand/ipkg/zone/config.xml @@ -23,6 +23,7 @@ Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. DO NOT EDIT THIS FILE. + Copyright 2014 Nexenta Systems, Inc. All rights reserved. --> <!DOCTYPE brand PUBLIC "-//Sun Microsystems Inc//DTD Brands//EN" @@ -42,6 +43,7 @@ <boot></boot> <sysboot>/usr/lib/brand/ipkg/prestate %z %R 2 0</sysboot> <halt></halt> + <shutdown>/usr/sbin/shutdown -y -g0 -i5</shutdown> <verify_cfg></verify_cfg> <verify_adm></verify_adm> <postclone></postclone> diff --git a/usr/src/lib/brand/labeled/zone/config.xml b/usr/src/lib/brand/labeled/zone/config.xml index 1bad9a9a11..61db7bcbf3 100644 --- a/usr/src/lib/brand/labeled/zone/config.xml +++ b/usr/src/lib/brand/labeled/zone/config.xml @@ -23,6 +23,7 @@ Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. DO NOT EDIT THIS FILE. + Copyright 2014 Nexenta Systems, Inc. All rights reserved. --> <!DOCTYPE brand PUBLIC "-//Sun Microsystems Inc//DTD Brands//EN" @@ -43,6 +44,7 @@ <boot></boot> <sysboot>/usr/lib/brand/ipkg/prestate %z %R 2 0</sysboot> <halt></halt> + <shutdown>/usr/sbin/shutdown -y -g0 -i5</shutdown> <verify_cfg></verify_cfg> <verify_adm></verify_adm> <postclone></postclone> diff --git a/usr/src/lib/brand/solaris10/zone/config.xml b/usr/src/lib/brand/solaris10/zone/config.xml index e1bd2b64b0..a0eeaa0c98 100644 --- a/usr/src/lib/brand/solaris10/zone/config.xml +++ b/usr/src/lib/brand/solaris10/zone/config.xml @@ -23,6 +23,7 @@ Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. DO NOT EDIT THIS FILE. + Copyright 2014 Nexenta Systems, Inc. All rights reserved. --> <!DOCTYPE brand PUBLIC "-//Sun Microsystems Inc//DTD Brands//EN" @@ -40,6 +41,7 @@ <boot>/usr/lib/brand/solaris10/s10_boot %z %R</boot> <sysboot>/usr/lib/brand/solaris10/prestate %z %R 2 0</sysboot> <halt></halt> + <shutdown>/usr/sbin/shutdown -y -g0 -i5</shutdown> <verify_cfg>/usr/lib/brand/solaris10/s10_support verify</verify_cfg> <verify_adm></verify_adm> <postattach>/usr/lib/brand/solaris10/postattach %z %R</postattach> diff --git a/usr/src/lib/libbrand/common/libbrand.c b/usr/src/lib/libbrand/common/libbrand.c index 5034715a7e..6cbc90eb59 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 2014 Nexenta Systems, Inc. All rights reserved. */ #include <assert.h> @@ -71,6 +72,7 @@ #define DTD_ELEM_PREUNINSTALL ((const xmlChar *) "preuninstall") #define DTD_ELEM_PRIVILEGE ((const xmlChar *) "privilege") #define DTD_ELEM_QUERY ((const xmlChar *) "query") +#define DTD_ELEM_SHUTDOWN ((const xmlChar *) "shutdown") #define DTD_ELEM_SYMLINK ((const xmlChar *) "symlink") #define DTD_ELEM_SYSBOOT ((const xmlChar *) "sysboot") #define DTD_ELEM_UNINSTALL ((const xmlChar *) "uninstall") @@ -502,6 +504,15 @@ brand_get_halt(brand_handle_t bh, const char *zonename, } int +brand_get_shutdown(brand_handle_t bh, const char *zonename, + const char *zonepath, char *buf, size_t len) +{ + struct brand_handle *bhp = (struct brand_handle *)bh; + return (brand_get_value(bhp, zonename, zonepath, NULL, NULL, + buf, len, DTD_ELEM_SHUTDOWN, B_TRUE, B_TRUE)); +} + +int brand_get_initname(brand_handle_t bh, char *buf, size_t len) { struct brand_handle *bhp = (struct brand_handle *)bh; diff --git a/usr/src/lib/libbrand/common/libbrand.h b/usr/src/lib/libbrand/common/libbrand.h index 19231604a5..6e8a596b3a 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 2014 Nexenta Systems, Inc. All rights reserved. */ #ifndef _LIBBRAND_H @@ -54,6 +55,8 @@ extern int brand_get_clone(brand_handle_t, const char *, const char *, char *, size_t); extern int brand_get_detach(brand_handle_t, const char *, const char *, char *, size_t); +extern int brand_get_shutdown(brand_handle_t, const char *, const char *, + char *, size_t); 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); diff --git a/usr/src/lib/libbrand/common/mapfile-vers b/usr/src/lib/libbrand/common/mapfile-vers index 7b961c3c18..7b932b927f 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 2014 Nexenta Systems, Inc. All rights reserved. # # @@ -66,6 +67,7 @@ SYMBOL_VERSION SUNWprivate { brand_get_preuninstall; brand_get_query; brand_get_sysboot; + brand_get_shutdown; brand_get_uninstall; brand_get_user_cmd; brand_get_validatesnap; diff --git a/usr/src/lib/libbrand/dtd/brand.dtd.1 b/usr/src/lib/libbrand/dtd/brand.dtd.1 index 15542102db..86c0085d51 100644 --- a/usr/src/lib/libbrand/dtd/brand.dtd.1 +++ b/usr/src/lib/libbrand/dtd/brand.dtd.1 @@ -23,6 +23,8 @@ Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. DO NOT EDIT THIS FILE. + + Copyright 2014 Nexenta Systems, Inc. All rights reserved. --> <!-- @@ -166,6 +168,27 @@ <!ATTLIST halt> <!-- + shutdown + + This is a program which gets run by zoneadmd when a zone is being + shutdown gracefully. Currently only asynchronous mode is supported. + + If this program succeeds it should not generate any output. If this + program returns an error, any output generated by the program will be + sent to the zoneadmd message log. + + The following replacements are performed: + + %z Name of zone + %R Zonepath of zone + Additional arguments, if any, are appended. + + It has no attributes. +--> +<!ELEMENT shutdown (#PCDATA) > +<!ATTLIST shutdown> + +<!-- modname Path to the kernel module that implements the kernel-level @@ -607,9 +630,9 @@ <!ELEMENT brand (modname?, initname, login_cmd, forcedlogin_cmd, user_cmd, install, - installopts?, boot?, sysboot?, halt?, verify_cfg?, - verify_adm?, postattach?, postclone?, postinstall?, - predetach?, attach?, detach?, clone?, + installopts?, boot?, sysboot?, halt?, shutdown?, + verify_cfg?, verify_adm?, postattach?, postclone?, + postinstall?, predetach?, attach?, detach?, clone?, presnap?, postsnap?, validatesnap?, preuninstall?, uninstall?, prestatechange?, poststatechange?, query?, |