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