From 2b8e0679960b50d6511b2ecde8b69afeb2f7402e Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Fri, 15 Sep 2006 04:32:28 +0000 Subject: [PATCH] Make vshelper reboot/halt work correctly when CONFIG_VSERVER_LEGACY is disabled and the helper is run synchronously. git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2312 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- scripts/functions | 24 ++++++++++++++++++++++++ scripts/vserver.stop | 2 ++ scripts/vshelper | 20 ++++++++++++++++---- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/scripts/functions b/scripts/functions index 0a21393..51318e7 100644 --- a/scripts/functions +++ b/scripts/functions @@ -1014,6 +1014,30 @@ function vshelper.getSyncTimeout eval $2=\$_vgst_tmp } +function vshelper.initStopSync +{ + local _iss_sync_dir=$($_MKTEMPDIR vshelper-stop-sync.XXXXXX) || { + warning $"Failed to generate directory for vshelper sync" + exit 1 + } + $_MKFIFO -m700 "$_iss_sync_dir/pipe" + + eval "$1"=\$_iss_sync_dir + VSHELPER_STOP_SYNC="$_iss_sync_dir/pipe" + export VSHELPER_STOP_SYNC +} + +function vshelper.waitForStopSync +{ + local sync_dir=$1 + cat "$sync_dir/pipe" &> /dev/null + rm -fr "$sync_dir" +} + +function vshelper.doStopSync +{ + test ! -p "$VSHELPER_STOP_SYNC" || echo stopped > "$VSHELPER_STOP_SYNC" +} function _rpmFake.getCapFlags { diff --git a/scripts/vserver.stop b/scripts/vserver.stop index 9a5b292..794ac5c 100644 --- a/scripts/vserver.stop +++ b/scripts/vserver.stop @@ -84,6 +84,8 @@ else "${INITCMD_STOP[@]}" || fail=1 fi +vshelper.doStopSync + waitForSync "$VSERVER_DIR" "$sync_fifo" "$vwait_statdir" vshelper.doDestroy "$VSERVER_DIR" "$S_CONTEXT" diff --git a/scripts/vshelper b/scripts/vshelper index 9738ba8..b9dfdf9 100755 --- a/scripts/vshelper +++ b/scripts/vshelper @@ -54,13 +54,25 @@ function doInternalMethod case "$ACTION" in (restart) logging $"Restarting vserver '$VSERVER'" - spawn killContext "$XID" - execute $_VSERVER --defaulttty "$VSERVER" restart + + local sync_dir + vshelper.initStopSync sync_dir + + spawn $_VSERVER --defaulttty "$VSERVER" restart & + + disown %% + vshelper.waitForStopSync "$sync_dir" ;; (halt|poweroff) logging $"Stopping vserver '$VSERVER'" - spawn killContext "$XID" - execute $_VSERVER --defaulttty "$VSERVER" stop + + local sync_dir + vshelper.initStopSync sync_dir + + spawn $_VSERVER --defaulttty "$VSERVER" stop & + + disown %% + vshelper.waitForStopSync "$sync_dir" ;; (swsusp) ## TODO: any senseful action here? Perhaps shutdown scheduler for it? -- 1.8.1.5