Commit f5e68537 authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

Add support for newer versions of Xen

Create a XEN_CMD variable that will host the Xen CLI tool to be used.
This depends on the Xen version and configuration. Older versions of Xen
used xm. This was deprecated in favor of xl in version 4.1 and
completely removed in version 4.5.
parent 5adac9a6
......@@ -42,6 +42,7 @@ edit = sed \
-e 's|@INSTALL_MBR[@]|$(INSTALL_MBR)|g' \
-e 's|@PROGRESS_MONITOR[@]|$(PROGRESS_MONITOR)|g' \
-e 's|@UNATTEND[@]|$(UNATTEND)|g' \
-e 's|@XEN_CMD[@]|$(XEN_CMD)|g' \
-e 's|@MULTISTRAP_CONFIG[@]|$(MULTISTRAP_CONFIG)|g' \
-e 's|@MULTISTRAP_APTPREFDIR[@]|$(MULTISTRAP_APTPREFDIR)|g'
......
......@@ -472,6 +472,7 @@ fi
: ${UNATTEND:="@UNATTEND@"}
: ${WINDOWS_TIMEZONE:="GMT Standard Time"}
: ${XEN_SCRIPTS_DIR="@sysconfdir@/xen/scripts"}
: ${XEN_CMD:="@XEN_CMD@"}
: ${MULTISTRAP_CONFIG:="@MULTISTRAP_CONFIG@"}
: ${MULTISTRAP_APTPREFDIR:="@MULTISTRAP_APTPREFDIR@"}
: ${DHCP_TAGS:="auto dhcp nfdhcpd"}
......
......@@ -71,6 +71,26 @@ AC_ARG_WITH([multistrap-config],
)
AC_SUBST(MULTISTRAP_CONFIG, $multistrap_config)
# --with-xen-cmd
AC_ARG_WITH([xen-cmd],
[AS_HELP_STRING([--with-xen-cmd=XEN_CLI_TOOL],
[the default Xen CLI tool
[xl]]
)],
[if test "$withval" != "yes" -a "$withval" != "no"; then
if test "$withval" != xm -a "$withval" != xl; then
AC_MSG_ERROR([valid values for --with-xen-cmd are 'xm' and 'xl'])
fi
xen_cmd="$withval"
AC_MSG_NOTICE(using Xen CLI tool: $withval)
elif test "$withval" != "no"; then
AC_MSG_ERROR([you must specify a CLI tool if --with-xen-cmd is specified])
fi],
[xen_cmd="xl"]
)
AC_SUBST(XEN_CMD, $xen_cmd)
# --with-multistrap-aptprefdir
AC_ARG_WITH([multistrap-aptprefdir],
[AS_HELP_STRING([--with-multistrap-aptprefdir=MULTISTRAP_APTPREFDIR],
......
......@@ -57,6 +57,12 @@
# XEN_SCRIPTS_DIR: Directory where the Xen scripts are stored
# XEN_SCRIPTS_DIR="@sysconfdir@/xen/scripts"
# XEN_CMD: This variable specifies the Xen CLI tool snf-image should use. This
# depends on the XEN version and configuration and should probably coincide
# with the Ganeti's xen_cmd hypervisor parameter for xen-hvm or xen-pvm. Right
# now the supported ones are 'xm' and 'xl'.
# XEN_CMD="@XEN_CMD@"
# PITHOS_DB: Pithos database in SQLAlchemy format
# PITHOS_DB="sqlite:////@localstatedir@/lib/pithos/backend.db"
......
......@@ -33,7 +33,7 @@ launch_helper() {
floppy="$1"
name="snf-image-helper-$instance-$RANDOM"
name="snf-image-helper-$instance-$(date +%Y-%m-%d_%k_%M_%S_%N).cfg"
report_info "Starting customization VM..."
echo "$($DATE +%Y:%m:%d-%H:%M:%S.%N) VM START" >&2
......@@ -56,25 +56,34 @@ launch_helper() {
xen_dev="xvd$1"; shift
disks+=" disk=$ftype:$disk_path,$xen_dev,w"
disks+=",'$ftype:$disk_path,$xen_dev,w'"
done
xm create /dev/null \
kernel="$HELPER_DIR/kernel" ramdisk="$HELPER_DIR/initrd" \
root="/dev/xvda" memory="$HELPER_MEMORY" boot="c" vcpus=1 name="$name" \
extra="console=hvc0 hypervisor=$HYPERVISOR snf_image_activate_helper \
ipv6.disable=1 rules_dev=/dev/xvdb 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="file:$floppy,xvdb,r" $disks \
vif="script=${XEN_SCRIPTS_DIR}/vif-snf-image"
add_cleanup suppress_errors xm destroy "$name"
cat >/etc/xen/$name <<EOF
# this is a temporary file autogenerated by snf-image
#
kernel='$HELPER_DIR/kernel'
ramdisk='$HELPER_DIR/initrd'
root='/dev/xvda'
memory='$HELPER_MEMORY'
boot='c'
vcpus=1
name='$name'
extra='console=hvc0 hypervisor=$HYPERVISOR snf_image_activate_helper ipv6.disable=1 rules_dev=/dev/xvdb 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','file:$floppy,xvdb,r'$disks]
vif=['script=${XEN_SCRIPTS_DIR}/vif-snf-image']
EOF
add_cleanup rm -f "$name"
$XEN_CMD create /etc/xen/$name
add_cleanup suppress_errors $XEN_CMD destroy "$name"
if ! xenstore-exists snf-image-helper; then
xenstore-write snf-image-helper ""
#add_cleanup xenstore-rm snf-image-helper
fi
helperid=$(xm domid "$name")
helperid=$($XEN_CMD domid "$name")
xenstore-write snf-image-helper/${helperid} ""
add_cleanup xenstore-rm snf-image-helper/${helperid}
xenstore-chmod snf-image-helper/${helperid} r0 w${helperid}
......@@ -86,7 +95,7 @@ launch_helper() {
set +e
$TIMEOUT -k $HELPER_HARD_TIMEOUT $HELPER_SOFT_TIMEOUT \
socat EXEC:"xm console $name",pty STDOUT | sed -u 's|^|HELPER: |g'
socat EXEC:"$XEN_CMD console $name",pty STDOUT | sed -u 's|^|HELPER: |g'
rc=$?
set -e
......
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