Halt() does not wait for the VM to be powered off.
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/bin/LibvirtTool.pl | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/testbot/bin/LibvirtTool.pl b/testbot/bin/LibvirtTool.pl index f714e48545..44b4e4950f 100755 --- a/testbot/bin/LibvirtTool.pl +++ b/testbot/bin/LibvirtTool.pl @@ -280,6 +280,21 @@ sub GetPrivilegedTA($) return $TA->SetTime() ? $TA : $VM->GetAgent(1); }
+sub Halt() +{ + my $Cmd = $VM->Type =~ /^win(?:32|64)$/ ? + ["shutdown.exe", "/s", "/d", "00:00", "/t", "0"] : + ["/sbin/shutdown", "--poweroff", "now"]; + Debug(Elapsed($Start), " Running: @$Cmd\n"); + my $PTA = GetPrivilegedTA($VM->GetAgent()); + if (!$PTA->Run($Cmd, 0)) + { + Error "Could not run @$Cmd on $VMKey: ". $PTA->GetLastError() ."\n"; + return 0; + } + return 1; +} + =pod =over 12
@@ -305,16 +320,7 @@ sub ShutDownIfOffSnapshot()
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", "/s", "/d", "00:00", "/t", "0"] : - ["/sbin/shutdown", "--poweroff", "now"]; - Debug(Elapsed($Start), " Running @$Cmd\n"); - my $PTA = GetPrivilegedTA($VM->GetAgent()); - if (!$PTA->Run($Cmd, 0)) - { - Error "Could not run @$Cmd on $VMKey: ". $PTA->GetLastError() ."\n"; - return 0; - } + return 0 if (!Halt());
Debug(Elapsed($Start), " Waiting for the VM to shut down\n"); my $Deadline = time() + $WaitForShutdown;