\ ========== Copyright Header Begin ==========================================
\ Hypervisor Software File: multipath-boot.fth
\ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
\ - Do no alter or remove copyright notices
\ - Redistribution and use of this software in source and binary forms, with
\ or without modification, are permitted provided that the following
\ - Redistribution of source code must retain the above copyright notice,
\ this list of conditions and the following disclaimer.
\ - Redistribution in binary form must reproduce the above copyright notice,
\ this list of conditions and the following disclaimer in the
\ documentation and/or other materials provided with the distribution.
\ Neither the name of Sun Microsystems, Inc. or the names of contributors
\ may be used to endorse or promote products derived from this software
\ without specific prior written permission.
\ This software is provided "AS IS," without a warranty of any kind.
\ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
\ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
\ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
\ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
\ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
\ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
\ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
\ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
\ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
\ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
\ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
\ You acknowledge that this software is not designed, licensed or
\ intended for use in the design, construction, operation or maintenance of
\ ========== Copyright Header End ============================================
id: @(#)multipath-boot.fth 1.5 07/02/27
copyright: Copyright 2007 Sun Microsystems, Inc. All rights reserved.
copyright: Copyright 2007 Fujitsu Limited. All Rights Reserved.
copyright: Use is subject to license terms.
\ Multipath boot controlling methods
\ OS --+---> cif: boot --> $reboot-hook : mpb-$reboot-hook
\ | Increment boot-device-index when called due to
\ | unsuccessful boot. Abort rebooting if all devices
\ | have failed in boot-device configuration.
\ +---> cif: exit --> client-fail-exited-chain : mpb-fail-exited-chain
\ | Increment boot-device-index when called due to
\ | unsuccessful boot. Reboot if alternative available
\ | devices are left in boot-device configuration.
\ +---> XIR --> (arch/sun4ju/error-reset.fth)
\ +---> error trap --> Degrade and reset
\ +---> FATAL --> Clear Reset. SCF might degrade the fault unit.
\ +---> POFF/PON --> Clear Reset
\ +---> hangup --> SCF might issue XIR
\ +---> XIR --> (arch/sun4ju/error-reset.fth)
false value boot-path-specified?
\ Create multipath-boot property in chosen node.
\ This property is created at run time by obp to indicate that
\ boot device was picked up from "boot-device" config variable
\ and "multipath-boot?" configuration-variable is currently
: make-multipath-boot-property ( -- )
0 0 encode-bytes " multipath-boot" property
: no-available-device-error ( -- )
cmn-error[ " All device paths in boot-device have failed." ]cmn-end
: all-devices-failed? ( -- flag )
count-words boot-device-index < ( flag )
\ Indicate if multipath-boot (mpb) is enabled or not.
: mpb-enable? ( -- enable? )
multipath-boot? ( enable? )
diagnostic-mode? 0= and ( enable?' )
boot-path-specified? 0= and ( enabled? )
: increment-boot-device-index ( -- )
boot-device-index 1+ to boot-device-index
: multipath-default-device ( -- $devname )
false to boot-path-specified? ( )
(default-device) ( devname$ )
boot-device ( devnames$ )
boot-device-index 0 ( devnames$ index 0 )
-leading bl left-parse-string ( right$ left$ )
??cr ." skip boot device '" 2dup type ." '" cr
strip-blanks dup ( devnames$ len )
bl left-parse-string ( right$ left$ )
??cr ." current boot index : " boot-device-index .d
." current boot device '" 2dup type ." '" cr
2dup locate-device 0= if ( right$ left$ phandle )
device-status-ok? if ( right$ left$ )
2dup open-dev ?dup if ( right$ left$ ihandle )
close-dev 2swap 2drop ( left$ )
\ Create multipath-boot property
make-multipath-boot-property
default-device-hook ( right$ left$ )
increment-boot-device-index ( right$ )
no-available-device-error ( )
' multipath-default-device to default-device
\ Check and detect the multipath boot failure.
\ - error-reset-recovery, and
\ - the failure case of opening boot-device, and
\ - and case where OBP detects some error but could not identify the
\ The multipath boot failure is determined if
\ - OBP has not relinquished its trap handling to the client program
\ although we are in process of those methods
\ if multipath-boot feature is enabled.
\ Case caused by command line operation is excluded.
: multipath-boot-failed? ( -- failed? )
already-go? and ( failed? ) \ open-dev succeed?
obp-control-relinquished? 0= and ( failed?' ) \ boot-failed or shutdowned
ok-prompt? 0= and ( failed?'') \ not commandline operation?
\ Set boot-path-specified? to default value.
defer old-mpb-$boot-load-hook
' $boot-load-hook behavior is old-mpb-$boot-load-hook
: mpb-$boot-load-hook ( -- )
true to boot-path-specified? \ default setting
' mpb-$boot-load-hook is $boot-load-hook
\ Reboot for multipath-boot feature. Ignore path-buf to continue autoboot.
args-buf cscount " " " boot" $restart ( )
\ Common code to detect and recover the multipath boot failure.
\ This code is supposed to be called in
\ - rebooting via "$reboot", CIF "exit"
\ - the case where load of boot-device fail in "boot-read" or "$boot"
\ - the case where OBP detects some error but could not identify
\ This code checks if those methods are called due to multipath boot failure.
\ If so, increment boot-device-index. Then, if any other alternative
\ boot-device is present, take the specified action: force the system to
\ reboot so that we can try the next possible boot-device, or to do nothing
\ but exit. If all boot-devices fail, abort to drop at OBP prompt with an
: boot-failure-recovery ( force-reboot? -- )
multipath-boot-failed? 0= if
increment-boot-device-index ( reboot? )
all-devices-failed? if ( reboot? )
\ Drop at OBP prompt if all boot-devices fail.
no-available-device-error ( )
\ Force reboot if specified.
\ path-buf will be ignored to continue autoboot.
\ Hook "$reboot", which is called by CIF "boot' and "$load", to check
\ and recover the multipath-boot failure. Even if OBP detects a boot
\ failure and can select alternate device from "boot-device"
\ configuration, this method does nothing but exit. Subsequent
\ "$reboot" code is expected to reboot the system.
defer old-mpb-$reboot-hook
' $reboot-hook behavior is old-mpb-$reboot-hook
false boot-failure-recovery
' mpb-$reboot-hook is $reboot-hook
\ Called to hook the methods except "$reboot". If OBP detects
\ multipath boot failure and can select alternate device from
\ "boot-device" configuration, force to reboot the system.
: mpb-recovery-with-reboot ( -- )
true boot-failure-recovery
' mpb-recovery-with-reboot is cmn-end-mpb-recovery
\ Hook CIF "exit" to check and recover the multipath-boot failure
defer old-mpb-fail-exited-chain
: mpb-fail-exited-chain ( -- )
old-mpb-fail-exited-chain
\ Hook CIF "SUNW,set-trap-table" to initialize boot-device-index
defer old-mpb-starting-chain
: mpb-starting-chain ( -- )
\ reset the index value at SUNW,set-trap-table only if it is non-zero
\ Following hooks must be installed at stand-init, because
\ these chains are initialized to noop at cleanup on make.
stand-init: Install multipath boot hooks
['] client-fail-exited-chain behavior is old-mpb-fail-exited-chain
['] mpb-fail-exited-chain is client-fail-exited-chain
['] client-starting-chain behavior is old-mpb-starting-chain
['] mpb-starting-chain is client-starting-chain