Module: tools Branch: master Commit: 3c9cd9cb11a328d5125f4b922208df91e1976f20 URL: https://source.winehq.org/git/tools.git/?a=commit;h=3c9cd9cb11a328d5125f4b92...
Author: Francois Gouget fgouget@codeweavers.com Date: Mon Sep 16 15:31:24 2019 +0200
testbot/LibvirtTool: Fix FatalError() when the VM status is not as expected.
If the VM Status is not in the expected state then it no longer belongs to this process. So don't even try to save it as that could cause interference. Also don't notify the administrator about putting it offline since that will not be happening. However if the VM is merely in maintenance mode that means the tool is being debugged so proceed normally except for the VM Status which must not be modified to avoid inteference from the scheduler.
Signed-off-by: Francois Gouget fgouget@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
testbot/bin/LibvirtTool.pl | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/testbot/bin/LibvirtTool.pl b/testbot/bin/LibvirtTool.pl index f031c78..5c39065 100755 --- a/testbot/bin/LibvirtTool.pl +++ b/testbot/bin/LibvirtTool.pl @@ -166,23 +166,31 @@ sub FatalError($) my ($ErrMessage) = @_; Error $ErrMessage;
+ # Get the up-to-date VM status + $VM = CreateVMs()->GetItem($VMKey); + # Put the VM offline or mark it for maintenance my $Errors = ($VM->Errors || 0) + 1; my $NewStatus = $Errors < $MaxVMErrors ? "offline" : "maintenance";
- $VM = CreateVMs()->GetItem($VMKey); - # Put the VM offline if nobody else modified its status before us - if ($VM->Status eq $CurrentStatus) + if ($VM->Status eq "maintenance") { - $VM->Status($NewStatus); - $VM->ChildDeadline(undef); - $VM->ChildPid(undef); - $VM->Errors($Errors); + # Still proceed with changing the non-Status fields and notifying the + # administrator to allow for error handling debugging. + } + elsif ($VM->Status ne $CurrentStatus) + { + LogMsg "Not updating the VM because its status changed: ". $VM->Status ." != $CurrentStatus\n"; + exit 1; } else { - $NewStatus = ""; + $VM->Status($NewStatus); } + $VM->ChildDeadline(undef); + $VM->ChildPid(undef); + $VM->Errors($Errors); + my ($ErrProperty, $SaveErrMessage) = $VM->Save(); if (defined $SaveErrMessage) { @@ -198,7 +206,7 @@ sub FatalError($) elsif ($NewStatus eq "maintenance") { NotifyAdministrator("The $VMKey VM needs maintenance", - "Got ". $VM->Errors ." consecutive errors working on the $VMKey VM:\n". + "Got $Errors consecutive errors working on the $VMKey VM:\n". "\n$ErrMessage\n". "An administrator needs to look at it and to put it back online."); }