Don't log that the shutdown was successful if it failed or timed out.
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/bin/LibvirtTool.pl | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-)
diff --git a/testbot/bin/LibvirtTool.pl b/testbot/bin/LibvirtTool.pl index f14d54cd3b..db85f43e2f 100755 --- a/testbot/bin/LibvirtTool.pl +++ b/testbot/bin/LibvirtTool.pl @@ -290,10 +290,8 @@ sub ShutDown() return 1; }
- Debug(Elapsed($Start), " Performing a clean shutdown of $VMKey $CurrentSnapshot\n"); - LogMsg "Performing a clean shutdown of $VMKey $CurrentSnapshot\n"; - - my $Success = 1; + Debug(Elapsed($Start), " Performing a clean shutdown of $VMKey/$CurrentSnapshot\n"); + LogMsg "Performing a clean shutdown of $VMKey/$CurrentSnapshot\n"; my $Cmd = $VM->Type =~ /^win(?:32|64)$/ ? ["shutdown.exe", "/p", "/d", "00:00"] : ["/sbin/shutdown", "--poweroff", "now"]; @@ -302,28 +300,24 @@ sub ShutDown() if (!$PTA->Run($Cmd, 0)) { Error "Could not run @$Cmd on $VMKey: ". $PTA->GetLastError() ."\n"; - $Success = 0; + return 0; } - else + + Debug(Elapsed($Start), " Waiting for the VM to shut down\n"); + my $Deadline = time() + $WaitForShutdown; + while (time() <= $Deadline) { - Debug(Elapsed($Start), " Waiting for the VM to power off\n"); - my $Deadline = time() + $WaitForShutdown; - while ($Domain->IsPoweredOn()) + if (!$Domain->IsPoweredOn()) { - if (time() >= $Deadline) - { - Error "Timed out waiting for $VMKey to perform a clean shutdown. Forcefully shutting down now...\n"; - $Success = 0; - last; - } - sleep(1); + Debug(Elapsed($Start), " Successfully shut down $VMKey\n"); + LogMsg "Successfully shut down $VMKey\n"; + return 1; } + sleep(1); } - $PTA->Disconnect(); + Error "Timed out waiting for $VMKey to perform a clean shutdown. Forcefully shutting down now...\n";
- Debug(Elapsed($Start), " Successfully shut down $VMKey\n"); - LogMsg "Successfully shut down $VMKey\n"; - return $Success; + return 0; }
sub Monitor()