[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 4/4] Runvar functions: Introduce target_var and target_store_runvar



guest_var would check GUEST_VN and guests_VN.  target_var_prefix would
return GUEST_ or `' (for a host), but can only be sensibly used for
setting, not getting (since a getter ought to check guests_VN as well).

But we might want to be able to set different runvars for different
hosts, so we would like to be able to check IDENT_VN as well as VN.

So:

Introduce target_var_prefixlist to replace target_var_prefix, and make
it return a sensible list for hosts.

Provide target_var, a replacement for guest_var.  Mostly this is a
rename (although target_var does not require a default value).

Provide target_store_runvar, which stores the value in the first entry
in the prefixlist.

Adjust the non-runvar-handling-core users of target_var_prefix to use
target_var and target-store_runvar.

Runvars xen_kernel_{path,ver} are now HOSTIDENT_xen_kernel_{path,ver};
adjust target_xenkernel_var accordingly.  There should be no
functional change with existing constructed flights.  These are all
synth runvars, so bisection etc., and copies of old flights, are not
going to be affected.  The change may break ad-hoc reuse of a flight
(eg a standalone mode flight) where a different version of osstest did
the ts-xen-install as is now doing a guest install which involves use
of the host's kernel (ie, ts-debian-install, mostly).

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
 Osstest/Debian.pm      |    4 ++--
 Osstest/TestSupport.pm |   46 ++++++++++++++++++++++++++++------------------
 2 files changed, 30 insertions(+), 20 deletions(-)

diff --git a/Osstest/Debian.pm b/Osstest/Debian.pm
index 47d1767..a65664e 100644
--- a/Osstest/Debian.pm
+++ b/Osstest/Debian.pm
@@ -116,8 +116,8 @@ sub debian_boot_setup ($$$$$;$) {
 
     $bootloader->{UpdateConfig}($ho);
 
-    store_runvar(target_var_prefix($ho).'xen_kernel_path',$kernpath);
-    store_runvar(target_var_prefix($ho).'xen_kernel_ver',$kernver);
+    target_store_runvar($ho,'xen_kernel_path',$kernpath);
+    target_store_runvar($ho,'xen_kernel_ver',$kernver);
 }
 
 sub bl_getmenu_open ($$$) {
diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index a21d835..a03c9fb 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -90,7 +90,8 @@ BEGIN {
                       target_ping_check_down target_ping_check_up
                       target_kernkind_check target_kernkind_console_inittab
                       target_xenkernel_ver
-                      target_var target_var_prefix
+                      target_var target_var_prefixlist
+                      target_store_runvar
                       selectguest prepareguest more_prepareguest_hvm
                       guest_var guest_var_commalist guest_var_boolean
                       prepareguest_part_lvmdisk prepareguest_part_diskimg
@@ -1583,9 +1584,8 @@ END
 
 sub guest_var ($$$) {
     my ($gho, $runvartail, $default) = @_;
-    my $val= $r{ $gho->{Guest}."_".$runvartail };  return $val if defined $val;
-    $val= $r{ "guests_$runvartail" };              return $val if defined $val;
-    return $default;
+    # deprecated - use target_var instead
+    return target_var($gho, $runvartail, $default);
 }
 
 sub guest_var_boolean ($$) {
@@ -1995,35 +1995,45 @@ sub guest_await ($$) {
     return $gho;
 }
 
-sub target_var_prefix ($) {
-    my ($ho) = @_;
-    if (exists $ho->{Guest}) { return $ho->{Guest}.'_'; }
-    return '';
+sub target_var_prefixlist ($) {
+    my ($tho) = @_;
+    defined $ho->{Guest} ?
+       ("$gho->{Guest}_", "guests_") :
+       ("$gho->{Ident}_", "");
 }
 
-sub target_var ($$) {
-    my ($ho,$vn) = @_;
-    return $r{ target_var_prefix($ho). $vn };
+sub target_store_runvar ($$$) {
+    my ($tho,$vn,$val) = @_;
+    my ($pfx) = target_var_prefixlist($tho); # pick first prefix
+    store_runvar("${pfx}${vn}",$val);
+}
+
+sub target_var ($$;$) {
+    my ($tho,$vn,$default) = @_;
+    foreach my $pfx (target_var_prefixlist($tho)) {
+       my $v = $r{"${pfx}${vn}"};
+       return $v if defined $v;
+    }
+    return $default;
 }
 
 sub target_kernkind_check ($) {
     my ($gho) = @_;
-    my $pfx= target_var_prefix($gho);
-    my $kernkind= $r{$pfx."kernkind"};
+    my $kernkind= target_var($gho,"kernkind"};
     my $isguest= exists $gho->{Guest};
     if ($kernkind eq 'pvops') {
-        store_runvar($pfx."rootdev", 'xvda') if $isguest;
-        store_runvar($pfx."console", 'hvc0');
+        target_store_runvar($gho, "rootdev", 'xvda') if $isguest;
+        target_store_runvar($gho, "console", 'hvc0');
     } elsif ($kernkind !~ m/2618/) {
-        store_runvar($pfx."console", 'xvc0') if $isguest;
+        target_store_runvar($gho, "console", 'xvc0') if $isguest;
     }
 }
 
 sub target_xenkernel_var ($$) {
     my ($tho,$vn) = @_;
     return
-       guest_var($gho,$vn,undef) //
-       $r{"xen_${vn}"};
+       target_var($gho,$vn) //
+       ($tho->{Host} and target_var($tho->{Host},"xen_${vn}"));
 }
 
 sub target_kernkind_console_inittab ($$$) {
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.