Package: autopkgtest-xen
Architecture: all
-Depends: pbuilder, libadns1-bin, chiark-utils-bin
+Depends: pbuilder, libadns1-bin, chiark-utils-bin, iproute
--- /dev/null
+---------- Introduction ----------
+
+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)
+ 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
+ and whose default values depend on circumstances (including
+ on other variables)
+
+---------- Items which definitely need attention ----------
+
+adt_guests_domain .<domain-of-host_hostname>
+adt_guest_hostname <distro>.[<nominum>.]<domain>
+adt_guest_ipaddr from looking hostname up in the DNS
+ Hostname and IP address for the testbed.
+ If the configuration specifies one of the address and hostname
+ but not the other, the missing information will be found with
+ a DNS lookup. If neither is specified, adt_guests_domain is
+ used; if it starts with `.' then <distro>.<nominum> is
+ prepended; otherwise just <distro>. is prepended. NOTE: some
+ effort by the local network administrator to allocate an IP
+ address (and ideally create DNS entries) is essential. It is
+ not possible to use DHCP for IP address allocation for the
+ testbed.
+
+---------- Items that are likely to need attention ----------
+
+adt_kernel the booted kernel file /boot/xen*`uname -r`
+ Kernel to boot in the testbed image
+
+adt_ramdisk <kernel>.initrd.img
+ Initial ramdisk to provide to the testbid image.
+ "none" means do not provide an initial ramdisk.
+
+adt_modules /lib/modules/`uname -r`
+ Directory with modules to be copied into the testbed.
+
+adt_lvm_vg the system's LVM volume group if there is only one
+ LVM volume group to create base filesystem image in.
+
+adt_fs_type ext3
+adt_fs_mkfs_args <none>
+ Filesystem type and any additional arguments to mkfs. If
+ _args contains whitespace, it results in multiple arguments;
+ it is not possible to pass whitespace-containing arguments to
+ mkfs.
+
+adt_pbuilder_args <none>
+ Extra arguments to pass to pbuilder.
+
+---------- Tuning parameters ----------
+
+adt_testbed_ram 256 [Mby]
+ Physical RAM allocated for each testbed instance while
+ creating and running.
+
+adt_freeze_ram 32 [Mby]
+ Physical RAM size for frozen image; we reduce the testbed
+ to this before freezing it and grow it again when we resume
+ it.
+
+adt_fs_size 1G
+ Size of base filesystem image. Should be big enough to
+ contain all of the software under test and all of its working
+ space, as no running testbed can ever use more than this
+ (despite copy-on-write).
+
+adt_fs_snapsize 500M
+ Space to allocate for copy-on-write snapshot data. This is
+ the maximum amount of data that a running testbed can use.
+ This value should be less than the adt_fs_size.
+
+adt_fs_cowchunk 8 [Mby]
+ Copy-on-write chunk size.
+
+adt_vm_reduce_retries 10 [seconds]
+ Time to wait for VM to reduce its memory following
+ xm mem-set.
+
+---------- Configuration for advanced uses ----------
+
+adt_config /etc/autopkgtest/xenlvm_<nominum>_conf
+
+adt_ssh_keytype dsa
+adt_ssh_privkey /root/.ssh/id_<ssh_keytype>_<nominum>
+adt_ssh_pubkey <ssh_privkey>.pub
+adt_ssh_keyident_args -i <ssh_privkey>
+adt_ssh_keygen_args -t <ssh_keytype>
+ SSH keypair to use for authentication to the testbed.
+ If the pubkey file and privkey file do not exist and
+ correspond to each other, a new key will be generated.
+ The best combinations of these variables to set are:
+ keytype [& keygen_args] - just change the key type
+ privkey [& keygen_args] - generate/use a different keypair
+ pubkey, keyident_args - use an existing key via agent etc.,
+ privkey is ignored if pubkey and keyident_args
+ are set and pubkey file exists
+
+adt_nominum adt
+ Namespace prefix for Xen domains, LVM volumes, devmapper
+ devices, entries in /dev, files in /var, and so on. You may
+ run several instances of the adt virtualisation system with
+ different nominums and they won't interact. It is best for
+ this to be a legal DNS label (using alphanumerics and hyphens
+ only); normally it when it is used to construct an identifier
+ it will be separated by other parts by underscores `_', so
+ they should be avoided.
+
+
+---------- Items which should not usually need to be changed ----------
+
+adt_host_hostname `hostname -f`
+adt_host_ipaddr from looking hostname up in the DNS
+ Hostname and IP address for the host, ie the Xen dom0 system.
+ If the configuration specifies one of the address and hostname
+ but not the other, the missing information will be found with
+ a DNS lookup. Note that if the host system uses a dynamically
+ allocated DHCP address, things will go wrong when the address
+ changes.
+
+adt_playbase /var/lib/autopkgtest/xenlvm
+ Base of filesystem playground areas.
+
+adt_play <playbase>/<nominum>_<distro>
+ Playground area for this particular testbed construction and
+ data.
+
+adt_xmconfig <play>/xmconfig
+ Xen virtual machine creation configuration for xm create.
+ This file will be (over)written during testbed setup.
+
+adt_lvm_baselv <nominum>_<distro>_base
+adt_lvm_cowdatalv <nominum>_<distro>_cowdata
+ LVM volume for base filesystem image, and copy-on-write
+ buffer. Will be created during testbed setup, destroying any
+ previous volume if necessary. This is the logical volume name
+ not including /dev/<lvm_vg>.
+
+adt_devmapper_cowdev <nominum>_<distro>_snap
+ devmapper device for copy-on-write image used by testbed when
+ running. This is the device name in the devmapper namespace,
+ ie not including /dev/mapper.
+
+adt_fslink_dir adt-xenlvm
+adt_fslink_name <nominum>_<distro>_fs
+ Directory in /dev, and filename in that directory, where the
+ scripts put the symlink used to trick Xen into using a
+ different block device on resume than was used for creation.
+
+adt_xmname <nominum>_<distro>
+ Xen virtual machine name, as passed to xm create.
+++ /dev/null
-1. read config-defaults
-2. process command line args
-3. read user config
-4. process command line args again
-5. process tail-config
set -e
. ./config
-mkdir -p $play $snap
+mkdir -p $adt_play $snap
try () { "$@" >/dev/null 2>&1 ||:; }
-try xm destroy $xmname
-try umount $lvbase
-try dmsetup remove $nsnap
+try xm destroy $adt_xmname
+try umount $adt_lvm_baselv
+try dmsetup remove $adt_devmapper_cowdev
rm -f $lvfsptr
-adt_testbed_ram 256 [Mby]
- Physical RAM allocated for each testbed instance while
- creating and running.
-
-adt_freeze_ram 32 [Mby]
- Physical RAM size for frozen image; we reduce the testbed
- to this before freezing it and grow it again when we resume
- it.
-
-adt_filesys_size 1G
- Size of base filesystem image. Should be big enough to
- contain all of the software under test and all of its working
- space, as no running testbed can ever use more than this
- (despite copy-on-write).
-
-adt_filesys_snapsize 500M
- Space to allocate for copy-on-write snapshot data. This is
- the maximum amount of data that a running testbed can use.
- This value should be less than the adt_filesys_size.
-
-adt_filesys_cowchunk 8 [Mby]
- Copy-on-write chunk size.
-
-adt_nominum adt
- Namespace prefix for Xen domains, LVM volumes, devmapper
- devices, entries in /dev, files in /var, and so on. You may
- run several instances of the adt virtualisation system with
- different nominums and they won't interact.
-
-adt_lvm_vg the system's LVM volume group if there is only one
- LVM volume group to create base filesystem image in.
-
-adt_kernel the booted kernel file /boot/xen*`uname -r`
- Kernel to boot in the testbed image
-
-adt_ramdisk <kernel>.initrd.img
- Initial ramdisk to provide to the testbid image.
- "none" means do not provide an initial ramdisk.
-
+adt_nominum=${adt_nominum}
adt_testbed_ram=256
adt_freeze_ram=32
-adt_filesys_size=1G
-adt_filesys_snapsize=100M
-adt_filesys_cowchunk=8
-
-adt_nominum=${adt_nominum}
+adt_fs_size=1G
+adt_fs_snapsize=100M
+adt_fs_cowchunk=8
+adt_playbase=/var/lib/autopkgtest/xenlvm
+adt_fs_type=ext3
+adt_fs_mkfs_args=''
+adt_vm_reduce_retries=10
+adt_ssh_keytype=dsa
-adt_pbuilderopts='--mirror http://mirror.relativity.greenend.org.uk/mirror/ubuntu.early'
+adt_pbuilder_args='--mirror http://mirror.relativity.greenend.org.uk/mirror/ubuntu.early'
adt_guests_domain=.relativity.greenend.org.uk
adt_host_hostname=samual.relativity.greenend.org.uk
#!/bin/sh
set -ex
+. ${ADT_XENLVM_SHARE:=/usr/share/autopkgtest/xenlvm}/readconfig
-dest=$1
-adt_host_hostname=$2
-adt_guest_hostname=$3; shift
+dest=$adt_play/base
echo '---fixups:'
-cp xen-divert-tls-libc \
- fixups-inside \
- $dest/root/
+cp ${ADT_XENLVM_SHARE}/fixups-inside $dest/root/
mkdir -p $dest/lib/modules
-cp -a /lib/modules/`uname -r`/ $dest/lib/modules/.
+cp -a "${adt_modules}" $dest/lib/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>"
+ fi
+ if test -f "${adt_ssh_privkey}"; then
+ fail "will not overwrite existing private key \`$adt_ssh_privkey' - but where is public key \`$adt_ssh_pubkey' ?"
+ fi
+
+ mkdir -p /root/.ssh
+ ssh-keygen -N '' ${adt_ssh_keygen_args} -f "${adt_ssh_privkey}"
+fi
-mkdir -p /root/.ssh
-id_dsa=/root/.ssh/id_dsa_adt
-test -f $id_dsa || ssh-keygen -t dsa -N '' -f $id_dsa
mkdir -m 02700 -p $dest/root/.ssh
-cp $id_dsa.pub $dest/root/.ssh/authorized_keys
+cp -- "${adt_ssh_pubkey}" $dest/root/.ssh/authorized_keys
cat <<END >$dest/etc/init.d/xenethtoolk
#!/bin/sh
+# work around checksum offload bug in Xen network bridge driver
case "$1" in
start)
ethtool -K eth0 tx off
chmod +x $dest/etc/init.d/xenethtoolk
ln -s ../init.d/xenethtoolk $dest/etc/rc2.d/S21xenethtoolk
-chroot $dest root/fixups-inside "$@" "$adt_host_ipaddr" "$adt_guest_ipaddr"
+chroot $dest root/fixups-inside \
+ "$adt_host_hostname" "$adt_guest_hostname" \
+ "$adt_host_ipaddr" "$adt_guest_ipaddr" \
+ "$adt_fs_type"
kh=/etc/ssh/ssh_known_hosts
test ! -f $kh || cp $kh $kh.new
adt_guest_hostname=$2
adt_host_ipaddr=$3
adt_guest_ipaddr=$4
+adt_fs_type=$5
echo '(---'
cd /root
-perl -i~ -pe 's/ main$/ main universe/ if m/^deb http/' /etc/apt/sources.list
-apt-get update
+if test -f /etc/lsb-release; then
+ . /etc/lsb-release
+ if [ "x$DISTRIB_ID" = xUbuntu ]; then
+ perl -i~ -pe 's/ main$/ main universe/ if m/^deb http/' \
+ /etc/apt/sources.list
+ fi
+fi
-apt-get -y --force-yes install libc6-xen || ./xen-divert-tls-libc do
+apt-get update
+apt-get -y --force-yes install libc6-xen
ldconfig
cat >/etc/fstab <<END
proc /proc proc defaults 0 0
-/dev/hda1 / ext3 defaults,errors=remount-ro 0 1
+/dev/hda1 / $adt_fs_type defaults,errors=remount-ro 0 1
END
mkdir -p /etc/network
#!/bin/sh
set -e
. ./config
-ssh -i $sshkey $adt_guest_ipaddr "$@"
+ssh -i $adt_sshkey $adt_guest_ipaddr "$@"
--- /dev/null
+# This bash script is sourced by the various tools to set the
+# adt_... variables.
+
+fail () {
+ echo >&2 "xenlvm: ${0##*/}: error: $*"
+ exit 16
+}
+
+cmdline_args () {
+ while [ $# -gt 0 ]; do
+ arg="$1"
+ case "$arg" in
+ --*=*)
+ value="${arg#*=}"
+
+ var=${arg%%=*}
+ var=${var#--}
+ case "$var" in
+ *-*) var="$(printf "%s" "$var" | tr -- - _)" ;;
+ esac
+ var=${var#adt_}
+
+ case $var in
+ *) ;; # @@varlist@@
+ *) fail "unknown configuration variable \`$var'" ;;
+ esac
+
+ eval "$var=\"\$value\""
+ shift ;;
+
+ --) break ;;
+ -*) fail "unknown option \`$arg'" ;;
+ *) shift; break ;;
+ esac
+ done
+ test $# = 0 || fail "non-option arguments not allowed"
+}
+
+. $ADT_XENLVM_SHARE/config-default
+cmdline_args
+. ${adt_config}
+
+.
+
+
+lvm_baselv_namerhs=${adt_vg}/${adt_lvm_baselv}
+lvm_baselv_namepath=/dev/${adt_lvbaserhs}
+
+lvm_cowdata_namerhs:=${adt_vg}/${adt_lvm_cowdatalv}
+adt_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}
#!/bin/bash
set -e
-. ./config
-./cleanup
-lvchange -a n $lvcowdata ||:
-lvremove $lvbase ||:
-lvremove $lvcowdata ||:
+. ${ADT_XENLVM_SHARE:=/usr/share/autopkgtest/xenlvm}/readconfig
-lvcreate -L $adt_filesys_size -n $lvbase $adt_lvm_vg
-lvcreate -L $adt_filesys_snapsize -n $ncowdata $adt_lvm_vg
-#dd if=/dev/zero of=$lvbase
-mkfs -t ext3 $lvbase
+$ADT_XENLVM_SHARE/cleanup
+lvchange -a n $lvm_cowdata_namepath ||:
+lvremove $lvm_baselv_namepath ||:
+lvremove $lvm_cowdata_namepath ||:
-mkdir -p $play/base
-mount $lvbase $play/base
+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
-#--basetgz $play/base.tgz --buildplace
+mkdir -p $adt_play/base
+mount $adt_lvm_baselv $adt_play/base
-pbuilder create --configfile ./pbuilderrc --distribution $distro \
- --no-targz --buildplace $play/base \
- $pbuilderopts --debootstrapopts --variant=''
+pbuilder create --configfile /dev/null --distribution $distro \
+ --no-targz --buildplace $adt_play/base \
+ $adt_pbuilder_args --debootstrapopts --variant=''
-./fixups $play/base $adt_host_hostname $adt_guest_hostname
+$ADT_XENLVM_SHARE/fixups "$@"
echo "
--- writing $adt_xmconfig ---
"
-adt_host_ipaddr=`adnshost -t a +Do +Dt +Dc $adt_host_hostname`
-
cat <<END >$adt_xmconfig
kernel = "$kernel"
memory = $adt_testbed_ram
root = "/dev/hda1"
extra = "ro console=tty0"
-disk = [ "phy:$lvfsptrrhs,hda1,w" ]
+disk = [ "phy:$lvm_fslink_ptrrhs,hda1,w" ]
vif = [ "bridge=none,mac=00:16:3e:7c:aa:7f,ip=$adt_guest_ipaddr,script=/etc/xen/scripts/vif-route-adt" ]
on_crash = "preserve"
on_reboot = "preserve"
END
fi
-umount $lvbase
+umount $adt_lvm_baselv
-mkdir -p /dev/${pfx}_fs
-ln -sf ../$lvbaserhs $lvfsptr
-xm create $adt_xmconfig name=$xmname
+mkdir -p /dev/${lvm_fslink_dirpath}
+ln -sf ../$lvm_baselv_namerhs ${lvm_fslink_ptr}
+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 [ $retries -le 0 ]; then
echo >&2 'no response from guest'
- xm console $xmname
+ xm console $adt_xmname
exit 1
fi
retries=$(($retries-1))
sleep 2
done
-xm mem-set $xmname $adt_freeze_ram
-retries=10
+xm mem-set $adt_xmname $adt_freeze_ram
+retries=$adt_vm_reduce_retries
while sleep 1; do
- if xm mem-max $xmname $adt_freeze_ram; then break; fi
+ if 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 $xmname $play/xen-save
-rm $lvfsptr
+xm save $adt_xmname $adt_play/xen-save
+rm ${lvm_fslink_ptr}
*) ;;
esac
+case "$adt_modules" in
+'') /lib/modules/`uname -r` ;;
+*) ;;
+esac
+
case "$adt_distro" in
'')
echo "considering which distro to use ..."
ipaddr_from_hostname guest
ipaddr_from_hostname host
+: ${adt_config:=/etc/autopkgtest/xenlvm_${adt_nominum}_config}
+
# SSH
-: ${adt_sshkey:=/root/.ssh/id_dsa_${adt_nominum}}
+: ${adt_ssh_privkey:=/root/.ssh/id_${adt_ssh_keytype}_${adt_nominum}}
+: ${adt_ssh_pubkey:=${adt_ssh_privkey}.pub}
+: ${adt_ssh_keyident_args:=-i ${adt_ssh_privkey}}
+: ${adt_ssh_keygen_args:=-t ${adt_ssh_keytype}}
# Xen
: ${adt_xmname:=${adt_nominum}_${adt_distro}}
# In-host-file-system playground
-: ${adt_play:=${adt_playbase}/${adt_distro}}
+: ${adt_play:=${adt_playbase}/${adt_nominum}_${adt_distro}}
: ${adt_xmconfig:=${adt_play}/xmconfig}
# LVM
-: ${adt_nbase:=${adt_nominum}_${adt_distro}_base}
-: ${adt_lvbaserhs:=${adt_vg}/${adt_nbase}}
-: ${adt_lvbase:=/dev/${adt_lvbaserhs}}
-
-: ${adt_nsnap:=${adt_nominum}_${adt_distro}_snap}
-: ${adt_lvsnap:=/dev/mapper/${adt_nsnap}}
-
-: ${adt_ncowdata:=${adt_nominum}_${adt_distro}_cowdata}
-: ${adt_lvcowdatarhs:=${adt_vg}/${adt_ncowdata}}
-: ${adt_lvcowdata:=/dev/${adt_lvcowdatarhs}}
+: ${adt_lvm_baselv:=${adt_nominum}_${adt_distro}_base}
+: ${adt_lvm_cowdatalv:=${adt_nominum}_${adt_distro}_cowdata}
+: ${adt_devmapper_cowdev:=${adt_nominum}_${adt_distro}_snap}
-: ${adt_lvfsptrrhs:=${adt_nominum}_fs/${adt_distro}}
-: ${adt_lvfsptr:=/dev/${adt_lvfsptrrhs}}
+: ${adt_fslink_dir:=adt-xenlvm}
+: ${adt_fslink_name:=${adt_nominum}_${adt_distro}_fs}
modprobe dm-snapshot ||:
-#dd if=/dev/zero of=/dev/$lvcowdata bs=512 count=$adt_filesys_cowchunk status=noxfer
+#dd if=/dev/zero of=/dev/$lvm_cowdata_namepath bs=512 count=$adt_fs_cowchunk status=noxfer
-bdsize=$(blockdev --getsize $lvbase)
-dmsetup create $nsnap <<END
-0 $bdsize snapshot $lvbase $lvcowdata n $adt_filesys_cowchunk
+bdsize=$(blockdev --getsize $adt_lvm_baselv)
+dmsetup create $adt_devmapper_cowdev <<END
+0 $bdsize snapshot $adt_lvm_baselv $lvm_cowdata_namepath n $adt_fs_cowchunk
END
-mkdir -p /dev/${pfx}_fs
-ln -s $lvsnap $lvfsptr
+mkdir -p $lvm_fslink_dirpath
+ln -s $lvm_snapdev $lvm_fslink_ptr
-xm restore $play/xen-save
-xm mem-set $xmname $adt_testbed_ram
+xm restore $adt_play/xen-save
+xm mem-set $adt_xmname $adt_testbed_ram
udevsettle
set +e
rc=$?
set -e
-xm destroy $xmname
-dmsetup remove $nsnap
+xm destroy $adt_xmname
+dmsetup remove $adt_devmapper_cowdev
trap '' 0
exit $rc