]> xenbits.xensource.com Git - people/iwj/osstest.git/commitdiff
selecthost: Support nested hosts (guests which are also hosts)
authorIan Jackson <ian.jackson@eu.citrix.com>
Fri, 25 Sep 2015 16:24:00 +0000 (17:24 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Wed, 11 Nov 2015 16:48:16 +0000 (16:48 +0000)
We introduce a new syntax: instead of a hostname (which might appear
in a command line argument to a ts-* script and hence be passed to
selecthost, or which might be in a runvar), we now support
<hostspec>:<domname>.

Such `hosts' (let us refer to such a thing as an L1, although in
principle further nesting may be possible) are expected to be
dynamically created.  So they do not have flags and properties in the
configuration (or in an Executive instance's database).

The IP address is determined dynamically from the leases file.  If the
L1 is not running, then no IP address may be found.  This is not an
error.  Users of this facility will need to make sure that ts-*
scripts which are unaware of the L1's special status are only invoked
when it is known that the L1 is up and has obtained its IP address.

`Power cycling' the L1 will be done by VM control operations in the
L0; this will come in a subsequent patch.

`Serial access' to the L1 guest will likewise need to be done via the
console arrangements in L0.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Tested-by: Robert Ho <robert.hu@intel.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
v14: New patch

Osstest/TestSupport.pm

index 8c3612c872e22360d3c8a7b0236e2b95d6044967..314504098c75aa0b07001be6880b63c71bc5cbf1 100644 (file)
@@ -807,6 +807,7 @@ sub power_state ($$) {
 
 #---------- host selection and properties ----------
 
+sub selecthost ($);
 sub selecthost ($) {
     my ($ident) = @_;
     # must be run outside transaction
@@ -821,8 +822,12 @@ sub selecthost ($) {
     # which means ignore <ident> except for logging purposes etc.
     # and use <hostspec>
     #
-    # <hostspec> is <hostname> which means use that host (and all
+    # <hostspec> can be <hostname> which means use that host (and all
     # its flags and properties from the configuration and database)
+    # OR
+    # <hostspec> can be <parent_identspec>:<domname> meaning use the
+    # Xen domain name <domname> on the host specified by
+    # <parent_identspec>, which is an <identspec> as above.
 
     my $name;
     if ($ident =~ m/=/) {
@@ -838,6 +843,7 @@ sub selecthost ($) {
         Ident => $ident,
         Name => $name,
         TcpCheckPort => 22,
+        NestingLevel => 0,
         Info => [],
     };
     if (defined $job) {
@@ -845,6 +851,35 @@ sub selecthost ($) {
                                          $c{DebianSuite});
     }
 
+    #----- handle hosts which are themselves guests (nested) -----
+
+    if ($name =~ s/^(.*)://) {
+       my $parentname = $1;
+       my $parent = selecthost($parentname);
+       my $child = selectguest($name,$parent);
+       $child->{Ident} = $ho->{Ident};
+       $child->{Info} = [ "in", $parent->{Name}, @{ $parent->{Info} } ];
+       $child->{NestingLevel} = $parent->{NestingLevel}+1;
+
+       # $child->{Power} = 'guest';   todo
+       power_cycle_host_setup($child);
+
+       $child->{Properties}{Serial} = 'noop'; # todo
+       serial_host_setup($child);
+
+       my $msg = "L$child->{NestingLevel} host $child->{Ident}:";
+       $msg .= " guest $child->{Guest} (@{ $child->{Info} })";
+       $msg .= " $child->{Ether}";
+
+       my $err = guest_check_ip($child);
+       $msg .= " ".(defined $err ? "<no-ip> $err" : $child->{Ip});
+
+       logm($msg);
+
+       # all the rest of selecthost is wrong for this case
+       return $child;
+    }
+
     #----- calculation of the host's properties -----
 
     $ho->{Properties} = { };