Module: tools Branch: master Commit: d6523a05cd74501cab92c6451275819757b67ba1 URL: http://source.winehq.org/git/tools.git/?a=commit;h=d6523a05cd74501cab92c6451...
Author: Francois Gouget fgouget@codeweavers.com Date: Mon Dec 18 23:53:51 2017 +0100
testbot: Save the status of all VMs on startup.
This allows providing more information about the initial state of the VMs such as linking running VMs to the corresponding Task, and identifying the initial dirty status as running 'LibvirtTool checkidle'.
Signed-off-by: Francois Gouget fgouget@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
testbot/bin/Engine.pl | 44 ++++++++++++++++++++++++++++++++++-------- testbot/lib/WineTestBot/VMs.pm | 7 +++++++ 2 files changed, 43 insertions(+), 8 deletions(-)
diff --git a/testbot/bin/Engine.pl b/testbot/bin/Engine.pl index 7dab98e..36a18ad 100755 --- a/testbot/bin/Engine.pl +++ b/testbot/bin/Engine.pl @@ -52,6 +52,7 @@ use WineTestBot::Jobs; use WineTestBot::Log; use WineTestBot::Patches; use WineTestBot::PendingPatchSets; +use WineTestBot::RecordGroups; use WineTestBot::Utils; use WineTestBot::VMs;
@@ -102,7 +103,7 @@ sub Cleanup($;$$)
# Verify that the running tasks are still alive and requeue them if not. # Ignore the Job and Step status fields because they may be a bit out of date. - my %BusyVMs; + my %RunningVMs; foreach my $Job (@{CreateJobs()->GetItems()}) { my $CallUpdateStatus; @@ -135,7 +136,7 @@ sub Cleanup($;$$) { # This task is still running! LogMsg "$TaskKey is still running\n"; - $BusyVMs{$Task->VM->GetKey()} = 1; + $RunningVMs{$Task->VM->GetKey()} = join(" ", "running", $Job->Id, $Step->No, $Task->No); next; } if ($Requeue) @@ -158,16 +159,27 @@ sub Cleanup($;$$) }
# Get the VMs in order now + my $RecordGroups = CreateRecordGroups(); + my $Records = $RecordGroups->Add()->Records; + # Save the new RecordGroup now so its Id is lower than those of the groups + # created by the scripts called from Cleanup(). + $RecordGroups->Save(); + my $VMs = CreateVMs(); - $VMs->FilterEnabledRole(); - $VMs->FilterEnabledStatus(); foreach my $VM (@{$VMs->GetItems()}) { my $VMKey = $VM->GetKey(); - if ($BusyVMs{$VMKey}) + if (!$VM->HasEnabledRole() or !$VM->HasEnabledStatus()) + { + $VM->RecordStatus($Records); + next; + } + + if ($RunningVMs{$VMKey}) { # This VM is still running a task. Let it. - LogMsg "$VMKey is used by a task\n"; + LogMsg "$VMKey is $RunningVMs{$VMKey}\n"; + $VM->RecordStatus($Records, $RunningVMs{$VMKey}); next; }
@@ -177,27 +189,39 @@ sub Cleanup($;$$) { $VM->KillChild(); $VM->RunPowerOff(); + $VM->RecordStatus($Records, "dirty poweroff (kill tasks)"); } elsif ($KillVMs and $VM->Status ne "running") { $VM->KillChild(); # $KillVMs is normally used on shutdown so don't start a process that # will get stuck 'forever' waiting for an offline VM. - $VM->RunPowerOff() if ($VM->Status ne "offline"); + if ($VM->Status ne "offline") + { + $VM->RunPowerOff(); + $VM->RecordStatus($Records, "dirty poweroff (kill vms)"); + } } elsif (!$VM->CanHaveChild()) { # The VM should not have a process. $VM->KillChild(); $VM->RunPowerOff(); + $VM->RecordStatus($Records, "dirty poweroff (unexpected process)"); + } + elsif ($Starting) + { + # Let the process finish its work. Note that on shutdown we don't + # record the VM status if it did not change. + $VM->RecordStatus($Records); } - # else let the process finish its work } elsif ($Starting) { if ($VM->Status eq "idle") { $VM->RunCheckIdle(); + $VM->RecordStatus($Records, "dirty idle check"); } else { @@ -205,6 +229,7 @@ sub Cleanup($;$$) # 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"); } } # $KillVMs is normally used on shutdown so don't start a process that @@ -212,8 +237,11 @@ sub Cleanup($;$$) elsif ($KillVMs and $VM->Status !~ /^(?:off|offline)$/) { $VM->RunPowerOff(); + $VM->RecordStatus($Records, "dirty poweroff (kill vms)"); } + # Note that on shutdown we don't record the VM status if it did not change. } + $RecordGroups->Save(); }
diff --git a/testbot/lib/WineTestBot/VMs.pm b/testbot/lib/WineTestBot/VMs.pm index a8da842..961be52 100644 --- a/testbot/lib/WineTestBot/VMs.pm +++ b/testbot/lib/WineTestBot/VMs.pm @@ -183,6 +183,13 @@ sub HasEnabledRole($) return $self->Role ne "retired" && $self->Role ne "deleted"; }
+sub HasEnabledStatus($) +{ + my ($self) = @_; + # Filter out the maintenance VMs + return $self->Status ne "maintenance"; +} + sub GetHost($) { my ($self) = @_;