Module: tools Branch: master Commit: 070b78e17a9a0408eb17f01f96860fcd1d846923 URL: https://source.winehq.org/git/tools.git/?a=commit;h=070b78e17a9a0408eb17f01f...
Author: Francois Gouget fgouget@codeweavers.com Date: Wed Feb 28 02:01:03 2018 +0100
testbot: Avoid race conditions between LibvirtTool monitor and other tools.
If another tool was trying to connect to the VM's TestAgent server when 'LibvirtTool monitor' powered off the VM, that other tool may mark the VM as offline right after it has been put back online. So wait for other tools to time out after monitor powers off a VM.
Signed-off-by: Francois Gouget fgouget@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
testbot/bin/LibvirtTool.pl | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/testbot/bin/LibvirtTool.pl b/testbot/bin/LibvirtTool.pl index 76ea707..c0288e7 100755 --- a/testbot/bin/LibvirtTool.pl +++ b/testbot/bin/LibvirtTool.pl @@ -285,7 +285,12 @@ sub Monitor() else { my $IsPoweredOn; - if (!defined $SnapshotName or $SnapshotName ne $VM->IdleSnapshot) + if (!defined $SnapshotName) + { + Debug("$VMKey has no snapshot (reverting?)\n"); + $IsPoweredOn = undef; + } + elsif (!defined $SnapshotName or $SnapshotName ne $VM->IdleSnapshot) { $IsPoweredOn = 0; } @@ -298,8 +303,16 @@ sub Monitor() if (defined $ErrMessage) { Error "$ErrMessage\n"; - $IsPoweredOn = undef; } + else + { + # Another process might have been trying to connect to the VM's + # TestAgent server. Wait for it to time out so it does not set the + # VM offline right after we have put it back online. + LogMsg "Powered off $VMKey. Sleep until all other processes accessing it are gone.\n"; + sleep(3 * $WaitForToolsInVM); + } + $IsPoweredOn = undef; } } if (defined $IsPoweredOn)