All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Robert Hu <robert.hu@intel.com>,
	LongtaoX Pang <longtaox.pang@intel.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Ian Campbell <ian.campbell@citrix.com>
Subject: [OSSTEST PATCH 4/9] TestSupport: Provide get_target_property
Date: Tue, 17 Feb 2015 17:50:26 +0000	[thread overview]
Message-ID: <1424195431-1493-5-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1424195431-1493-1-git-send-email-ian.jackson@eu.citrix.com>

This looks in the supplied $ho, but if that's a $gho (ie it has a
$gho->{Host}) it also looks in its host.

This is going to be useful for a fair variety of host-specific or
infrastructure-determined properties.

It seems to me that whether a property ought to be looked up in the
host if not found in a particular guest depends mostly on the
property, and not on the way the guest is configured.  The easiest way
to represent that in the osstest codebase is probably to call
get_target_property instead of get_host_property in the appropriate
places.

The use of recursion will make this look through a series of nested
hosts if we have nested virtualisation going on.  Indeed, nested
virtualisation may benefit from replacement of get_host_property by
get_target_property in a number of cases.  (At the time of writing
there is no nested virt in osstest mainline, but it's on the way.)

Currently there are no callers of get_target_property.  One will
appear shortly.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Robert Hu <robert.hu@intel.com>
CC: LongtaoX Pang <longtaox.pang@intel.com>
---
 Osstest/TestSupport.pm |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 8aed285..8754e22 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -66,7 +66,7 @@ BEGIN {
                       contents_make_cpio file_simple_write_contents
 
                       selecthost get_hostflags get_host_property
-                      get_host_native_linux_console
+                      get_target_property get_host_native_linux_console
                       power_state power_cycle power_cycle_sleep
                       serial_fetch_logs
                       propname_massage
@@ -906,6 +906,17 @@ sub get_host_property ($$;$) {
     return defined($val) ? $val : $defval;
 }
 
+sub get_target_property ($$;$);
+sub get_target_property ($$;$) {
+    my ($ho, $prop, $defval) = @_;
+    # $ho may be a guest; if so we look for the property in the
+    # guest and failing that the same property in the host.
+    return
+	get_host_property($ho, $prop) //
+	($ho->{Host} && get_target_property($ho->{Host}, $prop)) //
+	$defval;
+}
+
 sub get_host_native_linux_console ($) {
     my ($ho) = @_;
 
-- 
1.7.10.4

  parent reply	other threads:[~2015-02-17 18:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-17 17:50 [OSSTEST PATCH 0/9] Fix NTP unreliability, and other fixes Ian Jackson
2015-02-17 17:50 ` [OSSTEST PATCH 1/9] cs-adjust-flight: Add missing `use Data::Dumper' Ian Jackson
2015-02-17 17:50 ` [OSSTEST PATCH 2/9] sg-report-job-history: Increase default history depth to 500 Ian Jackson
2015-02-17 17:50 ` [OSSTEST PATCH 3/9] config: Tiny fixes Ian Jackson
2015-02-17 17:50 ` Ian Jackson [this message]
2015-02-17 17:50 ` [OSSTEST PATCH 5/9] Debian.pm: Pass $ho/$gho to preseed_base Ian Jackson
2015-02-17 17:50 ` [OSSTEST PATCH 6/9] Debian.pm: Slightly refactor preseed_base Ian Jackson
2015-02-17 17:50 ` [OSSTEST PATCH 7/9] NTP servers: Introduce new NtpServer host property Ian Jackson
2015-02-17 17:50 ` [OSSTEST PATCH 8/9] NTP servers: Use " Ian Jackson
2015-02-17 17:50 ` [OSSTEST PATCH 9/9] NTP servers: Work around Debian's failure to honour preseed Ian Jackson

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=1424195431-1493-5-git-send-email-ian.jackson@eu.citrix.com \
    --to=ian.jackson@eu.citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=longtaox.pang@intel.com \
    --cc=robert.hu@intel.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 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.