Make vshelper reboot/halt work correctly when CONFIG_VSERVER_LEGACY is disabled and...
authorDaniel Hokka Zakrisson <daniel@hozac.com>
Fri, 15 Sep 2006 04:32:28 +0000 (04:32 +0000)
committerDaniel Hokka Zakrisson <daniel@hozac.com>
Fri, 15 Sep 2006 04:32:28 +0000 (04:32 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2312 94cd875c-1c1d-0410-91d2-eb244daf1a30

scripts/functions
scripts/vserver.stop
scripts/vshelper

index 0a21393..51318e7 100644 (file)
@@ -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
 {
index 9a5b292..794ac5c 100644 (file)
@@ -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"
index 9738ba8..b9dfdf9 100755 (executable)
@@ -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?