From patchwork Tue Jun 17 15:26:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 32065 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f199.google.com (mail-ie0-f199.google.com [209.85.223.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 051CB206A0 for ; Tue, 17 Jun 2014 15:27:54 +0000 (UTC) Received: by mail-ie0-f199.google.com with SMTP id rd18sf42627767iec.2 for ; Tue, 17 Jun 2014 08:27:54 -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:in-reply-to :references: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=lHgN9m/G3RAaXZ31kHrhFmr/nKbSlJItT6SMMsVfHl8=; b=CefdUMxgUom6Z6AL+dChLYZ9wyYnp/VBTIzR4D3ZzF72EcpBPkLq1sumaCC3dD3v84 ImLkC0iub+7vcB8zqgbKC/eLoXeokOqymwYlBtFKFvr3pX4xFypPX+wvOgND55WlRlBk WDyKysvfkPOW1IsXL2ryMaMj2SVWrtwBKuTIwUy3CDr3pA3vKiN+spK+M43ELwqMGqzO CsvWNjVizx3jd0bQG3svGNQ/HZJWbVexoiBfoBmqOTXEK8cO881mYJLj/09+f7TJ0rw3 qX52F6NO6EDFtIOihJag5HnRGh2iwmf1sF5FQ8/QTzoCajn67j2Gs6HEKtvzoOwVM+BJ ygmA== X-Gm-Message-State: ALoCoQkK7jbg5LdWdNsu+mpkUD6rYgn9OV389IjLlNygBo3XhBdM1EV8I39hMwTdtjFAtW0rh4fs X-Received: by 10.182.213.37 with SMTP id np5mr1214796obc.36.1403018874545; Tue, 17 Jun 2014 08:27:54 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.83.50 with SMTP id i47ls5039525qgd.38.gmail; Tue, 17 Jun 2014 08:27:54 -0700 (PDT) X-Received: by 10.220.119.18 with SMTP id x18mr965925vcq.68.1403018874468; Tue, 17 Jun 2014 08:27:54 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id o10si5598004vdo.29.2014.06.17.08.27.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 17 Jun 2014 08:27:54 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id la4so6717424vcb.28 for ; Tue, 17 Jun 2014 08:27:54 -0700 (PDT) X-Received: by 10.52.114.105 with SMTP id jf9mr802207vdb.79.1403018874379; Tue, 17 Jun 2014 08:27:54 -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.221.54.6 with SMTP id vs6csp217975vcb; Tue, 17 Jun 2014 08:27:54 -0700 (PDT) X-Received: by 10.58.178.2 with SMTP id cu2mr983158vec.70.1403018873210; Tue, 17 Jun 2014 08:27:53 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id i5si5610383vcp.33.2014.06.17.08.27.52 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 17 Jun 2014 08:27:53 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) 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 1WwvHO-0005sU-I0; Tue, 17 Jun 2014 15:26:34 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WwvHM-0005qi-UW for xen-devel@lists.xen.org; Tue, 17 Jun 2014 15:26:33 +0000 Received: from [85.158.139.211:25446] by server-9.bemta-5.messagelabs.com id 62/0B-01655-82E50A35; Tue, 17 Jun 2014 15:26:32 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-13.tower-206.messagelabs.com!1403018788!10468546!3 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n X-StarScan-Received: X-StarScan-Version: 6.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31012 invoked from network); 17 Jun 2014 15:26:31 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-13.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 17 Jun 2014 15:26:31 -0000 X-IronPort-AV: E=Sophos;i="5.01,494,1400025600"; d="scan'208";a="144219448" Received: from accessns.citrite.net (HELO FTLPEX01CL02.citrite.net) ([10.9.154.239]) by FTLPIPO02.CITRIX.COM with ESMTP; 17 Jun 2014 15:26:28 +0000 Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.79) with Microsoft SMTP Server id 14.3.181.6; Tue, 17 Jun 2014 11:26:27 -0400 Received: from kazak.uk.xensource.com ([10.80.2.80] helo=kazak.uk.xensource.com.) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1WwvHH-00010a-IA; Tue, 17 Jun 2014 16:26:27 +0100 From: Ian Campbell To: Date: Tue, 17 Jun 2014 16:26:20 +0100 Message-ID: <1403018787-25442-2-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1403018758.25074.5.camel@kazak.uk.xensource.com>#> References: <1403018758.25074.5.camel@kazak.uk.xensource.com>#> MIME-Version: 1.0 X-DLP: MIA2 Cc: Ian Campbell , xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH RFC OSSTEST 2/9] Pass host to toolstack() 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=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) 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: This will be needed in a future patch. Everywhere already has a $ho in hand. Also cache the answer as $ho->{Toolstack}. I scanned the source with: find -name \*.pm -exec perl -c {} \; for i in ts-* ; do perl -c $i; done which reported "Not enough arguments for Osstest::TestSupport::toolstack" for each callsite which needed changing. Also don't pass the toolstack command name directly to host_get_free_memory(). Look it up instead. Signed-off-by: Ian Campbell --- Osstest/TestSupport.pm | 16 ++++++++++------ ts-debian-fixup | 2 +- ts-debian-hvm-install | 4 ++-- ts-guest-localmigrate | 2 +- ts-guest-migrate | 2 +- ts-guest-saverestore | 8 ++++---- ts-guest-start | 4 ++-- ts-guest-stop | 2 +- ts-logs-capture | 2 +- ts-migrate-support-check | 4 ++-- ts-redhat-install | 2 +- ts-windows-install | 2 +- ts-xen-install | 10 +++++----- 13 files changed, 32 insertions(+), 28 deletions(-) diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm index bad0458..1377610 100644 --- a/Osstest/TestSupport.pm +++ b/Osstest/TestSupport.pm @@ -922,8 +922,9 @@ sub host_reboot ($) { }); } -sub host_get_free_memory($$) { - my ($ho,$toolstack) = @_; +sub host_get_free_memory($) { + my ($ho) = @_; + my $toolstack = toolstack($ho)->{Command}; # The line is as followed: # free_memory : XXXX my $info = target_cmd_output_root($ho, "$toolstack info", 10); @@ -1266,7 +1267,7 @@ sub guest_await_reboot ($$$) { sub guest_destroy ($$) { my ($ho,$gho) = @_; - target_cmd_root($ho, toolstack()->{Command}." destroy $gho->{Name}", 40); + target_cmd_root($ho, toolstack($ho)->{Command}." destroy $gho->{Name}", 40); } sub guest_create ($$) { @@ -1557,7 +1558,7 @@ sub guest_check_up ($) { sub guest_get_state ($$) { my ($ho,$gho) = @_; - my $domains= target_cmd_output_root($ho, toolstack()->{Command}." list"); + my $domains= target_cmd_output_root($ho, toolstack($ho)->{Command}." list"); $domains =~ s/^Name.*\n//; foreach my $l (split /\n/, $domains) { $l =~ m/^(\S+) (?: \s+ \d+ ){3} \s+ ([-a-z]+) \s/x or die "$l ?"; @@ -1762,7 +1763,7 @@ sub guest_find_domid ($$) { my ($ho,$gho) = @_; return if defined $gho->{Domid}; my $list= target_cmd_output_root($ho, - toolstack()->{Command}." list $gho->{Name}"); + toolstack($ho)->{Command}." list $gho->{Name}"); $list =~ m/^(?!Name\s)(\S+)\s+(\d+)\s+(\d+)+(\d+)\s.*$/m or die "domain list: $list"; $1 eq $gho->{Name} or die "domain list name $1 expected $gho->{Name}"; @@ -1832,7 +1833,9 @@ our %toolstacks= }, ); -sub toolstack () { +sub toolstack ($) { + my ($ho) = @_; + return $ho->{Toolstack} if $ho->{Toolstack}; my $tsname= $r{toolstack}; $tsname= 'xend' if !defined $tsname; my $ts= $toolstacks{$tsname}; @@ -1841,6 +1844,7 @@ sub toolstack () { logm("toolstack $tsname"); $ts->{Name}= $tsname; } + $ho->{Toolstack} = $ts; return $ts; } diff --git a/ts-debian-fixup b/ts-debian-fixup index f001418..11e956c 100755 --- a/ts-debian-fixup +++ b/ts-debian-fixup @@ -142,7 +142,7 @@ sub otherfixupcfg () { if (@pcipt) { logm("checking passthrough device(s) are assignable: @pcipt"); my @assignables= split /\n/, - target_cmd_output_root($ho, toolstack()->{Command}. + target_cmd_output_root($ho, toolstack($ho)->{Command}. " pci-assignable-list"); foreach my $pcipt (@pcipt) { die "not assignable: $pcipt (not in: @assignables)" diff --git a/ts-debian-hvm-install b/ts-debian-hvm-install index 37eade2..0148eef 100755 --- a/ts-debian-hvm-install +++ b/ts-debian-hvm-install @@ -41,7 +41,7 @@ our $disk_mb= 10000; our $guesthost= "$gn.guest.osstest"; our $gho; -our $toolstack= toolstack()->{Command}; +our $toolstack= toolstack($ho)->{Command}; sub preseed () { @@ -171,7 +171,7 @@ 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, $toolstack); +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) { diff --git a/ts-guest-localmigrate b/ts-guest-localmigrate index e50e93a..f3381da 100755 --- a/ts-guest-localmigrate +++ b/ts-guest-localmigrate @@ -33,7 +33,7 @@ our ($ho,$gho) = ts_get_host_guest(@ARGV); sub migrate () { guest_checkrunning($ho,$gho) or die $gho->{Name}; target_cmd_root($ho, - toolstack()->{Command} + toolstack($ho)->{Command} ." migrate $gho->{Name} localhost", $timeout{Migrate}); } diff --git a/ts-guest-migrate b/ts-guest-migrate index 17ac8a0..65e7b42 100755 --- a/ts-guest-migrate +++ b/ts-guest-migrate @@ -32,7 +32,7 @@ sub migrate () { guest_checkrunning($sho,$gho) or die $gho->{Name}; my $err= guest_check_ip($gho); die "$err $gho->{Name}" if defined $err; target_cmd_root($sho, - toolstack()->{Command} + toolstack($sho)->{Command} ." migrate $gho->{Name} $dho->{Name}", $timeout{Migrate}); } diff --git a/ts-guest-saverestore b/ts-guest-saverestore index 81671c8..9e04ae9 100755 --- a/ts-guest-saverestore +++ b/ts-guest-saverestore @@ -28,17 +28,17 @@ sub save () { guest_checkrunning($ho,$gho) or die $gho->{Name}; my $err= guest_check_ip($gho); die "$err $gho->{Name}" if defined $err; target_cmd_root($ho, - toolstack()->{Command} + toolstack($ho)->{Command} ." save $gho->{Name} image", 200); target_ping_check_down($gho); } sub restore () { target_cmd_root($ho, - toolstack()->{Command} + toolstack($ho)->{Command} ." restore " - .(toolstack()->{RestoreNeedsConfig} ? - $r{ $gho->{Guest}.'_'. toolstack()->{CfgPathVar} } : '') + .(toolstack($ho)->{RestoreNeedsConfig} ? + $r{ $gho->{Guest}.'_'. toolstack($ho)->{CfgPathVar} } : '') ." image", 200); target_ping_check_up($gho); } diff --git a/ts-guest-start b/ts-guest-start index 057afe6..bfbb734 100755 --- a/ts-guest-start +++ b/ts-guest-start @@ -26,8 +26,8 @@ our ($ho,$gho) = ts_get_host_guest(@ARGV); sub start () { guest_umount_lv($ho, $gho); - my $cmd= toolstack()->{Command}." create ". - $r{ $gho->{Guest}.'_'. toolstack()->{CfgPathVar} }; + my $cmd= toolstack($ho)->{Command}." create ". + $r{ $gho->{Guest}.'_'. toolstack($ho)->{CfgPathVar} }; target_cmd_root($ho, $cmd, 30); } diff --git a/ts-guest-stop b/ts-guest-stop index cc7db4c..0e3a863 100755 --- a/ts-guest-stop +++ b/ts-guest-stop @@ -27,7 +27,7 @@ our ($ho,$gho) = ts_get_host_guest(@ARGV); sub stop () { guest_checkrunning($ho, $gho) or die "$gho->{Name} not running"; target_cmd_root($ho, - toolstack()->{Command} + toolstack($ho)->{Command} ." shutdown -w " .$gho->{Name}, 200); guest_checkrunning($ho, $gho) and die $gho->{Name}; diff --git a/ts-logs-capture b/ts-logs-capture index ae32883..9df5485 100755 --- a/ts-logs-capture +++ b/ts-logs-capture @@ -192,7 +192,7 @@ sub fetch_logs_guest ($) { logm("cannot find domid: $@"); return; } - my $consolecmd= toolstack()->{Command}." console $gho->{Name}"; + my $consolecmd= toolstack($ho)->{Command}." console $gho->{Name}"; try_cmd_output_save("sleep 1 | $consolecmd | cat", "guest-$gho->{Name}-console"); diff --git a/ts-migrate-support-check b/ts-migrate-support-check index ffae1b3..c70b77a 100755 --- a/ts-migrate-support-check +++ b/ts-migrate-support-check @@ -25,9 +25,9 @@ tsreadconfig(); our $ho = selecthost($ARGV[0]); # all xend/xm platforms support migration -exit(0) if toolstack()->{Command} eq "xm"; +exit(0) if toolstack($ho)->{Command} eq "xm"; -my $help = target_cmd_output_root($ho, toolstack()->{Command}." help"); +my $help = target_cmd_output_root($ho, toolstack($ho)->{Command}." help"); my $rc = ($help =~ m/^\s*migrate/m) ? 0 : 1; diff --git a/ts-redhat-install b/ts-redhat-install index 56d4129..a0b1fab 100755 --- a/ts-redhat-install +++ b/ts-redhat-install @@ -37,7 +37,7 @@ our $disk_mb= 50000; our $guesthost= "$gn.guest.osstest"; our $gho; -our $xl= toolstack()->{Command}; +our $xl= toolstack($ho)->{Command}; sub kickstart () { diff --git a/ts-windows-install b/ts-windows-install index 0a69f8e..4b06310 100755 --- a/ts-windows-install +++ b/ts-windows-install @@ -50,7 +50,7 @@ END } sub start () { - target_cmd_root($ho, toolstack()->{Command}. + target_cmd_root($ho, toolstack($ho)->{Command}. " create $gho->{CfgPath}", 100); } diff --git a/ts-xen-install b/ts-xen-install index 0b84b7b..31cd7c3 100755 --- a/ts-xen-install +++ b/ts-xen-install @@ -60,8 +60,8 @@ sub packages () { if ($r{arch} eq 'i386') { target_install_packages($ho, 'libc6-xen'); } - target_install_packages($ho, @{toolstack()->{ExtraPackages}}) - if toolstack()->{ExtraPackages}; + target_install_packages($ho, @{toolstack($ho)->{ExtraPackages}}) + if toolstack($ho)->{ExtraPackages}; } sub extract () { @@ -101,7 +101,7 @@ sub adjustconfig () { } } print EO $extra or die $!; - }) if toolstack()->{Name} eq "xend"; + }) if toolstack($ho)->{Name} eq "xend"; my $trace_config_file; foreach my $try (qw(/etc/default/xencommons @@ -147,7 +147,7 @@ sub setupboot () { } else { mlog("No Xen console device defined for host"); } - if (toolstack()->{Dom0MemFixed}) { + if (toolstack($ho)->{Dom0MemFixed}) { $xenhopt .= " dom0_mem=512M,max:512M"; } my $append= $r{xen_boot_append}; @@ -179,7 +179,7 @@ sub setupboot () { our $initscripts_nobridge; sub setupinitd () { - my $ts= toolstack(); + my $ts= toolstack($ho); my $xencommons= '/etc/init.d/xencommons'; my $have_xencommons= !!target_cmd_output_root($ho, <