xref: /titanic_50/usr/src/cmd/ldmad/ldoms-agents (revision 3d729aecc03ea6ebb9bd5d56b8dccd24f57daa41)
1#!/bin/sh
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22
23#
24# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26#
27
28. /lib/svc/share/smf_include.sh
29
30SVCNAME='Logical Domains agents'
31LDMAD='/usr/lib/ldoms/ldmad'
32VLDS='/devices/virtual-devices@100/channel-devices@200/virtual-domain-service@0:vlds'
33mach=`/sbin/uname -m`
34
35if [ "$mach" != "sun4v" ]; then
36	echo "The $SVCNAME service is not supported on this platform."
37	exit "$SMF_EXIT_ERR_FATAL"
38fi
39
40if smf_is_nonglobalzone; then
41	echo "The $SVCNAME service has been disabled because " \
42	    "it is not supported in a local zone."
43	/usr/sbin/svcadm disable "$SMF_FMRI"
44	sleep 5 &
45	exit "$SMF_EXIT_OK"
46fi
47
48#
49# The Logical Domains agents service is enabled by default on sun4v platforms.
50# However it can fail to start if the domain has a machine description in which
51# the vlds node is not defined (because it has an old MD or firmware). So we
52# check if a vlds device is effectively defined. If not then we disable the
53# service for this session. We don't return an error so that the service does
54# not go into the maintenance state and generate spurious error (especially if
55# the system is not configured with LDoms). The service is not permanently
56# disabled so that the service can come up if the domain is restarted with a
57# compatible MD.
58#
59if [ ! -c "$VLDS" ]; then
60	echo "The $SVCNAME service has been disabled because the system" \
61	    "has no virtual domain service (vlds) device."
62	/usr/sbin/svcadm disable -t "$SMF_FMRI"
63	sleep 5 &
64	exit "$SMF_EXIT_OK"
65fi
66
67if [ ! -x "$LDMAD" ]; then
68	echo "The $SVCNAME service requires the $LDMAD executable."
69	exit "$SMF_EXIT_ERR_CONFIG"
70fi
71
72$LDMAD
73
74EXIT=$?
75
76if [ "$EXIT" != 0 ]; then
77	exit "$EXIT"
78fi
79
80exit "$SMF_EXIT_OK"
81