Introduction of the patches.
cover Introduction of the patches.
Robert and I made these patchs about adding Nested test job into OSSTest.
Nested virtualization is the ability to run a hypervisor inside of a virtual machine. The hypervisor that runs on the real hardware is called a level 0 or L0; The hypervisor that runs as a guest on L0 is called level 1 or L1;
A guest that runs on the L1 hypervisor is called a level 2 or L2.
We should run build-amd64 job and build-amd64-hvm job first.
For Nested testing, we will install L1 guest VM under L0, the L1 guest should build xen and HVM Dom0 kernel and then boot into xen kernel.
Then install L2 guest VM inside L1.
After that, make sure ping L2 is successfully.
----------------------------------------------------------------
longtao.pang (3):
Add nested testcase of installing L1 guest VM. Add nested testcase of installing L2 guest VM. Insert job name and runvars into standalone.db
Osstest/Debian.pm | 25 ++-- Osstest/TestSupport.pm | 31 +++- make-flight | 19 +++ mfi-common | 9 ++ sg-run-job | 7 + ts-nested-L1-debian-install | 534 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ts-nested-L2-debian-install | 148 +++++++++++++++++++ 7 files changed, 759 insertions(+), 14 deletions(-) create mode 100755 ts-nested-L1-debian-install create mode 100755 ts-nested-L2-debian-install
PATCH 1/3 Add nested testcase of installing L1 guest VM.
From: "Robert.ho" <[email protected]>
Adding nested test case <ts-nested-L1-debian-install> which is used for installing L1. Inside L1 guest VM, need build xen and HVM dom0 kernel and then boot into xen kernel. After that, get ready to install L2 guest VM inside L1.
--- Osstest/Debian.pm | 25 +- Osstest/TestSupport.pm | 31 ++- sg-run-job | 6 + ts-nested-L1-debian-install | 534 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 582 insertions(+), 14 deletions(-) create mode 100755 ts-nested-L1-debian-install
Osstest/Debian.pm +16 -9
@@ -1,5 +1,6 @@ # This is part of "osstest", an automated testing framework for Xen. # Copyright (C) 2009-2013 Citrix Inc. +# Copyright (C) 2014 Intel 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
@@ -286,15 +287,18 @@ sub setupboot_grub2 ($$$) { my $count= 0; my $entry; + my $submenu; while (<$f>) { next if m/^\s*\#/ || !m/\S/; if (m/^\s*\}\s*$/) { - die unless $entry; + die unless $entry || $submenu; + if(!defined $entry && defined $submenu){ + logm("Met end of a submenu starting from $submenu->{StartLine}.Our want kern is $want_kernver"); + $submenu=undef; + next; + } my (@missing) = - grep { !defined $entry->{$_} } - (defined $xenhopt - ? qw(Title Hv KernDom0 KernVer) - : qw(Title Hv KernOnly KernVer)); + grep { !defined $entry->{$_} } (defined $xenhopt ? qw(Title Hv KernDom0 KernVer) : qw(Title Hv KernOnly KernVer)); if (@missing) { logm("(skipping entry at $entry->{StartLine};". " no @missing)");
@@ -317,21 +321,24 @@ sub setupboot_grub2 ($$$) { $entry= { Title => $1, StartLine => $., Number => $count }; $count++; } - if (m/^\s*multiboot\s*\/(xen\-[0-9][-+.0-9a-z]*\S+)/) { + if(m/^submenu\s+[\'\"](.*)[\'\"].*\{\s*$/){ + $submenu={ StartLine =>$.}; + } + if (m/^\s*multiboot\s*(?:\/boot)*\/(xen\-[0-9][-+.0-9a-z]*\S+)/) { die unless $entry; $entry->{Hv}= $1; } - if (m/^\s*multiboot\s*\/(vmlinu[xz]-(\S+))/) { + if (m/^\s*multiboot\s*(?:\/boot)*\/(vmlinu[xz]-(\S+))/) { die unless $entry; $entry->{KernOnly}= $1; $entry->{KernVer}= $2; } - if (m/^\s*module\s*\/(vmlinu[xz]-(\S+))/) { + if (m/^\s*module\s*(?:\/boot)*\/(vmlinu[xz]-(\S+))/) { die unless $entry; $entry->{KernDom0}= $1; $entry->{KernVer}= $2; } - if (m/^\s*module\s*\/(initrd\S+)/) { + if (m/^\s*module\s*(?:\/boot)*\/(initrd\S+)/) { $entry->{Initrd}= $1; } }
Osstest/TestSupport.pm +26 -5
@@ -55,8 +55,9 @@ BEGIN { target_putfilecontents_stash target_putfilecontents_root_stash target_put_guest_image target_editfile - target_editfile_root target_file_exists - target_run_apt + target_editfile_root target_file_exists + target_file_exists_root + target_run_apt target_install_packages target_install_packages_norec target_jobdir target_extract_jobdistpath_subdir target_extract_jobdistpath target_guest_lv_name
@@ -66,7 +67,7 @@ BEGIN { selecthost get_hostflags get_host_property power_state power_cycle power_cycle_time - serial_fetch_logs + serial_fetch_logs select_ether propname_massage get_stashed open_unique_stashfile compress_stashed
@@ -108,6 +109,7 @@ BEGIN { iso_gen_flags_basic iso_copy_content_from_image guest_editconfig_nocd + guest_editconfig_cd ); %EXPORT_TAGS = ( );
@@ -480,6 +482,14 @@ sub target_file_exists ($$) { die "$rfile $out ?"; } +sub target_file_exists_root ($$) { + my ($ho,$rfile) = @_; + my $out= target_cmd_output_root($ho, "if test -e $rfile; then echo y; fi"); + return 1 if $out =~ m/^y$/; + return 0 if $out !~ m/\S/; + die "$rfile $out ?"; +} + sub teditfileex { my $user= shift @_; my $code= pop @_;
@@ -715,6 +725,7 @@ sub power_cycle_time ($) { sub power_cycle ($) { my ($ho) = @_; $mjobdb->host_check_allocated($ho); + $mjobdb->xen_check_installed($ho); die "refusing to set power state for host $ho->{Name}". " possibly shared with other jobs\n" if $ho->{SharedMaybeOthers};
@@ -911,7 +922,7 @@ sub compress_stashed($) { sub host_reboot ($) { my ($ho) = @_; target_reboot($ho); - poll_loop(40,2, 'reboot-confirm-booted', sub { + poll_loop(200,2, 'reboot-confirm-booted', sub { my $output; if (!eval { $output= target_cmd_output($ho,
@@ -1438,7 +1449,7 @@ sub prepareguest_part_xencfg ($$$$$) { my $xencfg= <<END; name = '$gho->{Name}' memory = ${ram_mb} -vif = [ 'type=ioemu,mac=$gho->{Ether}' ] +vif = [ 'type=ioemu,model=e1000,mac=$gho->{Ether}' ] # on_poweroff = 'destroy' on_reboot = '$onreboot'
@@ -2036,4 +2047,14 @@ sub guest_editconfig_nocd ($$) { }); } +sub guest_editconfig_cd ($) { + my ($gho) = @_; + guest_editconfig($gho->{Host}, $gho, sub { + if (m/^\s*boot\s*= '\s*d\s*c\s*'/) { + s/dc/cd/; + } + s/^on_reboot.*/on_reboot='restart'/; + }); +} + 1;
sg-run-job +6 -0
@@ -288,6 +288,12 @@ proc run-job/test-pair {} { # run-ts . remus-failover ts-remus-check src_host dst_host + debian } +proc need-hosts/test-nested {} {return host} +proc run-job/test-nested {} { + run-ts . = ts-nested-L1-debian-install + run-ts . = ts-guest-destroy + host nested +} + proc test-guest-migr {g} { if {[catch { run-ts . = ts-migrate-support-check + host $g }]} return
ts-nested-L1-debian-install new file +534 -0
534 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Re: [PATCH 1/3] Add nested testcase of installing L1 guest VM.
Quoted 6 lines · longtao.pang
From: "Robert.ho" <[email protected]>
Adding nested test case <ts-nested-L1-debian-install> which is used for installing L1. Inside L1 guest VM, need build xen and HVM dom0 kernel and then boot into xen kernel. After that, get ready to install L2 guest VM inside L1.
This patch mixes mechanical changes with the actual test script. Please break it down to smaller self-contained patches.
Quoted 62 lines
--- Osstest/Debian.pm | 25 +- Osstest/TestSupport.pm | 31 ++- sg-run-job | 6 + ts-nested-L1-debian-install | 534 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 582 insertions(+), 14 deletions(-) create mode 100755 ts-nested-L1-debian-installOsstest/Debian.pm +14
-8@@ -1,5 +1,6 @@ # This is part of "osstest", an automated testing framework for Xen. # Copyright (C) 2009-2013 Citrix Inc. +# Copyright (C) 2014 Intel 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@@ -286,15 +287,18 @@ sub setupboot_grub2 ($$$) { my $count= 0; my $entry; + my $submenu; while (<$f>) { next if m/^\s*\#/ || !m/\S/; if (m/^\s*\}\s*$/) { - die unless $entry; + die unless $entry || $submenu; + if(!defined $entry && defined $submenu){ + logm("Met end of a submenu starting from $submenu->{StartLine}.Our want kern is $want_kernver"); + $submenu=undef; + next; + } my (@missing) = - grep { !defined $entry->{$_} } - (defined $xenhopt - ? qw(Title Hv KernDom0 KernVer) - : qw(Title Hv KernOnly KernVer)); + grep { !defined $entry->{$_} } (defined $xenhopt ? qw(Title Hv KernDom0 KernVer) : qw(Title Hv KernOnly KernVer)); if (@missing) { logm("(skipping entry at $entry->{StartLine};". " no @missing)");@@ -317,21 +321,24 @@ sub setupboot_grub2 ($$$) { $entry= { Title => $1, StartLine => $., Number => $count }; $count++; } - if (m/^\s*multiboot\s*\/(xen\-[0-9][-+.0-9a-z]*\S+)/) { + if(m/^submenu\s+[\'\"](.*)[\'\"].*\{\s*$/){ + $submenu={ StartLine =>$.}; + } + if (m/^\s*multiboot\s*(?:\/boot)*\/(xen\-[0-9][-+.0-9a-z]*\S+)/) { die unless $entry; $entry->{Hv}= $1; } - if (m/^\s*multiboot\s*\/(vmlinu[xz]-(\S+))/) { + if (m/^\s*multiboot\s*(?:\/boot)*\/(vmlinu[xz]-(\S+))/) { die unless $entry; $entry->{KernOnly}= $1; $entry->{KernVer}= $2; } - if (m/^\s*module\s*\/(vmlinu[xz]-(\S+))/) {
Osstest/Debian.pm sub setupboot_grub2 ($$$) { · line 344
Quoted 10 lines
Osstest/Debian.pm +2
-1+ if (m/^\s*module\s*(?:\/boot)*\/(vmlinu[xz]-(\S+))/) { die unless $entry; $entry->{KernDom0}= $1; $entry->{KernVer}= $2; } - if (m/^\s*module\s*\/(initrd\S+)/) { + if (m/^\s*module\s*(?:\/boot)*\/(initrd\S+)/) { $entry->{Initrd}= $1; } }
For example, this hunk should be a separate patch. If I'm not mistaken, this is to make this routine parse "submenu".
Osstest/TestSupport.pm BEGIN { · line 60
Quoted 13 lines
Osstest/TestSupport.pm +3
-2@@ -55,8 +55,9 @@ BEGIN { target_putfilecontents_stash target_putfilecontents_root_stash target_put_guest_image target_editfile - target_editfile_root target_file_exists - target_run_apt + target_editfile_root target_file_exists + target_file_exists_root + target_run_apt
Please configure your editor to not alter white spaces.
If these changes are made by you as cleanup, they should come in separate patch, too.
Quoted 13 lines
Osstest/TestSupport.pm +1
-1target_install_packages target_install_packages_norec target_jobdir target_extract_jobdistpath_subdir target_extract_jobdistpath target_guest_lv_name@@ -66,7 +67,7 @@ BEGIN { selecthost get_hostflags get_host_property power_state power_cycle power_cycle_time - serial_fetch_logs + serial_fetch_logs select_ether propname_massage get_stashed open_unique_stashfile compress_stashed
Osstest/TestSupport.pm BEGIN { · line 112
Quoted 4 lines
Osstest/TestSupport.pm +1
-0@@ -108,6 +109,7 @@ BEGIN { iso_gen_flags_basic iso_copy_content_from_image guest_editconfig_nocd + guest_editconfig_cd
And the introduction of these new helper functions should be in their own patches.
Quoted 36 lines
Osstest/TestSupport.pm +10
-1); %EXPORT_TAGS = ( );@@ -480,6 +482,14 @@ sub target_file_exists ($$) { die "$rfile $out ?"; } +sub target_file_exists_root ($$) { + my ($ho,$rfile) = @_; + my $out= target_cmd_output_root($ho, "if test -e $rfile; then echo y; fi"); + return 1 if $out =~ m/^y$/; + return 0 if $out !~ m/\S/; + die "$rfile $out ?"; +} + sub teditfileex { my $user= shift @_; my $code= pop @_;@@ -715,6 +725,7 @@ sub power_cycle_time ($) { sub power_cycle ($) { my ($ho) = @_; $mjobdb->host_check_allocated($ho); + $mjobdb->xen_check_installed($ho); die "refusing to set power state for host $ho->{Name}". " possibly shared with other jobs\n" if $ho->{SharedMaybeOthers};@@ -911,7 +922,7 @@ sub compress_stashed($) { sub host_reboot ($) { my ($ho) = @_; target_reboot($ho); - poll_loop(40,2, 'reboot-confirm-booted', sub { + poll_loop(200,2, 'reboot-confirm-booted', sub { my $output; if (!eval { $output= target_cmd_output($ho,
Osstest/TestSupport.pm sub prepareguest_part_xencfg ($$$$$) { · line 1452
Quoted 5 lines
Osstest/TestSupport.pm +1
-1@@ -1438,7 +1449,7 @@ sub prepareguest_part_xencfg ($$$$$) { my $xencfg= <<END; name = '$gho->{Name}' memory = ${ram_mb} -vif = [ 'type=ioemu,mac=$gho->{Ether}' ] +vif = [ 'type=ioemu,model=e1000,mac=$gho->{Ether}' ]
This should also be in its own patch, with the reasoning in commit log.
ts-nested-L1-debian-install
Quoted 40 lines
Osstest/TestSupport.pm +10
-0# on_poweroff = 'destroy' on_reboot = '$onreboot'@@ -2036,4 +2047,14 @@ sub guest_editconfig_nocd ($$) { }); } +sub guest_editconfig_cd ($) { + my ($gho) = @_; + guest_editconfig($gho->{Host}, $gho, sub { + if (m/^\s*boot\s*= '\s*d\s*c\s*'/) { + s/dc/cd/; + } + s/^on_reboot.*/on_reboot='restart'/; + }); +} + 1;sg-run-job +6
-0@@ -288,6 +288,12 @@ proc run-job/test-pair {} { # run-ts . remus-failover ts-remus-check src_host dst_host + debian } +proc need-hosts/test-nested {} {return host} +proc run-job/test-nested {} { + run-ts . = ts-nested-L1-debian-install + run-ts . = ts-guest-destroy + host nested +} + proc test-guest-migr {g} { if {[catch { run-ts . = ts-migrate-support-check + host $g }]} returnts-nested-L1-debian-install new file +0
-0
Looks like you're pulling in different functions from various parts of OSSTest into this script. It makes this script very hard to maintain. Why don't you just use them directly?
Wei.
PATCH 2/3 Add nested testcase of installing L2 guest VM.
In reply to longtao.pangFrom: "longtao.pang" <[email protected]>
Adding <ts-nested-L2-debian-install> which is used for installing L2 guest VM inside L1 guest VM.
--- sg-run-job | 1 + ts-nested-L2-debian-install | 148 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 149 insertions(+) create mode 100755 ts-nested-L2-debian-install
sg-run-job +1 -0
@@ -291,6 +291,7 @@ proc run-job/test-pair {} { proc need-hosts/test-nested {} {return host} proc run-job/test-nested {} { run-ts . = ts-nested-L1-debian-install + run-ts . = ts-nested-L2-debian-install run-ts . = ts-guest-destroy + host nested }
ts-nested-L2-debian-install new file +148 -0
148 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Re: [PATCH 2/3] Add nested testcase of installing L2 guest VM.
Quoted 5 lines · longtao.pang
From: "longtao.pang" <[email protected]>
Adding <ts-nested-L2-debian-install> which is used for installing L2 guest VM inside L1 guest VM.
Can you reuse ts-debian-install to achieve this? From the look of this patch it duplicates code snippets in ts-debian-install. At the very least the runes to install guests should be made shared among various users.
Wei.
PATCH 3/3 Insert job name and runvars into standalone.db
In reply to longtao.pangFrom: "longtao.pang" <[email protected]>
Insert job names and runvars into standalone.db after executing the command "./standalone-reset"
--- make-flight | 19 +++++++++++++++++++ mfi-common | 9 +++++++++ 2 files changed, 28 insertions(+)
make-flight +19 -0
@@ -197,6 +197,24 @@ do_hvm_win7_x64_tests () { all_hostflags=$most_hostflags,hvm } +do_hvm_debian_nested_tests () { + if [ $xenarch != amd64 ]; then + return + fi + if [ $dom0arch != amd64 ]; then + return + fi + + job_create_test test-$xenarch$kern-$dom0arch-nested test-nested xl \ + $xenarch $dom0arch \ + nested_image=debian-7.6.0-amd64-DVD-1.iso \ + bios=seabios \ + kernbuildjob=build-amd64-hvm \ + kernkind=hvm \ + device_model_version=qemu-xen \ + all_hostflags=$most_hostflags,hvm +} + do_hvm_debian_test_one () { testname=$1 bios=$2
@@ -364,6 +382,7 @@ test_matrix_do_one () { fi + do_hvm_debian_nested_tests do_passthrough_tests }
mfi-common +9 -0
@@ -167,6 +167,15 @@ create_build_jobs () { revision_qemuu=$REVISION_QEMU_UPSTREAM fi + ./cs-job-create $flight build-$arch-hvm build-kern \ + arch=$arch kconfighow=xen-enable-xen-config \ + $RUNVARS $BUILD_RUNVARS $BUILD_LINUX_RUNVARS $arch_runvars \ + $suite_runvars \ + host_hostflags=$build_hostflags \ + revision_linux=HEAD \ + tree_linux=git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git \ + ${TREEVCS_LINUX:+treevcs_linux=}${TREEVCS_LINUX} + ./cs-job-create $flight build-$arch-pvops build-kern \ arch=$arch kconfighow=xen-enable-xen-config \ $RUNVARS $BUILD_RUNVARS $BUILD_LINUX_RUNVARS $arch_runvars \
Signature · 1 line
1.7.10.4