xref: /illumos-gate/usr/src/cmd/ldmad/ldoms-agents (revision e8d3efa1c56e5f2b5368600a2baeb7b1d54a07f8)
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 non-global zone."
43	smf_method_exit $SMF_EXIT_TEMP_DISABLE "non-global zone"
44fi
45
46#
47# The Logical Domains agents service is enabled by default on sun4v platforms.
48# However it can fail to start if the domain has a machine description in which
49# the vlds node is not defined (because it has an old MD or firmware). So we
50# check if a vlds device is effectively defined. If not then we disable the
51# service for this session. We don't return an error so that the service does
52# not go into the maintenance state and generate spurious error (especially if
53# the system is not configured with LDoms). The service is not permanently
54# disabled so that the service can come up if the domain is restarted with a
55# compatible MD.
56#
57if [ ! -c "$VLDS" ]; then
58	echo "The $SVCNAME service has been disabled because the system" \
59	    "has no virtual domain service (vlds) device."
60	smf_method_exit $SMF_EXIT_TEMP_DISABLE \
61	    "no virtual domain service (vlds) device"
62fi
63
64if [ ! -x "$LDMAD" ]; then
65	echo "The $SVCNAME service requires the $LDMAD executable."
66	exit "$SMF_EXIT_ERR_CONFIG"
67fi
68
69$LDMAD
70
71EXIT=$?
72
73if [ "$EXIT" != 0 ]; then
74	exit "$EXIT"
75fi
76
77exit "$SMF_EXIT_OK"
78