Francois Gouget : testbot: Replace poweroff with checkoff in the Engine' s Cleanup().

Alexandre Julliard julliard at winehq.org
Wed Feb 28 15:22:31 CST 2018


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

Author: Francois Gouget <fgouget at 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 at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at 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.




More information about the wine-cvs mailing list