Make sure the xen helper VM always terminates
authorNikos Skalkotos <skalkoto@grnet.gr>
Thu, 21 Feb 2013 17:07:24 +0000 (19:07 +0200)
committerNikos Skalkotos <skalkoto@grnet.gr>
Thu, 21 Feb 2013 17:07:24 +0000 (19:07 +0200)
snf-image-host/common.sh.in
snf-image-host/xen-common.sh

index d657c62..539920f 100644 (file)
@@ -318,11 +318,15 @@ EOF
    rm -rf "$target/etc/apt/preferences.d"
 }
 
-report_and_cleanup(){
+report_and_cleanup() {
     send_errors
     cleanup
 }
 
+suppress_errors() {
+    "$@" &> /dev/null || true
+}
+
 cleanup() {
     # if something fails here, it souldn't call cleanup again...
     trap - EXIT
index aec5876..33ff29a 100644 (file)
@@ -25,6 +25,7 @@ launch_helper() {
          ipv6.disable=1 rules_dev=/dev/xvdc ro boot=local init=/usr/bin/snf-image-helper" \
       disk="file:$HELPER_DIR/image,xvda,r" disk="phy:$blockdev,xvdb,w" \
       disk="file:$floppy,xvdc,r" vif="script=${XEN_SCRIPTS_DIR}/vif-snf-image"
+    add_cleanup suppress_errors xm destroy "$name"
 
     if ! xenstore-exists snf-image-helper; then
         xenstore-write snf-image-helper ""
@@ -36,7 +37,8 @@ launch_helper() {
     add_cleanup xenstore-rm snf-image-helper/${helperid}
     xenstore-chmod snf-image-helper/${helperid} r0 w${helperid}
 
-    socat EXEC:"./helper-monitor.py ${MONITOR_FD}" INTERFACE:vif${helperid}.0 &
+    socat INTERFACE:vif${helperid}.0 EXEC:"./helper-monitor.py ${MONITOR_FD}" &
+    monitor_pid=$!
 
     set +e