1 # Copyright (C) 2013 GRNET S.A.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 local result_file result snapshot rc floppy blockdev
28 result_file=$(mktemp result.XXXXXX)
29 add_cleanup rm "$result_file"
31 report_info "Starting customization VM..."
32 echo "$($DATE +%Y:%m:%d-%H:%M:%S.%N) VM START" >&2
36 $TIMEOUT -k "$HELPER_HARD_TIMEOUT" "$HELPER_SOFT_TIMEOUT" \
37 kvm -runas "$HELPER_USER" -drive file="$HELPER_DIR/image",format=raw,if=virtio,readonly \
38 -drive file="$blockdev",format=raw,if=virtio,cache=none -m "$HELPER_MEMORY" \
39 -boot c -serial stdio -serial "file:$(printf "%q" "$result_file")" \
40 -serial file:>(./helper-monitor.py ${MONITOR_FD}) \
41 -fda "$floppy" -vga none -nographic -parallel none -monitor null \
42 -kernel "$HELPER_DIR/kernel" -initrd "$HELPER_DIR/initrd" \
43 -append "quiet ro root=/dev/vda1 console=ttyS0,9600n8 \
44 hypervisor=$HYPERVISOR snf_image_activate_helper \
45 rules_dev=/dev/fd0 init=/usr/bin/snf-image-helper" \
46 2>&1 | sed -u 's|^|HELPER: |g'
50 echo "$($DATE +%Y:%m:%d-%H:%M:%S.%N) VM STOP" >&2
54 report_info "Checking customization status..."
55 # Read the first line. This will remove \r and \n chars
56 result=$(sed 's|\r||g' "$result_file" | head -1)
57 report_info "Customization status is: $result"
59 check_helper_result "$result"
62 # vim: set sta sts=4 shiftwidth=4 sw=4 et ai :