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

[Xen-devel] [OSSTEST PATCH 06/26] power handling: Introduce power_reboot_attempts



This is going to be the new preferred interface for rebooting a host.

Introduce the first two call sites in ts-host-install and
ts-freebsd-host-install.  power_cycle_sleep is an internal function
now.

No overall functional change, since currently power_reboot_attempts
only ever tries one method.

Do not adjust ts-freebsd-host-install yet as we have a problem there,
which will be discussed in a moment.

CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 Osstest/TestSupport.pm | 23 ++++++++++++++++++++++-
 ts-host-install        | 19 +++++++------------
 2 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 68b51728..fb6a407c 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -81,7 +81,7 @@ BEGIN {
                       selecthost get_hostflags get_host_property
                       get_target_property get_host_native_linux_console
                       hostnamepath hostnamepath_list set_runtime_hostflag
-                      power_state power_cycle power_cycle_sleep
+                      power_state power_cycle power_reboot_attempts
                       serial_fetch_logs set_host_property
                       propname_massage propname_check
                       hostprop_putative_record
@@ -939,6 +939,27 @@ sub power_cycle_host_setup ($) {
     $ho->{PowerMethobjs} = power_cycle_parse_method($ho,$spec);
 }
 
+sub power_reboot_attempts ($$$) {
+    my ($ho, $setup, $await) = @_;
+    # Power cycles $ho, calling $setup->() while it is (supposedly) off.
+    # Then, just after turning $ho on, calls $await->().
+    # If $await->() succeeds, great: returns.
+    #
+    # If it fails (dies), power_reboot_attempts will attempt to power
+    # cycle $ho using a more certain method and call $fn again.  This
+    # may occur multiple times.
+    #
+    # All but the last method used for power cycling are not certain
+    # to work.  $setup and $await should tolerate this situation; in
+    # particular $await must only succeed if the host really did reboot
+    # into the boot environment that $await expects.
+    power_state($ho, 0);
+    $setup->();
+    power_cycle_sleep($ho);
+    power_state($ho, 1);
+    $await->();
+}
+
 sub power_cycle_sleep ($) {
     my ($ho) = @_;
     my $to = get_host_property($ho, 'power-cycle-time', 5);
diff --git a/ts-host-install b/ts-host-install
index c5b92b8d..068242eb 100755
--- a/ts-host-install
+++ b/ts-host-install
@@ -56,8 +56,6 @@ our %timeout= qw(ReadPreseed  350
                  Sshd        2400);
 
 sub install () {
-    power_state($ho, 0);
-
     my ($ps_url,$ps_file)= preseed_create
         ($ho, '',
          DiskDevice => $ho->{DiskDevice},
@@ -67,19 +65,16 @@ d-i netcfg/get_hostname string $ho->{Name}
 d-i netcfg/get_ipaddress string $ho->{Ip}
 END
 
-    setup_netboot_firstboot($ps_url);
-    power_cycle_sleep($ho);
-
-    my $logtailer= Osstest::Logtailer->new($c{WebspaceLog});
-    power_state($ho, 1);
-
-    await_webspace_fetch_byleaf(get_timeout($ho,'reboot',$timeout{ReadPreseed})
-                                , 1,
-                                $logtailer, $ho, $ps_url);
+    power_reboot_attempts($ho, sub {
+        setup_netboot_firstboot($ps_url);
+    }, sub {
+       my $logtailer= Osstest::Logtailer->new($c{WebspaceLog});
+       my $timeout = get_timeout($ho,'reboot',$timeout{ReadPreseed});
+       await_webspace_fetch_byleaf($timeout, 1, $logtailer, $ho, $ps_url);
+    });
 
     if ($poweron_test_only) {
        logm("Hooray, power on worked.");
-       power_state($ho, 0);
        exit 0;
     }
 
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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