All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: ian.jackson@eu.citrix.com
Cc: Jim Fehlig <jfehlig@suse.com>,
	Ian Campbell <ian.campbell@citrix.com>,
	xen-devel@lists.xen.org
Subject: [PATCH OSSTEST v2 03/18] Pass host to toolstack()
Date: Tue, 2 Dec 2014 16:04:44 +0000	[thread overview]
Message-ID: <1417536299-1810-3-git-send-email-ian.campbell@citrix.com> (raw)
In-Reply-To: <1417536141.29004.6.camel@citrix.com>

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 <ian.campbell@citrix.com>
---
 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-rumpuserxen-demo-xenstorels |  4 ++--
 ts-windows-install             |  2 +-
 ts-xen-install                 | 10 +++++-----
 14 files changed, 34 insertions(+), 30 deletions(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 2ac490f..b7887bc 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -954,8 +954,9 @@ END
     });
 }
 
-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);
@@ -1318,7 +1319,7 @@ sub guest_await_shutdown ($$$) {
 
 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 ($$) {
@@ -1609,7 +1610,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 ?";
@@ -1814,7 +1815,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}";
@@ -1884,7 +1885,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};
@@ -1893,6 +1896,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 6cf51c1..841ad5a 100755
--- a/ts-logs-capture
+++ b/ts-logs-capture
@@ -195,7 +195,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-rumpuserxen-demo-xenstorels b/ts-rumpuserxen-demo-xenstorels
index 6db7024..a2a6a77 100755
--- a/ts-rumpuserxen-demo-xenstorels
+++ b/ts-rumpuserxen-demo-xenstorels
@@ -40,8 +40,8 @@ sub arrangepreserve () {
 }
 
 sub start () {
-    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);
 
     $domid = target_cmd_output_root($ho,"xl domid $gho->{Guest}");
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 4d34d1f..7cfe344 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 {
 	logm("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, <<END);
-- 
2.1.1

  parent reply	other threads:[~2014-12-02 16:04 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-02 16:02 [PATCH v2 OSSTEST 0/18] Implement for driving libvirt via virsh Ian Campbell
2014-12-02 16:04 ` [PATCH OSSTEST v2 01/18] apt: lock osstest's usages of apt-get against each other Ian Campbell
2015-01-20 18:19   ` Ian Jackson
2015-01-21 11:29     ` Ian Campbell
2015-01-21 12:13       ` Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 02/18] ts-logs-capture: Collect some libvirt logs and capabilities Ian Campbell
2015-01-20 18:20   ` Ian Jackson
2014-12-02 16:04 ` Ian Campbell [this message]
2015-01-20 18:21   ` [PATCH OSSTEST v2 03/18] Pass host to toolstack() Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 04/18] ts-rumpuserxen-demo-xenstorels: Use standard functions for things Ian Campbell
2015-01-20 18:22   ` Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 05/18] Toolstack: use get_host_method_object() to manage toolstack selection Ian Campbell
2015-01-20 18:23   ` Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 06/18] TestSupport: always use xl for generic operations Ian Campbell
2015-01-20 18:26   ` Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 07/18] TestSupport: guest_create takes a $ho Ian Campbell
2015-01-20 18:27   ` Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 08/18] Toolstack: Refactor guest lifecycle Ian Campbell
2015-01-13 16:16   ` Ian Campbell
2015-01-14 17:01     ` Ian Jackson
2015-01-20 18:32   ` Ian Jackson
2015-01-21 15:59     ` Ian Campbell
2015-01-21 16:28       ` Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 09/18] Toolstack: Refactor consolecmd handling Ian Campbell
2015-01-20 18:34   ` Ian Jackson
2015-01-22 11:24     ` Ian Campbell
2015-01-22 11:26       ` Ian Campbell
2015-01-22 14:35         ` Ian Campbell
2015-01-22 14:41           ` Ian Jackson
2015-01-22 14:42             ` Ian Campbell
2015-01-22 15:15               ` Ian Jackson
2015-01-22 15:17                 ` Ian Campbell
2014-12-02 16:04 ` [PATCH OSSTEST v2 10/18] Toolstack: Refactor shutdown support Ian Campbell
2015-01-20 18:35   ` Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 11/18] Toolstack: Refactor migration support check Ian Campbell
2015-01-20 18:45   ` Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 12/18] Toolstack: Refactor migration support Ian Campbell
2015-01-20 18:38   ` Ian Jackson
2015-01-22 15:06     ` Ian Campbell
2015-01-22 15:17       ` Ian Jackson
2015-01-22 15:19         ` Ian Campbell
2015-01-22 15:38           ` Ian Jackson
2015-01-22 16:11           ` Ian Campbell
2014-12-02 16:04 ` [PATCH OSSTEST v2 13/18] Toolstack: Refactor save/restore support Ian Campbell
2015-01-20 18:41   ` Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 14/18] libvirt: Implement initscript restart which has some hope of working Ian Campbell
2015-01-20 18:37   ` Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 15/18] libvirt: Implement shutdown_wait Ian Campbell
2015-01-20 18:44   ` Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 16/18] Toolstack: Remove Command field for all toolstacks Ian Campbell
2015-01-20 18:39   ` Ian Jackson
2015-01-21 11:49     ` Ian Campbell
2015-01-21 12:14       ` Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 17/18] ts-guest-start: Use guest_create Ian Campbell
2015-01-20 18:46   ` Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 18/18] WIP: libvirt: migration + save/restore support Ian Campbell
2014-12-13 16:06   ` Wei Liu
2015-01-20 18:49   ` Ian Jackson
2015-01-21  5:42     ` Jim Fehlig
2015-01-21  9:48       ` Ian Campbell
2015-01-21 11:36         ` [PATCH OSSTEST v2 18/18] WIP: libvirt: migration + save/restore support. [and 1 more messages] Ian Jackson
2015-01-21 15:05           ` Jim Fehlig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1417536299-1810-3-git-send-email-ian.campbell@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jfehlig@suse.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.