4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
29 * RCM module for managing the OS Quiesce event (SUNW_OS) in a
30 * clustered environment.
42 #include <sys/param.h>
44 #include <sys/types.h>
46 #include <sys/cladm.h>
47 #include "rcm_module.h"
49 #define SUNW_OS "SUNW_OS"
50 #define OS_USAGE gettext("Sun Cluster")
51 #define OS_SUSPEND_ERR gettext("OS cannot be quiesced on clustered nodes")
52 #define OS_OFFLINE_ERR gettext("Invalid operation: OS cannot be offlined")
53 #define OS_REMOVE_ERR gettext("Invalid operation: OS cannot be removed")
55 static int cluster_register(rcm_handle_t
*);
56 static int cluster_unregister(rcm_handle_t
*);
57 static int cluster_getinfo(rcm_handle_t
*, char *, id_t
, uint_t
,
58 char **, char **, nvlist_t
*, rcm_info_t
**);
59 static int cluster_suspend(rcm_handle_t
*, char *, id_t
,
60 timespec_t
*, uint_t
, char **, rcm_info_t
**);
61 static int cluster_resume(rcm_handle_t
*, char *, id_t
, uint_t
,
62 char **, rcm_info_t
**);
63 static int cluster_offline(rcm_handle_t
*, char *, id_t
, uint_t
,
64 char **, rcm_info_t
**);
65 static int cluster_online(rcm_handle_t
*, char *, id_t
, uint_t
,
66 char **, rcm_info_t
**);
67 static int cluster_remove(rcm_handle_t
*, char *, id_t
, uint_t
,
68 char **, rcm_info_t
**);
70 static int cluster_SUNW_os_registered
= 0;
72 static struct rcm_mod_ops cluster_ops
=
91 return (&cluster_ops
);
97 return (gettext("RCM Cluster module 1.3"));
103 return (RCM_SUCCESS
);
107 cluster_register(rcm_handle_t
*hdl
)
111 if (cluster_SUNW_os_registered
)
112 return (RCM_SUCCESS
);
114 if (_cladm(CL_INITIALIZE
, CL_GET_BOOTFLAG
, &bootflags
) != 0) {
115 rcm_log_message(RCM_ERROR
,
116 gettext("unable to check cluster status\n"));
117 return (RCM_FAILURE
);
120 /* attempt to determine if we are in cluster mode */
122 if (bootflags
& CLUSTER_BOOTED
) {
123 if (rcm_register_interest(hdl
, SUNW_OS
, 0, NULL
) !=
125 rcm_log_message(RCM_ERROR
,
126 gettext("failed to register\n"));
127 return (RCM_FAILURE
);
129 cluster_SUNW_os_registered
= 1;
130 rcm_log_message(RCM_DEBUG
, "registered " SUNW_OS
135 return (RCM_SUCCESS
);
139 cluster_unregister(rcm_handle_t
*hdl
)
142 if (cluster_SUNW_os_registered
) {
143 if (rcm_unregister_interest(hdl
, SUNW_OS
, 0) !=
145 rcm_log_message(RCM_ERROR
,
146 gettext("failed to unregister"));
148 cluster_SUNW_os_registered
= 0;
150 return (RCM_SUCCESS
);
155 cluster_getinfo(rcm_handle_t
*hdl
, char *rsrcname
, id_t id
, uint_t flags
,
156 char **infostr
, char **errstr
, nvlist_t
*props
, rcm_info_t
**dependent
)
159 assert(rsrcname
!= NULL
&& infostr
!= NULL
);
161 if ((*infostr
= strdup(OS_USAGE
)) == NULL
)
162 rcm_log_message(RCM_ERROR
, gettext("strdup failure\n"));
164 return (RCM_SUCCESS
);
169 cluster_suspend(rcm_handle_t
*hdl
, char *rsrcname
, id_t id
,
170 timespec_t
*interval
, uint_t flags
, char **errstr
,
171 rcm_info_t
**dependent
)
173 if ((*errstr
= strdup(OS_SUSPEND_ERR
)) == NULL
)
174 rcm_log_message(RCM_ERROR
, gettext("strdup failure\n"));
176 return (RCM_FAILURE
);
181 cluster_resume(rcm_handle_t
*hdl
, char *rsrcname
, id_t id
, uint_t flags
,
182 char **errstr
, rcm_info_t
**dependent
)
184 return (RCM_SUCCESS
);
188 * By default, reject offline. If offline request is
189 * forced, attempt to relocate the cluster device.
193 cluster_offline(rcm_handle_t
*hdl
, char *rsrcname
, id_t id
, uint_t flags
,
194 char **errstr
, rcm_info_t
**dependent
)
196 if ((*errstr
= strdup(OS_OFFLINE_ERR
)) == NULL
)
197 rcm_log_message(RCM_ERROR
, gettext("strdup failure\n"));
199 return (RCM_FAILURE
);
204 cluster_online(rcm_handle_t
*hdl
, char *rsrcname
, id_t id
, uint_t flags
,
205 char **errstr
, rcm_info_t
**dependent
)
207 return (RCM_SUCCESS
);
212 cluster_remove(rcm_handle_t
*hdl
, char *rsrcname
, id_t id
, uint_t flags
,
213 char **errstr
, rcm_info_t
**dependent
)
215 if ((*errstr
= strdup(OS_REMOVE_ERR
)) == NULL
)
216 rcm_log_message(RCM_ERROR
, gettext("strdup failure\n"));
218 return (RCM_FAILURE
);