From patchwork Tue Mar 18 14:56:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 26525 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f69.google.com (mail-pb0-f69.google.com [209.85.160.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9C20E202FA for ; Tue, 18 Mar 2014 22:38:39 +0000 (UTC) Received: by mail-pb0-f69.google.com with SMTP id md12sf19926876pbc.4 for ; Tue, 18 Mar 2014 15:38:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id :mime-version:cc:subject:precedence:list-id:list-unsubscribe :list-post:list-help:list-subscribe:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :list-archive:content-type:content-transfer-encoding; bh=x0NOIVrSoZ7NBN+CVFWUNbQ1b3nzd14EymBfn31FM2k=; b=OmgJd3UUcaG9QD/5yx6p55ieFW2yYouyeNJJFQl182F6Vrd/hFT0US8GxrSKIWEnBn cJA/piIsgwwkcy9wNHRnMqckUAZziHTfFXURbl3hLWc+PZuEK/CGqqm+G1/FRUVNkqcw 74+SrIig2VfDy+M8S8Abgz+fRWv4umgDjcFkrwSktRELvUEmGR8oy8skVoavjzhKOxtS kQscGvqTholniVRc8yxx0Wc6/OSsJb16iNCeb46rPwzkJEBOyP3AH+Es714Yj5kq9QHt 3TAwwIIDY78Y5iOnTw2IcvghQ0kPICp5xFa4Flg6Nfd7kR69fhOZOFkVHiqwsbpUPU+i aLgg== X-Gm-Message-State: ALoCoQkebqXbn1zRsHLJQBGlZfRMH3EIIWEKdRxe1IbxninWpde8MclQhEO4W5Y1GaBZ18hSaGTb X-Received: by 10.68.134.233 with SMTP id pn9mr13214117pbb.5.1395182318899; Tue, 18 Mar 2014 15:38:38 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.22.167 with SMTP id 36ls366914qgn.55.gmail; Tue, 18 Mar 2014 15:38:38 -0700 (PDT) X-Received: by 10.58.37.232 with SMTP id b8mr6660986vek.27.1395182318648; Tue, 18 Mar 2014 15:38:38 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id sa10si3006063vdc.103.2014.03.18.15.38.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Mar 2014 15:38:38 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id id10so8272951vcb.12 for ; Tue, 18 Mar 2014 15:38:38 -0700 (PDT) X-Received: by 10.52.78.231 with SMTP id e7mr8789229vdx.28.1395182318492; Tue, 18 Mar 2014 15:38:38 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.78.9 with SMTP id i9csp251573vck; Tue, 18 Mar 2014 15:38:38 -0700 (PDT) X-Received: by 10.43.65.145 with SMTP id xm17mr27365371icb.35.1395182314478; Tue, 18 Mar 2014 15:38:34 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id ac8si13996838icc.144.2014.03.18.15.38.33 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 18 Mar 2014 15:38:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xen.org designates 50.57.142.19 as permitted sender) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WPvRn-0007Kq-Og; Tue, 18 Mar 2014 14:56:55 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WPvRm-0007KK-6C for xen-devel@lists.xen.org; Tue, 18 Mar 2014 14:56:54 +0000 Received: from [85.158.137.68:37392] by server-5.bemta-3.messagelabs.com id B7/8D-18761-5BE58235; Tue, 18 Mar 2014 14:56:53 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-6.tower-31.messagelabs.com!1395154608!1395122!2 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n X-StarScan-Received: X-StarScan-Version: 6.11.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 13187 invoked from network); 18 Mar 2014 14:56:52 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-6.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 18 Mar 2014 14:56:52 -0000 X-IronPort-AV: E=Sophos;i="4.97,678,1389744000"; d="scan'208";a="112508994" Received: from accessns.citrite.net (HELO FTLPEX01CL03.citrite.net) ([10.9.154.239]) by FTLPIPO01.CITRIX.COM with ESMTP; 18 Mar 2014 14:56:52 +0000 Received: from norwich.cam.xci-test.com (10.80.248.129) by smtprelay.citrix.com (10.13.107.80) with Microsoft SMTP Server id 14.2.342.4; Tue, 18 Mar 2014 10:56:51 -0400 Received: from spare.cam.xci-test.com ([10.80.2.80] helo=kazak.uk.xensource.com.) by norwich.cam.xci-test.com with esmtp (Exim 4.72) (envelope-from ) id 1WPvRj-0008VQ-6N; Tue, 18 Mar 2014 14:56:51 +0000 From: Ian Campbell To: Date: Tue, 18 Mar 2014 14:56:51 +0000 Message-ID: <1395154611-28847-1-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 1.8.5.2 MIME-Version: 1.0 X-DLP: MIA2 Cc: Ian Campbell , xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH OSSTEST v3] Allow per-host TFTP setup X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ian.campbell@citrix.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: I run osstest against machines which are in both the XenServer and XenClient administrative domains, and hence which have different TFTP servers, accessible locally via different NFS mounted paths. Make it possible to specify various bits of TFTP path via ~/.xen-osstest/config by introducing the idea of Tftp "scope" and allowing that to be configurable on a per-host basis. For example I have: TftpDefaultScope xenserver TftpPath_xenserver /usr/groups/netboot/ TftpPxeDir_xenserver pxelinux.cfg/ TftpPath_xenclient /home/xc_tftpboot/pxe/ TftpPxeDir_xenclient / TftpPxeTemplates_xenclient %ipaddrhex%/pxelinux.cfg HostProp_marilith-n4_TftpScope xenclient and I am now able to install on both cam-st16 (a xenserver world test box) and marilith-n4 (an osstest machine hosted in the xenclient network) without messing around with my configuration every time. I ran build-$ARCH, build-$ARCH-pvops and test-$ARCH-$ARCH-xl in both cases. Per-host Tftp settings are now in the $ho->{Tftp} hash instead of in $c. $c{TftpHost} is unused -- remove the setting of its default. Signed-off-by: Ian Campbell --- v3: README improvements, use foreach to define ->{Tftp}{_} v2: Do not allow TftpDiVersion to be a host var, this must be push gated. Implement scope scheme README updates tftp fixups --- Osstest.pm | 3 ++- Osstest/Debian.pm | 3 ++- Osstest/TestSupport.pm | 17 ++++++++++++++--- README | 26 ++++++++++++++++++++++++++ mg-hosts | 4 ++-- ts-host-install | 14 +++++++------- 6 files changed, 53 insertions(+), 14 deletions(-) diff --git a/Osstest.pm b/Osstest.pm index 4600709..1033dd1 100644 --- a/Osstest.pm +++ b/Osstest.pm @@ -161,8 +161,9 @@ sub readglobalconfig () { chomp($nodename) or die; my $myfqdn = "$nodename.$c{DnsDomain}"; + $c{TftpDefaultScope} ||= "default"; + $c{TftpPath} ||= "/tftpboot/"; - $c{TftpHost} ||= $myfqdn; $c{TftpPxeDir} ||= "pxelinux.cfg/"; $c{TftpPxeTemplates} ||= '%ipaddrhex% 01-%etherhyph%'; $c{TftpPlayDir} ||= "$whoami/osstest/"; diff --git a/Osstest/Debian.pm b/Osstest/Debian.pm index 336043c..1ca6fb0 100644 --- a/Osstest/Debian.pm +++ b/Osstest/Debian.pm @@ -554,7 +554,8 @@ END foreach my $kp (keys %{ $ho->{Flags} }) { $kp =~ s/need-kernel-deb-// or next; - my $d_i= $c{TftpPath}.'/'.$c{TftpDiBase}.'/'.$r{arch}.'/'.$c{TftpDiVersion}.'-'.$ho->{Suite}; + my $d_i= $ho->{Tftp}{Path}.'/'.$ho->{Tftp}{DiBase}.'/'.$r{arch}.'/'. + $c{TftpDiVersion}.'-'.$ho->{Suite}; my $kurl = create_webfile($ho, "kernel", sub { copy("$d_i/$kp.deb", $_[0]) diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm index b6a6fb5..a957a69 100644 --- a/Osstest/TestSupport.pm +++ b/Osstest/TestSupport.pm @@ -795,6 +795,16 @@ sub selecthost ($) { } $ho->{Ip}= $ho->{IpStatic}; + #----- tftp ----- + + my $tftpscope = get_host_property($ho, 'TftpScope', $c{TftpDefaultScope}); + logm("TftpScope is $tftpscope"); + $ho->{Tftp} = { }; + $ho->{Tftp}{$_} = $c{"Tftp${_}_${tftpscope}"} || $c{"Tftp${_}"} + foreach qw(Path TmpDir PxeDir PxeGroup PxeTemplates DiBase); + + #----- finalise ----- + $mjobdb->host_check_allocated($ho); logm("host: selected $ho->{Name} ". @@ -1181,6 +1191,7 @@ sub selectguest ($$) { Guest => $gn, Name => $r{"${gn}_hostname"}, CfgPath => $r{"${gn}_cfgpath"}, + Tftp => $ho->{Tftp}, Host => $ho, }; foreach my $opt (guest_var_commalist($gho,'options')) { @@ -1841,7 +1852,7 @@ sub host_pxefile ($) { $v{'ipaddr'} = $ip; $v{'ipaddrhex'} = sprintf "%02X%02X%02X%02X", split /\./, $ip; } - foreach my $pat (split /\s+/, $c{TftpPxeTemplates}) { + foreach my $pat (split /\s+/, $ho->{Tftp}{PxeTemplates}) { # we skip patterns that contain any references to undefined %var%s $pat =~ s{\%(\w*)\%}{ $1 eq '' ? '%' : @@ -1851,14 +1862,14 @@ sub host_pxefile ($) { # and return the first pattern we managed to completely substitute return $pat; } - die "no pxe template matched $c{TftpPxeTemplates} ". + die "no pxe template matched $ho->{Tftp}{PxeTemplates} ". (join ",", sort keys %v)." ?"; } sub setup_pxeboot ($$) { my ($ho, $bootfile) = @_; my $f= host_pxefile($ho); - file_link_contents("$c{TftpPath}$c{TftpPxeDir}$f", $bootfile); + file_link_contents("$ho->{Tftp}{Path}$ho->{Tftp}{PxeDir}$f", $bootfile); } sub setup_pxeboot_local ($) { diff --git a/README b/README index 60379c4..a4d5aac 100644 --- a/README +++ b/README @@ -326,6 +326,10 @@ HostProp__RebootTimeExtra where Xen takes really long time to boot (typically because of the "Scrubbing free RAM" phase). +HostProp__TftpScope + Defines the Tftp scope (i.e. subnet) where this host resides. See + "TftpFoo_ and TftpFoo" below. + DebianPreseed Text to add to the debian-installer preseed file. Optional but you will need to set some NTP servers here if your firewall @@ -391,6 +395,28 @@ GuestDebianSuite defaults to DebianSuite DebianPreseed added to existing preseed file +TftpFoo_ and TftpFoo + + Describes various properties relating to Tftp in a given , + where a is a given subnet, DHCP server etc. Valid + properties are: + + Path The path to the root of the directory which is exposed by + the tftpserver (e.g. /tftpboot). + TmpDir A directory under `Path' to use for temporary files. + + PxeDir The path under `Path' to the PXE configuration directory + (e.g. pxelinux.cfg) + PxeGroup The Unix group which should own files under `PxeDir'. + PxeTemplates See TftpPxeTemplates + + DiBase The path under `Path' to the root of the debian installer + images. + + For hosts in scope "default", TftpFoo_default (if set) takes + precedence over TftpFoo. TftpFoo is used when the setting Foo is + not defined for the host's scope. + TftpPxeTemplates List (space-separated) of template filenames for writing The templates contain variable substitutions %var% diff --git a/mg-hosts b/mg-hosts index e409201..d7223a1 100755 --- a/mg-hosts +++ b/mg-hosts @@ -44,8 +44,8 @@ sub cmd_mkpxedir () { $macdir =~ s/\:/-/g; system_checked(<{Tftp}{Path}$ho->{Tftp}{PxeDir} + sudo chown root.$ho->{Tftp}{PxeGroup} $macdir sudo chmod 2775 $macdir sudo rm -f $hn sudo ln -s $macdir $hn diff --git a/ts-host-install b/ts-host-install index 8e119ca..95ce845 100755 --- a/ts-host-install +++ b/ts-host-install @@ -122,19 +122,19 @@ END sub setup_pxeboot_firstboot($) { my ($ps_url) = @_; - my $d_i= $c{TftpDiBase}.'/'.$r{arch}.'/'.$c{TftpDiVersion}.'-'.$ho->{Suite}; + my $d_i= $ho->{Tftp}{DiBase}.'/'.$r{arch}.'/'.$c{TftpDiVersion}.'-'.$ho->{Suite}; my @installcmdline= qw(vga=normal); push @installcmdline, di_installcmdline_core($ho, $ps_url, %xopts); my $src_initrd= "$d_i/initrd.gz"; - my @initrds= "$c{TftpPath}/$src_initrd"; + my @initrds= "$ho->{Tftp}{Path}/$src_initrd"; my $kernel; foreach my $fp (keys %{ $ho->{Flags} }) { $fp =~ s/^need-firmware-deb-// or next; - my $cpio= "$c{TftpPath}/$d_i/$fp.cpio.gz"; + my $cpio= "$ho->{Tftp}{Path}/$d_i/$fp.cpio.gz"; if (stat $cpio) { logm("using firmware from: $cpio"); push @initrds, $cpio; @@ -147,7 +147,7 @@ sub setup_pxeboot_firstboot($) { foreach my $kp (keys %{ $ho->{Flags} }) { $kp =~ s/need-kernel-deb-// or next; - my $kern= "$c{TftpPath}/$d_i/linux.$kp"; + my $kern= "$ho->{Tftp}{Path}/$d_i/linux.$kp"; if (stat $kern) { logm("using kernel from: $kern"); $kernel = "/$d_i/linux.$kp"; @@ -157,7 +157,7 @@ sub setup_pxeboot_firstboot($) { die "$kp $kern $!"; } - my $cpio= "$c{TftpPath}/$d_i/$kp.cpio.gz"; + my $cpio= "$ho->{Tftp}{Path}/$d_i/$kp.cpio.gz"; if (stat $cpio) { logm("using kernel modules from: $cpio"); push @initrds, $cpio; @@ -196,8 +196,8 @@ END push @initrds, "$initrd_overlay.cpio.gz"; logm("using initrds: @initrds"); - my $initrd= "$c{TftpTmpDir}$ho->{Name}--initrd.gz"; - system_checked("cat -- @initrds >$c{TftpPath}$initrd"); + my $initrd= "$ho->{Tftp}{TmpDir}$ho->{Name}--initrd.gz"; + system_checked("cat -- @initrds >$ho->{Tftp}{Path}$initrd"); push @installcmdline, ("initrd=/$initrd", "domain=$c{TestHostDomain}",