STDERR_LINE_SIZE=10
-IP="10.0.0.1"
-NETWORK="$IP/24"
-BROADCAST="${IP%.*}.255"
-PORT="48000"
-
add_cleanup() {
local cmd=""
for arg; do cmd+=$(printf "%q " "$arg"); done
send_monitor_message_xen() {
#Broadcast the message
- echo "$@" | socat STDIO UDP-DATAGRAM:${BROADCAST}:${PORT},broadcast
+ echo "$@" | socat "STDIO" "UDP-DATAGRAM:${BROADCAST}:${MONITOR_PORT},broadcast"
}
prepare_helper() {
read -a cmdline < /proc/cmdline
for item in "${cmdline[@]}"; do
- key=$(cut -d= -f1 <<< "$item")
- val=$(cut -d= -f2 <<< "$item")
- if [ "$key" = "hypervisor" ]; then
- hypervisor="$val"
- fi
- if [ "$key" = "rules_dev" ]; then
- export RULES_DEV="$val"
- fi
+ key=$(cut -d= -f1 <<< "$item")
+ val=$(cut -d= -f2 <<< "$item")
+ if [ "$key" = "hypervisor" ]; then
+ hypervisor="$val"
+ fi
+ if [ "$key" = "rules_dev" ]; then
+ export RULES_DEV="$val"
+ fi
+ if [ "$key" = "helper_ip" ]; then
+ export IP="$val"
+ export NETWORK="$IP/24"
+ export BROADCAST="${IP%.*}.255"
+ fi
+ if [ "$key" = "monitor_port" ]; then
+ export MONITOR_PORT="$val"
+ fi
done
case "$hypervisor" in
HYPERVISOR=kvm
;;
xen-hvm|xen-pvm)
+ if [ -z "$IP" ]; then
+ echo "ERROR: \`helper_ip' not defined or empty" >&2
+ exit 1
+ fi
+ if [ -z "$MONITOR_PORT" ]; then
+ echo "ERROR: \`monitor_port' not defined or empty" >&2
+ exit 1
+ fi
$MOUNT -t xenfs xenfs /proc/xen
ip addr add "$NETWORK" dev eth0
ip link set eth0 up
kernel="$HELPER_DIR/kernel-xen" ramdisk="$HELPER_DIR/initrd-xen" \
root="/dev/xvda1" memory="256" boot="c" vcpus=1 name="$name" \
extra="console=hvc0 hypervisor=$HYPERVISOR snf_image_activate_helper \
- ipv6.disable=1 rules_dev=/dev/xvdc ro boot=local init=/usr/bin/snf-image-helper" \
+ ipv6.disable=1 rules_dev=/dev/xvdc ro boot=local helper_ip=10.0.0.1 \
+ monitor_port=48888 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"
add_cleanup xenstore-rm snf-image-helper/${helperid}
xenstore-chmod snf-image-helper/${helperid} r0 w${helperid}
- filter='udp and dst port 48000 and dst host 10.0.0.255 and src host 10.0.0.1'
+ filter='udp and dst port 48888 and dst host 10.0.0.255 and src host 10.0.0.1'
$TIMEOUT -k $HELPER_HARD_TIMEOUT $HELPER_SOFT_TIMEOUT \
./helper-monitor.py -i "vif${helperid}.0" -f "$filter" ${MONITOR_FD} &
monitor_pid=$!
monitor_rc=$?
set -e
- if [ $monitor_rc -ne 0 ];
+ if [ $monitor_rc -ne 0 ]; then
log_error "Helper VM monitoring failed"
report_error "Helper VM monitoring failed"
exit 1