Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 216944 - sys-apps/openrc: needs to create /reboot on reboot for openvz systems
Summary: sys-apps/openrc: needs to create /reboot on reboot for openvz systems
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-08 19:47 UTC by Anthony Sowden
Modified: 2008-05-16 13:32 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Anthony Sowden 2008-04-08 19:47:19 UTC
Openvz (and maybe other virtualisation systems?) require a /reboot file to be created immediately prior to reboot, to flag the host node to restart the virtual server.  If this file is not created, the host node has no way to distinguish a reboot from a shutdown, and the virtual server will be left stopped.

For normal reboot, the last openrc script to run is /etc/init.d/halt.sh.  This script already has been modified to support virtual systems.  A simple additional change will create the needed file at the right time:

diff -ur a/init.d/halt.sh.in b/init.d/halt.sh.in
--- a/init.d/halt.sh.in 2008-04-02 17:35:28.000000000 +0100
+++ b/init.d/halt.sh.in 2008-04-08 19:32:51.000000000 +0100
@@ -28,6 +28,7 @@
 #   1) we don't need (and by default can't) umount anything (VServer) or
 #   2) the host utils take care of all umounting stuff (OpenVZ)
 if [ "${RC_SYS}" = "VSERVER" -o "${RC_SYS}" = "OPENVZ" ]; then
+       [ "$1" = "reboot" -a "${RC_SYS}" = "OPENVZ" ] && >/reboot
        if [ -e @SYSCONFDIR@/init.d/"$1".sh ]; then
                . @SYSCONFDIR@/init.d/"$1".sh
        else


Reproducible: Always

Steps to Reproduce:
1.Install openrc on otherwise stable system
2.Start VPS under OpenVZ
3.Attempt to reboot by '/sbin/reboot' or '/sbin/shutdown -r now'

Actual Results:  
VPS shuts down instead of rebooting

Expected Results:  
VPS should have been restarted by the host node following a request to reboot

Creating a /reboot file before issuing the reboot request fixes the problem.

The suggested fix will not cater for '/sbin/reboot -f'.

/etc/init.d/reboot.sh could be modified, but this script is part of the init package (sysvinit on my system) which does not "know" about virtual servers.  Openrc seems the logical package to me.

The suggested fix will not work on some older openvz systems.  On these systems, a bug in openvz means that killall5 (invoked by halt.sh) actually kills the init process, which prevents the rest of halt.sh from running (the system does however shutdown).  See http://bugzilla.openvz.org/show_bug.cgi?id=533.
Comment 1 SpanKY gentoo-dev 2008-04-08 20:32:48 UTC
it belongs in reboot.sh, not halt.sh
Comment 2 Doug Goldstein (RETIRED) gentoo-dev 2008-04-08 20:37:15 UTC
Does Vserver need this or only OpenVZ?
Comment 3 Benedikt Böhm (RETIRED) gentoo-dev 2008-04-08 21:20:12 UTC
(In reply to comment #2)
> Does Vserver need this or only OpenVZ?

no, not needed, since sys_reboot is virtualized, and can distinguish between shutdown and restart
Comment 4 Doug Goldstein (RETIRED) gentoo-dev 2008-04-15 05:55:32 UTC
fixed in openrc-0.2.1-r2
Comment 5 Anthony Sowden 2008-04-15 16:41:58 UTC
Openrc-0.2.1-r2 includes the fix for openvz bug 215167, but not this one.

Re-opened.

Logically I agree with comment 1 that the fix should be in reboot.sh.

However, RC_SYS is a variable set by the openrc scripts, and using it in reboot.sh, which is part of sysvinit, creates an implicit cross-package dependency.  The current version of reboot.sh already references an old variable left over from the earlier version of baselayout (RC_DOWN_INTERFACE).

To keep package boundaries clear, I'd modify halt.sh, part of openrc, which already contains logic that relies on RC_SYS.
Comment 6 Doug Goldstein (RETIRED) gentoo-dev 2008-04-15 16:49:13 UTC
gah. I closed the wrong bug. sorry.
Comment 7 Roy Marples 2008-04-15 21:51:05 UTC
(In reply to comment #5)
> To keep package boundaries clear, I'd modify halt.sh, part of openrc, which
> already contains logic that relies on RC_SYS.

Can't fault that logic. I've fixed halt.sh accordingly and attributed the fix to you in my git repo. Will be in openrc-0.2.3 or newer.
Comment 8 Anthony Sowden 2008-05-16 13:32:55 UTC
I can confirm that openrc now fixes this problem (0.2.4 tested).

Many thanks.