Print this page
2594 implement graceful shutdown for local zones in zoneadm

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/zoneadm/svc-zones
          +++ new/usr/src/cmd/zoneadm/svc-zones
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14  # When distributing Covered Code, include this CDDL HEADER in each
  15   15  # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16   16  # If applicable, add the following below this CDDL HEADER, with the
  17   17  # fields enclosed by brackets "[]" replaced with your own identifying
  18   18  # information: Portions Copyright [yyyy] [name of copyright owner]
  19   19  #
  20   20  # CDDL HEADER END
  21   21  #
  22   22  #
  23   23  # Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
       24 +# Copyright 2014 Nexenta Systems, Inc. All rights reserved.
  24   25  
  25   26  . /lib/svc/share/smf_include.sh
  26   27  
  27   28  #
  28   29  # Return a list of running, non-global zones for which a shutdown via
  29   30  # "/sbin/init 0" may work (typically only Solaris zones.)
  30   31  #
  31   32  shutdown_zones()
  32   33  {
  33   34          zoneadm list -p | nawk -F: '{
↓ open down ↓ 68 lines elided ↑ open up ↑
 102  103  
 103  104          zonelist=`shutdown_zones`
 104  105  
 105  106          if [ -n "$zonelist" ]; then
 106  107                  SHUTDOWN=0
 107  108                  echo "Shutting down running zones (for up to $MAXSHUT" \
 108  109                      "seconds):\c"
 109  110  
 110  111                  for zone in $zonelist; do
 111  112                          echo " $zone\c"
 112      -                        zlogin -S $zone /sbin/init 0 < /dev/null >&0 2>&0 &
      113 +                        zoneadm -z $zone shutdown &
 113  114                          SHUTDOWN=1
 114  115                  done
 115  116  
 116  117                  [ $SHUTDOWN -eq 1 ] && echo "."
 117  118  
 118  119                  # Allow time for zones to shutdown cleanly
 119  120  
 120  121                  while [ $MAXSHUT -gt 0 -a "`shutdown_zones`" != "" ]; do
 121  122                          MAXSHUT=`expr $MAXSHUT - 1`
 122  123                          sleep 1 # wait a bit longer
↓ open down ↓ 53 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX