Skip to contentSkip to conversation

Debian PV netboot guest test

PATCH/RFC OSSTEST Ian Campbell 3 participants 7 messages Nov 25, 2013

lore
Share & tools
lore
#0 lore raw

I've been working on this on the odd occasion, I think it mostly works, or it did last I tried which was a while back. I'm sure it is too hacky in places. My plan was to clean it up on the next test day.

I'm mostly just sending this for Wei's benefit since he is independently looking at adding Debian HVM guest tests for OVMF purposes.

Ian.

commit f7ac42c6384cbf0f221b556c9c91ee5e8b944752

Author: Ian Campbell <[email protected]>
Date:   Sun Nov 17 15:30:29 2013 +0000

DI

Osstest/Debian.pm +125 -41
index e51a233..4b0911c 100644
@@ -34,6 +34,7 @@ BEGIN {
     @EXPORT      = qw(debian_boot_setup
                       %preseed_cmds
                       preseed_create
+                      preseed_create_guest
                       preseed_hook_command preseed_hook_installscript
                       di_installcmdline_core
                       );
@@ -434,6 +435,128 @@ sub di_installcmdline_core ($$;@) {
     return @cl;
 }             
 
+sub preseed_base ($) {
+    my ($suite) = @_;
+
+    my $preseed= (<<END);
+d-i mirror/suite string $suite
+
+d-i debian-installer/locale string en_GB
+d-i console-keymaps-at/keymap select gb
+d-i keyboard-configuration/xkb-keymap string en_GB
+
+#d-i debconf/frontend string readline
+
+d-i mirror/country string manual
+d-i mirror/http/proxy string
+
+d-i clock-setup/utc boolean true
+d-i time/zone string Europe/London
+d-i clock-setup/ntp boolean true
+
+#d-i netcfg/disable_dhcp boolean true
+d-i netcfg/get_nameservers string $c{NetNameservers}
+#d-i netcfg/get_netmask string \$c{NetNetmask}
+#d-i netcfg/get_gateway string \$c{NetGateway}
+d-i netcfg/confirm_static boolean true
+d-i netcfg/get_domain string $c{TestHostDomain}
+d-i netcfg/wireless_wep string
+
+d-i passwd/root-password password xenroot
+d-i passwd/root-password-again password xenroot
+d-i passwd/user-fullname string FLOSS Xen Test
+d-i passwd/username string osstest
+d-i passwd/user-password password osstest
+d-i passwd/user-password-again password osstest
+
+console-common  console-data/keymap/policy      select  Don't touch keymap
+console-data    console-data/keymap/policy      select  Don't touch keymap
+console-data    console-data/keymap/family      select  qwerty
+console-data console-data/keymap/template/layout select British
+
+popularity-contest popularity-contest/participate boolean false
+
+d-i mirror/http/hostname string $c{DebianMirrorHost}
+d-i mirror/http/directory string /$c{DebianMirrorSubpath}
+END
+    return $preseed;
+}
+
+sub preseed_create_guest ($$;@) {
+    my ($ho, $sfx, %xopts) = @_;
+
+    my $suite= $xopts{Suite} || $c{DebianSuite};
+
+    my $preseed_file= preseed_base($suite);
+    $preseed_file.= (<<END);
+d-i     partman-auto/method             string regular
+d-i     partman-auto/choose_recipe \\
+                select All files in one partition (recommended for new users)
+d-i     partman/confirm_write_new_label boolean true
+d-i     partman/choose_partition \\
+                select Finish partitioning and write changes to disk
+
+d-i     partman/confirm                 boolean true
+
+d-i     partman-partitioning/confirm_write_new_label boolean true
+d-i     partman/choose_partition select finish
+d-i     partman/confirm boolean true
+d-i     partman/confirm_nooverwrite boolean true
+
+d-i     grub-installer/only_debian      boolean true
+
+tasksel tasksel/first                   multiselect standard
+
+d-i     pkgsel/include string openssh-server, ntp, ntpdate
+
+d-i     finish-install/reboot_in_progress       note
+
+
+END
+#$xopts{ExtraPreseed}
+
+    my $authkeys= authorized_keys();
+
+    my $hostkeyfile= "$c{OverlayLocal}/etc/ssh/ssh_host_rsa_key";
+    my $host_rsa_key= get_filecontents($hostkeyfile);
+    chomp($host_rsa_key); $host_rsa_key.="\n";
+
+    preseed_hook_command($ho, 'late_command', $sfx, <<END);
+#!/bin/sh
+set -ex
+
+r=/target/root
+cd \$r
+
+umask 022
+mkdir .ssh
+cat <<'ENDKEYS' >.ssh/authorized_keys
+$authkeys
+ENDKEYS
+
+u=osstest
+h=/home/\$u
+mkdir /target\$h/.ssh
+cp .ssh/authorized_keys /target\$h/.ssh
+chroot /target chown -R \$u.\$u \$h/.ssh
+
+rm -f /target/etc/ssh/ssh_host_*_key
+rm -f /target/etc/ssh/ssh_host_*_key.pub
+
+cat <<'ENDKEYS' > /target/etc/ssh/ssh_host_rsa_key
+$host_rsa_key
+ENDKEYS
+chmod 0600 /target/etc/ssh/ssh_host_rsa_key
+END
+
+    foreach my $di_key (keys %preseed_cmds) {
+        $preseed_file .= "d-i preseed/$di_key string ".
+            (join ' && ', @{ $preseed_cmds{$di_key} }). "\n";
+    }
+
+    return create_webfile($ho, "preseed$sfx", $preseed_file);
+}
+
 sub preseed_create ($$;@) {
     my ($ho, $sfx, %xopts) = @_;
 
@@ -619,22 +742,8 @@ END
 
     my $extra_packages = join(",",@extra_packages);
 
-    my $preseed_file= (<<END);
-d-i mirror/suite string $suite
-
-d-i debian-installer/locale string en_GB
-d-i console-keymaps-at/keymap select gb
-d-i keyboard-configuration/xkb-keymap string en_GB
-
-#d-i debconf/frontend string readline
-
-d-i mirror/country string manual
-d-i mirror/http/proxy string
-
-d-i clock-setup/utc boolean true
-d-i time/zone string Europe/London
-d-i clock-setup/ntp boolean true
-
+    my $preseed_file= preseed_base($suite);
+    $preseed_file.= (<<END);
 d-i partman-auto/method string lvm
 #d-i partman-auto/method string regular
 
@@ -650,14 +759,6 @@ d-i partman-lvm/confirm_nooverwrite true
 d-i partman-md/confirm_nooverwrite true
 d-i partman-crypto/confirm_nooverwrite true
 
-#d-i netcfg/disable_dhcp boolean true
-d-i netcfg/get_nameservers string $c{NetNameservers}
-#d-i netcfg/get_netmask string \$c{NetNetmask}
-#d-i netcfg/get_gateway string \$c{NetGateway}
-d-i netcfg/confirm_static boolean true
-d-i netcfg/get_domain string $c{TestHostDomain}
-d-i netcfg/wireless_wep string
-
 #d-i partman-auto/init_automatically_partition select regular
 d-i partman-auto/disk string $disk
 
@@ -685,19 +786,6 @@ d-i partman-auto/expert_recipe string					\\
 			lv_name{ dummy }				\\
 		.
 
-d-i passwd/root-password password xenroot
-d-i passwd/root-password-again password xenroot
-d-i passwd/user-fullname string FLOSS Xen Test
-d-i passwd/username string osstest
-d-i passwd/user-password password osstest
-d-i passwd/user-password-again password osstest
-
-console-common  console-data/keymap/policy      select  Don't touch keymap
-console-data    console-data/keymap/policy      select  Don't touch keymap
-console-data    console-data/keymap/family      select  qwerty
-console-data console-data/keymap/template/layout select British
-
-popularity-contest popularity-contest/participate boolean false
 tasksel tasksel/first multiselect standard, web-server
 
 d-i pkgsel/include string openssh-server, ntp, ntpdate, $extra_packages
@@ -708,12 +796,8 @@ d-i finish-install/keep-consoles boolean true
 d-i finish-install/reboot_in_progress note
 d-i cdrom-detect/eject boolean false
 
-d-i mirror/http/hostname string $c{DebianMirrorHost}
-d-i mirror/http/directory string /$c{DebianMirrorSubpath}
-
 $xopts{ExtraPreseed}
 END
-
     foreach my $di_key (keys %preseed_cmds) {
         $preseed_file .= "d-i preseed/$di_key string ".
             (join ' && ', @{ $preseed_cmds{$di_key} }). "\n";
Osstest/TestSupport.pm +13 -1
index a9cdc9c..dbe5e31 100644
@@ -87,7 +87,8 @@ BEGIN {
                       guest_umount_lv guest_await guest_await_dhcp_tcp
                       guest_checkrunning guest_check_ip guest_find_ether
                       guest_find_domid guest_check_up guest_check_up_quick
-                      guest_get_state guest_await_reboot guest_destroy
+                      guest_get_state guest_await_reboot
+                      guest_await_shutdown guest_destroy
                       guest_vncsnapshot_begin guest_vncsnapshot_stash
 		      guest_check_remus_ok guest_editconfig
                       host_involves_pcipassthrough host_get_pcipassthrough_devs
@@ -1190,6 +1191,17 @@ sub guest_await_reboot ($$$) {
         return undef if $st eq 'sr';
         fail("guest unexpectedly shutdown; state is '$st'")
             if $st =~ m/^s/ || $st eq '';
+        return "guest state is \"$st\"";
+    });
+}
+
+sub guest_await_shutdown ($$$) {
+    my ($ho,$gho, $timeout) = @_;
+    poll_loop($timeout, 30, "await shutdown request from $gho->{Guest}", sub {
+        my $st= guest_get_state($ho,$gho);
+        return undef if $st eq 's';
+        fail("guest unexpectedly shutdown; state is '$st'")
+            if $st =~ m/^s/ || $st eq '';
         return "guest state is $st";
     });
 }
make-flight +23 -0
index a5d21af..95f8d53 100755
@@ -329,6 +329,29 @@ for xenarch in ${TEST_ARCHES- i386 amd64 armhf } ; do
 		kernkind=$kernkind		        	\
 		$arch_runvars $suite_runvars
 		"
+
+      case ${xenarch} in
+	  amd64) domUarches="amd64 i386";;
+	  i386)  domUarches="";;
+	  armhf) domUarches="armhf";;
+      esac
+
+      for domU in $domUarches ; do
+        for dist in squeeze wheezy jessie ; do
+	  case $domU_$dist in
+	  armhf_squeeze) continue;;
+	  *) continue;;
+	  esac
+	  job_create_test test-$xenarch$kern-$dom0arch-$domU-di test-debian-di xl \
+		xenbuildjob=${bfi}build-$xenarch        	\
+		kernbuildjob=${bfi}build-$dom0arch-$kernbuild 	\
+		buildjob=${bfi}build-$dom0arch	        	\
+	        debian_arch=$domU \
+	        debian_dist=$dist \
+	        all_hostflags=$most_hostflags
+        done
+      done
+
       if [ $dom0arch = armhf ]; then
 	  job_create_test test-$xenarch$kern-$dom0arch-xl test-debian xl \
 		debian_kernkind=$kernkind				  \
