Module: tools
Branch: master
Commit: 070b78e17a9a0408eb17f01f96860fcd1d846923
URL: https://source.winehq.org/git/tools.git/?a=commit;h=070b78e17a9a0408eb17f01…
Author: Francois Gouget <fgouget(a)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(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)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)
Module: tools
Branch: master
Commit: cad513a33e9c0f32af427ac2d2caf63f23f168b0
URL: https://source.winehq.org/git/tools.git/?a=commit;h=cad513a33e9c0f32af427ac…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Wed Feb 28 01:55:41 2018 +0100
testbot: Replace poweroff with checkoff in the Engine's Cleanup().
checkoff verifies that the hypervisor domain state matches that of the
current VM instance before powering it off.
If the state does not match then the VM is just marked off.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
testbot/bin/Engine.pl | 8 ++++----
testbot/bin/LibvirtTool.pl | 28 ++++++++++++++++++++++++++--
testbot/lib/WineTestBot/VMs.pm | 20 ++++++++++++++++++++
3 files changed, 50 insertions(+), 6 deletions(-)
diff --git a/testbot/bin/Engine.pl b/testbot/bin/Engine.pl
index 2e62c66..a03fa06 100755
--- a/testbot/bin/Engine.pl
+++ b/testbot/bin/Engine.pl
@@ -206,8 +206,8 @@ sub Cleanup($;$$)
{
# The VM should not have a process.
$VM->KillChild();
- $VM->RunPowerOff();
- $VM->RecordStatus($Records, "dirty poweroff (unexpected process)");
+ $VM->RunCheckOff();
+ $VM->RecordStatus($Records, "dirty off check (unexpected process)");
}
elsif ($Starting)
{
@@ -228,8 +228,8 @@ sub Cleanup($;$$)
# Power off the VM, even if its status is already off.
# This is the simplest way to resync the VM status field.
# Also powering off a powered off VM will detect offline VMs.
- $VM->RunPowerOff();
- $VM->RecordStatus($Records, "dirty poweroff");
+ $VM->RunCheckOff();
+ $VM->RecordStatus($Records, "dirty off check");
}
}
# $KillVMs is normally used on shutdown so don't start a process that
diff --git a/testbot/bin/LibvirtTool.pl b/testbot/bin/LibvirtTool.pl
index 0293bae..76ea707 100755
--- a/testbot/bin/LibvirtTool.pl
+++ b/testbot/bin/LibvirtTool.pl
@@ -104,7 +104,7 @@ while (@ARGV)
{
$LogOnly = 1;
}
- elsif ($Arg =~ /^(?:checkidle|monitor|poweroff|revert)$/)
+ elsif ($Arg =~ /^(?:checkidle|checkoff|monitor|poweroff|revert)$/)
{
$Action = $Arg;
}
@@ -163,7 +163,7 @@ if (!defined $Usage)
}
if (defined $Usage)
{
- print "Usage: $Name0 [--debug] [--log-only] [--help] (checkidle|monitor|poweroff|revert) VMName\n";
+ print "Usage: $Name0 [--debug] [--log-only] [--help] (checkidle|checkoff|monitor|poweroff|revert) VMName\n";
exit $Usage;
}
@@ -344,6 +344,26 @@ sub CheckIdle()
return ChangeStatus("dirty", $NewStatus, "done");
}
+sub CheckOff()
+{
+ $CurrentStatus = "dirty";
+ my $IsPoweredOn = $VM->GetDomain()->IsPoweredOn();
+ return ChangeStatus("dirty", "offline", "done") if (!defined $IsPoweredOn);
+
+ if ($IsPoweredOn)
+ {
+ my ($ErrMessage, $SnapshotName) = $VM->GetDomain()->GetSnapshotName();
+ FatalError("$ErrMessage\n") if (defined $ErrMessage);
+ if ($SnapshotName eq $VM->IdleSnapshot)
+ {
+ my $ErrMessage = $VM->GetDomain()->PowerOff();
+ FatalError("$ErrMessage\n") if (defined $ErrMessage);
+ }
+ }
+
+ return ChangeStatus("dirty", "off", "done");
+}
+
sub Revert()
{
my $VM = CreateVMs()->GetItem($VMKey);
@@ -405,6 +425,10 @@ if ($Action eq "checkidle")
{
$Rc = CheckIdle();
}
+elsif ($Action eq "checkoff")
+{
+ $Rc = CheckOff();
+}
elsif ($Action eq "monitor")
{
$Rc = Monitor();
diff --git a/testbot/lib/WineTestBot/VMs.pm b/testbot/lib/WineTestBot/VMs.pm
index f098639..afc7af9 100644
--- a/testbot/lib/WineTestBot/VMs.pm
+++ b/testbot/lib/WineTestBot/VMs.pm
@@ -451,6 +451,26 @@ sub RunCheckIdle($)
=pod
=over 12
+=item C<RunCheckOff()>
+
+If the hypervisor domain state matches that of this VM instance, power if off.
+If not the VM is simply marked as off. While this is happening the VM status
+is set to dirty so the job scheduler does not try to use it.
+
+This operation can take a long time so it is performed in a separate process.
+
+=back
+=cut
+
+sub RunCheckOff($)
+{
+ my ($self) = @_;
+ return $self->_RunVMTool("dirty", ["--log-only", "checkoff", $self->GetKey()]);
+}
+
+=pod
+=over 12
+
=item C<RunMonitor()>
Monitors an offline VM to detect when it becomes accessible again.
Module: tools
Branch: master
Commit: ab35ecaf100d649a8b182e1bfba22c1b754cb8bc
URL: https://source.winehq.org/git/tools.git/?a=commit;h=ab35ecaf100d649a8b182e1…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Wed Feb 28 01:54:45 2018 +0100
testbot: Check the current snapshot in LibvirtTool monitor.
If the snapshot does not match when the hypervisor domain becomes
accessible again, then don't try to power if off and just mark the
VM instance as off.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
testbot/bin/LibvirtTool.pl | 44 ++++++++++++++++++++++++++++++--------------
1 file changed, 30 insertions(+), 14 deletions(-)
diff --git a/testbot/bin/LibvirtTool.pl b/testbot/bin/LibvirtTool.pl
index 12eaa66..0293bae 100755
--- a/testbot/bin/LibvirtTool.pl
+++ b/testbot/bin/LibvirtTool.pl
@@ -277,23 +277,39 @@ sub Monitor()
return 0;
}
- my $IsPoweredOn = $VM->GetDomain()->IsPoweredOn();
- if ($IsPoweredOn)
+ my ($ErrMessage, $SnapshotName) = $VM->GetDomain()->GetSnapshotName();
+ if (defined $ErrMessage)
{
- my $ErrMessage = $VM->GetDomain()->PowerOff();
- if (defined $ErrMessage)
- {
- Error "$ErrMessage\n";
- $IsPoweredOn = undef;
- }
+ Error "$ErrMessage\n";
}
- if (defined $IsPoweredOn)
+ else
{
- return 1 if (ChangeStatus("offline", "off", "done"));
- NotifyAdministrator("The $VMKey VM is working again",
- "The $VMKey VM started working again after ".
- Elapsed($Start) ." seconds.");
- return 0;
+ my $IsPoweredOn;
+ if (!defined $SnapshotName or $SnapshotName ne $VM->IdleSnapshot)
+ {
+ $IsPoweredOn = 0;
+ }
+ else
+ {
+ $IsPoweredOn = $VM->GetDomain()->IsPoweredOn();
+ if ($IsPoweredOn)
+ {
+ $ErrMessage = $VM->GetDomain()->PowerOff();
+ if (defined $ErrMessage)
+ {
+ Error "$ErrMessage\n";
+ $IsPoweredOn = undef;
+ }
+ }
+ }
+ if (defined $IsPoweredOn)
+ {
+ return 1 if (ChangeStatus("offline", "off", "done"));
+ NotifyAdministrator("The $VMKey VM is working again",
+ "The $VMKey VM started working again after ".
+ Elapsed($Start) ." seconds.");
+ return 0;
+ }
}
Debug(Elapsed($Start), " $VMKey is still unreachable\n");