Print this page
2594 implement graceful shutdown for local zones in zoneadm
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/zoneadmd/zoneadmd.h
+++ new/usr/src/cmd/zoneadmd/zoneadmd.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
24 + * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
24 25 */
25 26
26 27 #ifndef _ZONEADMD_H
27 28 #define _ZONEADMD_H
28 29
29 30 #ifdef __cplusplus
30 31 extern "C" {
31 32 #endif
32 33
33 34 #include <libdladm.h>
34 35
35 36 /*
36 37 * Multi-threaded programs should avoid MT-unsafe library calls (i.e., any-
37 38 * thing which could try to acquire a user-level lock unprotected by an atfork
38 39 * handler) between fork(2) and exec(2). See the pthread_atfork(3THR) man
39 40 * page for details. In particular, we want to avoid calls to zerror() in
40 41 * such situations, as it calls setlocale(3c) which is susceptible to such
41 42 * problems. So instead we have the child use one of the special exit codes
42 43 * below when needed, and the parent look out for such possibilities and call
43 44 * zerror() there.
44 45 *
45 46 * Since 0, 1 and 2 are generally used for success, general error, and usage,
46 47 * we start with 3.
47 48 */
48 49 #define ZEXIT_FORK 3
49 50 #define ZEXIT_EXEC 4
50 51 #define ZEXIT_ZONE_ENTER 5
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
51 52
52 53 #define DEVFSADM "devfsadm"
53 54 #define DEVFSADM_PATH "/usr/sbin/devfsadm"
54 55
55 56 #define EXEC_PREFIX "exec "
56 57 #define EXEC_LEN (strlen(EXEC_PREFIX))
57 58
58 59 #define CLUSTER_BRAND_NAME "cluster"
59 60 #define LABELED_BRAND_NAME "labeled"
60 61
62 +#define SHUTDOWN_WAIT 60
63 +#define SHUTDOWN_DEFAULT "/sbin/init 0"
64 +#define SHUTDOWN_FMRI "svc:/system/zones:default"
65 +
61 66 /* 0755 is the default directory mode. */
62 67 #define DEFAULT_DIR_MODE \
63 68 (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
64 69 #define DEFAULT_DIR_USER -1 /* user ID for chown: -1 means don't change */
65 70 #define DEFAULT_DIR_GROUP -1 /* grp ID for chown: -1 means don't change */
66 71
67 72
68 73 typedef struct zlog {
69 74 FILE *logfile; /* file to log to */
70 75
71 76 /*
72 77 * The following are used if logging to a buffer.
73 78 */
74 79 char *log; /* remaining log */
75 80 size_t loglen; /* size of remaining log */
76 81 char *buf; /* underlying storage */
77 82 size_t buflen; /* total len of 'buf' */
78 83 char *locale; /* locale to use for gettext() */
79 84 } zlog_t;
80 85
81 86 extern zlog_t logsys;
82 87
83 88 extern mutex_t lock;
84 89 extern mutex_t msglock;
85 90 extern boolean_t in_death_throes;
86 91 extern boolean_t bringup_failure_recovery;
87 92 extern char *zone_name;
88 93 extern char pool_name[MAXNAMELEN];
89 94 extern char brand_name[MAXNAMELEN];
90 95 extern char default_brand[MAXNAMELEN];
91 96 extern char boot_args[BOOTARGS_MAX];
92 97 extern char bad_boot_arg[BOOTARGS_MAX];
93 98 extern boolean_t zone_isnative;
94 99 extern boolean_t zone_iscluster;
95 100 extern dladm_handle_t dld_handle;
96 101
97 102 extern void zerror(zlog_t *, boolean_t, const char *, ...);
98 103 extern char *localize_msg(char *locale, const char *msg);
99 104
100 105 /*
101 106 * Eventstream interfaces.
102 107 */
103 108 typedef enum {
104 109 Z_EVT_NULL = 0,
105 110 Z_EVT_ZONE_BOOTING,
106 111 Z_EVT_ZONE_REBOOTING,
107 112 Z_EVT_ZONE_HALTED,
108 113 Z_EVT_ZONE_READIED,
109 114 Z_EVT_ZONE_UNINSTALLING,
110 115 Z_EVT_ZONE_BOOTFAILED,
111 116 Z_EVT_ZONE_BADARGS
112 117 } zone_evt_t;
113 118
114 119 extern int eventstream_init();
115 120 extern void eventstream_write(zone_evt_t evt);
116 121
117 122 /*
118 123 * Zone mount styles. Boot is the standard mount we do when booting the zone,
119 124 * scratch is the standard scratch zone mount for upgrade and update is a
120 125 * variation on the scratch zone where we don't lofs mount the zone's /etc
121 126 * and /var back into the scratch zone so that we can then do an
122 127 * 'update on attach' within the scratch zone.
123 128 */
124 129 typedef enum {
125 130 Z_MNT_BOOT = 0,
126 131 Z_MNT_SCRATCH,
127 132 Z_MNT_UPDATE
128 133 } zone_mnt_t;
129 134
130 135 /*
131 136 * Virtual platform interfaces.
132 137 */
133 138 extern zoneid_t vplat_create(zlog_t *, zone_mnt_t);
134 139 extern int vplat_bringup(zlog_t *, zone_mnt_t, zoneid_t);
135 140 extern int vplat_teardown(zlog_t *, boolean_t, boolean_t);
136 141 extern int vplat_get_iptype(zlog_t *, zone_iptype_t *);
137 142
138 143 /*
139 144 * Filesystem mounting interfaces.
140 145 */
141 146 extern int valid_mount_path(zlog_t *, const char *, const char *,
142 147 const char *, const char *);
143 148 extern int make_one_dir(zlog_t *, const char *, const char *,
144 149 mode_t, uid_t, gid_t);
145 150 extern void resolve_lofs(zlog_t *zlogp, char *path, size_t pathlen);
146 151
147 152 /*
148 153 * Console subsystem routines.
149 154 */
150 155 extern int init_console(zlog_t *);
151 156 extern void serve_console(zlog_t *);
152 157
153 158 /*
154 159 * Contract handling.
155 160 */
156 161 extern int init_template(void);
157 162
158 163 /*
159 164 * Routine to manage child processes.
160 165 */
161 166 extern int do_subproc(zlog_t *, char *, char **);
162 167
163 168 #ifdef __cplusplus
164 169 }
165 170 #endif
166 171
167 172 #endif /* _ZONEADMD_H */
↓ open down ↓ |
97 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX