Remove the boot and shutdown process in helper VM
authorNikos Skalkotos <skalkoto@grnet.gr>
Wed, 26 Sep 2012 12:05:10 +0000 (15:05 +0300)
committerNikos Skalkotos <skalkoto@grnet.gr>
Wed, 26 Sep 2012 12:05:10 +0000 (15:05 +0300)
Make snf-image-helper ran as init process when calling the helper
VM. Also make the helper VM shut down quickly by using the shut off
SysRq.

snf-image-helper/common.sh
snf-image-helper/snf-image-helper.in
snf-image-host/create

index e7f5ecb..5e2e27b 100644 (file)
@@ -85,6 +85,10 @@ report_error() {
     fi
 }
 
+system_poweroff() {
+    echo o > /proc/sysrq-trigger
+}
+
 get_base_distro() {
     local root_dir=$1
 
index 9d57ad5..9a1bc10 100644 (file)
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 # 02110-1301, USA.
 
-. @commondir@/common.sh
+PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
 
-set -e
+if [ $$ -eq 1 ]; then
+    mount / -o remount
+    /etc/init.d/udev start
+    hwclock -u -s
 
-if [ "x$1" != "x--force" ]; then
-    echo "WARNING: Exiting, this command would cause the system to halt." >&2
-    echo "Use --force if you know what you're doing." >&2
-    exit 1
+    (exec $0) &
+    wait
+    exit 0 # Hopefully this is never called...
 fi
 
+. @commondir@/common.sh
+
+set -e
+
 # terminate helper vm when the script exits
-add_cleanup telinit 0
+add_cleanup system_poweroff
 
 if [ ! -b "$FLOPPY_DEV" ]; then
     log_error "Floppy device is not present!"
index 0c5990a..f6f291a 100755 (executable)
@@ -176,7 +176,7 @@ $TIMEOUT -k "$HELPER_HARD_TIMEOUT" "$HELPER_SOFT_TIMEOUT" \
     -serial file:>(./helper-monitor.py ${MONITOR_FD}) \
     -fda "$floppy" -vga none -nographic -parallel none -monitor null \
     -kernel "$HELPER_KERNEL" -initrd "$HELPER_INITRD" \
-    -append "quiet ro root=/dev/sda1 console=ttyS0,9600n8 snf_image_activate_helper" \
+    -append "quiet ro root=/dev/sda1 console=ttyS0,9600n8 snf_image_activate_helper init=/usr/bin/snf-image-helper" \
     2>&1 | sed -u 's|^|HELPER: |g'
 rc=$?
 set -e