From patchwork Tue Jun 17 15:26:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 32072 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f200.google.com (mail-ig0-f200.google.com [209.85.213.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 745E2206A0 for ; Tue, 17 Jun 2014 15:28:22 +0000 (UTC) Received: by mail-ig0-f200.google.com with SMTP id hn18sf4271287igb.11 for ; Tue, 17 Jun 2014 08:28:22 -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=CquVv+BLZwemTDXlVggCdFvWr98Ne3U/yzO1HJsb7kNLB4M+ACSKenQOzoOXkwiyWu aV8LYH06cJNl6fjbp4yJU3EPsKwy/Kx3RyYxtOoO08NvUVvEGU5RYuhYVxIpwji4u1lc s0De8RPXcgWlCv8CnvzXu6MsOpa7iptGckunqH2K/PWBouwfpqlIJ5wmtUyavLa5sJZh u6QnqH0u0YucsSlgRR3uCRJYXwsW/BspoyeiFxwdON1c8idgGpEtyhmq+VbExKPBmWmG sU5xk2/dVNHzt+IDuqO2QpFi3CQaAWyHGFNUbGljJZZlK/G6IJcocffqhQRtYJj35K6u Kz5g== X-Gm-Message-State: ALoCoQmpIYUgT1SA0x81TYm0CXsDFn6qaO1nr1pg6NlROcWSgAZTqfKpOq/JSge1KMshLpqMEM/L X-Received: by 10.43.124.136 with SMTP id go8mr1992243icc.26.1403018902034; Tue, 17 Jun 2014 08:28:22 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.49.130 with SMTP id q2ls5004409qga.91.gmail; Tue, 17 Jun 2014 08:28:21 -0700 (PDT) X-Received: by 10.220.175.70 with SMTP id w6mr978620vcz.72.1403018901879; Tue, 17 Jun 2014 08:28:21 -0700 (PDT) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by mx.google.com with ESMTPS id b4si5594981vdf.59.2014.06.17.08.28.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 17 Jun 2014 08:28:21 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.169 as permitted sender) client-ip=209.85.128.169; Received: by mail-ve0-f169.google.com with SMTP id pa12so7914379veb.28 for ; Tue, 17 Jun 2014 08:28:21 -0700 (PDT) X-Received: by 10.53.8.162 with SMTP id dl2mr18752760vdd.24.1403018901785; Tue, 17 Jun 2014 08:28:21 -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 vs6csp218007vcb; Tue, 17 Jun 2014 08:28:21 -0700 (PDT) X-Received: by 10.140.93.136 with SMTP id d8mr23084928qge.1.1403018901292; Tue, 17 Jun 2014 08:28:21 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id hl16si9067901qcb.1.2014.06.17.08.28.20 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 17 Jun 2014 08:28:21 -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 1WwvHl-0006Hj-N9; Tue, 17 Jun 2014 15:26:57 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WwvHj-0006El-W7 for xen-devel@lists.xen.org; Tue, 17 Jun 2014 15:26:56 +0000 Received: from [193.109.254.147:10977] by server-16.bemta-14.messagelabs.com id 1F/CB-16986-F3E50A35; Tue, 17 Jun 2014 15:26:55 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-9.tower-27.messagelabs.com!1403018812!11869034!1 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.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 5393 invoked from network); 17 Jun 2014 15:26:54 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-9.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 17 Jun 2014 15:26:54 -0000 X-IronPort-AV: E=Sophos;i="5.01,494,1400025600"; d="scan'208";a="144521864" Received: from accessns.citrite.net (HELO FTLPEX01CL02.citrite.net) ([10.9.154.239]) by FTLPIPO01.CITRIX.COM with ESMTP; 17 Jun 2014 15:26:51 +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:50 -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 1WwvHe-00010t-2m; Tue, 17 Jun 2014 16:26:50 +0100 From: Ian Campbell To: Date: Tue, 17 Jun 2014 16:26:42 +0100 Message-ID: <1403018809-25509-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.128.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, <