SHELL=/bin/bash
p=autopkgtest
-px=autopkgtest-xenlvm
+x=xenlvm
topdir=`pwd`
build build-indep:
$(MAKE) install-here prefix=debian/$p/usr
$(MAKE) -C xen install \
- pkgname=autopkgtest-xenlvm \
- prefix=$(topdir)/debian/$(px)/usr \
- sharedir=$(topdir)/debian/$(px)/usr/share/autopkgtest/xenlvm \
- etcdir=$(topdir)/debian/$(px)/etc cfg_suffix=''
+ pkgname=$p-$x \
+ prefix=$(topdir)/debian/$p-$x/usr \
+ sharedir_lnfrom=/usr/share/$p/$x \
+ sharedir=$(topdir)/debian/$p-$x/usr/share/$p/$x \
+ etcdir=$(topdir)/debian/$p-$x/etc cfg_suffix=''
cat CREDITS debian/copyright.suffix \
>debian/$p/usr/share/doc/$p/copyright
- dh_installinit -p $(px) --onlyscripts --name=adtxenlvm -- defaults 19
+ dh_installinit -p $p-$x --onlyscripts --name=adt$x -- defaults 19
dh_compress
dh_link
dh_md5sums
pkgname = autopkgtest
docdir = $(share)/doc/$(pkgname)
sharedir = $(share)/$(pkgname)
+sharedir_lnfrom = $(share)/$(pkgname)
etcdir = /etc
+etcconfdir = $(etcdir)/autopkgtest
etcinitddir = $(etcdir)/init.d
xenscripts = $(etcdir)/xen/scripts
cfg_suffix = .dist
all: readconfig
install: all
- $(INSTALL_DIRS) $(bindir) $(docdir) $(man1dir) \
+ $(INSTALL_DIRS) $(bindir) $(docdir) $(man1dir) $(etcconfdir) \
$(sharedir) $(etcinitddir) $(xenscripts)
set -e; for f in $(programs) $(shareprograms); do \
$(INSTALL_PROGRAM) $$f $(sharedir); \
done
set -e; for f in $(programs); do \
- ln -sf $(sharedir)/$$f $(bindir)/$(exec_prefix)$$f; \
+ ln -sf $(sharedir_lnfrom)/$$f $(bindir)/$(exec_prefix)$$f; \
test ! -f $$f.1 || $(INSTALL_DOC) $$f.1 \
$(man1dir)/$(exec_prefix)$$f; \
done
done
$(INSTALL_DATA) initscript $(etcinitddir)/adtxenlvm$(cfg_suffix)
$(INSTALL_DATA) vif-route-adt $(xenscripts)/vif-route-adt$(cfg_suffix)
- $(INSTALL_DOC) README $(docdir)
+ $(INSTALL_DOC) README example-config $(docdir)
readconfig: sed-readconfig readconfig.in
sed -f $^ >$@.new && mv -f $@.new $@
----------- Introduction ----------
+========== Introduction ==========
+
+Basic approach:
+ 1. Get yourself a working Xen dom0 setup, eg according to
+ https://wiki.ubuntu.com/XenOnEdgy
+ 2. Configure adtxenlvm:
+ - assign a fixed IP address for the host and the testbed
+ - create DNS entries (forward and reverse)
+ for the testbed hostname edgy.adt.<your.domain.here>
+ - read below about settings you might want to set
+ creating /etc/autopkgtest/xenlvm_adt_config if needed
+ 3. adt-xenlvm-setup
+ 4. adt-xenlvm-with-testbed
+ 5. adt-xenlvm-on-testbed
+
+In some more detail, there are four main programs provided:
+
+ adt-xenlvm-setup [<config settings>]
+ Creates the snapshot. Broadly speaking, does the following:
+ - deletes any existing snapshot, virtual machine, etc.
+ - creates a new lvm volume and filesystem for the snapshot base
+ - runs debootstrap to install a system into the new filesystem
+ - makes necessary config changes to the testbed and the host
+ - boots the testbed and waits for it to start
+ - freezes the testbed into a snapshot file
+ After this, you can run with-testbed.
+
+ adt-xenlvm-with-testbed [<config settings>] [<master> [<args...>]]
+ Starts the testbed and runs <master> _on the HOST_. When
+ <master> finishes, the testbed state will be discarded. While
+ <master> is running, you can interact with the testbed. If
+ <master> is not specified, you get an interactive shell.
+
+ adt-xenlvm-on-testbed [<config settings>] [<command and args>]
+ Runs <command and args> on the running testbed. A <master>
+ child of adt-xenlvm-with-testbed must be running, or the
+ behaviour is not defined. However, adt-xenlvm-on-testbed does
+ not need to be a descendent of adt-xenlvm-with-testbed.
+ The arguments <command and args> are passed to ssh verbatim
+ and are therefore subject to ssh's unpleasant mangling.
+
+ adt-xenlvm-cleanup [<config settings>]
+ Cleans up any running testbed state. This is not normally
+ needed, as adt-xenlvm-with-testbed and adt-xenlvm-setup run it
+ at appropriate moments. However, if one of these should fail
+ and it is desirable to reclaim any resources used by the
+ testbed, cleanup will do this job.
+
+Note that there is NO LOCKING. If you run more than one of either
+adt-xenlvm-with-testbed or adt-xenlvm-setup (or one of each)
+simultaneously, the behaviour is not defined, except that the host
+will definitely not be trashed, and just two or more copies of
+adt-xenlvm-with-testbed at once has no bad effects that
+adt-xenlvm-cleanup won't fix.
+
+
+========== Configuration ==========
The configuration is read as follows:
1. set all variables whose defaults are fixed strings to
those built-in default values
2. process the command line arguments
3. read the user configuration file (sourced by bash)
+ this file must not use fds 10 onwards, which may have been used
+ for other purposes by other adtxenlvm machinery
4. process the command line arguments again, so they
can easily be made to override the user configuration file
5. calculate the values for variables which haven't been set
List of ports to which the testbed will be allowed to make
outgoing connections.
+adt_fw_hook <config> with _config replaced with _fwhook
+ or none of <config> doesn't end in _config
+ bash fragment to source during firewall setup
+
---------- Items that are likely to need attention ----------
adt_kernel the booted kernel file /boot/xen*`uname -r`
adt_pbuilder_args <none>
Extra arguments to pass to pbuilder.
+adt_lvm_erasebase yes
+ Whether the base filesystem image needs to be filled with
+ zeroes. If you are going to be using the image only locally
+ and so don't care whether the base image contains bits of
+ previous data from the disk, you may set this to `no'.
+
+adt_debootstrap_includemore <empty>
+adt_debootstrap_include libc6-xen,openssh-server,ed
+ Comma-separated lists of packages for --include option to
+ debootstrap. It is best to set includemore.
+
+adt_debootstrap_components *
+ Components of the distribution to consider. (Eg, `main'.)
+
+adt_debootstrap_mirrors <empty string>
+adt_debootstrap_script <empty string>
+ Third and fourth arguments to debootstrap.
+
---------- Tuning parameters ----------
adt_fs_type ext3
#!/bin/bash
set -e
. ${ADT_XENLVM_SHARE:=/usr/share/autopkgtest/xenlvm}/readconfig
+test $nonoptargs = 0 || fail "non-option arguments not allowed"
mkdir -p $adt_play $snap
-try () { "$@" >/dev/null 2>&1 ||:; }
+try () { printf "%s\n" "- $*"; "$@" >/dev/null 2>&1 ||:; }
-try xm destroy $adt_xmname
-try umount $adt_lvm_baselv
+n=0
+while x xm destroy $adt_xmname 2>/dev/null; do
+ sleep $n
+ n=$(( $n+1 ))
+done
+try umount $lvm_baselv_namepath
try dmsetup remove $adt_devmapper_cowdev
-rm -f $lvfsptr
+rm -f $lvm_fslink_ptr
-adt_pbuilder_args='--mirror http://mirror.relativity.greenend.org.uk/mirror/ubuntu.early'
+adt_debootstrap_mirrors=http://mirror.relativity.greenend.org.uk/mirror/ubuntu
adt_guests_domain=.relativity.greenend.org.uk
adt_host_hostname=samual.relativity.greenend.org.uk
adt_fw_localmirrors=172.18.45.6
adt_fw_testbedclients='172.18.45.97 172.18.45.6'
+
+adt_lvm_erasebase=n
+
+#export http_proxy=http://www-cache.relativity.greenend.org.uk:3128/
+
+
-#!/bin/sh
-set -ex
+#!/bin/bash
+set -e
. ${ADT_XENLVM_SHARE:=/usr/share/autopkgtest/xenlvm}/readconfig
dest=$adt_play/base
mkdir -p $dest/lib/modules
cp -a "${adt_modules}" $dest/lib/modules/.
+echo xennet >>$dest/etc/modules
+
if ! test -f "${adt_ssh_pubkey}"; then
if [ "x${adt_ssh_pubkey}" != "x${adt_ssh_privkey}.priv" ]; then
fail "cannot generate keypair automatically because adt_ssh_privkey \`$adt_ssh_privkey' and adt_ssh_pubkey \`$adt_ssh_pubkey' do not match up in the way required by ssh-keygen (<pubkey> must be <privkey>.pub>"
-#!/bin/sh
-set -ex
+#!/bin/bash
+set -e${ADT_SHELLX}
adt_host_hostname=$1
adt_guest_hostname=$2
fi
fi
-apt-get update
-apt-get -y --force-yes install libc6-xen
-
ldconfig
cat >/etc/fstab <<END
echo $adt_guest_hostname >/etc/hostname
-apt-get -y --force-yes install \
- openssh-server ed build-essential
-
perl -i~ -wne '
BEGIN {
$pep= PermitEmptyPasswords;
-#!/bin/sh
+#!/bin/bash
set -e
-. ${ADT_XENLVM_SHARE:=/usr/share/autopkgtest/xenlvm}/readconfig
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
-default=/etc/default/adt-xen
-if test -f $default; then
- . $default
+lsbif=/lib/lsb/init-functions
+if test -e $lsbif; then
+ . $lsbif
+else
+ log_daemon_msg () { printf "%s: " "$1"; }
+ log_progress_msg () { printf "%s " "$1"; }
+ log_end_msg () { echo "done."; }
fi
+. /etc/default/rcS
chains='AdtXenIn AdtXenFwd AdtXenIcmp'
fi
safety () {
+ log_progress_msg block
iptables -I INPUT -j DROP
iptables -I FORWARD -j DROP
trap '
}
unsafety () {
+ log_progress_msg unblock
iptables -D INPUT -j DROP
iptables -D FORWARD -j DROP
trap '' 0
case "$1" in
stop)
+ log_daemon_msg "adtxenlvm: removing firewall rules"
safety
+ log_progress_msg clear
for chain in $chains; do
- if iptables -L $chain >/dev/null 2>&1; then
+ if iptables -L -n $chain >/dev/null 2>&1; then
+ log_progress_msg $chain
iptables -F $chain
iptables -X $chain
fi
done
unsafety
+ log_end_msg 0
exit 0
;;
start|restart|force-reload)
;;
esac
+set --
+
+exec 10>&1
+case "$VERBOSE" in
+no) exec >/dev/null ;;
+esac
+
+printf "adtxenlvm: reading configuration for firewall setup:\n"
+. ${ADT_XENLVM_SHARE:=/usr/share/autopkgtest/xenlvm}/readconfig
+
+exec >&10 10>&-
+
+log_daemon_msg "adtxenlvm: installing firewall rules"
+
safety
+
+log_progress_msg create
for chain in $chains; do
+ log_progress_msg $chain
iptables -N $chain >/dev/null 2>&1 || iptables -F $chain
iptables -I $chain -j DROP
done
unsafety
+log_progress_msg rules
+
iptables -A AdtXenIcmp -j ACCEPT -p icmp --icmp-type echo-request
# per RFC1122, allow ICMP echo exchanges with anyone we can talk to at all
iptables -A $main -p tcp --dport $port -j ACCEPT
done
-if test -f $default-rules; then
- . $default-rules
+if [ "x$adt_fw_hook" != x ]; then
+ log_progress_msg hook
+ . $adt_fw_hook
fi
+log_progress_msg confirm
+
iptables -A $main -j REJECT --reject-with icmp-admin-prohibited
-iptables -A $main -j ACCEPT
iptables -D $main -j DROP
+log_progress_msg engage
+
iptables -A AdtXenIn -j ACCEPT -p icmp --icmp-type echo-request
iptables -A AdtXenIn -j ACCEPT -m conntrack --ctstate ESTABLISHED
iptables -A AdtXenIn -j AdtXenFwd
iptables -D AdtXenIn -j DROP
+iptables -D AdtXenIcmp -j DROP
+
+log_progress_msg proxyarp
+
echo 1 >/proc/sys/net/ipv4/conf/eth0/proxy_arp
+
+log_end_msg 0
-#!/bin/sh
+#!/bin/bash
set -e
+exec 10>&1 >/dev/null
. ${ADT_XENLVM_SHARE:=/usr/share/autopkgtest/xenlvm}/readconfig
+exec >&10
+exec 10>&-
+while test $# -gt $nonoptargs; do shift; done
+
ssh $adt_ssh_keyident_args $adt_guest_ipaddr "$@"
+++ /dev/null
-# this is your configuration file for pbuilder.
-# the file in /usr/share/pbuilder/pbuilderrc is the default template.
-# /etc/pbuilderrc is the one meant for editing.
-#
-# read pbuilderrc.5 document for notes on specific options.
-
-BASETGZ=/var/cache/pbuilder/base.tgz
-#EXTRAPACKAGES=gcc3.0-athlon-builder
-#export DEBIAN_BUILDARCH=athlon
-BUILDPLACE=/var/cache/pbuilder/build/
-MIRRORSITE=http://ftp.jp.debian.org/debian
-#NONUSMIRRORSITE="http://ftp.jp.debian.org/debian-non-US"
-#OTHERMIRROR="deb http://www.home.com/updates/ ./"
-#export http_proxy=http://your-proxy:8080/
-USEPROC=yes
-USEDEVPTS=yes
-USEDEVFS=no
-BUILDRESULT=/var/cache/pbuilder/result/
-
-# specifying the distribution forces the distribution on "pbuilder update"
-#DISTRIBUTION=sarge
-#specify the cache for APT
-APTCACHE="/var/cache/pbuilder/aptcache/"
-APTCACHEHARDLINK="no"
-REMOVEPACKAGES="lilo"
-#HOOKDIR="/usr/lib/pbuilder/hooks"
-HOOKDIR=""
-
-# make debconf not interact with user
-export DEBIAN_FRONTEND="noninteractive"
-
-DEBEMAIL=""
-
-#for pbuilder debuild
-BUILDSOURCEROOTCMD="fakeroot"
-PBUILDERROOTCMD="sudo"
-
-#default is to build everything. Passed on to dpkg-buildpackage
-#DEBBUILDOPTS="-b"
-DEBBUILDOPTS=""
-
-#APT configuration files directory
-APTCONFDIR=""
-
-# the username and ID used by pbuilder, inside chroot. Needs fakeroot, really
-BUILDUSERID=1234
-BUILDUSERNAME=pbuilder
-
-# BINDMOUNTS is a space separated list of things to mount
-# inside the chroot.
-BINDMOUNTS=""
-
-# Set the debootstrap variant to 'buildd' type.
-# DEBOOTSTRAPOPTS[0]='--variant=buildd'
-# or work around bug in debootstrap 3.0.0 (314858)
-unset DEBOOTSTRAPOPTS
-
-# Set the PATH I am going to use inside pbuilder: default is "/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin"
-export PATH="/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin"
-
-# SHELL variable is used inside pbuilder by commands like 'su'; and they need sane values
-export SHELL=/bin/bash
-
-# The name of debootstrap command.
-DEBOOTSTRAP="debootstrap"
# This bash script is sourced by the various tools to set the
# adt_... variables and some other useful ones.
+set -e${ADT_SHELLX}
+
#---------- useful general functions ----------
fail () {
exit 16
}
+x () { echo "x $*"; "$@"; }
+
+case "$BASH_VERSION" in
+'') fail 'scripts using adtxenlvm readconfig must be bash scripts' ;;
+*) ;;
+esac
+
#---------- default values for simple settings ----------
adt_nominum=adt
adt_vm_reduce_retries=10
adt_ssh_keytype=dsa
+adt_debootstrap_components='*'
+adt_debootstrap_include=libc6-xen,openssh-server,ed
+adt_debootstrap_includemore=
+adt_debootstrap_mirrors=''
+adt_debootstrap_script=''
+
adt_fw_localmirrors=''
adt_fw_prohibnets='192.168.0.0/24 172.16.0.0/12 10.0.0.0/8'
adt_fw_allowglobalports='80'
eval "$var=\"\$value\""
shift ;;
- --) break ;;
+ --) shift; break ;;
-*) fail "unknown option \`$arg'" ;;
- *) shift; break ;;
+ *) break ;;
esac
done
- test $# = 0 || fail "non-option arguments not allowed"
+ nonoptargs=$#
}
-cmdline_args
-. ${adt_config}
-cmdline_args
+cmdline_args "$@"
+: "${adt_config:=/etc/autopkgtest/xenlvm_${adt_nominum}_config}"
+test ! -e "${adt_config}" || . "${adt_config}"
+cmdline_args "$@"
#---------- calculated defaults for complex settings ----------
case "$adt_lvm_vg" in
'')
- echo "searching for default volume group ..."
- vgdisplay_out=`vgdisplay -c`
+ printf "searching for default volume group ... "
+ vgdisplay_out=`vgdisplay -c 10>&-`
case "$vgdisplay_out" in
"") fail 'no volume groups found';;
*"
"*) fail 'several volume groups, config must specify which';;
esac
- $adt_lvm_vg=${vgdisplay_out%%:*}
- echo "system has one volume group, $adt_vg, using that."
+ adt_lvm_vg=${vgdisplay_out%%:*}
+ case "$adt_lvm_vg" in
+ *[^\ ]\ *) fail "volume group name \`$adt_lvm_vg' has spaces!";;
+ esac
+ adt_lvm_vg=${adt_lvm_vg##* }
+ echo "using system's only volume group: $adt_lvm_vg"
;;
esac
case "$adt_kernel" in
'')
- echo "searching for kernel ..."
+ printf "searching for kernel ... "
for f in /boot/xen*"`uname -r`"; do
- test -f "$f" || continue
+ test -e "$f" || continue
test "x$adt_kernel" = x || \
fail 'several kernels, config must specify which'
adt_kernel="$f"
done
- echo "... using currently booted kernel $adt_kernel"
+ echo "using currently booted kernel: $adt_kernel"
;;
esac
none) echo "ramdisk \`none' specified, using static kernel"
adt_ramdisk='' ;;
'') adt_ramdisk="$adt_kernel.initrd.img"
- echo "using default ramdisk <kernel>.initrd.img, $adt_ramdisk" ;;
+ echo "using default ramdisk <kernel>.initrd.img: $adt_ramdisk" ;;
*) ;;
esac
case "$adt_modules" in
-'') /lib/modules/`uname -r` ;;
+'') adt_modules="/lib/modules/`uname -r`" ;;
*) ;;
esac
case "$adt_distro" in
'')
- echo "considering which distro to use ..."
- test -f /etc/lsb-release || \
+ printf "considering which distro to use ... "
+ test -e /etc/lsb-release || \
fail 'no /etc/lsb-version, config must specify adt_distro'
. /etc/lsb-release
- $adt_distro=$DISTRIB_CODENAME
+ adt_distro=$DISTRIB_CODENAME
+ echo "using same distro as host: $adt_distro"
;;
esac
eval '
if [ x"$adt_'$1'_hostname" = x ] && \
[ x"$adt_'$1'_ipaddr" != x ]; then
- echo "finding '$1' hostname from IP address $adt_'$1'_ipaddr"
+ printf "%s" "finding '$1' hostname from IP address $adt_'$1'_ipaddr: "
adt_'$1'_hostname=`adnshost -t ptr +Do +Dt +Dc -i $adt_'$1'_ipaddr`
+ printf "%s\n" "${adt_'$1'_hostname}"
fi
'
}
hostname_from_ipaddr host
if [ x"$adt_host_hostname" = x ]; then
- echo "finding host hostname, supposely our own FQDN ..."
+ printf "finding host hostname, supposely our own FQDN: "
adt_host_hostname=`hostname -f`
+ printf "%s\n" "$adt_host_hostname"
fi
if [ x"$adt_guest_hostname" = x ]; then
case "$adt_guests_domain" in
- '') echo "guessing guest hostname from host hostname ..."
+ '') printf "guessing guest hostname from host hostname: "
adt_guest_hostname=$adt_distro.$adt_nominum.${adt_host_hostname#*.} ;;
- .*) echo "setting guest hostname using distro and nominum ..."
+ .*) printf "setting guest hostname using distro and nominum: "
adt_guest_hostname=$adt_distro.$adt_nominum$adt_guests_domain ;;
- *) echo "setting guest hostname using distro and domain ..."
+ *) printf "setting guest hostname using distro and domain: "
adt_guest_hostname=$adt_distro.$adt_guests_domain ;;
esac
+ printf "%s\n" "$adt_guest_hostname"
fi
ipaddr_from_hostname () {
eval '
if [ x"$adt_'$1'_ipaddr" = x ] && \
[ x"$adt_'$1'_hostname" != x ]; then
- echo "finding '$1' IP address from hostname $adt_'$1'_hostname"
- adt_'$1'_ipaddr=`adnshost -t a +Do +Dt +Dc -i - "$adt_'$1'_hostname"`
+ printf "%s" "finding '$1' IP address from hostname $adt_'$1'_hostname: "
+ adt_'$1'_ipaddr=`adnshost -t a +Do +Dt +Dc - "$adt_'$1'_hostname"`
+ echo "${adt_'$1'_ipaddr}"
fi
'
}
ipaddr_from_hostname guest
ipaddr_from_hostname host
-: ${adt_config:=/etc/autopkgtest/xenlvm_${adt_nominum}_config}
+printf "looking for firewall hook ... "
+case "$adt_fw_hook" in
+'')
+ case "$adt_config" in
+ *_config)
+ adt_fw_hook=${adt_config%_config}_fwhook
+ if test -e "$adt_fw_hook"; then
+ echo "default exists: $adt_fw_hook"
+ else
+ echo "default $adt_fw_hook is not a file, so: none"
+ adt_fw_hook=''
+ fi
+ ;;
+ *)
+ echo "not specified, not computable from config, so: none"
+ adt_fw_hook=''
+ ;;
+ esac
+ ;;
+*)
+ if test -e "$adt_fw_hook"; then
+ echo "exists: $adt_fw_hook"
+ else
+ echo "specified as $adt_fw_hook, but not a file, so: none"
+ adt_fw_hook=''
+ fi
+ ;;
+esac
+
+boolean_config () {
+ eval '
+ case "${adt_'$1'}" in
+ y*|Y*|1*|t*) adt_'$1'=true ;;
+ n*|N*|0*|f*) adt_'$1'=false ;;
+ "") adt_'$1'=$2 ;;
+ *) fail "unknown boolean value \`$1'\'' for adt_'$1'" ;;
+ esac
+ '
+}
# SSH
: ${adt_ssh_privkey:=/root/.ssh/id_${adt_ssh_keytype}_${adt_nominum}}
# In-host-file-system playground
: ${adt_play:=${adt_playbase}/${adt_nominum}_${adt_distro}}
: ${adt_xmconfig:=${adt_play}/xmconfig}
+: ${adt_lock:=${adt_play}/lock}
# LVM
+boolean_config lvm_erasebase true
: ${adt_lvm_baselv:=${adt_nominum}_${adt_distro}_base}
: ${adt_lvm_cowdatalv:=${adt_nominum}_${adt_distro}_cowdata}
: ${adt_devmapper_cowdev:=${adt_nominum}_${adt_distro}_snap}
# Firewall
: ${adt_fw_testbedclients:=${adt_host_ipaddr}}
-lvm_baselv_namerhs=${adt_vg}/${adt_lvm_baselv}
-lvm_baselv_namepath=/dev/${adt_lvbaserhs}
+lvm_baselv_namerhs=${adt_lvm_vg}/${adt_lvm_baselv}
+lvm_baselv_namepath=/dev/${lvm_baselv_namerhs}
-lvm_cowdata_namerhs:=${adt_vg}/${adt_lvm_cowdatalv}
-lvm_cowdata_namepath:=/dev/${lvm_cowdata_namerhs}
+lvm_cowdata_namerhs=${adt_lvm_vg}/${adt_lvm_cowdatalv}
+lvm_cowdata_namepath=/dev/${lvm_cowdata_namerhs}
lvm_snapdev=/dev/mapper/${adt_devmapper_cowdev}
lvm_fslink_ptrrhs=${adt_fslink_dir}/${adt_fslink_name}
lvm_fslink_dirpath=/dev/${adt_fslink_dir}
-lvm_fslink_ptr=/dev/${lvm_fslink_dir}/${adt_fslink_name}
+lvm_fslink_ptr=/dev/${adt_fslink_dir}/${adt_fslink_name}
+
+echo "adtxenlvm: configuration for read for nominum=${adt_nominum}"
#!/bin/bash
set -e
. ${ADT_XENLVM_SHARE:=/usr/share/autopkgtest/xenlvm}/readconfig
+test $nonoptargs = 0 || fail "non-option arguments not allowed"
$ADT_XENLVM_SHARE/cleanup
-lvchange -a n $lvm_cowdata_namepath ||:
-lvremove $lvm_baselv_namepath ||:
-lvremove $lvm_cowdata_namepath ||:
+x lvchange -a n $lvm_baselv_namepath ||:
+x lvchange -a n $lvm_cowdata_namepath ||:
+x lvremove $lvm_baselv_namepath ||:
+x lvremove $lvm_cowdata_namepath ||:
-lvcreate -L $adt_fs_size -n $adt_lvm_baselv $adt_lvm_vg
-lvcreate -L $adt_fs_snapsize -n $adt_lvm_cowdatalv $adt_lvm_vg
-dd if=/dev/zero of=$lvm_baselv_namepath
-mkfs -t $adt_fs_type $adt_mkfs_args $lvm_baselv_namepath
+x lvcreate -L $adt_fs_size -n $adt_lvm_baselv $adt_lvm_vg
+x lvcreate -L $adt_fs_snapsize -n $adt_lvm_cowdatalv $adt_lvm_vg
+
+if $adt_lvm_erasebase; then
+ x dd if=/dev/zero of=$lvm_baselv_namepath
+fi
+x mkfs -t $adt_fs_type $adt_mkfs_args $lvm_baselv_namepath
mkdir -p $adt_play/base
-mount $adt_lvm_baselv $adt_play/base
+x mount $lvm_baselv_namepath $adt_play/base
+
+x debootstrap \
+ --components="${adt_debootstrap_components}" \
+ --include=${adt_debootstrap_include},${adt_debootstrap_includemore} \
+ $adt_debootstrap_opts \
+ "$adt_distro" "$adt_play/base" \
+ "$adt_debootstrap_mirrors" "$adt_debootstrap_script"
-pbuilder create --configfile /dev/null --distribution $distro \
- --no-targz --buildplace $adt_play/base \
- $adt_pbuilder_args --debootstrapopts --variant=''
+#x pbuilder create \
+# --configfile /usr/share/autopkgtest/xenlvm/pbuilderrc \
+# --distribution "$adt_distro" \
+# --no-targz --buildplace $adt_play/base \
+# $adt_pbuilder_args --debootstrapopts --variant=''
$ADT_XENLVM_SHARE/fixups "$@"
"
cat <<END >$adt_xmconfig
-kernel = "$kernel"
+kernel = "$adt_kernel"
memory = $adt_testbed_ram
root = "/dev/hda1"
extra = "ro console=tty0"
on_shutdown = "preserve"
END
-if [ "x$ramdisk" != x ]; then
+if [ "x$adt_ramdisk" != x ]; then
cat <<END >>$adt_xmconfig
-ramdisk = "$ramdisk"
+ramdisk = "$adt_ramdisk"
END
fi
-umount $adt_lvm_baselv
+x umount $lvm_baselv_namepath
-mkdir -p /dev/${lvm_fslink_dirpath}
+mkdir -p ${lvm_fslink_dirpath}
ln -sf ../$lvm_baselv_namerhs ${lvm_fslink_ptr}
-xm create $adt_xmconfig name=$adt_xmname
+x xm create $adt_xmconfig name=$adt_xmname
retries=10
while true; do
- if ping -c 1 $adt_guest_ipaddr && ./on-testbed id; then break; fi
+ if ping -c 1 $adt_guest_ipaddr && \
+ /usr/share/autopkgtest/xenlvm/on-testbed id; then break; fi
if [ $retries -le 0 ]; then
echo >&2 'no response from guest'
- xm console $adt_xmname
+ x xm console $adt_xmname
exit 1
fi
retries=$(($retries-1))
sleep 2
done
-xm mem-set $adt_xmname $adt_freeze_ram
+x xm mem-set $adt_xmname $adt_freeze_ram
retries=$adt_vm_reduce_retries
while sleep 1; do
- if xm mem-max $adt_xmname $adt_freeze_ram; then break; fi
+ if x xm mem-max $adt_xmname $adt_freeze_ram; then break; fi
if [ $retries -le 0 ]; then echo >&2 'cannot reduce memory'; exit 1; fi
retries=$(($retries-1))
done
-xm save $adt_xmname $adt_play/xen-save
+x xm save $adt_xmname $adt_play/xen-save
rm ${lvm_fslink_ptr}
trap 'exit 127' 0
+exec 10>&1 >/dev/null
. ${ADT_XENLVM_SHARE:=/usr/share/autopkgtest/xenlvm}/readconfig
-${ADT_XENLVM_SHARE}/cleanup
+exec >&10 10>&-
+
+while test $# -gt $nonoptargs; do shift; done
+
+${ADT_XENLVM_SHARE}/cleanup >/dev/null
modprobe dm-snapshot ||:
-bdsize=$(blockdev --getsize $adt_lvm_baselv)
+bdsize=$(blockdev --getsize $lvm_baselv_namepath)
dmsetup create $adt_devmapper_cowdev <<END
-0 $bdsize snapshot $adt_lvm_baselv $lvm_cowdata_namepath n $adt_fs_cowchunk
+0 $bdsize snapshot $lvm_baselv_namepath $lvm_cowdata_namepath n $adt_fs_cowchunk
END
mkdir -p $lvm_fslink_dirpath
udevsettle
set +e
-"$@"
+case $# in
+0) debian_chroot="<with-adtxenlvm_$adt_nominum>$debian_chroot" $SHELL -i ;;
+*) "$@" ;;
+esac
rc=$?
set -e