From 907172185deaf4d880e4ca8153933a2e90b40560 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 27 Sep 2006 16:35:06 +0100 Subject: [PATCH] Initial work on configuration arrangements --- Makefile | 13 +--- debian/control | 4 ++ settings.make | 12 ++++ xen/Makefile | 34 +++++++++++ xen/README.config-processing | 5 ++ xen/config | 43 -------------- xen/default-config | 10 ++++ xen/example-config | 3 + xen/fixups | 11 ++-- xen/fixups-inside | 18 +++--- xen/on-testbed | 2 +- xen/setup | 16 ++--- xen/tail-config | 111 +++++++++++++++++++++++++++++++++++ xen/vif-common.sh | 1 - 14 files changed, 203 insertions(+), 80 deletions(-) create mode 100644 settings.make create mode 100644 xen/Makefile create mode 100644 xen/README.config-processing create mode 100644 xen/default-config create mode 100644 xen/example-config create mode 100644 xen/tail-config delete mode 120000 xen/vif-common.sh diff --git a/Makefile b/Makefile index cdb2c0c..d747249 100644 --- a/Makefile +++ b/Makefile @@ -20,17 +20,7 @@ # See the file CREDITS for a full list of credits information (often # installed as /usr/share/doc/autopkgtest/CREDITS). -prefix = /usr/local -share = $(prefix)/share -bindir = $(prefix)/bin -mandir = $(share)/man -man1dir = $(mandir)/man1 -docdir = $(share)/doc/autopkgtest - -INSTALL = install -INSTALL_DIRS = $(INSTALL) -d -INSTALL_PROGRAM = $(INSTALL) -m 0755 -INSTALL_DOC = $(INSTALL) +include settings.make programs = virt-chroot/adt-virt-chroot \ runner/adt-run @@ -41,4 +31,5 @@ install: $(INSTALL_PROGRAM) $$f $(bindir); \ test ! -f $$f.1 || $(INSTALL_DOC) $$f.1 $(man1dir); \ done + cd xen && $(MAKE) install $(INSTALL_DOC) CREDITS debian/changelog $(docdir) diff --git a/debian/control b/debian/control index 863d5be..211ab21 100644 --- a/debian/control +++ b/debian/control @@ -18,3 +18,7 @@ Description: automatic as-installed testing for Debian packages and /usr/share/doc/autopkgtest. . Status: this release is still pretty much a proof of concept. + +Package: autopkgtest-xen +Architecture: all +Depends: pbuilder, libadns1-bin, chiark-utils-bin diff --git a/settings.make b/settings.make new file mode 100644 index 0000000..1a817cb --- /dev/null +++ b/settings.make @@ -0,0 +1,12 @@ +prefix = /usr/local +share = $(prefix)/share +bindir = $(prefix)/bin +mandir = $(share)/man +man1dir = $(mandir)/man1 +docdir = $(share)/doc/autopkgtest + +INSTALL = install +INSTALL_DIRS = $(INSTALL) -d +INSTALL_PROGRAM = $(INSTALL) -m 0755 +INSTALL_DOC = $(INSTALL) + diff --git a/xen/Makefile b/xen/Makefile new file mode 100644 index 0000000..73d2580 --- /dev/null +++ b/xen/Makefile @@ -0,0 +1,34 @@ +# This file is part of autopkgtest +# autopkgtest is a tool for testing Debian binary packages +# +# autopkgtest is Copyright (C) 2006 Canonical Ltd. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# See the file CREDITS for a full list of credits information (often +# installed as /usr/share/doc/autopkgtest/CREDITS). + +include ../settings.make + +install: + + + $(INSTALL_DIRS) -d $(bindir) $(docdir) $(man1dir) + set -e; for f in $(programs); do \ + $(INSTALL_PROGRAM) $$f $(bindir); \ + test ! -f $$f.1 || $(INSTALL_DOC) $$f.1 $(man1dir); \ + done + cd xen && $(MAKE) install + $(INSTALL_DOC) CREDITS debian/changelog $(docdir) diff --git a/xen/README.config-processing b/xen/README.config-processing new file mode 100644 index 0000000..bf524e8 --- /dev/null +++ b/xen/README.config-processing @@ -0,0 +1,5 @@ +1. read config-defaults +2. process command line args +3. read user config +4. process command line args again +5. process tail-config diff --git a/xen/config b/xen/config index 61f000a..ef6c52e 100644 --- a/xen/config +++ b/xen/config @@ -6,46 +6,3 @@ # /etc/default/adt-xen # /etc/init.d/adt-xen and links #---------- - -#kernel=/boot/boot/vmlinuz-2.6-xen -kernel=/boot/xen0-linux-2.6.16-1-686 -ramdisk=/boot/xen-initrd - -tbmem=256 -frzmem=32 -fssize=1G -snapsize=100M -cowchunk=8 - -vg=glalonde -#distro=dapper -distro=edgy -pbuilderopts='--mirror http://mirror.relativity.greenend.org.uk/mirror/ubuntu.early' -domain=adt.relativity.greenend.org.uk -sshkey=/root/.ssh/id_dsa_adt - -pfx=adt -guesthname=$distro.$domain -playbase=/var/lib/autopkgtest/xenlvm-play -#hosthname=`hostname -f` -hosthname=samual.relativity.greenend.org.uk -xmname=${pfx}_${distro} - -play=${playbase}/${distro} - -nbase=${pfx}_${distro}_base -lvbaserhs=$vg/$nbase -lvbase=/dev/$lvbaserhs - -nsnap=${pfx}_${distro}_snap -lvsnap=/dev/mapper/$nsnap - -ncowdata=${pfx}_${distro}_cowdata -lvcowdatarhs=$vg/$ncowdata -lvcowdata=/dev/$lvcowdatarhs - -lvfsptrrhs=${pfx}_fs/${distro} -lvfsptr=/dev/$lvfsptrrhs -xmdomain=$play/xmdomain - -guestaddr=`adnshost -t a +Do +Dt +Dc $guesthname` diff --git a/xen/default-config b/xen/default-config new file mode 100644 index 0000000..31e80c6 --- /dev/null +++ b/xen/default-config @@ -0,0 +1,10 @@ +tbmem=256 +frzmem=32 +fssize=1G +snapsize=100M +cowchunk=8 + +adt_nominum=${adt_nominum} + +sshkey=/root/.ssh/id_dsa_${adt_nominum} +playbase=/var/lib/autopkgtest/xenlvm-play diff --git a/xen/example-config b/xen/example-config new file mode 100644 index 0000000..b95bed0 --- /dev/null +++ b/xen/example-config @@ -0,0 +1,3 @@ +adt_pbuilderopts='--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 diff --git a/xen/fixups b/xen/fixups index 55cb069..9c9c83d 100755 --- a/xen/fixups +++ b/xen/fixups @@ -2,11 +2,8 @@ set -ex dest=$1 -hosthname=$2 -guesthname=$3; shift - -hostaddr=`adnshost -t a +Do +Dt +Dc $hosthname` -guestaddr=`adnshost -t a +Do +Dt +Dc $guesthname` +adt_host_hostname=$2 +adt_guest_hostname=$3; shift echo '---fixups:' @@ -35,12 +32,12 @@ END chmod +x $dest/etc/init.d/xenethtoolk ln -s ../init.d/xenethtoolk $dest/etc/rc2.d/S21xenethtoolk -chroot $dest root/fixups-inside "$@" "$hostaddr" "$guestaddr" +chroot $dest root/fixups-inside "$@" "$adt_host_ipaddr" "$adt_guest_ipaddr" kh=/etc/ssh/ssh_known_hosts test ! -f $kh || cp $kh $kh.new exec 3>$kh.new -pfx="$guesthname,$guestaddr" +pfx="$adt_guest_hostname,$adt_guest_ipaddr" test ! -f $kh || perl -pe '$_="" if m/^(\S+)\s/ && $1 eq "'$pfx'";' $kh >&3 for f in $dest/etc/ssh/ssh_host_*_key.pub; do perl -pe '$_= "'$pfx' ".$_;' $f >&3 diff --git a/xen/fixups-inside b/xen/fixups-inside index a4d4bf4..4bee8d8 100755 --- a/xen/fixups-inside +++ b/xen/fixups-inside @@ -1,10 +1,10 @@ #!/bin/sh set -ex -hosthname=$1 -guesthname=$2 -hostaddr=$3 -guestaddr=$4 +adt_host_hostname=$1 +adt_guest_hostname=$2 +adt_host_ipaddr=$3 +adt_guest_ipaddr=$4 echo '(---' @@ -29,14 +29,14 @@ iface lo inet loopback auto eth0 iface eth0 inet static - address $guestaddr - broadcast $guestaddr + address $adt_guest_ipaddr + broadcast $adt_guest_ipaddr netmask 255.255.255.255 - pointopoint $hostaddr - gateway $hostaddr + pointopoint $adt_host_ipaddr + gateway $adt_host_ipaddr END -echo $guesthname >/etc/hostname +echo $adt_guest_hostname >/etc/hostname apt-get -y --force-yes install \ openssh-server ed build-essential diff --git a/xen/on-testbed b/xen/on-testbed index 7a34c8f..5967150 100755 --- a/xen/on-testbed +++ b/xen/on-testbed @@ -1,4 +1,4 @@ #!/bin/sh set -e . ./config -ssh -i $sshkey $guestaddr "$@" +ssh -i $sshkey $adt_guest_ipaddr "$@" diff --git a/xen/setup b/xen/setup index 64c5403..b3c9b69 100755 --- a/xen/setup +++ b/xen/setup @@ -20,28 +20,28 @@ pbuilder create --configfile ./pbuilderrc --distribution $distro \ --no-targz --buildplace $play/base \ $pbuilderopts --debootstrapopts --variant='' -./fixups $play/base $hosthname $guesthname +./fixups $play/base $adt_host_hostname $adt_guest_hostname echo " ---- writing $xmdomain --- +--- writing $adt_xmconfig --- " -hostaddr=`adnshost -t a +Do +Dt +Dc $hosthname` +adt_host_ipaddr=`adnshost -t a +Do +Dt +Dc $adt_host_hostname` -cat <$xmdomain +cat <$adt_xmconfig kernel = "$kernel" memory = $tbmem root = "/dev/hda1" extra = "ro console=tty0" disk = [ "phy:$lvfsptrrhs,hda1,w" ] -vif = [ "bridge=none,mac=00:16:3e:7c:aa:7f,ip=$guestaddr,script=/etc/xen/scripts/vif-route-adt" ] +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" on_shutdown = "preserve" END if [ "x$ramdisk" != x ]; then -cat <>$xmdomain +cat <>$adt_xmconfig ramdisk = "$ramdisk" END fi @@ -50,11 +50,11 @@ umount $lvbase mkdir -p /dev/${pfx}_fs ln -sf ../$lvbaserhs $lvfsptr -xm create $xmdomain name=$xmname +xm create $adt_xmconfig name=$xmname retries=10 while true; do - if ping -c 1 $guestaddr && ./on-testbed id; then break; fi + 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 diff --git a/xen/tail-config b/xen/tail-config new file mode 100644 index 0000000..ea4acf8 --- /dev/null +++ b/xen/tail-config @@ -0,0 +1,111 @@ +case "$adt_vg" in +'') + echo "searching for default volume group ..." + vgdisplay_out=`vgdisplay -c` + case "$vgdisplay_out" in + "") fail 'no volume groups found';; + *" +"*) fail 'several volume groups, config must specify which';; + esac + $adt_vg=${vgdisplay_out%%:*} + echo "system has one volume group, $adt_vg, using that." + ;; +esac + +case "$adt_kernel" in +'') + echo "searching for kernel ..." + for f in /boot/xen*"`uname -r`"; do + test -f "$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" + ;; +esac + +case "$adt_ramdisk" in +none) echo "ramdisk \`none' specified, using static kernel" + adt_ramdisk='' ;; +'') adt_ramdisk="$adt_kernel.initrd.img" + echo "using default ramdisk .initrd.img, $adt_ramdisk" ;; +*) ;; +esac + +case "$adt_distro" in +'') + echo "considering which distro to use ..." + test -f /etc/lsb-release || \ + fail 'no /etc/lsb-version, config must specify adt_distro' + . /etc/lsb-release + $adt_distro=$DISTRIB_CODENAME + ;; +esac + +hostname_from_ipaddr () { + eval ' + if [ x"$adt_'$1'_hostname" = x ] && \ + [ x"$adt_'$1'_ipaddr" != x ]; then + echo "finding '$1' hostname from IP address $adt_'$1'_ipaddr" + adt_'$1'_hostname=`adnshost -t ptr +Do +Dt +Dc -i $adt_'$1'_ipaddr` + fi + ' +} + +hostname_from_ipaddr guest +hostname_from_ipaddr host + +if [ x"$adt_host_hostname" = x ]; then + echo "finding host hostname, supposely our own FQDN ..." + adt_host_hostname=`hostname -f` +fi + +if [ x"$adt_guest_hostname" = x ]; then + case "$adt_guests_domain" in + '') echo "guessing guest hostname from host hostname ..." + adt_guest_hostname=$adt_distro.$adt_nominum.${adt_host_hostname#*.} ;; + .*) echo "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 ..." + adt_guest_hostname=$adt_distro.$adt_guests_domain ;; + esac +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"` + fi + ' +} + +ipaddr_from_hostname guest +ipaddr_from_hostname host + +# SSH +: ${adt_sshkey:=/root/.ssh/id_dsa_${adt_nominum}} + +# Xen +: ${adt_xmname:=${adt_nominum}_${adt_distro}} + +# In-host-file-system playground +: ${adt_play:=${adt_playbase}/${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_lvfsptrrhs:=${adt_nominum}_fs/${adt_distro}} +: ${adt_lvfsptr:=/dev/${adt_lvfsptrrhs}} diff --git a/xen/vif-common.sh b/xen/vif-common.sh deleted file mode 120000 index 044e402..0000000 --- a/xen/vif-common.sh +++ /dev/null @@ -1 +0,0 @@ -/etc/xen/scripts/vif-common.sh \ No newline at end of file -- 2.30.2