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 # Copyright 2017 RackTop Systems.
  28 #
  29 
  30 . /lib/svc/share/smf_include.sh
  31 
  32 SVCNAME='Logical Domains agents'
  33 LDMAD='/usr/lib/ldoms/ldmad'
  34 VLDS='/devices/virtual-devices@100/channel-devices@200/virtual-domain-service@0:vlds'
  35 mach=`/sbin/uname -m`
  36 
  37 if [ "$mach" != "sun4v" ]; then
  38         echo "The $SVCNAME service is not supported on this platform."
  39         exit "$SMF_EXIT_ERR_FATAL"
  40 fi
  41 
  42 if smf_is_nonglobalzone; then
  43         echo "The $SVCNAME service has been disabled because " \
  44             "it is not supported in a local zone."
  45         /usr/sbin/svcadm disable "$SMF_FMRI"
  46         exit "$SMF_EXIT_TEMP_TRANSIENT"
  47 fi
  48 
  49 #
  50 # The Logical Domains agents service is enabled by default on sun4v platforms.
  51 # However it can fail to start if the domain has a machine description in which
  52 # the vlds node is not defined (because it has an old MD or firmware). So we
  53 # check if a vlds device is effectively defined. If not then we disable the
  54 # service for this session. We don't return an error so that the service does
  55 # not go into the maintenance state and generate spurious error (especially if
  56 # the system is not configured with LDoms). The service is not permanently
  57 # disabled so that the service can come up if the domain is restarted with a
  58 # compatible MD.
  59 #
  60 if [ ! -c "$VLDS" ]; then
  61         echo "The $SVCNAME service has been disabled because the system" \
  62             "has no virtual domain service (vlds) device."
  63         /usr/sbin/svcadm disable -t "$SMF_FMRI"
  64         exit "$SMF_EXIT_TEMP_TRANSIENT"
  65 fi
  66 
  67 if [ ! -x "$LDMAD" ]; then
  68         echo "The $SVCNAME service requires the $LDMAD executable." 
  69         exit "$SMF_EXIT_ERR_CONFIG"
  70 fi
  71 
  72 $LDMAD
  73 
  74 EXIT=$?
  75 
  76 if [ "$EXIT" != 0 ]; then
  77         exit "$EXIT"
  78 fi
  79 
  80 exit "$SMF_EXIT_OK"