Commit 1ea8db72 authored by Dimitris Aragiorgis's avatar Dimitris Aragiorgis
Browse files

Use socat to dump helper messages in case of xen



Helper gets a dummy interface and communication between helper
and host is done via socat STDIO INTERFACE:eth0/vif$helperid.0
Signed-off-by: default avatarDimitris Aragiorgis <dimara@grnet.gr>
parent e9413eab
......@@ -46,29 +46,39 @@ STDERR_LINE_SIZE=10
case "$hypervisor" in
kvm)
FLOPPY_DEV=/dev/fd0
ROOT_FSTAB_ENTRY=/dev/sda1
IMG_DEV=/dev/vda
RESULT=/dev/ttyS1
MONITOR=/dev/ttyS2
;;
xen-hvm|xen-pvm)
FLOPPY_DEV=/dev/xvdc1
ROOT_FSTAB_ENTRY=/dev/xvda1
IMG_DEV=/dev/xvdb
RESULT=/dev/hvc0
MONITOR=/dev/hvc0
;;
esac
to_monitor() {
echo "HELPER_MONITOR_$@" > "$MONITOR"
case $hypervisor in
kvm)
echo "HELPER_MONITOR_$@" > "$MONITOR"
;;
xen-pvm|xen-hvm)
echo "HELPER_MONITOR_$@" | socat STDIO INTERFACE:eth0
;;
esac
}
to_result() {
echo "HELPER_RESULT_$@" > "$RESULT"
case $hypervisor in
kvm)
echo "HELPER_RESULT_$@" > "$RESULT"
;;
xen-pvm|xen-hvm)
domid=$(xenstore-read domid)
xenstore-write /local/domain/0/helper/$domid "HELPER_RESULT_$@"
;;
esac
}
......@@ -88,7 +98,7 @@ log_error() {
warn() {
echo "Warning: $@" >&2
to_monitor "WARNING:$@"
to_monitor "WARNING: $@"
}
report_task_start() {
......@@ -423,15 +433,7 @@ check_if_excluded() {
return_success() {
case $hypervisor in
kvm)
echo "SUCCESS" > "$RESULT"
;;
xen-pvm|xen-kvm)
domid=$(xenstore-read domid)
xenstore-write /local/domain/0/helper/$domid SUCCESS
;;
esac
to_result SUCCESS
}
......
......@@ -388,7 +388,7 @@ fi
: ${HELPER_USER:="nobody"}
: ${HELPER_CACHE_FILE:="@HELPER_DIR@/cache.tar"}
: ${HELPER_CACHE_PKGS:="@HELPER_DIR@/packages"}
: ${HELPER_EXTRA_PKGS:="xenstore-utils,e2fsprogs,ntfs-3g,ntfsprogs,xmlstarlet,python,parted,reglookup,chntpw,util-linux"}
: ${HELPER_EXTRA_PKGS:="iproute,socat,xenstore-utils,e2fsprogs,ntfs-3g,ntfsprogs,xmlstarlet,python,parted,reglookup,chntpw,util-linux"}
: ${HELPER_LINUX_IMAGE_PKG:="linux-image-amd64"}
: ${HELPER_LINUX_IMAGE_XEN_PKG:="linux-image-xen-amd64"}
: ${HELPER_MIRROR:=""}
......
......@@ -148,7 +148,7 @@ jail=$(mktemp -d --tmpdir tmpfsXXXXXXX)
add_cleanup rmdir "$jail"
mount tmpfs -t tmpfs "$jail" -o size=1G
add_cleanup umount "$jail"
add_cleanup umount -l "$jail"
result_file=$(mktemp --tmpdir="$jail" result.XXXXXX)
add_cleanup rm "$result_file"
......@@ -188,7 +188,7 @@ fi
get_helper_result
if [ "x$result" != "xSUCCESS" ]; then
if [ "x$result" != "xHELPER_RESULT_SUCCESS" ]; then
log_error "Image customization failed."
exit 1
fi
......
......@@ -53,7 +53,7 @@
# HELPER_EXTRA_PKGS: Extra packages that will need to be supplied
# to debootstrap to make the resulting helper image workable.
# DO NOT OVERWRITE THIS UNLESS YOU KNOW WHAT YOU ARE DOING
# HELPER_EXTRA_PKGS="xenstore-utils,e2fsprogs,ntfs-3g,ntfsprogs,xmlstarlet,python,parted,reglookup,chntpw,util-linux"
# HELPER_EXTRA_PKGS="iproute,socat,xenstore-utils,e2fsprogs,ntfs-3g,ntfsprogs,xmlstarlet,python,parted,reglookup,chntpw,util-linux"
# HELPER_LINUX_IMAGE_PKG="linux-image-amd64"
# HELPER_LINUX_XEN_IMAGE_PKG="linux-image-xen-amd64"
......
......@@ -290,7 +290,11 @@ else
esac
done
case \$hypervisor in
xen-pvm|xen-kvm) mount -t xenfs xenfs /proc/xen ;;
xen-pvm|xen-hvm)
mount -t xenfs xenfs /proc/xen
ip link set eth0 up
echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
;;
esac
/usr/bin/snf-image-helper --force
fi
......
......@@ -13,14 +13,15 @@ launch_helper() {
helper_name=helper$$
xm create /dev/null \
kernel="$HELPER_KERNEL" ramdisk="$HELPER_INITRD" \
extra="console=hvc0 hypervisor=$HYPERVISOR snf_image_activate_helper" \
disk="file:$snapshot,xvda,w" \
disk="phy:$blockdev,xvdb,w" \
disk="file:$floppy,xvdc1,w" \
extra="console=hvc0 hypervisor=$HYPERVISOR snf_image_activate_helper" \
vif="mac=aa:00:00:00:00:11,bridge=xenbr" \
memory="256" root="/dev/xvda1 quiet ro boot=local" boot="c" vcpus=1 \
name="$helper_name"
if ! xenstore-exists helper;
if [ ! $(xenstore-exists helper) ]; then
xenstore-write helper ""
fi
helperid=$(xm domid $helper_name)
......@@ -28,12 +29,18 @@ launch_helper() {
xenstore-chmod helper/$helperid r0 w$helperid
tail -f --pid=$$ "$result_file" | sed -u 's|^|HELPER: |' &
brctl delif xenbr vif$helperid.0
screen -d -m -c /etc/screenrc bash -c 'socat STDIO INTERFACE:vif'$helperid'.0 | ./helper-monitor.py 1 > '$monitor_pipe' '
$TIMEOUT -k $HELPER_HARD_TIMEOUT $HELPER_SOFT_TIMEOUT \
screen -D -m -c /etc/screenrc bash -c ' xm console '$helper_name' > '$result_file''
}
get_helper_result() {
result=$(xenstore-read helper/$helperid)
xenstore-rm helper/$helperid
}
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