Re: [PATCH 4/4] Make s390 shutdown/reboot/halt more like other systems.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/01/2009 10:32 PM, Chris Lumens wrote:
> We don't need to do the reipl signal passing game when we could just have
> anaconda check a value and take the appropriate action at the end of
> installation.  This also gets linuxrc.s390 out of the reboot game entirely
> and makes it shutdown only in cases where anaconda exits abnormally.
> ---
>  anaconda            |   18 ++++++++++++++++--
>  iutil.py            |   13 -------------
>  loader/linuxrc.s390 |   26 +++-----------------------
>  3 files changed, 19 insertions(+), 38 deletions(-)
> 
> diff --git a/anaconda b/anaconda
> index f404f14..be5785c 100755
> --- a/anaconda
> +++ b/anaconda
> @@ -1088,9 +1088,23 @@ if __name__ == "__main__":
>          # default action for anaconda is to reboot, so we don't need to do
>          # that here.
>          if rc == 0 and anaconda.id.ksdata.reboot.action == KS_HALT:
> -            iutil.execWithRedirect("halt", [], searchPath=1)
> +            if iutil.isS390():
> +                iutil.execWithRedirect("shutdown", [], searchPath=1)

this exec

> +            else:
> +                iutil.execWithRedirect("halt", [], searchPath=1)
>          elif rc == 0 and anaconda.id.ksdata.reboot.action == KS_POWEROFF:
> -            iutil.execWithRedirect("poweroff", [], searchPath=1)
> +            if iutil.isS390():
> +                iutil.execWithRedirect("shutdown", ["-P"], searchPath=1)

this exec

> +            else:
> +                iutil.execWithRedirect("poweroff", [], searchPath=1)
> +    elif rc == 0 and iutil.isS390():

and the execs in this whole else case don't have to be s390 specific but
should rather do the same thing as for all other platforms, namely
exec'ing reboot/halt/poweroff which are in fact symlinks to the init
binary, which happens to be linuxrc.s390 in our case.

> +        # Only perform these actions if anaconda properly finished up.  If
> +        # anaconda has crashed, linuxrc.s390 will take care of how to shutdown
> +        # the machine.
> +        if anaconda.canReIPL:
> +            iutil.execWithRedirect("shutdown", ["-r"], searchPath=1)
> +        else:
> +            iutil.execWithRedirect("shutdown", [], searchPath=1)
> 
>      sys.exit(rc)

As mentioned in
http://git.fedorahosted.org/git/anaconda.git?h=f3d9882a64394c35c7d9e3de1b1ace265b794fcd
there are code paths in anaconda that directly exit without going
through the bottom of anaconda.py. E.g. the default installation ending,
when the user presses the reboot button in the GUI. In that case
http://git.fedorahosted.org/git/anaconda.git?h=8bc669549ddcc7040a5ba56b8afafa18684bac4e
calls the following and the anaconda object does not return:

    def _doExit (self, *args):
        gtk.main_quit()
        os._exit(0)

That's why I had to move the reIPLtrigger from the bottom of anaconda.py
to another place and defer the shutdown signaling in loader. That is not
to imply we should leave it as is. In fact, I like the removal of the
s390 specific signaling. Maybe the triggering of shutdown at the end of
anaconda.py should go into an exit handler?

> 
> diff --git a/loader/linuxrc.s390 b/loader/linuxrc.s390
> index a3ee665..acde20f 100644
> --- a/loader/linuxrc.s390
> +++ b/loader/linuxrc.s390
> @@ -93,24 +93,7 @@ function checkipv4()
>  function doshutdown()
>  {
>      echo $"about to exec shutdown"
> -    exec /sbin/shutdown
> -    exit 0
> -}
> -
> -function doreboot()
> -{
> -    if [ -e "/sys/firmware/reipl" ]; then
> -        read REIPL_TYPE < /sys/firmware/reipl/reipl_type
> -        echo "reipl_type=$REIPL_TYPE"
> -        pushd /sys/firmware/reipl/$REIPL_TYPE >/dev/null 2>&1
> -        for i in *; do
> -            echo "$i=`cat $i`"
> -        done
> -        popd >/dev/null 2>&1
> -    fi
> -
> -    echo $"about to exec shutdown -r"
> -    exec /sbin/shutdown -r
> +    exec /sbin/shutdown -h
>      exit 0
>  }
> 
> @@ -3054,17 +3037,14 @@ EOF
> 
>      echo -n $$ > /var/run/init.pid
> 
> -    # shutdown (halt) on SIGUSR1
> -    trap doshutdown SIGUSR1
> -    # reboot on SIGUSR2
> -    trap doreboot SIGUSR2
> -

We need signal handlers here just as in init.c, since
reboot/halt/poweroff are symlinks to init=linuxrc.s390 and init checks
its argv[0] to decide if it was called as reboot/halt/poweroff to then
signal the real init process with PID 1 for actually triggering the
shutdown. init.c calls shutDown() whereas linuxrc.s390 execs the
standalone shutdown containing the same function init.c calls directly.
As mentioned previously in
https://www.redhat.com/archives/anaconda-devel-list/2009-November/msg00417.html
shutdown only works if exec'ed from PID 1 since it kills PID -1 and thus
itself, if it was not the real init process (see also
https://bugzilla.redhat.com/show_bug.cgi?id=528380#c5).

>      startinetd
> 
>      if [ -n "$RUNKS" ]; then
>          /sbin/loader
>      fi
> 
> +    # We only ever get here if anaconda exits abnormally, as usually anaconda
> +    # handles calling shutdown for us.
>      doshutdown
> 
>  fi # testing

Steffen

Linux on System z Development

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294




_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux