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

[Xen-devel] [OSSTEST PATCH 4/5] power: ts-freebsd-host-install: Use power_reboot_attempts



We look at the installer environment uptime, to
 | check that this is the installer environment
as requested by the comment
 | in particular $await must only succeed if the host really did
 | reboot into the boot environment that $await expects.
near the top of power_reboot_attempts

CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 ts-freebsd-host-install | 33 +++++++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 8 deletions(-)

diff --git a/ts-freebsd-host-install b/ts-freebsd-host-install
index 53daeefc..3c3e9c34 100755
--- a/ts-freebsd-host-install
+++ b/ts-freebsd-host-install
@@ -259,14 +259,31 @@ END
 }
 
 # Switch off, setup PXE and switch on to the installer
-power_state($ho, 0);
-setup_netboot_installer();
-power_cycle_sleep($ho);
-power_state($ho, 1);
-
-# Wait for the host to finish booting
-logm("Waiting for the installer to boot");
-await_tcp(get_timeout($ho,'reboot',$timeout), 5, $ho);
+power_reboot_attempts($ho, sub {
+    setup_netboot_installer();
+}, sub {
+    # Wait for the host to finish booting
+    logm("Waiting for the installer to boot");
+    my $wait_start = time;
+    await_tcp(get_timeout($ho,'reboot',$timeout), 5, $ho);
+
+    # We want to check that we actually rebooted.  We do this by
+    # comparing the (putative) installer environment's uptime,
+    # with the time we spent waiting for it to appear.
+    my $timeoutput = target_cmd_output_root($ho,
+        'date +%s; sysctl -n kern.boottime');
+    logm("got:\n$timeoutput");
+    $timeoutput =~ s{^(\d+)\n}{} or die "date: $timeoutput ?";
+    my $target_now = $1;
+    $timeoutput =~ m{\ssec\s?=\s?(\d+)\b} or die "sysctl: $timeoutput ?";
+    my $target_boottime = $1;
+
+    my $uptime = $target_now - $target_boottime;
+    my $elapsed = time - $wait_start;
+    logm("uptime=$uptime elapsed=$elapsed");
+    $uptime < $elapsed or die "uptime >= elapsed";
+
+}, undef, 'install');
 
 if ($bootonly) {
     hostprop_putative_record($ho, "MemdiskAppend", $memdisk_append)
-- 
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®.