Skip to contentSkip to conversation

Introduction of netsted HVM test job

PATCH Superseded longtao.pang 2 participants 21 messages May 2, 2015 – May 7, 2015

v9 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

v9 cover Introduction of netsted HVM test job

This patch set adds nested HVM test case for osstest.
In this test case, a Xen hypervisor (L1) runs on top of another Xen hypervisor (L0).
Upon L1 hypervisor, we will then create a nested guest (L2), and test if the Linux guest can then be installed and run well.
About nested Xen virtualization,
refer to http://wiki.xenproject.org/wiki/Nested_Virtualization_in_Xen.

Test steps
0. To run osstest in standalone mode, write a config file in '~/.xen-osstest/config', and then create a standalone.config file to define 'TREE_LINUX', 'REVISION_LINUX' which will be used for nested test. The directory path of 'Debian Images' could be defined in '~/.xen-osstest/config'.
1. run './standalone-reset' to generate standalone.db firstly then run 'build-amd64' job and then 'build-amd64-pvops', to prepare xen installation tarball and hvm guest kernel.
2. run 'test-amd64-amd6-qemuu-nested' job, it does following:
a. invoke test step of 'ts-debain-hvm-install' to install
a normal HVM guest
b. invoke test step of 'ts-nested-setup' to make some
appropriate runvars which selecthost() would recognise and prepare the configurations for installing L2 guest VM.
c. invoke test step of 'ts-xen-install' to install xen on
the normal guest, alter it into a L1 hypervisor
d. invoke test step of 'ts-debain-hvm-install' again, but
take the L1 hypervisor as host, install the L2 guest on it
e. invoke test step of 'ts-guest-stop', stop L2 guest. f. invoke test step of 'ts-guest-destroy' to destroy L1 guest.

This patch set reuse 'ts-debian-hvm-install' for both L1 installation and L2 installation, use 'nestedl1' as L1's guestname and identity and use 'nestedl2 as L2's guestname.
It also reuses 'ts-xen-install' with L1's identity 'nestedl1' input parameter to differentiate from L0 Xen installation.
This patch series has been tested on test machines of amd64 arch, Debian-7.2.0-amd64 as guests OS, with hvm domain0 of Linux kernel 3.18.5, in standalone mode.
Also, we use linux-stable tree as domain0 kernel source.
----------------------------------------------------------------
longtao.pang (9):
parsing grub which has 'submenu' primitive
Changes to support '/boot' leading paths of kernel, xen, in grub Refactor installation of overlays for guest used
Edit some APIs in TestSupport.pm for nested test
Move the codes about memory size setting into prep() Changes on test step of Debian hvm guest install
Add new script to customize nested test configuration Compose the main recipe of nested test job
Add test job for nest test case

 Osstest/Debian.pm      |   22 ++++++++++++----
 Osstest/TestSupport.pm |   27 ++++++++++++--------
 make-flight            |   32 +++++++++++++++++++++++
 sg-run-job             |   11 ++++++++
 ts-debian-hvm-install  |   37 +++++++++++++++++----------
 ts-nested-setup        |   66 ++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 167 insertions(+), 28 deletions(-)
 create mode 100755 ts-nested-setup
#1 lore raw

PATCH v9 1/9 parsing grub which has 'submenu' primitive

From: "longtao.pang" <[email protected]>

Quoted 1 line

From a hvm kernel build from Linux stable Kernel tree,

the auto generated grub2 menu will have 'submenu' primitive, upon the 'menuentry' items. Xen boot entries will be grouped into a submenu. This patch adds capability to support such grub formats.

---
 Osstest/Debian.pm |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
Osstest/Debian.pm +12 -1
index bd506a6..1e7e8e3 100644
@@ -407,10 +407,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
@@ -441,6 +449,9 @@ sub setupboot_grub2 ($$$$) {
                 $entry= { Title => $1, StartLine => $., Number => $count };
                 $count++;
             }
