xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Ian Campbell <ian.campbell@citrix.com>
Subject: [OSSTEST PATCH 4/4] Runvar functions: Introduce target_var and target_store_runvar
Date: Tue, 29 Sep 2015 17:21:28 +0100	[thread overview]
Message-ID: <1443543688-1195-5-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1443543688-1195-1-git-send-email-ian.jackson@eu.citrix.com>

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@eu.citrix.com>
---
 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

  parent reply	other threads:[~2015-09-29 16:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-29 16:21 [OSSTEST PATCH 0/4] Miscellaneous bald yaks Ian Jackson
2015-09-29 16:21 ` [OSSTEST PATCH 1/4] ts-debian-fixup: Set password Ian Jackson
2015-09-29 16:21 ` [OSSTEST PATCH 2/4] Do not multiply console hvc0 getty entries Ian Jackson
2015-09-29 16:21 ` [OSSTEST PATCH 3/4] Runvar functions: Provide target_xenkernel_ver Ian Jackson
2015-09-29 16:21 ` Ian Jackson [this message]
2015-09-30  8:20 ` [OSSTEST PATCH 0/4] Miscellaneous bald yaks Ian Campbell

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=1443543688-1195-5-git-send-email-ian.jackson@eu.citrix.com \
    --to=ian.jackson@eu.citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=xen-devel@lists.xenproject.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).