[tools 1/2] testbot/LibvirtTool: Split off Halt() from ShutDown().

Francois Gouget fgouget at codeweavers.com
Thu Feb 17 11:52:22 CST 2022


Halt() does not wait for the VM to be powered off.

Signed-off-by: Francois Gouget <fgouget at 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;
-- 
2.30.2




More information about the wine-devel mailing list