From b2bffe915fc23201c007043d16358d66c994c48d Mon Sep 17 00:00:00 2001 From: Nikos Skalkotos Date: Wed, 26 Sep 2012 15:05:10 +0300 Subject: [PATCH] Remove the boot and shutdown process in helper VM 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 | 4 ++++ snf-image-helper/snf-image-helper.in | 20 +++++++++++++------- snf-image-host/create | 2 +- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/snf-image-helper/common.sh b/snf-image-helper/common.sh index e7f5ecb..5e2e27b 100644 --- a/snf-image-helper/common.sh +++ b/snf-image-helper/common.sh @@ -85,6 +85,10 @@ report_error() { fi } +system_poweroff() { + echo o > /proc/sysrq-trigger +} + get_base_distro() { local root_dir=$1 diff --git a/snf-image-helper/snf-image-helper.in b/snf-image-helper/snf-image-helper.in index 9d57ad5..9a1bc10 100644 --- a/snf-image-helper/snf-image-helper.in +++ b/snf-image-helper/snf-image-helper.in @@ -17,18 +17,24 @@ # 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!" diff --git a/snf-image-host/create b/snf-image-host/create index 0c5990a..f6f291a 100755 --- a/snf-image-host/create +++ b/snf-image-host/create @@ -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 -- 1.7.10.4