Commit 21063d2d authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

Make helper_ip and monitor_port configurable

Let the host system provide those values to the helper through the
kernel command line.
parent eb5554b1
......@@ -44,11 +44,6 @@ MSG_TYPE_TASK_END="TASK_END"
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
......@@ -75,7 +70,7 @@ send_result_xen() {
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() {
......@@ -83,14 +78,22 @@ 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
......@@ -98,6 +101,14 @@ prepare_helper() {
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
......
......@@ -22,7 +22,8 @@ launch_helper() {
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"
......@@ -37,7 +38,7 @@ launch_helper() {
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=$!
......@@ -57,7 +58,7 @@ launch_helper() {
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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment