Francois Gouget : testbot/LibvirtTool: Simplify and fix logging in ShutDown().

Alexandre Julliard julliard at winehq.org
Thu Feb 10 16:10:04 CST 2022


Module: tools
Branch: master
Commit: b6218171b0daeae13ba72e349f55edc33c0de6a9
URL:    https://source.winehq.org/git/tools.git/?a=commit;h=b6218171b0daeae13ba72e349f55edc33c0de6a9

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Thu Feb 10 19:51:52 2022 +0100

testbot/LibvirtTool: Simplify and fix logging in ShutDown().

Don't log that the shutdown was successful if it failed or timed out.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 e3bc2a0..4b84f9b 100755
--- a/testbot/bin/LibvirtTool.pl
+++ b/testbot/bin/LibvirtTool.pl
@@ -289,10 +289,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"];
@@ -301,28 +299,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()




More information about the wine-cvs mailing list