+            if (m/^submenu\s+[\'\"](.*)[\'\"].*\{\s*$/) {
+                $submenu={ StartLine =>$.};
+            }
             if (m/^\s*multiboot\s*\/(xen\-[0-9][-+.0-9a-z]*\S+)/) {
                 die unless $entry;
                 $entry->{Hv}= $1;
Signature · 1 line
1.7.10.4
#3 lore raw

PATCH v9 2/9 Changes to support '/boot' leading paths of kernel, xen, in grub

In reply to longtao.pang

From: "longtao.pang" <[email protected]>

Support situations of grub that have vmlinuz and other things starting with path of '/boot' rather than '/'.

---
 Osstest/Debian.pm |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Osstest/Debian.pm +4 -4
index 1e7e8e3..6691ff6 100644
@@ -452,21 +452,21 @@ sub setupboot_grub2 ($$$$) {
             if (m/^submenu\s+[\'\"](.*)[\'\"].*\{\s*$/) {
                 $submenu={ StartLine =>$.};
             }
-            if (m/^\s*multiboot\s*\/(xen\-[0-9][-+.0-9a-z]*\S+)/) {
+            if (m/^\s*multiboot\s*(?:\/boot)?\/(xen\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;
             }
 	    if (m/^\s*module\s*\/(xenpolicy\S+)/) {
Signature · 1 line
1.7.10.4
#5 lore raw

PATCH v9 3/9 Refactor installation of overlays for guest used

In reply to longtao.pang

From: "longtao.pang" <[email protected]>

Based on Ian Campbell's v5_patch [04,05,06], I create this patch to refactor installation of overlays for guest used.

Link of Ian Campbell's patch:
http://lists.xenproject.org/archives/html/xen-devel/2015-04/msg01452.html
http://lists.xenproject.org/archives/html/xen-devel/2015-04/msg01447.html

---
 Osstest/Debian.pm |    1 +
 1 file changed, 1 insertion(+)
Osstest/Debian.pm +1 -0
index 6691ff6..4af6957 100644
@@ -624,6 +624,7 @@ sub preseed_base ($$$$;@) {
 
     preseed_ssh($ho, $sfx);
     preseed_hook_overlay($ho, $sfx, $c{OverlayLocal}, 'overlay-local.tar');
+    preseed_hook_overlay($ho, $sfx, 'overlay', 'overlay.tar');
 
     my $preseed = <<"END";
 d-i mirror/suite string $suite
Signature · 1 line
1.7.10.4
#7 lore raw

PATCH v9 4/9 Edit some APIs in TestSupport.pm for nested test

In reply to longtao.pang

From: "longtao.pang" <[email protected]>

1. If vif model is defined for guest, use it in guest's configuration
2. In L2 installation context, its host (L1) shall not have a static IP but stored in runvar in L1 installation before; use this stored runvar IP.

---
Changes in v9:
1. Refactor 'selecthost' to set L1 guest's IpAddr for nested job.
2. Change $vifmodel to a reasonable format.
3. Refactor 'prepareguest' to use a specific disksize for nested L1 guest.

---
 Osstest/TestSupport.pm |   27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)
Osstest/TestSupport.pm +17 -10
index 1bde67d..2d7ecc0 100644
@@ -865,13 +865,17 @@ sub selecthost ($) {
     serial_host_setup($ho);
 
     $ho->{IpStatic} = get_host_property($ho,'ip-addr');
-    if (!defined $ho->{IpStatic}) {
-	my $ip_packed= gethostbyname($ho->{Fqdn});
-	die "$ho->{Fqdn} ?" unless $ip_packed;
-	$ho->{IpStatic}= inet_ntoa($ip_packed);
-	die "$ho->{Fqdn} ?" unless defined $ho->{IpStatic};
+    if (defined $r{"${ident}_ip"}) {
+        $ho->{Ip} = $r{"${ident}_ip"};
+    } else {
+        if (!defined $ho->{IpStatic}) {
+	    my $ip_packed= gethostbyname($ho->{Fqdn});
+	    die "$ho->{Fqdn} ?" unless $ip_packed;
+	    $ho->{IpStatic}= inet_ntoa($ip_packed);
+	    die "$ho->{Fqdn} ?" unless defined $ho->{IpStatic};
+        }
+        $ho->{Ip}= $ho->{IpStatic};
     }
-    $ho->{Ip}= $ho->{IpStatic};
 
     #----- tftp -----
 
@@ -1513,14 +1517,15 @@ sub prepareguest ($$$$$$) {
     store_runvar("${gn}_hostname", $hostname);
     store_runvar("${gn}_tcpcheckport", $tcpcheckport);
     store_runvar("${gn}_boot_timeout", $boot_timeout);
+    my $gho= selectguest($gn, $ho);
+    store_runvar("${gn}_domname", $gho->{Name});
+    #if we have defined guest specific disksize, override it
+    $mb = guest_var($gho,'disksize',$mb);
 
     if (defined $mb) {
 	store_runvar("${gn}_disk_lv", $r{"${gn}_hostname"}.'-disk');
     }
 
-    my $gho= selectguest($gn, $ho);
-    store_runvar("${gn}_domname", $gho->{Name});
-
     if (defined $mb) {
 	store_runvar("${gn}_vg", '');
 	if (!length $r{"${gn}_vg"}) {
@@ -1548,11 +1553,13 @@ sub prepareguest_part_xencfg ($$$$$) {
     my $oncrash= $xopts->{OnCrash} || 'preserve';
     my $vcpus= guest_var($gho, 'vcpus', $xopts->{DefVcpus} || 2);
     my $xoptcfg= $xopts->{ExtraConfig};
+    my $vif= guest_var($gho, 'vifmodel','');
+    my $vifmodel= $vif ? ",model=$vif" : '';
     $xoptcfg='' unless defined $xoptcfg;
     my $xencfg= <<END;
 name        = '$gho->{Name}'
 memory = ${ram_mb}
-vif         = [ 'type=ioemu,mac=$gho->{Ether}' ]
+vif         = [ 'type=ioemu,mac=$gho->{Ether}${vifmodel}' ]
 #
 on_poweroff = '$onpoweroff'
 on_reboot   = '$onreboot'
Signature · 1 line
1.7.10.4
#9 lore raw

PATCH v9 5/9 Move the codes about memory size setting into prep()

In reply to longtao.pang

From: "longtao.pang" <[email protected]>

Move the codes about memory size setting from outside into prep(), where these $ram_mb operations are only used; and in next patch, for L2 guest installation, $ram_mb will be override by a runvar value, which needs $gho in scope.

---
 ts-debian-hvm-install |   24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
ts-debian-hvm-install +12 -12
index 0085d82..fd28abc 100755
@@ -149,6 +149,18 @@ sub prep () {
     target_putfilecontents_root_stash($ho, 10, preseed(),
                                       $preseed_file_path);
 
+    # If host has >8G free memory, create a guest with 4G memory to catch
+    # any error that triggers cross 4G boundary
+    my $host_freemem_mb = host_get_free_memory($ho);
+    my $ram_minslop = 100;
+    my $ram_lots = 5000;
+    if ($host_freemem_mb > $ram_lots * 2 + $ram_minslop) {
+        $ram_mb = $ram_lots;
+    } else {
+        $ram_mb = 768;
+    }
+    logm("Host has $host_freemem_mb MB free memory, setting guest memory size to $ram_mb MB");
+
     more_prepareguest_hvm($ho,$gho, $ram_mb, $disk_mb,
                           OnReboot => 'preserve',
                           Bios => $r{bios},
@@ -166,18 +178,6 @@ sub prep () {
     });
 }
 
-# If host has >8G free memory, create a guest with 4G memory to catch
-# any error that triggers cross 4G boundary
-my $host_freemem_mb = host_get_free_memory($ho);
-my $ram_minslop = 100;
-my $ram_lots = 5000;
-if ($host_freemem_mb > $ram_lots * 2 + $ram_minslop) {
-    $ram_mb = $ram_lots;
-} else {
-    $ram_mb = 768;
-}
-logm("Host has $host_freemem_mb MB free memory, setting guest memory size to $ram_mb MB");
-
 if (!$stage) {
     prep();
     guest_create($gho);
Signature · 1 line
1.7.10.4
#11 lore raw

PATCH v9 6/9 Changes on test step of Debian hvm guest install

In reply to longtao.pang

From: "longtao.pang" <[email protected]>

1. Increase disk size to accommodate to nested test requirement.
2. Since 'Debain-xxx-.iso' image will be stored in rootfs of L1 guest, therefore needs more disk capacity, increase root partition size to 10000.
3. In L1 installation context, assign more memory (defined in runvar) to it; Since it acts as a nested hypervisor anyway.
4. Comment out CDROM entry in sources.list to make HTTP URL entry available for L1 hvm guest.
5. Enable nestedhvm feature in ExtraConfig for nested job.

---
Changes in v9:
1. Using 'guest_var' to get nested L1 guest's specific disk size and specific memory size.
2. Using 'guest_var' to enable or disable nestedhvm feature.

---
 ts-debian-hvm-install |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
ts-debian-hvm-install +14 -3
index fd28abc..d823233 100755
@@ -59,7 +59,7 @@ d-i partman-auto/expert_recipe string \\
                         use_filesystem{ } filesystem{ vfat } \\
                         mountpoint{ /boot/efi } \\
                 . \\
-                5000 50 5000 ext4 \\
+                10000 50 10000 ext4 \\
                         method{ format } format{ } \\
                         use_filesystem{ } filesystem{ ext4 } \\
                         mountpoint{ / } \\
@@ -73,6 +73,7 @@ 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 sed -i 's/^deb *cdrom/#&/g' /etc/apt/sources.list;
 END
 
     $preseed_file .= preseed_hook_cmds();
@@ -149,6 +150,11 @@ sub prep () {
     target_putfilecontents_root_stash($ho, 10, preseed(),
                                       $preseed_file_path);
 
+    my $extra_config='';
+    $extra_config .="nestedhvm=1\n"
+        # Use guest_var to get boolean value to enable nestedhvm
+        # feature or not
+        if guest_var($gho,"enable_nestedhvm",'false') eq 'true';
     # If host has >8G free memory, create a guest with 4G memory to catch
     # any error that triggers cross 4G boundary
     my $host_freemem_mb = host_get_free_memory($ho);
@@ -157,13 +163,18 @@ sub prep () {
     if ($host_freemem_mb > $ram_lots * 2 + $ram_minslop) {
         $ram_mb = $ram_lots;
     } else {
-        $ram_mb = 768;
+        # Use guest_var to get specific memsize, or will use default '768'
+        $ram_mb= guest_var($gho,'memsize',768);
     }
-    logm("Host has $host_freemem_mb MB free memory, setting guest memory size to $ram_mb MB");
+    logm("Host has $host_freemem_mb MB free memory,
+         setting guest memory size to $ram_mb MB");
+    # Use guest_var to get specific disk size, or will use default $disk_mb
+    $disk_mb= guest_var($gho,'disksize',$disk_mb);
 
     more_prepareguest_hvm($ho,$gho, $ram_mb, $disk_mb,
                           OnReboot => 'preserve',
                           Bios => $r{bios},
+                          ExtraConfig => $extra_config,
                           PostImageHook => sub {
         my $cmds = iso_copy_content_from_image($gho, $newiso);
         $cmds .= prepare_initrd($initrddir,$newiso,$preseed_file_path);
Signature · 1 line
1.7.10.4
#13 lore raw

PATCH v9 7/9 Add new script to customize nested test configuration

In reply to longtao.pang

From: "longtao.pang" <[email protected]>

1. In this script, make some appropriate runvars which selecthost would recognise.
2. Prepare the configurations for installing L2 guest VM.
3. Create a lv disk in L0 and hot-attach it to L1, need to restart L1 to make the block disk to be recognized by L1 system, then using this disk to create a VG that used for installing L2.

---
Changes in v9:
1. For L1, identical its ident and guestname as 'nestedl1'.
2. Reuse Ian Campbell's v5_patch[04,05,06] to avoid duplicated codes about 'ssh host keys' and 'overlays' when installing nested guest VM.
3. Refactor LV disk creating for L2 guest.

---
 ts-nested-setup |   66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100755 ts-nested-setup
ts-nested-setup new file +66 -0
new file mode 100755
index 0000000..566186c
@@ -0,0 +1,66 @@
+#!/usr/bin/perl -w
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2015 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
+# 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();
+# Pass L0's ident and L1's guestname
+our ($l0_ident,$l1_gn) = @ARGV;
+our ($l0,$l1) = ts_get_host_guest($l0_ident,$l1_gn);
+
+guest_check_ip($l1);
+# L1 guest's ident is same as guestname
+our $l1_ident = $l1->{Guest};
+
+store_runvar($l1_ident,$l1->{Guest});
+store_runvar("${l1_ident}_ip",$l1->{Ip});
+
+# Since Ian Campbell's v5_patch[04,05,06] has a bug that the
+# 'preseed/late_command' are unavailable, so add below line here to
+# make HTTP URL entry available in sources.list for L1 hvm guest.
+# Onece the bug is fiexed, this line code could be removed.
+target_cmd_root($l1, "sed -i 's/^deb *cdrom/#&/g' /etc/apt/sources.list");
+target_cmd_root($l1, "update-rc.d osstest-confirm-booted start 99 2 .");
+
+# Inside L0, create storage lv, attach this lv to L1, and then inside L1 using the storage for installing L2
+my $vgname = $l1->{Vg};
+my $guest_storage_lv_name = "${l1_ident}_guest_storage";
+my $guest_storage_lv_size = guest_var($l1,'guest_storage_size',undef);
+my $guest_storage_lvdev = "/dev/${vgname}/${guest_storage_lv_name}";
+
+target_cmd_root($l0, <<END);
+    lvremove -f $guest_storage_lvdev ||:
+    lvcreate -L ${guest_storage_lv_size}M -n $guest_storage_lv_name $vgname
+    dd if=/dev/zero of=$guest_storage_lvdev count=10
+    xl block-attach $l1->{Name} ${guest_storage_lvdev},raw,sdb,rw
+END
+# This is probably a bug here, if we use 'xvdx' as block 'dev'
+# after installing xen and boot into xen kernel, the disk will not be
+# recognized by OS. Also, if we use 'sde' instead of 'sdb' as block 'dev',
+# after installing xen and boot into xen kernel, the disk will be recognized
+# as 'sdb' not 'sde', so we will have to use 'sdb' here.
+
+target_install_packages_norec($l1, qw(lvm2 rsync genisoimage));
+# After block-attach lvdev to L1, need to reboot L1 to make the attach
+# to take effect. I think this is a bug for kernel.
+target_reboot($l1);
+# Create a vg in L1 guest and vg name is ${l1_gn}-disk
+target_cmd_root($l1, "pvcreate /dev/xvdb && vgcreate ${l1_gn}-disk /dev/xvdb");
Signature · 1 line
1.7.10.4
#17 lore raw

PATCH v9 8/9 Compose the main recipe of nested test job

In reply to longtao.pang

From: "longtao.pang" <[email protected]>

The ident and guestname are same of 'nestedl1' for L1 guest VM.

---
Changes in v9:
1. For L1, identical its ident and guestname as 'nestedl1'; And same for L2, 'nestedl2' is L2's name as well as its ident.
2. Place '+' to include parameters in the test id for ts-guest-destory step.

---
 sg-run-job |   11 +++++++++++
 1 file changed, 11 insertions(+)
sg-run-job +11 -0
index eae159d..b19f9f9 100755
@@ -299,6 +299,17 @@ 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-debian-hvm-install + host + nestedl1
+    run-ts . = ts-nested-setup + host + nestedl1
+    run-ts . = ts-xen-install nestedl1
+    run-ts . = ts-host-reboot nestedl1
+    run-ts . = ts-debian-hvm-install nestedl1 nestedl2
+    run-ts . = ts-guest-stop nestedl1 nestedl2
+    run-ts . = ts-guest-destroy + host + nestedl1
+}
+
 proc test-guest-migr {g} {
     if {[catch { run-ts . = ts-migrate-support-check + host $g }]} return
 
Signature · 1 line
1.7.10.4
#19 lore raw

PATCH v9 9/9 Add test job for nest test case

In reply to longtao.pang

From: "longtao.pang" <[email protected]>

1. This patch adds creation of the nested test job, when job creation procedure is invoked.
2. Set nested L1's vif model, nestedhvm feature, set specific disk size and memory size for nested test by make-flight.

---
Changes in v9:
1. Group 'nestedl1*' and 'nestedl2*' together in the list.
2. Remove duplicated runvars for nested job.
3. Avoid testing Xen branches before 4.4; Avoid flights of qemu traditional (i.e. qemu upstream supported only).

---
 make-flight |   32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
make-flight +32 -0
index cc8ecdb..b5c7c27 100755
@@ -204,6 +204,37 @@ do_hvm_win7_x64_tests () {
             all_hostflags=$most_hostflags,hvm
 }
 
+do_hvm_debian_nested_tests () {
+  if [ $xenarch != amd64 -o $dom0arch != amd64 \
+      -o "x$qemuu_suffix" != "x-qemuu" ]; then
+    return
+  fi
+
+  case $xenbranch in
+    xen-3.*-testing)      return;;
+    xen-4.0-testing)      return;;
+    xen-4.1-testing)      return;;
+    xen-4.2-testing)      return;;
+    xen-4.3-testing)      return;;
+  esac
+  # Define bios type, in 'ts-debian-hvm-install' script will use it,
+  # or will die if "$r{bios}" undefined.
+  bios=$1
+
+  job_create_test test-$xenarch$kern-$dom0arch$qemuu_suffix-nested \
+            test-nested xl $xenarch $dom0arch $qemuu_runvar \
+            nestedl1_image=debian-7.2.0-amd64-CD-1.iso \
+            nestedl1_vifmodel='e1000' \
+            nestedl1_disksize='15000' \
+            nestedl1_memsize='3072' \
+            nestedl1_enable_nestedhvm='true' \
+            nestedl1_guest_storage_size='20000' \
+            nestedl2_image=debian-7.2.0-amd64-CD-1.iso \
+            nestedl2_disksize='15000' \
+            bios=$bios
+            all_hostflags=$most_hostflags,hvm
+}
+
 do_hvm_debian_test_one () {
   testname=$1
   bios=$2
@@ -408,6 +439,7 @@ test_matrix_do_one () {
     do_hvm_rhel6_tests
 
     do_hvm_debian_tests
+    do_hvm_debian_nested_tests seabios
 
   done # qemuu_suffix
 
Signature · 1 line
1.7.10.4
#6 lore raw

Re: [OSSTEST Nested PATCH v9 3/9] Refactor installation of overlays for guest used

In reply to longtao.pang
Quoted 8 lines · longtao.pang

From: "longtao.pang" <[email protected]>

Based on Ian Campbell's v5_patch [04,05,06], I create this patch to refactor installation of overlays for guest used.

Link of Ian Campbell's patch:
http://lists.xenproject.org/archives/html/xen-devel/2015-04/msg01452.html
http://lists.xenproject.org/archives/html/xen-devel/2015-04/msg01447.html

This information is useful in the context of posting, but it should be after the main body of the commit log and a --- marker so it isn't included when committing.

The actual body of the commit message should offer some explanation of how/why it is safe to apply the overlay to guests as well as hosts as well as why you want it for guests.

Something like:

Apply overlay to guests as well as hosts by moving to preseed_base.

We do this because we want to be able to:

* Use /etc/init.d/osstest-confirm-booted for guests as well as hosts (in particular when testing nestedhvm we sometimes want to treat a guest as a host)
* Use grub's 20_linux_xen which is harmless unless Xen is installed in the guest which is the case only for nestedhvm testing when we want these changes.

The other things in the overlay are some initscripts (xenbridge and xenlightdaemons) which are not enabled for guests and hence are therefore harmless.

---
Base on Ian Campbell's v5_patch [04,05,06], I create this patch... etc

Osstest/Debian.pm sub preseed_base ($$$$;@) { · line 627

Quoted 5 lines
Osstest/Debian.pm +1 -0
@@ -624,6 +624,7 @@ sub preseed_base ($$$$;@) {
 
     preseed_ssh($ho, $sfx);
     preseed_hook_overlay($ho, $sfx, $c{OverlayLocal}, 'overlay-local.tar');
+    preseed_hook_overlay($ho, $sfx, 'overlay', 'overlay.tar');

I think you should also remove the existing one from preseed_create, else it will happen twice for L0 host install.

Ian.

#8 lore raw

Re: [OSSTEST Nested PATCH v9 4/9] Edit some APIs in TestSupport.pm for nested test

In reply to longtao.pang
Quoted 8 lines · longtao.pang

From: "longtao.pang" <[email protected]>

1. If vif model is defined for guest, use it in guest's configuration
2. In L2 installation context, its host (L1) shall not have a static IP but stored in runvar in L1 installation before; use this stored runvar IP.

The code looks good, thanks. I have some minor formatting/wording nits.

Osstest/TestSupport.pm sub prepareguest ($$$$$$) { · line 1519

Quoted 4 lines
Osstest/TestSupport.pm +0 -0
@@ -1513,14 +1517,15 @@ sub prepareguest ($$$$$$) {
     store_runvar("${gn}_hostname", $hostname);
     store_runvar("${gn}_tcpcheckport", $tcpcheckport);
     store_runvar("${gn}_boot_timeout", $boot_timeout);

Blank line here please.

Osstest/TestSupport.pm sub prepareguest ($$$$$$) { · line 1521

Quoted 2 lines
Osstest/TestSupport.pm +2 -0
+    my $gho= selectguest($gn, $ho);
+    store_runvar("${gn}_domname", $gho->{Name});

A blank line here please.

Osstest/TestSupport.pm sub prepareguest ($$$$$$) { · line 1522

Quoted 1 line
Osstest/TestSupport.pm +1 -0
+    #if we have defined guest specific disksize, override it

Space after "#" please and ideally "If" not "if".

I would say "use it" rather than "override it".

Osstest/TestSupport.pm sub prepareguest ($$$$$$) { · line 1524

Quoted 2 lines
Osstest/TestSupport.pm +1 -0
+    $mb = guest_var($gho,'disksize',$mb);
 

And no blank line here. (i.e. assignment of $mb nestles against the following if and not the preceding store_runvar)

With that stuff fixed: Acked-by: Ian Campbell <[email protected]>

Acked-by on v9 5/9
#10 lore raw

Re: [OSSTEST Nested PATCH v9 5/9] Move the codes about memory size setting into prep()

In reply to longtao.pang
Quoted 3 lines · longtao.pang

From: "longtao.pang" <[email protected]>

Move the codes about memory size setting from outside into prep(),

"code for setting memory size"

Quoted 2 lines

where these $ram_mb operations are only used; and in next patch, for L2 guest installation, $ram_mb will be override by a runvar value,

"overridden"

Quoted 1 line

which needs $gho in scope.

It is useful to say explicitly:

This is pure code motion. No functional change.

Quoted 1 line

With those minor changes:

#12 lore raw

Re: [OSSTEST Nested PATCH v9 6/9] Changes on test step of Debian hvm guest install

In reply to longtao.pang
Quoted 3 lines · longtao.pang

From: "longtao.pang" <[email protected]>

1. Increase disk size to accommodate to nested test requirement.

^ in preseed recipe (I think?)

Quoted 24 lines

2. Since 'Debain-xxx-.iso' image will be stored in rootfs of L1 guest, therefore needs more disk capacity, increase root partition size to 10000.
3. In L1 installation context, assign more memory (defined in runvar) to it; Since it acts as a nested hypervisor anyway.
4. Comment out CDROM entry in sources.list to make HTTP URL entry available for L1 hvm guest.
5. Enable nestedhvm feature in ExtraConfig for nested job.

---
Changes in v9:
1. Using 'guest_var' to get nested L1 guest's specific disk size and specific memory size.
2. Using 'guest_var' to enable or disable nestedhvm feature.

---
 ts-debian-hvm-install |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
ts-debian-hvm-install +0 -0
index fd28abc..d823233 100755

ts-debian-hvm-install d-i apt-setup/cdrom/set-first boolean false · line 76

Quoted 4 lines
ts-debian-hvm-install +1 -0
@@ -73,6 +73,7 @@ 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 sed -i 's/^deb *cdrom/#&/g' /etc/apt/sources.list;

When this is rebased onto v6 of my distro testing series this will need to become/use preseed_hook_command and you won't want to mix it with the EFI stuff since that has/will become conditional.

That change is probably enough to invalidate any Ack I might give now, or I would do so.

ts-debian-hvm-install sub prep () { · line 157

Quoted 12 lines
ts-debian-hvm-install +5 -0
 END
 
     $preseed_file .= preseed_hook_cmds();
@@ -149,6 +150,11 @@ sub prep () {
     target_putfilecontents_root_stash($ho, 10, preseed(),
                                       $preseed_file_path);
 
+    my $extra_config='';
+    $extra_config .="nestedhvm=1\n"
+        # Use guest_var to get boolean value to enable nestedhvm
+        # feature or not
+        if guest_var($gho,"enable_nestedhvm",'false') eq 'true';

IMHO a better formatting would be:

+    # Use guest_var to get boolean value to enable nestedhvm
+    # feature or not
+    $extra_config .="nestedhvm=1\n"

+ if guest_var($gho,"enable_nestedhvm",'false') eq 'true';

Although I think you could just omit the comment, it's not adding much.

Quoted 5 lines
ts-debian-hvm-install +0 -0
     # If host has >8G free memory, create a guest with 4G memory to catch
     # any error that triggers cross 4G boundary
     my $host_freemem_mb = host_get_free_memory($ho);

ts-debian-hvm-install sub prep () { · line 170

Quoted 10 lines
ts-debian-hvm-install +4 -2
@@ -157,13 +163,18 @@ sub prep () {
     if ($host_freemem_mb > $ram_lots * 2 + $ram_minslop) {
         $ram_mb = $ram_lots;
     } else {
-        $ram_mb = 768;
+        # Use guest_var to get specific memsize, or will use default '768'
+        $ram_mb= guest_var($gho,'memsize',768);
     }
-    logm("Host has $host_freemem_mb MB free memory, setting guest memory size to $ram_mb MB");
+    logm("Host has $host_freemem_mb MB free memory,
+         setting guest memory size to $ram_mb MB");

Blank line here please.

Quoted 10 lines
ts-debian-hvm-install +3 -0
+    # Use guest_var to get specific disk size, or will use default $disk_mb
+    $disk_mb= guest_var($gho,'disksize',$disk_mb);
 
     more_prepareguest_hvm($ho,$gho, $ram_mb, $disk_mb,
                           OnReboot => 'preserve',
                           Bios => $r{bios},
+                          ExtraConfig => $extra_config,
                           PostImageHook => sub {
         my $cmds = iso_copy_content_from_image($gho, $newiso);
         $cmds .= prepare_initrd($initrddir,$newiso,$preseed_file_path);
Acked-by on v9 9/9
#20 lore raw

Re: [OSSTEST Nested PATCH v9 9/9] Add test job for nest test case

In reply to longtao.pang
Quoted 14 lines · longtao.pang
make-flight +6 -0
index cc8ecdb..b5c7c27 100755
@@ -204,6 +204,37 @@ do_hvm_win7_x64_tests () {
             all_hostflags=$most_hostflags,hvm
 }
 
+do_hvm_debian_nested_tests () {
+  if [ $xenarch != amd64 -o $dom0arch != amd64 \
+      -o "x$qemuu_suffix" != "x-qemuu" ]; then
+    return
+  fi
+

make-flight do_hvm_win7_x64_tests () { · line 222

Quoted 10 lines
make-flight +10 -0
+  case $xenbranch in
+    xen-3.*-testing)      return;;
+    xen-4.0-testing)      return;;
+    xen-4.1-testing)      return;;
+    xen-4.2-testing)      return;;
+    xen-4.3-testing)      return;;
+  esac
+  # Define bios type, in 'ts-debian-hvm-install' script will use it,
+  # or will die if "$r{bios}" undefined.
+  bios=$1

Please can you just put

        bios=$1

as the first line in the function, followed by a blank line, followed by the $xenarch/$domarch/$qemuu_suffix test. No need for the comment.

make-flight do_hvm_win7_x64_tests () { · line 235

Quoted 13 lines
make-flight +13 -0
+
+  job_create_test test-$xenarch$kern-$dom0arch$qemuu_suffix-nested \
+            test-nested xl $xenarch $dom0arch $qemuu_runvar \
+            nestedl1_image=debian-7.2.0-amd64-CD-1.iso \
+            nestedl1_vifmodel='e1000' \
+            nestedl1_disksize='15000' \
+            nestedl1_memsize='3072' \
+            nestedl1_enable_nestedhvm='true' \
+            nestedl1_guest_storage_size='20000' \
+            nestedl2_image=debian-7.2.0-amd64-CD-1.iso \
+            nestedl2_disksize='15000' \
+            bios=$bios
+            all_hostflags=$most_hostflags,hvm

Looks good, thanks.

With the bios= moved:

Ian.

#14 lore raw

Re: [OSSTEST Nested PATCH v9 7/9] Add new script to customize nested test configuration

In reply to longtao.pang

ts-nested-setup line 40

Quoted 5 lines · longtao.pang
ts-nested-setup new file +5 -0
+# Since Ian Campbell's v5_patch[04,05,06] has a bug that the
+# 'preseed/late_command' are unavailable, so add below line here to
+# make HTTP URL entry available in sources.list for L1 hvm guest.
+# Onece the bug is fiexed, this line code could be removed.
+target_cmd_root($l1, "sed -i 's/^deb *cdrom/#&/g' /etc/apt/sources.list");

This should be fixed in my v6 posting of that series.

ts-nested-setup line 47

Quoted 7 lines
ts-nested-setup new file +7 -0
+target_cmd_root($l1, "update-rc.d osstest-confirm-booted start 99 2 .");
+
+# Inside L0, create storage lv, attach this lv to L1, and then inside L1 using the storage for installing L2
+my $vgname = $l1->{Vg};
+my $guest_storage_lv_name = "${l1_ident}_guest_storage";
+my $guest_storage_lv_size = guest_var($l1,'guest_storage_size',undef);
+my $guest_storage_lvdev = "/dev/${vgname}/${guest_storage_lv_name}";

Perhaps:

        die "guest_storage_lv_size" unless $guest_storage_lv_size;

?

ts-nested-setup line 52

Quoted 5 lines
ts-nested-setup new file +5 -0
+
+target_cmd_root($l0, <<END);
+    lvremove -f $guest_storage_lvdev ||:
+    lvcreate -L ${guest_storage_lv_size}M -n $guest_storage_lv_name $vgname
+    dd if=/dev/zero of=$guest_storage_lvdev count=10

I have some ideas/plans on how to refactor things so we can use prepareguest_part_lvmdisk for secondary disks too, but this is OK as it is for now IMHO.

Quoted 1 line

+ xl block-attach $l1->{Name} ${guest_storage_lvdev},raw,sdb,rw

This relies on/assumes the toolstack is xl (sorry for not spotting this before).

Really it should use a new block_attach method on toolstack($ho) (i.e. Osstest/Toolstack/*.pm) so it can work with libvirt etc.

However I think this hardcoding is tolerable for now (you've encoded that it is xl only in make-flight already), but please could you add near the top of this script:

        die "toolstack $r{toolstack}" unless $r{toolstack} eq "xl";

so it fails in an immediately obvious way if someone tries this with another toolstack.

Ian: Is that OK with you?

ts-nested-setup line 61

Quoted 8 lines
ts-nested-setup new file +8 -0
+END
+# This is probably a bug here, if we use 'xvdx' as block 'dev'
+# after installing xen and boot into xen kernel, the disk will not be
+# recognized by OS. Also, if we use 'sde' instead of 'sdb' as block 'dev',
+# after installing xen and boot into xen kernel, the disk will be recognized
+# as 'sdb' not 'sde', so we will have to use 'sdb' here.
+
+target_install_packages_norec($l1, qw(lvm2 rsync genisoimage));

Please can you put this above, just after the osstest-confirm-started stuff so that it is not mixed in with the stuff dealing with the additional disk.

ts-nested-setup line 63

Quoted 2 lines
ts-nested-setup new file +2 -0
+# After block-attach lvdev to L1, need to reboot L1 to make the attach
+# to take effect. I think this is a bug for kernel.

I've just tried this and it worked for me, i.e. /dev/xvdb appears immediately after xl block-attach with no reboot required. Perhaps this was an artefact of a bug in some previous iteration of the series?

I would replace this comment, and the "This is probably a bug here" and "Inside L0, create storage lv" ones above with a single (long) comment before all of this disk stuff which explains:

We need to attach an extra disk to the L1 guest to be used as L2 guest storage.

When running in a nested HVM environment the L1 domain is acting as both a guest to L0 and a host to L2 guests and therefore potentially sees connections to two independent xenstore instances, one provided by the L0 host and one which is provided by the L1 instance of xenstore.

Unfortunately the kernel is not capable of dealing with this and is only able to cope with a single xenstore connection. Since the L1 toolstack and L2 guests absolutely require xenstore to function we therefore cannot use the L0 xenstore and therefore cannot use PV devices (xvdX etc) in the L1 guest and must use emulated devices (sdX etc).

However at the moment we have not yet rebooted L1 into Xen and so it does have PV devices available and sdb actually appears as xvdb. We could disable the Xen platform device and use emulated devices for the install phase too but that would be needlessly slow.

It's a bit long (to say the least) but I think it is worth explaining since limitation of nestedhvm isn't obvious without thinking about it a bit...

Quoted 3 lines
ts-nested-setup new file +3 -0
+target_reboot($l1);
+# Create a vg in L1 guest and vg name is ${l1_gn}-disk
+target_cmd_root($l1, "pvcreate /dev/xvdb && vgcreate ${l1_gn}-disk /dev/xvdb");
Acked-by on v9 1/9
#2 lore raw

Re: [OSSTEST Nested PATCH v9 1/9] parsing grub which has 'submenu' primitive

In reply to longtao.pang
Quoted 8 lines · longtao.pang

From: "longtao.pang" <[email protected]>

From a hvm kernel build from Linux stable Kernel tree,
the auto generated grub2 menu will have 'submenu' primitive, upon the 'menuentry' items. Xen boot entries will be grouped into a submenu. This patch adds capability to support such grub formats.

Can I ask that when a patch is Acked (as I did this one in v8) that you add that Acked-by to the patch (immediately after your Signed-off-by) for the next posting, unless there have been major modifications which might invalidate the review (use your judgement here).

That essentially serves as a reminder to me and others that there is no need to look at the patch again which speeds up the review process for subsequent iterations.

Ian.

#15 lore raw

Re: [OSSTEST Nested PATCH v9 7/9] Add new script to customize nested test configuration

In reply to Ian Campbell
Quoted 76 lines

-----Original Message-----
From: Ian Campbell [mailto:[email protected]]
Sent: Wednesday, May 06, 2015 7:37 PM
To: Pang, LongtaoX
Cc: [email protected]; [email protected]; [email protected]; Hu, Robert
Subject: Re: [OSSTEST Nested PATCH v9 7/9] Add new script to customize nested test configuration

ts-nested-setup line 40

Quoted 5 lines · longtao.pang
ts-nested-setup new file +5 -0
+# Since Ian Campbell's v5_patch[04,05,06] has a bug that the
+# 'preseed/late_command' are unavailable, so add below line here to
+# make HTTP URL entry available in sources.list for L1 hvm guest.
+# Onece the bug is fiexed, this line code could be removed.
+target_cmd_root($l1, "sed -i 's/^deb *cdrom/#&/g' /etc/apt/sources.list");

This should be fixed in my v6 posting of that series.

ts-nested-setup

Quoted 3 lines
ts-nested-setup new file +3 -0
+target_cmd_root($l1, "update-rc.d osstest-confirm-booted start 99 2 .");
+
+# Inside L0, create storage lv, attach this lv to L1, and then inside L1 using the

storage for installing L2

ts-nested-setup line 47

Quoted 4 lines
ts-nested-setup new file +4 -0
+my $vgname = $l1->{Vg};
+my $guest_storage_lv_name = "${l1_ident}_guest_storage";
+my $guest_storage_lv_size = guest_var($l1,'guest_storage_size',undef);
+my $guest_storage_lvdev = "/dev/${vgname}/${guest_storage_lv_name}";

Perhaps:

        die "guest_storage_lv_size" unless $guest_storage_lv_size;

?

ts-nested-setup

Quoted 4 lines
ts-nested-setup new file +4 -0
+
+target_cmd_root($l0, <<END);
+    lvremove -f $guest_storage_lvdev ||:
+    lvcreate -L ${guest_storage_lv_size}M -n $guest_storage_lv_name

$vgname

Quoted 1 line

+ dd if=/dev/zero of=$guest_storage_lvdev count=10

I have some ideas/plans on how to refactor things so we can use prepareguest_part_lvmdisk for secondary disks too, but this is OK as it is for now IMHO.

Quoted 1 line

+ xl block-attach $l1->{Name} ${guest_storage_lvdev},raw,sdb,rw

This relies on/assumes the toolstack is xl (sorry for not spotting this before).

Really it should use a new block_attach method on toolstack($ho) (i.e. Osstest/Toolstack/*.pm) so it can work with libvirt etc.

However I think this hardcoding is tolerable for now (you've encoded that it is xl only in make-flight already), but please could you add near the top of this script:

        die "toolstack $r{toolstack}" unless $r{toolstack} eq "xl";

so it fails in an immediately obvious way if someone tries this with another toolstack.

Ian: Is that OK with you?

ts-nested-setup line 61

Quoted 8 lines
ts-nested-setup new file +8 -0
+END
+# This is probably a bug here, if we use 'xvdx' as block 'dev'
+# after installing xen and boot into xen kernel, the disk will not be
+# recognized by OS. Also, if we use 'sde' instead of 'sdb' as block 'dev',
+# after installing xen and boot into xen kernel, the disk will be recognized
+# as 'sdb' not 'sde', so we will have to use 'sdb' here.
+
+target_install_packages_norec($l1, qw(lvm2 rsync genisoimage));

Please can you put this above, just after the osstest-confirm-started stuff so that it is not mixed in with the stuff dealing with the additional disk.

Quoted 7 lines

ts-nested-setup line 63

Quoted 2 lines
ts-nested-setup new file +2 -0
+# After block-attach lvdev to L1, need to reboot L1 to make the attach
+# to take effect. I think this is a bug for kernel.

I've just tried this and it worked for me, i.e. /dev/xvdb appears immediately after xl block-attach with no reboot required. Perhaps this was an artefact of a bug in some previous iteration of the series?

Thanks for trying, I tried it in my environment, a reboot is not required now.
I think this bug happened just because I have used ' Debian-7.6.0-amd64-DVD-1.iso ' as installing L1's guest OS before, it did required a reboot and I assumed it's as a kernel bug.
According to you former comment, I change to use ' Debian-7.2.0-amd64-CD-1.iso' as installing L1's guest OS. I assumed that the bug still exist and keep to reboot L1 after block-attach 'lvdev'.
In fact, I should take a try for that, but I missed. Sorry for that.
So, the reboot action is no need now.

Quoted 35 lines

I would replace this comment, and the "This is probably a bug here" and "Inside L0, create storage lv" ones above with a single (long) comment before all of this disk stuff which explains:

We need to attach an extra disk to the L1 guest to be used as L2 guest storage.

When running in a nested HVM environment the L1 domain is acting as both a guest to L0 and a host to L2 guests and therefore potentially sees connections to two independent xenstore instances, one provided by the L0 host and one which is provided by the L1 instance of xenstore.

Unfortunately the kernel is not capable of dealing with this and is only able to cope with a single xenstore connection. Since the L1 toolstack and L2 guests absolutely require xenstore to function we therefore cannot use the L0 xenstore and therefore cannot use PV devices (xvdX etc) in the L1 guest and must use emulated devices (sdX etc).

However at the moment we have not yet rebooted L1 into Xen and so it does have PV devices available and sdb actually appears as xvdb. We could disable the Xen platform device and use emulated devices for the install phase too but that would be needlessly slow.

It's a bit long (to say the least) but I think it is worth explaining since limitation of nestedhvm isn't obvious without thinking about it a bit...

ts-nested-setup

Quoted 3 lines
ts-nested-setup new file +3 -0
+target_reboot($l1);
+# Create a vg in L1 guest and vg name is ${l1_gn}-disk
+target_cmd_root($l1, "pvcreate /dev/xvdb && vgcreate ${l1_gn}-disk

/dev/xvdb");

#16 lore raw

Re: [OSSTEST Nested PATCH v9 7/9] Add new script to customize nested test configuration

On Thu, 2015-05-07 at 07:42 +0000, Pang, LongtaoX wrote:
[...]

Quoted 6 lines

Thanks for trying, I tried it in my environment, a reboot is not required now.
I think this bug happened just because I have used ' Debian-7.6.0-amd64-DVD-1.iso ' as installing L1's guest OS before, it did required a reboot and I assumed it's as a kernel bug.
According to you former comment, I change to use ' Debian-7.2.0-amd64-CD-1.iso' as installing L1's guest OS. I assumed that the bug still exist and keep to reboot L1 after block-attach 'lvdev'.
In fact, I should take a try for that, but I missed. Sorry for that.

No problem.

In fact it seems like you may have highlighted a regression in Debian between the kernels used in 7.2.0 and 7.6.0.

Quoted 1 line

So, the reboot action is no need now.

Great!

Ian.