diff mbox

[OSSTEST,04/16] Support guest-specific "toolstack" for guest creation

Message ID 1475858096-16123-5-git-send-email-ian.jackson@eu.citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ian Jackson Oct. 7, 2016, 4:34 p.m. UTC
Some guests need creation in a special way.  For example, rump kernels
are ideally started with rumprun.  Honour a guest var which specifies
a toolstack name.

Osstest::TestSupport::toolstack now takes an optional $gho so it can
do this lookup when appropriate.

After creation the guest is necessarily managed with the toolstack for
the host, so we honour this (ie we pass the $gho) only for create.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 Osstest/TestSupport.pm | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index b18a19e..bc3ad13 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -1583,7 +1583,7 @@  sub guest_create ($) {
     my ($gho) = @_;
     my $ho = $gho->{Host};
     guest_prepare_disk($gho);
-    toolstack($ho)->create($gho);
+    toolstack($ho,$gho)->create($gho);
 }
 
 sub guest_prepare_disk ($) {
@@ -2257,13 +2257,16 @@  sub guest_vncsnapshot_stash ($$$$) {
     target_getfile_root($ho,100, "$rfile", "$stash/$leaf");
 }
 
-sub toolstack ($) {
-    my ($ho) = @_;
-    return $ho->{_Toolstack} if $ho->{_Toolstack};
+sub toolstack ($;$) {
+    my ($ho,$gho) = @_;
+
+    my $cache = $gho || $ho;
+    return $cache->{_Toolstack} if $cache->{_Toolstack};
 
     my $tsname= $r{toolstack} || 'xend';
-    $ho->{_Toolstack}= get_host_method_object($ho, 'Toolstack', $tsname);
-    return $ho->{_Toolstack};
+    $tsname= guest_var($gho, 'toolstack', $tsname) if $gho;
+    $cache->{_Toolstack} = get_host_method_object($ho, 'Toolstack', $tsname);
+    return $cache->{_Toolstack};
 }
 
 sub authorized_keys () {