From: "longtao.pang" <longtaox.p...@intel.com> 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.
Signed-off-by: longtao.pang <longtaox.p...@intel.com> --- 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 diff --git a/ts-nested-setup b/ts-nested-setup new file mode 100755 index 0000000..566186c --- /dev/null +++ b/ts-nested-setup @@ -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"); -- 1.7.10.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel