6 local name helperid rc blockdev floppy
13 report_info "Starting customization VM..."
14 echo "$($DATE +%Y:%m:%d-%H:%M:%S.%N) VM START" >&2
17 kernel="$HELPER_DIR/kernel-xen" ramdisk="$HELPER_DIR/initrd-xen" \
18 root="/dev/xvda1" memory="256" boot="c" vcpus=1 name="$name" \
19 extra="console=hvc0 hypervisor=$HYPERVISOR snf_image_activate_helper \
20 rules_dev=/dev/xvdc quiet ro boot=local init=/usr/bin/snf-image-helper" \
21 disk="file:$HELPER_DIR/image,xvda,r" disk="phy:$blockdev,xvdb,w" \
22 disk="file:$floppy,xvdc,r" vif="mac=aa:00:00:00:00:11,bridge=$XEN_BRIDGE" \
24 if ! xenstore-exists snf-image-helper; then
25 xenstore-write snf-image-helper ""
26 #add_cleanup xenstore-rm snf-image-helper
29 helperid=$(xm domid "$name")
30 xenstore-write snf-image-helper/${helperid} ""
31 add_cleanup xenstore-rm snf-image-helper/${helperid}
32 xenstore-chmod snf-image-helper/${helperid} r0 w${helperid}
34 brctl delif xenbr "vif${helperid}.0"
36 socat EXEC:"./helper-monitor.py ${MONITOR_FD}" INTERFACE:vif${helperid}.0 &
40 $TIMEOUT -k $HELPER_HARD_TIMEOUT $HELPER_SOFT_TIMEOUT \
41 socat EXEC:"xm console $name",pty STDOUT | sed -u 's|^|HELPER: |g'
46 echo "$($DATE +%Y:%m:%d-%H:%M:%S.%N) VM STOP" >&2
47 if [ $rc -ne 0 ]; then
48 if [ $rc -eq 124 ]; then
49 log_error "Customization VM was terminated. Did not finish on time."
50 report_error "Image customization failed. Did not finish on time."
51 elif [ $rc -eq 137 ]; then # (128 + SIGKILL)
52 log_error "Customization VM was killed. Did not finish on time."
53 report_error "Image customization failed. Did not finish on time."
54 elif [ $rc -eq 141 ]; then # (128 + SIGPIPE)
55 log_error "Customization VM was terminated by a SIGPIPE."
56 log_error "Maybe progress monitor has died unexpectedly."
57 elif [ $rc -eq 125 ]; then
58 log_error "Internal Error. Image customization could not start."
59 log_error "timeout did not manage to run."
61 log_error "Customization VM died unexpectedly (return code $rc)."
65 report_info "Customization VM exited normally."
68 report_info "Checking customization status..."
69 result=$(xenstore-read snf-image-helper/$helperid)
70 report_info "Customization status is: $result"
72 if [ "x$result" != "xSUCCESS" ]; then
73 log_error "Image customization failed."
74 report_error "Image customization failed."