]> xenbits.xensource.com Git - osstest.git/commitdiff
power: ts-freebsd-host-install: Use power_reboot_attempts
authorIan Jackson <ian.jackson@eu.citrix.com>
Thu, 24 Jan 2019 18:25:24 +0000 (18:25 +0000)
committerIan Jackson <ian.jackson@eu.citrix.com>
Fri, 25 Jan 2019 17:30:03 +0000 (17:30 +0000)
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

Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
ts-freebsd-host-install

index 53daeefc645d631fdd3d491f00b41b602e4bc1af..3c3e9c34298436dd23f166ef09c7d753c4ec55c9 100755 (executable)
@@ -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)