6 local name helperid rc blockdev floppy
13 kernel="$HELPER_KERNEL" ramdisk="$HELPER_INITRD" root="/dev/xvda1" \
14 extra="console=hvc0 hypervisor=$HYPERVISOR snf_image_activate_helper quiet ro boot=local" \
15 disk="file:${HELPER_IMG},xvda,w" disk="phy:$blockdev,xvdb,w" \
16 disk="file:$floppy,xvdc,r" vif="mac=aa:00:00:00:00:11,bridge=$XEN_BRIDGE" \
17 memory="256" boot="c" vcpus=1 name="$name"
19 if ! xenstore-exists snf-image-helper; then
20 xenstore-write snf-image-helper ""
21 #add_cleanup xenstore-rm snf-image-helper
24 helperid=$(xm domid "$name")
25 xenstore-write snf-image-helper/${helperid} ""
26 add_cleanup xenstore-rm snf-image-helper/${helperid}
27 xenstore-chmod snf-image-helper/${helperid} r0 w${helperid}
29 brctl delif xenbr "vif${helperid}.0"
31 socat EXEC:"./helper-monitor.py ${MONITOR_FD}" INTERFACE:vif${helperid}.0 &
35 $TIMEOUT -k $HELPER_HARD_TIMEOUT $HELPER_SOFT_TIMEOUT \
36 socat EXEC:"xm console $name",pty STDOUT | sed -u 's|^|HELPER: |g'
41 if [ $rc -ne 0 ]; then
42 if [ $rc -eq 124 ]; then
43 log_error "Image customization was terminated. Did not finish on time."
44 elif [ $rc -eq 137 ]; then # (128 + SIGKILL)
45 log_error "Image customization was killed. Did not finish on time."
46 elif [ $rc -eq 141 ]; then # (128 + SIGPIPE)
47 log_error "Image customization was terminated by a SIGPIPE."
48 log_error "Maybe progress monitor has died unexpectedly."
49 elif [ $rc -eq 125 ]; then
50 log_error "Internal Error. Image customization could not start."
51 log_error "timeout did not manage to run."
53 log_error "Image customization died unexpectedly (return code $rc)."
57 echo -n "$(date +%Y:%m:%d-%H:%M:%S.%N)" >&2
58 log_info "Customization VM finished."
61 result=$(xenstore-read snf-image-helper/$helperid)
63 if [ "x$result" != "xSUCCESS" ]; then
64 log_error "Image customization failed."