RFC v3 of this series This series implements a basic test job for OVMF guest. The test case will install an OVMF guest and try to boot it. I''ve tried my best to factor out common code. :-) Now the preseed data in the test case only contains essential items - partitioning recipe, late_command and two other items. As for the file manipulation code, it has a small portion (first 6 lines as IanJ pointed out) that''s copied from ts-redhat-install, but I don''t see a sensible to factor out that 6 lines of command. I basically didn''t touch that last two patches as IanJ will take care of them when he takes this series. Wei. Changes in v3: * consolidate more config items into preseed_base * ts-ovmf-debian-install -> ts-debian-hvm-install * factor out functions to create ISOs. * $xl -> $toolstack in test case script * add $flight $job and $gn to all file paths Changes in v2: * factor out preseed_base * make installation CD work with seabios Wei Liu (7): make-flight: disable OVMF build for 4.3 TestSupport.pm: add bios option to guest config file TestSupport.pm: functions for creating isos Debian.pm: factor out preseed_base Introduce ts-debian-hvm-install make-flight: OVMF test filght sg-run-job: OVMF job Osstest/Debian.pm | 143 +++++++++++++++++++--------------- Osstest/TestSupport.pm | 33 ++++++++ make-flight | 7 ++ sg-run-job | 6 ++ ts-debian-hvm-install | 202 ++++++++++++++++++++++++++++++++++++++++++++++++ ts-redhat-install | 13 +--- 6 files changed, 332 insertions(+), 72 deletions(-) create mode 100755 ts-debian-hvm-install -- 1.7.10.4
This was missing from previous patch. We should only build OVMF from 4.4 onwards. Signed-off-by: Wei Liu <wei.liu2@citrix.com> --- make-flight | 1 + 1 file changed, 1 insertion(+) diff --git a/make-flight b/make-flight index dcfdfe6..7d19af7 100755 --- a/make-flight +++ b/make-flight @@ -93,6 +93,7 @@ if [ x$buildflight = x ]; then xen-4.0-testing) enable_ovmf=false;; xen-4.1-testing) enable_ovmf=false;; xen-4.2-testing) enable_ovmf=false;; + xen-4.3-testing) enable_ovmf=false;; *) enable_ovmf=true; esac -- 1.7.10.4
Wei Liu
2013-Dec-12 21:02 UTC
[PATCH RFC V3 2/7] TestSupport.pm: add bios option to guest config file
Signed-off-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> --- Osstest/TestSupport.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm index a513540..ebe313c 100644 --- a/Osstest/TestSupport.pm +++ b/Osstest/TestSupport.pm @@ -1442,6 +1442,11 @@ END $cfg .= "device_model_version=''$devmodel''\n"; } + my $bios = $xopts{''Bios''}; + if (defined $bios) { + $cfg .= "bios=''$bios''\n"; + } + my $cfgpath= prepareguest_part_xencfg($ho, $gho, $ram_mb, \%xopts, $cfg); target_cmd_root($ho, <<END); (echo $passwd; echo $passwd) | vncpasswd $gho->{Guest}.vncpw -- 1.7.10.4
Wei Liu
2013-Dec-12 21:03 UTC
[PATCH RFC V3 3/7] TestSupport.pm: functions for creating isos
I would have replaced genisoimage with xorriso but I think it is better to keep it for compatibility. create_iso_xorriso is mainly used to create a EFI bootable ISO image. As far as I can tell Wheezy''s genisoimage cannot do that. Signed-off-by: Wei Liu <wei.liu2@citrix.com> --- Osstest/TestSupport.pm | 28 ++++++++++++++++++++++++++++ ts-redhat-install | 13 ++++--------- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm index ebe313c..31ca102 100644 --- a/Osstest/TestSupport.pm +++ b/Osstest/TestSupport.pm @@ -97,6 +97,9 @@ BEGIN { await_webspace_fetch_byleaf create_webfile file_link_contents get_timeout setup_pxeboot setup_pxeboot_local host_pxefile + + create_iso_genisoimage + create_iso_xorriso ); %EXPORT_TAGS = ( ); @@ -1859,4 +1862,29 @@ default local END } +#---------- ISO images ---------- +sub create_iso_genisoimage ($$$$;@) { + my ($ho,$iso,$dir,$isotimeout,@xopts) = @_; + + target_install_packages_norec($ho, qw(genisoimage)); + + target_cmd_root($ho, <<END, 60); + mkdir -p $dir + genisoimage @xopts -o $iso $dir/. +END + +} + +sub create_iso_xorriso ($$$$;@) { + my ($ho,$iso,$dir,$isotimeout,@xopts) = @_; + + target_install_packages_norec($ho, qw(xorriso)); + + target_cmd_root($ho, <<END, 60); + mkdir -p $dir + xorriso @xopts -o $iso $dir/. +END + +} + 1; diff --git a/ts-redhat-install b/ts-redhat-install index a945033..87f2335 100755 --- a/ts-redhat-install +++ b/ts-redhat-install @@ -112,7 +112,7 @@ END our $emptyiso= ''/root/empty.iso''; sub prep () { - target_install_packages_norec($ho, qw(lvm2 rsync genisoimage)); + target_install_packages_norec($ho, qw(lvm2 rsync)); my $isotimeout= 600; @@ -129,12 +129,9 @@ sub prep () { -no-emul-boot -boot-load-size 4 -boot-info-table); + my @isogen= (@isogen_base, @isogen_boot); - target_cmd_root($ho, <<END, 60); - set -e - mkdir -p $emptydir - genisoimage -o $emptyiso @isogen_base $emptydir/. -END + create_iso_genisoimage($ho, $emptyiso, $emptydir, 60, @isogen_base); more_prepareguest_hvm($ho,$gho, $ram_mb, $disk_mb, OnReboot => ''preserve'', @@ -163,9 +160,7 @@ END target_putfilecontents_root_stash($ho, 10, kickstart(), "$newiso/ks.cfg"); - target_cmd_root($ho, <<END, $isotimeout); - genisoimage -o $gho->{Rimage} @isogen_base @isogen_boot $newiso/. -END + create_iso_genisoimage($ho, $gho->{Rimage}, $newiso, $isotimeout, @isogen); }); } -- 1.7.10.4
Signed-off-by: Wei Liu <wei.liu2@citrix.com> --- Osstest/Debian.pm | 143 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 80 insertions(+), 63 deletions(-) diff --git a/Osstest/Debian.pm b/Osstest/Debian.pm index 6759263..485e165 100644 --- a/Osstest/Debian.pm +++ b/Osstest/Debian.pm @@ -33,6 +33,7 @@ BEGIN { @ISA = qw(Exporter); @EXPORT = qw(debian_boot_setup %preseed_cmds + preseed_base preseed_create preseed_hook_command preseed_hook_installscript di_installcmdline_core @@ -423,7 +424,83 @@ sub di_installcmdline_core ($$;@) { if defined $debconf_priority; return @cl; -} +} + +sub preseed_base ($$;@) { + my ($suite,$extra_packages,%xopts) = @_; + + return (<<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 partman-md/device_remove_md boolean true +d-i partman-lvm/device_remove_lvm 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-lvm/confirm boolean true + +d-i partman/confirm_nooverwrite true +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 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 grub-installer/only_debian boolean true + +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} +d-i apt-setup/use_mirror boolean yes +d-i apt-setup/another boolean false +d-i apt-setup/non-free boolean false +d-i apt-setup/contrib boolean false + +d-i pkgsel/include string openssh-server, ntp, ntpdate, $extra_packages + +$xopts{ExtraPreseed} + +### END OF DEBIAN PRESEED BASE + +END +} sub preseed_create ($$;@) { my ($ho, $sfx, %xopts) = @_; @@ -610,45 +687,12 @@ 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,$extra_packages,%xopts); + $preseed_file .= (<<END); d-i partman-auto/method string lvm #d-i partman-auto/method string regular -d-i partman-md/device_remove_md boolean true -d-i partman-lvm/device_remove_lvm 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-lvm/confirm boolean true - -d-i partman/confirm_nooverwrite true -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 @@ -676,33 +720,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 - -d-i grub-installer/only_debian boolean true - -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) { -- 1.7.10.4
This is debian hvm guest test case. It resembles ts-redhat-install: 1. prepare a auto install CD 2. install debian hvm guest, currently using OVMF 3. test if the guest is up The installtion CD is also bootable with seabios. Signed-off-by: Wei Liu <wei.liu2@citrix.com> --- ts-debian-hvm-install | 202 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100755 ts-debian-hvm-install diff --git a/ts-debian-hvm-install b/ts-debian-hvm-install new file mode 100755 index 0000000..66b5257 --- /dev/null +++ b/ts-debian-hvm-install @@ -0,0 +1,202 @@ +#!/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 $stage=0; +if (@ARGV && $ARGV[0] =~ m/^--stage(\d+)$/) { $stage=$1; shift @ARGV; } + +our ($whhost,$gn) = @ARGV; +$whhost ||= ''host''; +$gn ||= ''ovmf''; + +our $ho= selecthost($whhost); + +our $ram_mb= 768; +our $disk_mb= 10000; + +our $guesthost= "$gn.guest.osstest"; +our $gho; + +our $toolstack= toolstack()->{Command}; + + +sub preseed () { + + my $preseed_file = preseed_base(''wheezy'','''',()); + my $authkeys = join(''\\n'', split(/\n/, authorized_keys())); + + $preseed_file .= (<<END); +d-i netcfg/get_hostname string $gn + +d-i partman-auto/disk string /dev/xvda +d-i partman-auto/method string regular + +d-i partman-auto/expert_recipe string \\ + boot-root :: \\ + 512 50 512 vfat \\ + \$primary{ } \$bootable{ } \\ + method{ efi } format{ } \\ + use_filesystem{ } filesystem{ vfat } \\ + mountpoint{ /boot/efi } \\ + . \\ + 5000 50 5000 ext4 \\ + method{ format } format{ } \\ + use_filesystem{ } filesystem{ ext4 } \\ + mountpoint{ / } \\ + . \\ + 512 30 100% linux-swap \\ + method{ swap } format{ } \\ + . + +d-i apt-setup/cdrom/set-first boolean false + +d-i preseed/late_command string \\ + in-target mkdir -p /boot/efi/EFI/boot; \\ + in-target cp /boot/efi/EFI/debian/grubx64.efi /boot/efi/EFI/boot/bootx64.efi ;\\ + in-target mkdir -p /root/.ssh; \\ + in-target sh -c "echo -e ''$authkeys''> /root/.ssh/authorized_keys"; +END + return $preseed_file; +} + +sub grub_cfg () { + + return <<"END"; +set default="0" +set timeout=5 + +menuentry ''debian guest auto Install'' { + linux /install.amd/vmlinuz console=vga console=ttyS0,115200n8 preseed/file=/preseed.cfg + initrd /install.amd/initrd.gz +} +END +} + +sub isolinux_cfg () { + return <<"END"; + default autoinstall + prompt 0 + timeout 0 + + label autoinstall + kernel /install.amd/vmlinuz + append video=vesa:ywrap,mtrr vga=788 console=ttyS0,115200n8 preseed/file=/preseed.cfg initrd=/install.amd/initrd.gz +END +} + +our $emptyiso= "/root/$flight.$job.$gn-empty.iso"; + +sub prep () { + target_install_packages_norec($ho, qw(lvm2 rsync)); + + my $isotimeout= 600; + + $gho= prepareguest($ho, $gn, $guesthost, 22, + $disk_mb + 1, + 100); + + my $newiso= "/root/$flight.$job.$gn-newiso"; + my $emptydir= "/root/$flight.$job.$gn-empty-dir"; + my $initrddir= "/root/$flight.$job.$gn-initrd-dir"; + my $preseed_file_path = "/root/$flight.$job.$gn-preseed"; + + my @isogen_opts= qw(-R -J -T); + my @xorriso_opts= qw(-as mkisofs + -r + -b isolinux/isolinux.bin + -c isolinux/boot.cat + -no-emul-boot + -boot-load-size 4 + -boot-info-table + -eltorito-alt-boot + -e boot/grub/efi.img + -no-emul-boot); + + target_putfilecontents_root_stash($ho, 10, preseed(), + $preseed_file_path); + + create_iso_genisoimage($ho, $emptyiso, $emptydir, 60, @isogen_opts); + + more_prepareguest_hvm($ho,$gho, $ram_mb, $disk_mb, + OnReboot => ''preserve'', + Bios => ''ovmf'', + PostImageHook => sub { + target_cmd_root($ho, <<END, $isotimeout); + set -x + umount /mnt ||: + rm -rf $newiso + mount -o loop -r $gho->{Rimage} /mnt + mkdir $newiso + cp -a /mnt/. $newiso/. + umount /mnt + rm -rf $initrddir + mkdir $initrddir + cd $initrddir + gzip -d \< $newiso/install.amd/initrd.gz | cpio --extract --make-directories --no-absolute-filename + cp $preseed_file_path preseed.cfg + find . | cpio -H newc --create | gzip -9 \> $newiso/install.amd/initrd.gz + cd - + rm -rf $initrddir + cd $newiso + md5sum `find -L -type f -print0 | xargs -0` \> md5sum.txt + cd - +END + target_putfilecontents_root_stash($ho, 10, grub_cfg(), + "$newiso/debian/boot/grub/grub.cfg"); + + target_putfilecontents_root_stash($ho, 10, isolinux_cfg(), + "$newiso/isolinux/isolinux.cfg"); + + create_iso_xorriso($ho, $gho->{Rimage}, $newiso, $isotimeout, @xorriso_opts); + }); +} + +sub start () { + target_cmd_root($ho, "$toolstack create $gho->{CfgPath}", 100); +} + +sub rewrite_config_nocd () { + guest_editconfig($ho, $gho, sub { + if (m/^\s*disk\s*\=/ .. /\]/) { + s/\Q$gho->{Rimage}\E/$emptyiso/; + } + s/^on_reboot.*/on_reboot=''restart''/; + }); +} + +if (!$stage) { + prep(); + start(); +} else { + $gho= selectguest($gn,$gho); +} +if ($stage<2) { + guest_await_reboot($ho,$gho,2000); + guest_destroy($ho,$gho); +} + +rewrite_config_nocd(); +start(); +guest_await_dhcp_tcp($gho,300); +guest_check_up($gho); -- 1.7.10.4
Signed-off-by: Wei Liu <wei.liu2@citrix.com> --- make-flight | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/make-flight b/make-flight index 7d19af7..3192f5e 100755 --- a/make-flight +++ b/make-flight @@ -420,7 +420,13 @@ for xenarch in ${TEST_ARCHES- i386 amd64 armhf } ; do test-win xl $qemuu_runvar \ win_image=win7-x64.iso \ all_hostflags=$most_hostflags,hvm + fi + if [ $xenarch = amd64 -a "x$qemuu_suffix" = "x-qemuu" ]; then + job_create_test test-$xenarch$kern-$dom0arch-xl$qemuu_suffix-ovmf-amd64 \ + test-debianhvm xl $qemuu_runvar \ + ovmf_image=debian-7.2.0-amd64-CD-1.iso \ + all_hostflags=$most_hostflags,hvm fi if [ $xenarch = amd64 -a $dom0arch = i386 -a "$kern" = "" ]; then -- 1.7.10.4
Signed-off-by: Wei Liu <wei.liu2@citrix.com> --- sg-run-job | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sg-run-job b/sg-run-job index db62365..daa018d 100755 --- a/sg-run-job +++ b/sg-run-job @@ -265,6 +265,12 @@ proc run-job/test-rhelhvm {} { test-guest-nomigr redhat } +proc need-hosts/test-debianhvm {} { return host } +proc run-job/test-debianhvm {} { + run-ts . = ts-debian-hvm-install + test-guest ovmf +} + proc need-hosts/test-pair {} { return {src_host dst_host} } proc run-job/test-pair {} { run-ts . = ts-debian-install dst_host -- 1.7.10.4
Wei Liu
2013-Dec-12 21:06 UTC
Re: [PATCH RFC V3 1/7] make-flight: disable OVMF build for 4.3
On Thu, Dec 12, 2013 at 09:02:58PM +0000, Wei Liu wrote:> This was missing from previous patch. We should only build OVMF from 4.4 > onwards. > > Signed-off-by: Wei Liu <wei.liu2@citrix.com> > --- > make-flight | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/make-flight b/make-flight > index dcfdfe6..7d19af7 100755 > --- a/make-flight > +++ b/make-flight > @@ -93,6 +93,7 @@ if [ x$buildflight = x ]; then > xen-4.0-testing) enable_ovmf=false;; > xen-4.1-testing) enable_ovmf=false;; > xen-4.2-testing) enable_ovmf=false;; > + xen-4.3-testing) enable_ovmf=false;;Oh, this one is certainly not RFC. This should be considered a bug fix. :-) Wei.> *) enable_ovmf=true; > esac > > -- > 1.7.10.4