[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH/RFC OSSTEST] Debian PV netboot guest test



On Mon, Nov 25, 2013 at 02:44:41PM +0000, Ian Campbell wrote:
> 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.

> Ian.
> 
> commit f7ac42c6384cbf0f221b556c9c91ee5e8b944752
> Author: Ian Campbell <ian.campbell@xxxxxxxxxx>
> 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= (<<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";
> diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
> index a9cdc9c..dbe5e31 100644
> --- a/Osstest/TestSupport.pm
> +++ b/Osstest/TestSupport.pm
> @@ -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";
>      });
>  }
> 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 <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();
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.