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

[Xen-devel] [OSSTEST PATCH 4/9] TestSupport: Provide get_target_property

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

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@xxxxxxxxxxxxx>
CC: Robert Hu <robert.hu@xxxxxxxxx>
CC: LongtaoX Pang <longtaox.pang@xxxxxxxxx>
 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
@@ -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) = @_;

Xen-devel mailing list



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