ec3d4d7c874bf95491d55fb56c1aa230049dc45c
[snf-image] / snf-image-host / xen-common.sh
1 snf_export_DEV=/dev/xvdb
2 HELPER_KERNEL=${HELPER_KERNEL}-xen
3 HELPER_INITRD=${HELPER_INITRD}-xen
4
5 mk_snapshot() {
6
7     cp "$HELPER_IMG" "$snapshot"
8
9 }
10
11 launch_helper() {
12
13     helper_name=helper$$
14     xm create /dev/null \
15       kernel="$HELPER_KERNEL" ramdisk="$HELPER_INITRD" \
16       extra="console=hvc0 hypervisor=$HYPERVISOR snf_image_activate_helper" \
17       disk="file:$snapshot,xvda,w" \
18       disk="phy:$blockdev,xvdb,w" \
19       disk="file:$floppy,xvdc1,w" \
20       vif="mac=aa:00:00:00:00:11,bridge=xenbr" \
21       memory="256" root="/dev/xvda1 quiet ro boot=local" boot="c" vcpus=1 \
22       name="$helper_name"
23
24     if [ ! $(xenstore-exists helper) ]; then
25         xenstore-write helper ""
26     fi
27     helperid=$(xm domid $helper_name)
28     xenstore-write helper/$helperid ""
29     xenstore-chmod helper/$helperid r0 w$helperid
30
31     brctl delif xenbr vif$helperid.0
32
33     socat EXEC:"./helper-monitor.py ${MONITOR_FD}" INTERFACE:vif$helperid.0 &
34
35     $TIMEOUT -k $HELPER_HARD_TIMEOUT $HELPER_SOFT_TIMEOUT \
36       socat EXEC:"xm console $helper_name",pty STDOUT \
37     | sed -u 's|^|HELPER: |g'
38
39 }
40
41 get_helper_result() {
42
43     result=$(xenstore-read helper/$helperid)
44     xenstore-rm helper/$helperid
45
46 }