Francois Gouget : testbot/VMs: Make sure $VM->Errors does not overflow.

Alexandre Julliard julliard at winehq.org
Mon Feb 21 15:58:38 CST 2022


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

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Mon Feb 21 16:36:38 2022 +0100

testbot/VMs: Make sure $VM->Errors does not overflow.

The Errors field definition only allows two digits which sounds like
more than enough for a count of consecutive errors but can overflow in a
few days if the VM hosts are knocked out, which then causes the scripts
to die.
It would be easy to increase the maximum number of digits but that would
only postpone the issue so add VM::AddError() to make sure the field
does not overflow.

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

---

 testbot/bin/LibvirtTool.pl                  | 3 +--
 testbot/bin/WineRunBuild.pl                 | 3 +--
 testbot/bin/WineRunReconfig.pl              | 3 +--
 testbot/bin/WineRunTask.pl                  | 3 +--
 testbot/bin/WineRunWineTest.pl              | 3 +--
 testbot/lib/WineTestBot/Engine/Scheduler.pm | 6 ++----
 testbot/lib/WineTestBot/VMs.pm              | 9 +++++++++
 7 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/testbot/bin/LibvirtTool.pl b/testbot/bin/LibvirtTool.pl
index 47839b6..a025085 100755
--- a/testbot/bin/LibvirtTool.pl
+++ b/testbot/bin/LibvirtTool.pl
@@ -189,8 +189,7 @@ sub FatalError($)
   }
   $VM->ChildDeadline(undef);
   $VM->ChildPid(undef);
-  my $Errors = ($VM->Errors || 0) + 1;
-  $VM->Errors($Errors);
+  my $Errors = $VM->AddError();
 
   my ($ErrProperty, $SaveErrMessage) = $VM->Save();
   if (defined $SaveErrMessage)
diff --git a/testbot/bin/WineRunBuild.pl b/testbot/bin/WineRunBuild.pl
index 8585882..50696b7 100755
--- a/testbot/bin/WineRunBuild.pl
+++ b/testbot/bin/WineRunBuild.pl
@@ -241,8 +241,7 @@ sub WrapUpAndExit($;$$$$)
     $VM->Status($NewVMStatus);
     if ($NewVMStatus eq 'offline')
     {
-      my $Errors = ($VM->Errors || 0) + 1;
-      $VM->Errors($Errors);
+      $VM->AddError();
     }
     else
     {
diff --git a/testbot/bin/WineRunReconfig.pl b/testbot/bin/WineRunReconfig.pl
index 73595c1..5d9381d 100755
--- a/testbot/bin/WineRunReconfig.pl
+++ b/testbot/bin/WineRunReconfig.pl
@@ -243,8 +243,7 @@ sub WrapUpAndExit($;$$$$)
     $VM->Status($NewVMStatus);
     if ($NewVMStatus eq 'offline')
     {
-      my $Errors = ($VM->Errors || 0) + 1;
-      $VM->Errors($Errors);
+      $VM->AddError();
     }
     else
     {
diff --git a/testbot/bin/WineRunTask.pl b/testbot/bin/WineRunTask.pl
index ac9091d..72faf10 100755
--- a/testbot/bin/WineRunTask.pl
+++ b/testbot/bin/WineRunTask.pl
@@ -275,8 +275,7 @@ sub WrapUpAndExit($;$$$$)
     $VM->Status($NewVMStatus);
     if ($NewVMStatus eq 'offline')
     {
-      my $Errors = ($VM->Errors || 0) + 1;
-      $VM->Errors($Errors);
+      $VM->AddError();
     }
     else
     {
diff --git a/testbot/bin/WineRunWineTest.pl b/testbot/bin/WineRunWineTest.pl
index c9a57bb..c1a37ae 100755
--- a/testbot/bin/WineRunWineTest.pl
+++ b/testbot/bin/WineRunWineTest.pl
@@ -272,8 +272,7 @@ sub WrapUpAndExit($;$$$$)
     $VM->Status($NewVMStatus);
     if ($NewVMStatus eq 'offline')
     {
-      my $Errors = ($VM->Errors || 0) + 1;
-      $VM->Errors($Errors);
+      $VM->AddError();
     }
     else
     {
diff --git a/testbot/lib/WineTestBot/Engine/Scheduler.pm b/testbot/lib/WineTestBot/Engine/Scheduler.pm
index 800d136..f606c0d 100644
--- a/testbot/lib/WineTestBot/Engine/Scheduler.pm
+++ b/testbot/lib/WineTestBot/Engine/Scheduler.pm
@@ -272,8 +272,7 @@ sub _CheckAndClassifyVMs()
         $FoundVMErrors = 1;
         if ($VM->Status eq "reverting" or $VM->Status eq "sleeping")
         {
-          my $Errors = ($VM->Errors || 0) + 1;
-          $VM->Errors($Errors);
+          my $Errors = $VM->AddError();
           $VM->Status("offline");
           NotifyAdministrator("Putting the $VMKey VM offline",
                               "The last $Errors revert operations timed out.\n\n".
@@ -360,8 +359,7 @@ sub _CheckAndClassifyVMs()
         $FoundVMErrors = 1;
         $VM->ChildDeadline(undef);
         $VM->ChildPid(undef);
-        my $Errors = ($VM->Errors || 0) + 1;
-        $VM->Errors($Errors);
+        my $Errors = $VM->AddError();
         if ($Errors >= $MaxVMErrors)
         {
           $VM->Status("offline");
diff --git a/testbot/lib/WineTestBot/VMs.pm b/testbot/lib/WineTestBot/VMs.pm
index 596499a..60a52b8 100644
--- a/testbot/lib/WineTestBot/VMs.pm
+++ b/testbot/lib/WineTestBot/VMs.pm
@@ -264,6 +264,15 @@ sub Status($;$)
   return $NewStatus;
 }
 
+sub AddError($)
+{
+  my ($self) = @_;
+
+  my $Errors = ($self->Errors || 0) + 1;
+  $self->Errors($Errors) if ($Errors <= 99);
+  return $Errors;
+}
+
 =pod
 =over 12
 




More information about the wine-cvs mailing list