@@ -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;
}
@@ -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)"
@@ -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) {
@@ -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});
}
@@ -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});
}
@@ -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);
}
@@ -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);
}
@@ -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};
@@ -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");
@@ -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;
@@ -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 () {
@@ -50,7 +50,7 @@ END
}
sub start () {
- target_cmd_root($ho, toolstack()->{Command}.
+ target_cmd_root($ho, toolstack($ho)->{Command}.
" create $gho->{CfgPath}", 100);
}
@@ -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, <<END);
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-windows-install | 2 +- ts-xen-install | 10 +++++----- 13 files changed, 32 insertions(+), 28 deletions(-)