sg-run-job +13 -0
index 0124223..00328ef 100755
@@ -246,6 +246,19 @@ proc run-job/test-debian {} {
     test-guest debian
 }
 
+# + netboot
+proc install-guest-debian-di {} {
+    run-ts . = ts-debian-install-di
+    #run-ts . = ts-debian-fixup-di + debian
+    run-ts . = ts-guest-start + debian
+}
+
+proc need-hosts/test-debian-di {} { return host }
+proc run-job/test-debian-di {} {
+    install-guest-debian-di
+    test-guest debian
+}
+
 proc need-hosts/test-win {} { return host }
 proc run-job/test-win {} {
     run-ts . = ts-windows-install
ts-debian-install-di new file +137 -0

137 lines not on this page · raw message

#1 lore raw
Quoted 6 lines · Ian Campbell

I've been working on this on the odd occasion, I think it mostly works, or it did last I tried which was a while back. I'm sure it is too hacky in places. My plan was to clean it up on the next test day.

I'm mostly just sending this for Wei's benefit since he is independently looking at adding Debian HVM guest tests for OVMF purposes.

FWIW I was planning to introduce a separate "distros" flight to osstest, which would semiregularly test a bunch of distros (of which Debian happens to just be the one I was interested in).

My lashed up skanky thinking here is appended..

Ian.

commit 15e5f1c85e3ccf8ca70aacb116401b9332256894

Author: Ian Campbell <[email protected]>
Date:   Mon Nov 25 14:36:40 2013 +0000

Make a distro flight for running di jobs.

make-distro-flight new file +201 -0
new file mode 100644
index 0000000..b02281d
@@ -0,0 +1,201 @@
+#!/bin/bash
+
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2009-2013 Citrix Inc.
+# 
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 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 Affero General Public License for more details.
+# 
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+set -e
+
+branch=$1
+xenbranch=$2
+blessing=$3
+buildflight=$4
+
+flight=`./cs-flight-create $blessing $branch`
+
+. ap-common
+. cri-common
+
+bfi=${buildflight}.
+
+stripy () {
+        local out_vn="$1"; shift
+        local out_0="$1"; shift
+        local out_1="$1"; shift
+        local out_val=0
+        local this_val
+        local this_cmp
+        while [ $# != 0 ]; do
+                this_val="$1"; shift
+                this_cmp="$1"; shift
+                if [ "x$this_val" = "x$this_cmp" ]; then
+                        out_val=$(( $out_val ^ 1 ))
+                fi
+        done
+        eval "$out_vn=\"\$out_$out_val\""
+}
+
+job_create_test () {
+	local job=$1; shift
+	local recipe=$1; shift
+	local toolstack=$1; shift
+
+        local job_md5=`echo "$job" | md5sum`
+        job_md5="${job_md5%  -}"
+
+        if [ "x$JOB_MD5_PATTERN" != x ]; then
+                case "$job_md5" in
+                $JOB_MD5_PATTERN)       ;;
+                *)                      return;;
+                esac
+        fi
+
+	case "$branch" in
+	qemu-upstream-*)
+		case " $* " in
+		*" device_model_version=qemu-xen "*)
+			;;
+		*)
+			: "suppressed $job"
+			return;;
+		esac
+		;;
+	*)
+	        case "$job" in
+		*-qemuu-*)
+	           if [ "x$toolstack" != xxl ]; then return; fi
+
+	           case "$job" in
+	           *-win*)
+	                      case "$job_md5" in
+	                      *[0-a]) return;;
+	                      esac
+	                      ;;
+	           esac
+	           ;;
+		esac
+		;;
+        esac
+
+	./cs-job-create $flight $job $recipe toolstack=$toolstack \
+		$RUNVARS $TEST_RUNVARS $most_runvars "$@"
+}
+
+for xenarch in ${TEST_ARCHES- i386 amd64 armhf } ; do
+
+  if [ "x$xenarch" = xdisable ]; then continue; fi
+
+  case "$xenarch" in
+  armhf)
+	# Arm from 4.3 onwards only
+	case "$xenbranch" in
+	xen-3.*-testing) continue;;
+	xen-4.0-testing) continue;;
+	xen-4.1-testing) continue;;
+	xen-4.2-testing) continue;;
+	*) ;;
+	esac
+	;;
+  i386)
+	# 32-bit Xen is dropped from 4.3 onwards
+	case "$xenbranch" in
+	xen-3.*-testing) ;;
+	xen-4.0-testing) ;;
+	xen-4.1-testing) ;;
+	xen-4.2-testing) ;;
+	*) continue ;;
+	esac
+	;;
+  amd64)
+	;;
+  esac
+
+  case "$xenbranch" in
+  xen-3.*-testing)	onetoolstack=xend ;;
+  xen-4.0-testing)	onetoolstack=xend ;;
+  xen-4.1-testing)	onetoolstack=xend ;;
+  *)			onetoolstack=xl ;;
+  esac
+
+  for kern in ''; do
+
+    case $kern in
+    '')
+                kernbuild=pvops
+		kernkind=pvops
+		;;
+    -xcpkern)
+                kernbuild=xcpkern
+		kernkind=2627
+		if [ "x$REVISION_LINUX_XCP" = xdisable ]; then continue; fi
+		;;
+    *)		echo >&2 "kernkind ?  $kern"; exit 1 ;;
+    esac
+
+    for dom0arch in i386 amd64 armhf; do
+
+      case ${xenarch}_${dom0arch} in
+	  amd64_amd64) ;;
+	  amd64_i386) ;;
+	  i386_i386) ;;
+	  armhf_armhf) ;;
+	  *) continue ;;
+      esac
+
+      eval "
+	  arch_runvars=\"\$ARCH_RUNVARS_$dom0arch\"
+      "
+
+      if [ x$kern = x-xcpkern -a $dom0arch != i386 ]; then continue; fi
+
+      most_hostflags="arch-$dom0arch,arch-xen-$xenarch,suite-$suite,purpose-test"
+
+      most_runvars="
+		arch=$dom0arch			        	\
+		xenbuildjob=${bfi}build-$xenarch        	\
+		kernbuildjob=${bfi}build-$dom0arch-$kernbuild 	\
+		buildjob=${bfi}build-$dom0arch	        	\
+		kernkind=$kernkind		        	\
+		$arch_runvars $suite_runvars
+		"
+
+      case ${xenarch} in
+	  amd64) domUarches="amd64 i386";;
+	  i386)  domUarches="";;
+	  armhf) domUarches="armhf";;
+      esac
+
+      for domU in $domUarches ; do
+        for dist in squeeze wheezy jessie ; do
+	  case $domU_$dist in
+	  armhf_squeeze) continue;;
+	  *) ;;
+	  esac
+	  job_create_test test-$xenarch$kern-$dom0arch-$domU-$dist-di test-debian-di xl \
+		xenbuildjob=${bfi}build-$xenarch        	\
+		kernbuildjob=${bfi}build-$dom0arch-$kernbuild 	\
+		buildjob=${bfi}build-$dom0arch	        	\
+	        debian_arch=$domU \
+	        debian_dist=$dist \
+	        all_hostflags=$most_hostflags
+        done
+      done
+    done
+  done
+
+done
+
+echo $flight
make-flight +0 -23
index 95f8d53..a5d21af 100755
@@ -329,29 +329,6 @@ for xenarch in ${TEST_ARCHES- i386 amd64 armhf } ; do
 		kernkind=$kernkind		        	\
 		$arch_runvars $suite_runvars
 		"
