From: Ian Campbell Subject: [PATCH/RFC OSSTEST] Debian PV netboot guest test Date: Mon, 25 Nov 2013 14:44:41 +0000 Message-ID: <1385390681.22002.77.camel@kazak.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Wei Liu Cc: Ian Jackson , xen-devel List-Id: xen-devel@lists.xenproject.org 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 Date: Sun Nov 17 15:30:29 2013 +0000 DI diff --git a/Osstest/Debian.pm b/Osstest/Debian.pm index e51a233..4b0911c 100644 --- a/Osstest/Debian.pm +++ b/Osstest/Debian.pm @@ -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= (<.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= (<{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"; }); } diff --git a/make-flight b/make-flight index a5d21af..95f8d53 100755 --- a/make-flight +++ b/make-flight @@ -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 \ diff --git a/sg-run-job b/sg-run-job index 0124223..00328ef 100755 --- a/sg-run-job +++ b/sg-run-job @@ -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 diff --git a/ts-debian-install-di b/ts-debian-install-di new file mode 100755 index 0000000..ff17619 --- /dev/null +++ b/ts-debian-install-di @@ -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 . + +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, <{OnReboot} || 'restart'; + my $vcpus= guest_var($gho, 'vcpus', 2);#$xopts->{DefVcpus} || 2); + my $install_cfg= <{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= <{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();