]> xenbits.xensource.com Git - people/iwj/osstest.git/commitdiff
Nested hosts: Provide hostnamepath and hostnamepath_list
authorIan Jackson <ian.jackson@eu.citrix.com>
Mon, 16 Nov 2015 12:17:40 +0000 (12:17 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Mon, 16 Nov 2015 16:45:13 +0000 (16:45 +0000)
This can (and often should) be used to replace $ho->{Name}.

For an L0 host it returns "$ho->{Name}", ie HOST.

For a plain guest or L1 guest it returns
"$ho->{Host}{Name}_$ho->{Name}", ie HOST_GUEST or HOST_L1.

For an L2 guest it recurses further, giving HOST_L1_L2.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Robert Ho <robert.hu@intel.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Osstest/TestSupport.pm

index 6be50e3c7478e7491494d5be445370b172a82d59..47b3e6f108eebb53dfb400c2d474cddf7c646272 100644 (file)
@@ -70,6 +70,7 @@ BEGIN {
 
                       selecthost get_hostflags get_host_property
                       get_target_property get_host_native_linux_console
+                      hostnamepath hostnamepath_list
                       power_state power_cycle power_cycle_sleep
                       serial_fetch_logs
                       propname_massage propname_check
@@ -1063,6 +1064,20 @@ sub get_host_method_object ($$$) {
     return $mo;
 }
 
+sub hostnamepath_list ($);
+sub hostnamepath_list ($) {
+    # returns list of guest/host names, innermost first
+    my ($ho) = @_;
+    return () unless $ho && $ho->{Name};
+    return ($ho->{Name}, hostnamepath_list($ho->{Host}));
+}
+       
+sub hostnamepath ($) {
+    my ($ho) = @_;
+    my @l = hostnamepath_list($ho);
+    join '_', reverse @l;
+}
+
 #---------- stashed files ----------
 
 sub open_unique_stashfile ($) {