-
-      case ${xenarch} in
-	  amd64) domUarches="amd64 i386";;
-	  i386)  domUarches="";;
-	  armhf) domUarches="armhf";;
-      esac
-
-      for domU in $domUarches ; do
-        for dist in squeeze wheezy jessie ; do
-	  case $domU_$dist in
-	  armhf_squeeze) continue;;
-	  *) continue;;
-	  esac
-	  job_create_test test-$xenarch$kern-$dom0arch-$domU-di test-debian-di xl \
-		xenbuildjob=${bfi}build-$xenarch        	\
-		kernbuildjob=${bfi}build-$dom0arch-$kernbuild 	\
-		buildjob=${bfi}build-$dom0arch	        	\
-	        debian_arch=$domU \
-	        debian_dist=$dist \
-	        all_hostflags=$most_hostflags
-        done
-      done
-
       if [ $dom0arch = armhf ]; then
 	  job_create_test test-$xenarch$kern-$dom0arch-xl test-debian xl \
 		debian_kernkind=$kernkind				  \
sg-report-flight +7 -5
index 69ef252..65733d1 100755
@@ -95,7 +95,9 @@ while (@ARGV && $ARGV[0] =~ m/^-/) {
 @ARGV==1 or die;
 
 $_= shift @ARGV;
-if (m/^\d+$/) {
+if(m/^standalone.*$/) {
+    $specflight= $_;
+} elsif (m/^\d+$/) {
     $specflight= $_;
 } else {
     $branch= $_;
@@ -282,12 +284,12 @@ sub examineflight ($) {
 
     my $flightinfo= $dbh_tests->selectrow_hashref(<<END);
         SELECT * FROM flights
-            WHERE flight=$flight
+            WHERE flight="$flight"
 END
 
     my $jobs= $dbh_tests->selectall_arrayref(<<END, { Slice => {} });
         SELECT * FROM jobs
-            WHERE flight=$flight
+            WHERE flight="$flight"
 END
 
     my $colmap= sub {
@@ -303,7 +305,7 @@ END
 
     my $stepsq= $dbh_tests->prepare(<<END);
         SELECT * FROM steps
-            WHERE flight=$flight AND job=?
+            WHERE flight="$flight" AND job=?
             ORDER BY stepno
 END
 
@@ -425,7 +427,7 @@ END
 
         my $revh= $dbh_tests->prepare(<<END);
             SELECT * FROM runvars
-                WHERE flight=$flight AND job='$j->{job}'
+                WHERE flight="$flight" AND job='$j->{job}'
                   AND name like 'built_revision_%'
                 ORDER BY name
 END
standalone-reset +4 -1
index 8be7e86..b045dba 100755
@@ -156,7 +156,10 @@ fi
 export BUILD_LVEXTEND_MAX
 
 OSSTEST_FLIGHT=$flight \
-./make-flight "$branch" "$xenbranch" play $buildflight >/dev/null
+mainflight=`./make-flight "$branch" "$xenbranch" play $buildflight` >/dev/null
+
+OSSTEST_FLIGHT=${flight:-standalone}-distros \
+./make-distro-flight distros "$xenbranch" play $mainflight >/dev/null
 
 #---------- done ----------
#2 lore raw

Ian Campbell writes ("Re: [PATCH/RFC OSSTEST] Debian PV netboot guest test"):

Quoted 5 lines · Ian Campbell
Quoted 4 lines

I've been working on this on the odd occasion, I think it mostly works, or it did last I tried which was a while back. I'm sure it is too hacky in places. My plan was to clean it up on the next test day.

Quoted 8 lines
Quoted 2 lines

I'm mostly just sending this for Wei's benefit since he is independently looking at adding Debian HVM guest tests for OVMF purposes.

FWIW I was planning to introduce a separate "distros" flight to osstest, which would semiregularly test a bunch of distros (of which Debian happens to just be the one I was interested in).

My lashed up skanky thinking here is appended..

This is quite nasty, isn't it.

Quoted 7 lines
make-distro-flight new file +1 -0
new file mode 100644
index 0000000..b02281d
@@ -0,0 +1,201 @@
+#!/bin/bash

...

Quoted 5 lines
make-distro-flight new file +5 -0
+stripy () {
+        local out_vn="$1"; shift
+        local out_0="$1"; shift
+        local out_1="$1"; shift
+        local out_val=0

make-distro-flight line 48

Quoted 10 lines
make-distro-flight new file +10 -0
+        local this_val
+        local this_cmp
+        while [ $# != 0 ]; do
+                this_val="$1"; shift
+                this_cmp="$1"; shift
+                if [ "x$this_val" = "x$this_cmp" ]; then
+                        out_val=$(( $out_val ^ 1 ))
+                fi
+        done
+        eval "$out_vn=\"\$out_$out_val\""

make-flight is hardly the most well-structured area of osstest, but at the very least, much of this common code needs to be in a common script sourced by both make-flights.

As an alternative to this, perhaps you want to tangle make-flight some more by making its contents conditional :-/. Hmm. Not sure that appeals.

Quoted 5 lines
sg-report-flight +0 -0
index 69ef252..65733d1 100755
@@ -95,7 +95,9 @@ while (@ARGV && $ARGV[0] =~ m/^-/) {

...

sg-report-flight

Quoted 4 lines

my $flightinfo= $dbh_tests->selectrow_hashref(<<END);
SELECT * FROM flights

sg-report-flight +1 -1
-            WHERE flight=$flight
+            WHERE flight="$flight"

This needs to be done with ?-substitution, because in the actual database the flight columns are INTEGER.

standalone-reset fi · line 162

Quoted 13 lines
standalone-reset +4 -1
index 8be7e86..b045dba 100755
@@ -156,7 +156,10 @@ fi
 export BUILD_LVEXTEND_MAX
 
 OSSTEST_FLIGHT=$flight \
-./make-flight "$branch" "$xenbranch" play $buildflight >/dev/null
+mainflight=`./make-flight "$branch" "$xenbranch" play $buildflight` >/dev/null
+
+OSSTEST_FLIGHT=${flight:-standalone}-distros \
+./make-distro-flight distros "$xenbranch" play $mainflight >/dev/null

This really doesn't make any kind of sense.

Ian.

#3 lore raw
Quoted 9 lines · Ian Jackson

Ian Campbell writes ("Re: [PATCH/RFC OSSTEST] Debian PV netboot guest test"):

Quoted 8 lines · Ian Campbell
Quoted 6 lines

I've been working on this on the odd occasion, I think it mostly works, or it did last I tried which was a while back. I'm sure it is too hacky in places. My plan was to clean it up on the next test day.

I'm mostly just sending this for Wei's benefit since he is independently looking at adding Debian HVM guest tests for OVMF purposes.

Quoted 7 lines
Quoted 5 lines

FWIW I was planning to introduce a separate "distros" flight to osstest, which would semiregularly test a bunch of distros (of which Debian happens to just be the one I was interested in).

My lashed up skanky thinking here is appended..

This is quite nasty, isn't it.

Yeah, it was mostly just for completeness rather than because I thought it needed commenting on, I should have said so, sorry. Thanks anyway.

Quoted 25 lines
Quoted 8 lines
make-distro-flight new file +1 -0
new file mode 100644
index 0000000..b02281d
@@ -0,0 +1,201 @@
+#!/bin/bash

...

Quoted 5 lines
make-distro-flight new file +5 -0
+stripy () {
+        local out_vn="$1"; shift
+        local out_0="$1"; shift
+        local out_1="$1"; shift
+        local out_val=0

make-distro-flight line 48

Quoted 10 lines
make-distro-flight new file +10 -0
+        local this_val
+        local this_cmp
+        while [ $# != 0 ]; do
+                this_val="$1"; shift
+                this_cmp="$1"; shift
+                if [ "x$this_val" = "x$this_cmp" ]; then
+                        out_val=$(( $out_val ^ 1 ))
+                fi
+        done
+        eval "$out_vn=\"\$out_$out_val\""
Quoted 3 lines

make-flight is hardly the most well-structured area of osstest, but at the very least, much of this common code needs to be in a common script sourced by both make-flights.

That was along the lines of what I was thinking of doing eventually.

Quoted 11 lines

As an alternative to this, perhaps you want to tangle make-flight some more by making its contents conditional :-/. Hmm. Not sure that appeals.

Quoted 5 lines
sg-report-flight +0 -0
index 69ef252..65733d1 100755
@@ -95,7 +95,9 @@ while (@ARGV && $ARGV[0] =~ m/^-/) {

...

Quoted 7 lines

sg-report-flight

Quoted 4 lines

my $flightinfo= $dbh_tests->selectrow_hashref(<<END);
SELECT * FROM flights

sg-report-flight +1 -1
-            WHERE flight=$flight
+            WHERE flight="$flight"

This needs to be done with ?-substitution, because in the actual database the flight columns are INTEGER.

Ah, makes sense.

Quoted 8 lines
Quoted 8 lines
standalone-reset +0 -0
index 8be7e86..b045dba 100755
@@ -156,7 +156,10 @@ fi
 export BUILD_LVEXTEND_MAX
 
Quoted 8 lines

standalone-reset fi · line 162

Quoted 6 lines
standalone-reset +4 -1
 OSSTEST_FLIGHT=$flight \
-./make-flight "$branch" "$xenbranch" play $buildflight >/dev/null
+mainflight=`./make-flight "$branch" "$xenbranch" play $buildflight` >/dev/null
+
+OSSTEST_FLIGHT=${flight:-standalone}-distros \
+./make-distro-flight distros "$xenbranch" play $mainflight >/dev/null

This really doesn't make any kind of sense.

What I wanted to do eventually was have the distro flight pickup the build results from the most recent successful normal test flight (and/or avoid duplicating those bits of make-flight).

Perhaps I should just rebuild everything though. And the duplciation can be handled via the library scriptlet as you suggested.

Ian.

#4 lore raw

Ian Campbell writes ("Re: [PATCH/RFC OSSTEST] Debian PV netboot guest test"):

Quoted 8 lines · Ian Jackson
Quoted 4 lines

Ian Campbell writes ("Re: [PATCH/RFC OSSTEST] Debian PV netboot guest test"):

Quoted 1 line

My lashed up skanky thinking here is appended..

This is quite nasty, isn't it.

Yeah, it was mostly just for completeness rather than because I thought it needed commenting on, I should have said so, sorry. Thanks anyway.

You did warn me :-).

Quoted 1 line
Quoted 1 line
Quoted 1 line
standalone-reset +0 -0

...

Quoted 9 lines
Quoted 8 lines

standalone-reset fi · line 162

Quoted 6 lines

OSSTEST_FLIGHT=$flight \
-./make-flight "$branch" "$xenbranch" play $buildflight >/dev/null

standalone-reset +4 -0
+mainflight=`./make-flight "$branch" "$xenbranch" play $buildflight` >/dev/null
+
+OSSTEST_FLIGHT=${flight:-standalone}-distros \
+./make-distro-flight distros "$xenbranch" play $mainflight >/dev/null

This really doesn't make any kind of sense.

Quoted 6 lines

What I wanted to do eventually was have the distro flight pickup the build results from the most recent successful normal test flight (and/or avoid duplicating those bits of make-flight).

Perhaps I should just rebuild everything though. And the duplciation can be handled via the library scriptlet as you suggested.

Rebuilding is fine I think. Much of it will benefit from ccache.

Ian.

#5 lore raw
In reply to Ian Campbell
Quoted 7 lines · Ian Campbell

I've been working on this on the odd occasion, I think it mostly works, or it did last I tried which was a while back. I'm sure it is too hacky in places. My plan was to clean it up on the next test day.

I'm mostly just sending this for Wei's benefit since he is independently looking at adding Debian HVM guest tests for OVMF purposes.

A quick glance suggests that most configurations are the same. I will see if I can easily PXE-boot OVMF guest. But in any case it is fairly easy to reuse the generated preseed and put it in an ISO.

Wei.

Quoted 456 lines

Ian.

commit f7ac42c6384cbf0f221b556c9c91ee5e8b944752

Author: Ian Campbell <[email protected]>
Date:   Sun Nov 17 15:30:29 2013 +0000

DI

Osstest/Debian.pm +125 -41
index e51a233..4b0911c 100644
@@ -34,6 +34,7 @@ BEGIN {
     @EXPORT      = qw(debian_boot_setup
                       %preseed_cmds
                       preseed_create
+                      preseed_create_guest
                       preseed_hook_command preseed_hook_installscript
                       di_installcmdline_core
                       );
@@ -434,6 +435,128 @@ sub di_installcmdline_core ($$;@) {
     return @cl;
 }             
 
+sub preseed_base ($) {
+    my ($suite) = @_;
+
+    my $preseed= (<<END);
+d-i mirror/suite string $suite
+
+d-i debian-installer/locale string en_GB
+d-i console-keymaps-at/keymap select gb
+d-i keyboard-configuration/xkb-keymap string en_GB
+
+#d-i debconf/frontend string readline
+
+d-i mirror/country string manual
+d-i mirror/http/proxy string
+
+d-i clock-setup/utc boolean true
+d-i time/zone string Europe/London
+d-i clock-setup/ntp boolean true
+
+#d-i netcfg/disable_dhcp boolean true
+d-i netcfg/get_nameservers string $c{NetNameservers}
+#d-i netcfg/get_netmask string \$c{NetNetmask}
+#d-i netcfg/get_gateway string \$c{NetGateway}
+d-i netcfg/confirm_static boolean true
+d-i netcfg/get_domain string $c{TestHostDomain}
+d-i netcfg/wireless_wep string
+
+d-i passwd/root-password password xenroot
+d-i passwd/root-password-again password xenroot
+d-i passwd/user-fullname string FLOSS Xen Test
+d-i passwd/username string osstest
+d-i passwd/user-password password osstest
+d-i passwd/user-password-again password osstest
+
+console-common  console-data/keymap/policy      select  Don't touch keymap
+console-data    console-data/keymap/policy      select  Don't touch keymap
+console-data    console-data/keymap/family      select  qwerty
+console-data console-data/keymap/template/layout select British
+
+popularity-contest popularity-contest/participate boolean false
+
+d-i mirror/http/hostname string $c{DebianMirrorHost}
+d-i mirror/http/directory string /$c{DebianMirrorSubpath}
+END
+    return $preseed;
+}
+
+sub preseed_create_guest ($$;@) {
+    my ($ho, $sfx, %xopts) = @_;
+
+    my $suite= $xopts{Suite} || $c{DebianSuite};
+
+    my $preseed_file= preseed_base($suite);
+    $preseed_file.= (<<END);
+d-i     partman-auto/method             string regular
+d-i     partman-auto/choose_recipe \\
+                select All files in one partition (recommended for new users)
+d-i     partman/confirm_write_new_label boolean true
+d-i     partman/choose_partition \\
+                select Finish partitioning and write changes to disk
+
+d-i     partman/confirm                 boolean true
+
+d-i     partman-partitioning/confirm_write_new_label boolean true
+d-i     partman/choose_partition select finish
+d-i     partman/confirm boolean true
+d-i     partman/confirm_nooverwrite boolean true
+
+d-i     grub-installer/only_debian      boolean true
+
+tasksel tasksel/first                   multiselect standard
+
+d-i     pkgsel/include string openssh-server, ntp, ntpdate
+
+d-i     finish-install/reboot_in_progress       note
+
+
+END
+#$xopts{ExtraPreseed}
+
+    my $authkeys= authorized_keys();
+
+    my $hostkeyfile= "$c{OverlayLocal}/etc/ssh/ssh_host_rsa_key";
+    my $host_rsa_key= get_filecontents($hostkeyfile);
+    chomp($host_rsa_key); $host_rsa_key.="\n";
+
+    preseed_hook_command($ho, 'late_command', $sfx, <<END);
+#!/bin/sh
+set -ex
+
+r=/target/root
+cd \$r
+
+umask 022
+mkdir .ssh
+cat <<'ENDKEYS' >.ssh/authorized_keys
+$authkeys
+ENDKEYS
+
+u=osstest
+h=/home/\$u
+mkdir /target\$h/.ssh
+cp .ssh/authorized_keys /target\$h/.ssh
+chroot /target chown -R \$u.\$u \$h/.ssh
+
+rm -f /target/etc/ssh/ssh_host_*_key
+rm -f /target/etc/ssh/ssh_host_*_key.pub
+
+cat <<'ENDKEYS' > /target/etc/ssh/ssh_host_rsa_key
+$host_rsa_key
+ENDKEYS
+chmod 0600 /target/etc/ssh/ssh_host_rsa_key
+END
+
+    foreach my $di_key (keys %preseed_cmds) {
+        $preseed_file .= "d-i preseed/$di_key string ".
+            (join ' && ', @{ $preseed_cmds{$di_key} }). "\n";
+    }
+
+    return create_webfile($ho, "preseed$sfx", $preseed_file);
+}
+
 sub preseed_create ($$;@) {
     my ($ho, $sfx, %xopts) = @_;
 
@@ -619,22 +742,8 @@ END
 
     my $extra_packages = join(",",@extra_packages);
 
-    my $preseed_file= (<<END);
-d-i mirror/suite string $suite
-
-d-i debian-installer/locale string en_GB
-d-i console-keymaps-at/keymap select gb
-d-i keyboard-configuration/xkb-keymap string en_GB
-
-#d-i debconf/frontend string readline
-
-d-i mirror/country string manual
-d-i mirror/http/proxy string
-
-d-i clock-setup/utc boolean true
-d-i time/zone string Europe/London
-d-i clock-setup/ntp boolean true
-
+    my $preseed_file= preseed_base($suite);
+    $preseed_file.= (<<END);
 d-i partman-auto/method string lvm
 #d-i partman-auto/method string regular
 
@@ -650,14 +759,6 @@ d-i partman-lvm/confirm_nooverwrite true
 d-i partman-md/confirm_nooverwrite true
 d-i partman-crypto/confirm_nooverwrite true
 
-#d-i netcfg/disable_dhcp boolean true
-d-i netcfg/get_nameservers string $c{NetNameservers}
-#d-i netcfg/get_netmask string \$c{NetNetmask}
-#d-i netcfg/get_gateway string \$c{NetGateway}
-d-i netcfg/confirm_static boolean true
-d-i netcfg/get_domain string $c{TestHostDomain}
-d-i netcfg/wireless_wep string
-
 #d-i partman-auto/init_automatically_partition select regular
 d-i partman-auto/disk string $disk
 
@@ -685,19 +786,6 @@ d-i partman-auto/expert_recipe string					\\
 			lv_name{ dummy }				\\
 		.
 
-d-i passwd/root-password password xenroot
-d-i passwd/root-password-again password xenroot
-d-i passwd/user-fullname string FLOSS Xen Test
-d-i passwd/username string osstest
-d-i passwd/user-password password osstest
-d-i passwd/user-password-again password osstest
-
-console-common  console-data/keymap/policy      select  Don't touch keymap
-console-data    console-data/keymap/policy      select  Don't touch keymap
-console-data    console-data/keymap/family      select  qwerty
-console-data console-data/keymap/template/layout select British
-
-popularity-contest popularity-contest/participate boolean false
 tasksel tasksel/first multiselect standard, web-server
 
 d-i pkgsel/include string openssh-server, ntp, ntpdate, $extra_packages
@@ -708,12 +796,8 @@ d-i finish-install/keep-consoles boolean true
 d-i finish-install/reboot_in_progress note
 d-i cdrom-detect/eject boolean false
 
-d-i mirror/http/hostname string $c{DebianMirrorHost}
-d-i mirror/http/directory string /$c{DebianMirrorSubpath}
-
 $xopts{ExtraPreseed}
 END
-
     foreach my $di_key (keys %preseed_cmds) {
         $preseed_file .= "d-i preseed/$di_key string ".
             (join ' && ', @{ $preseed_cmds{$di_key} }). "\n";
Osstest/TestSupport.pm +13 -1
index a9cdc9c..dbe5e31 100644
@@ -87,7 +87,8 @@ BEGIN {
                       guest_umount_lv guest_await guest_await_dhcp_tcp
                       guest_checkrunning guest_check_ip guest_find_ether
                       guest_find_domid guest_check_up guest_check_up_quick
-                      guest_get_state guest_await_reboot guest_destroy
+                      guest_get_state guest_await_reboot
+                      guest_await_shutdown guest_destroy
                       guest_vncsnapshot_begin guest_vncsnapshot_stash
 		      guest_check_remus_ok guest_editconfig
                       host_involves_pcipassthrough host_get_pcipassthrough_devs
@@ -1190,6 +1191,17 @@ sub guest_await_reboot ($$$) {
         return undef if $st eq 'sr';
         fail("guest unexpectedly shutdown; state is '$st'")
             if $st =~ m/^s/ || $st eq '';
+        return "guest state is \"$st\"";
+    });
+}
+
+sub guest_await_shutdown ($$$) {
+    my ($ho,$gho, $timeout) = @_;
+    poll_loop($timeout, 30, "await shutdown request from $gho->{Guest}", sub {
+        my $st= guest_get_state($ho,$gho);
+        return undef if $st eq 's';
+        fail("guest unexpectedly shutdown; state is '$st'")
+            if $st =~ m/^s/ || $st eq '';
         return "guest state is $st";
     });
 }
make-flight +23 -0
index a5d21af..95f8d53 100755
@@ -329,6 +329,29 @@ for xenarch in ${TEST_ARCHES- i386 amd64 armhf } ; do
 		kernkind=$kernkind		        	\
 		$arch_runvars $suite_runvars
 		"
+
+      case ${xenarch} in
+	  amd64) domUarches="amd64 i386";;
+	  i386)  domUarches="";;
+	  armhf) domUarches="armhf";;
+      esac
+
+      for domU in $domUarches ; do
+        for dist in squeeze wheezy jessie ; do
+	  case $domU_$dist in
+	  armhf_squeeze) continue;;
+	  *) continue;;
+	  esac
+	  job_create_test test-$xenarch$kern-$dom0arch-$domU-di test-debian-di xl \
+		xenbuildjob=${bfi}build-$xenarch        	\
+		kernbuildjob=${bfi}build-$dom0arch-$kernbuild 	\
+		buildjob=${bfi}build-$dom0arch	        	\
+	        debian_arch=$domU \
+	        debian_dist=$dist \
+	        all_hostflags=$most_hostflags
+        done
+      done
+
       if [ $dom0arch = armhf ]; then
 	  job_create_test test-$xenarch$kern-$dom0arch-xl test-debian xl \
 		debian_kernkind=$kernkind				  \
sg-run-job +13 -0
index 0124223..00328ef 100755
@@ -246,6 +246,19 @@ proc run-job/test-debian {} {
     test-guest debian
 }
 
+# + netboot
+proc install-guest-debian-di {} {
+    run-ts . = ts-debian-install-di
+    #run-ts . = ts-debian-fixup-di + debian
+    run-ts . = ts-guest-start + debian
+}
+
+proc need-hosts/test-debian-di {} { return host }
+proc run-job/test-debian-di {} {
+    install-guest-debian-di
+    test-guest debian
+}
+
 proc need-hosts/test-win {} { return host }
 proc run-job/test-win {} {
     run-ts . = ts-windows-install
ts-debian-install-di new file +137 -0
new file mode 100755
index 0000000..ff17619
@@ -0,0 +1,137 @@
+#!/usr/bin/perl -w
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2009-2013 Citrix Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 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 Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+use strict qw(vars);
+use DBI;
+use Osstest;
+use Osstest::Debian;
+use Osstest::TestSupport;
+
+tsreadconfig();
+
+our ($whhost,$gn,$flav) = @ARGV;
+$whhost ||= 'host';
+$gn ||= 'debian';
+$flav ||= 'netboot';
+
+our $ho= selecthost($whhost);
+
+our $ram_mb=    512;
+our $disk_mb= 10000;
+
+our $guesthost= "$gn.guest.osstest";
+our $gho;
+
+sub prep () {
+    target_install_packages_norec($ho, qw(lvm2));
+
+    $gho= prepareguest($ho, $gn, $guesthost, 22,
+                       $disk_mb, 40);
+
+    prepareguest_part_lvmdisk($ho, $gho, $disk_mb);
+
+    target_cmd_root($ho, "umount $gho->{Lvdev} ||:");
+}
+
+sub ginstall () {
+    my $arch= $r{"$gho->{Guest}_arch"};
+    my $gsuite= guest_var($gho,'suite',$c{GuestDebianSuite});
+    my $di_ver= guest_var($gho,'diversion','current');
+
+    print("guest: $gho->{Guest}\n");
+    print("ginstall: $arch\n");
+    print("gsuite: $gsuite\n");
+    print("mirror: \n");
+
+    my $di_url = "http://$c{DebianMirrorHost}/$c{DebianMirrorSubpath}/dists/$gsuite/main/installer-$arch/$di_ver/images/netboot/xen/";
+
+    target_cmd($ho, <<END, 2000);
+	wget -O /tmp/di_kernel $di_url/vmlinuz
+	wget -O /tmp/di_initrd $di_url/initrd.gz
+END
+
+    my $ps_url = preseed_create_guest($gho, '');
+
+    print("preseed: $ps_url\n");
+
+    my $onreboot= 'restart';#$xopts->{OnReboot} || 'restart';
+    my $vcpus= guest_var($gho, 'vcpus', 2);#$xopts->{DefVcpus} || 2);
+    my $install_cfg= <<END;
+name        = '$gho->{Name}'
+memory = ${ram_mb}
+#
+kernel      = "/tmp/di_kernel"
+ramdisk     = "/tmp/di_initrd"
+extra       = "debian-installer/exit/always_halt=true -- console=hvc0 auto-install/enable=true hostname=$gho->{Name} domain=$c{TestHostDomain} url=$ps_url DEBIAN_FRONTEND=text netcfg/dhcp_timeout=150 netcfg/choose_interface=eth0"
+#
+vif         = [ 'mac=$gho->{Ether}' ]
+#
+on_poweroff = 'preserve'
+on_reboot   = '$onreboot'
+on_crash    = 'preserve'
+#
+vcpus = $vcpus
+#
+disk        = [
+            'phy:$gho->{Lvdev},xvda,w'
+            ]
+#
+#\$cfgrest
+#
+#\$xoptcfg
+END
+    my $cfgpath= "/etc/xen/$gho->{Name}.cfg";
+
+    $gho->{CfgPath}= $cfgpath;
+    store_runvar("$gho->{Guest}_cfgpath", "$cfgpath");
+    target_putfilecontents_root_stash($ho,30,$install_cfg, $cfgpath);
+
+    my $cmd= toolstack()->{Command}." create ".
+        $r{ $gho->{Guest}.'_'. toolstack()->{CfgPathVar} };
+    target_cmd_root($ho, $cmd, 300);
+
+    guest_checkrunning($ho, $gho) or die "$gho->{Name} not running";
+
+    guest_await_shutdown($ho,$gho,2000);
+    guest_destroy($ho,$gho);
+
+    my $runtime_cfg= <<END;
+name        = '$gho->{Name}'
+memory = ${ram_mb}
+#
+bootloader = "pygrub"
+#
+vif         = [ 'mac=$gho->{Ether}' ]
+#
+on_poweroff = 'destroy'
+on_reboot   = '$onreboot'
+on_crash    = 'preserve'
+#
+vcpus = $vcpus
+#
+disk        = [
+            'phy:$gho->{Lvdev},xvda,w'
+            ]
+END
+
+    target_putfilecontents_root_stash($ho,30,$runtime_cfg, $cfgpath);
+
+    return;
+}
+
+prep();
+ginstall();
#6 lore raw
In reply to Ian Campbell

Ian Campbell writes ("[PATCH/RFC OSSTEST] Debian PV netboot guest test"):

Quoted 6 lines

I've been working on this on the odd occasion, I think it mostly works, or it did last I tried which was a while back. I'm sure it is too hacky in places. My plan was to clean it up on the next test day.

I'm mostly just sending this for Wei's benefit since he is independently looking at adding Debian HVM guest tests for OVMF purposes.

It's a bit hard to read due to the mixture of code motion and new stuff, but in a quick skim nothing jumped out at me as mad.

Ian.