From: Wei Liu <wei.liu2@citrix.com>
To: xen-devel@lists.xen.org
Cc: Wei Liu <wei.liu2@citrix.com>,
ian.jackson@eu.citrix.com, ian.campbell@citrix.com
Subject: [PATCH V4 10/12] Introduce ts-debian-hvm-install
Date: Fri, 21 Mar 2014 16:14:24 +0000 [thread overview]
Message-ID: <1395418466-6997-11-git-send-email-wei.liu2@citrix.com> (raw)
In-Reply-To: <1395418466-6997-1-git-send-email-wei.liu2@citrix.com>
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 | 183 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 183 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..74acc66
--- /dev/null
+++ b/ts-debian-hvm-install
@@ -0,0 +1,183 @@
+#!/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
+}
+
+sub prepare_initrd ($$$) {
+ my ($initrddir,$newiso,$preseed_file_path) = @_;
+ return <<"END";
+ 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
+}
+
+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 @xorriso_extra = qw(-eltorito-alt-boot
+ -e boot/grub/efi.img
+ -no-emul-boot
+ -r);
+ my @xorriso_opts = (iso_gen_flags_basic(), @xorriso_extra);
+
+ create_empty_iso($ho, $emptyiso, $emptydir);
+
+ target_putfilecontents_root_stash($ho, 10, preseed(),
+ $preseed_file_path);
+
+ more_prepareguest_hvm($ho,$gho, $ram_mb, $disk_mb,
+ OnReboot => 'preserve',
+ Bios => 'ovmf',
+ PostImageHook => sub {
+ my $cmds = copy_iso_content_to_dir($gho, $newiso);
+ $cmds .= prepare_initrd($initrddir,$newiso,$preseed_file_path);
+ target_cmd_root($ho, $cmds, $isotimeout);
+ 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);
+ });
+}
+
+if (!$stage) {
+ prep();
+ guest_create($ho,$gho,$toolstack);
+} else {
+ $gho= selectguest($gn,$gho);
+}
+if ($stage<2) {
+ guest_await_reboot($ho,$gho,2000);
+ guest_destroy($ho,$gho);
+}
+
+rewrite_config_nocd($ho,$gho,$emptyiso);
+guest_create($ho,$gho,$toolstack);
+guest_await_dhcp_tcp($gho,300);
+guest_check_up($gho);
--
1.7.10.4
next prev parent reply other threads:[~2014-03-21 16:14 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-21 16:14 [PATCH V4 00/12] OSSTest: OVMF test job Wei Liu
2014-03-21 16:14 ` [PATCH V4 01/12] TestSupport.pm: add bios option to guest config file Wei Liu
2014-03-21 16:14 ` [PATCH V4 02/12] TestSupport.pm: introduce create_iso_xorriso for creating isos Wei Liu
2014-04-02 16:01 ` Ian Jackson
2014-04-02 17:36 ` Wei Liu
2014-04-02 17:43 ` Ian Jackson
2014-03-21 16:14 ` [PATCH V4 03/12] TestSupport.pm: move rewrite_config_nocd to support library Wei Liu
2014-04-02 16:04 ` Ian Jackson
2014-04-02 17:46 ` Wei Liu
2014-03-21 16:14 ` [PATCH V4 04/12] TestSupport.pm: introduce guest_create Wei Liu
2014-04-02 16:06 ` Ian Jackson
2014-04-02 17:53 ` Wei Liu
2014-04-03 14:15 ` Ian Jackson
2014-03-21 16:14 ` [PATCH V4 05/12] ts-redhat-install: use $flight, $job and $gn when creating iso Wei Liu
2014-04-02 16:06 ` Ian Jackson
2014-03-21 16:14 ` [PATCH V4 06/12] TestSupport.pm: introduce create_empty_iso Wei Liu
2014-04-02 16:08 ` Ian Jackson
2014-04-02 17:14 ` Wei Liu
2014-04-02 17:26 ` Ian Jackson
2014-03-21 16:14 ` [PATCH V4 07/12] TestSupport.pm: introduce iso_gen_flags_basic Wei Liu
2014-04-02 16:08 ` Ian Jackson
2014-03-21 16:14 ` [PATCH V4 08/12] TestSupport.pm: introduce copy_iso_content_to_dir Wei Liu
2014-04-02 16:10 ` Ian Jackson
2014-04-02 17:26 ` Wei Liu
2014-03-21 16:14 ` [PATCH V4 09/12] Debian.pm: factor out preseed_base Wei Liu
2014-03-21 16:14 ` Wei Liu [this message]
2014-04-02 16:15 ` [PATCH V4 10/12] Introduce ts-debian-hvm-install Ian Jackson
2014-04-02 18:17 ` Wei Liu
2014-04-03 14:15 ` Ian Jackson
2014-03-21 16:14 ` [PATCH V4 11/12] sg-run-job: OVMF job Wei Liu
2014-04-02 16:16 ` Ian Jackson
2014-03-21 16:14 ` [PATCH V4 12/12] make-flight: OVMF test flight Wei Liu
2014-04-02 16:27 ` Ian Jackson
2014-04-02 16:31 ` Ian Campbell
2014-04-01 13:43 ` [PATCH V4 00/12] OSSTest: OVMF test job Wei Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1395418466-6997-11-git-send-email-wei.liu2@citrix.com \
--to=wei.liu2@citrix.com \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).