Francois Gouget : testbot: PowerOff() should not return an error if a VM is already off.

Alexandre Julliard julliard at winehq.org
Tue Dec 17 10:10:03 CST 2013


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

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Tue Dec 17 11:00:48 2013 +0100

testbot: PowerOff() should not return an error if a VM is already off.

VMs may be put in unexpected states when an administrator manually
reconfigures them. So, even though we normally don't call PowerOff()
on powered off VMs, robustness dictates this change.  Also ensure that
if an error does occur the error message contains the VM name.  This
fixes various 'Scheduling problem in HandleXxx' error reports.

---

 testbot/bin/RevertVM.pl        |   13 +++++--------
 testbot/lib/WineTestBot/VMs.pm |   20 +++++++++++++++-----
 2 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/testbot/bin/RevertVM.pl b/testbot/bin/RevertVM.pl
index 5f98191..2ce3be1 100755
--- a/testbot/bin/RevertVM.pl
+++ b/testbot/bin/RevertVM.pl
@@ -97,15 +97,12 @@ if (defined($ErrMessage))
   FatalError "Can't change status for VM $VMKey: $ErrMessage", $VM;
 }
 
-if ($VM->IsPoweredOn())
+# Some QEmu/KVM versions are buggy and cannot revert a running VM
+$ErrMessage = $VM->PowerOff(1);
+if (defined $ErrMessage)
 {
-  # Some QEmu/KVM versions are buggy and cannot revert a running VM
-  $ErrMessage = $VM->PowerOff(1);
-  if (defined $ErrMessage)
-  {
-    LogMsg "Could not shut down $VMKey: $ErrMessage\n";
-    LogMsg "Trying the revert anyway\n";
-  }
+  LogMsg "$ErrMessage\n";
+  LogMsg "Trying the revert anyway\n";
 }
 
 $ErrMessage = $VM->RevertToSnapshot($VM->IdleSnapshot);
diff --git a/testbot/lib/WineTestBot/VMs.pm b/testbot/lib/WineTestBot/VMs.pm
index 7c403cd..d4267e0 100644
--- a/testbot/lib/WineTestBot/VMs.pm
+++ b/testbot/lib/WineTestBot/VMs.pm
@@ -375,11 +375,21 @@ sub PowerOff($$)
   my ($ErrMessage, $Domain) = $self->_GetDomain();
   return $ErrMessage if (defined $ErrMessage);
 
-  eval { $Domain->destroy() };
-  return $@->message() if ($@);
-
-  return $self->UpdateStatus($Domain) if (!$NoStatus);
-  return undef;
+  if ($self->IsPoweredOn())
+  {
+    eval { $Domain->destroy() };
+    if ($@)
+    {
+      $ErrMessage = $@->message();
+    }
+    elsif ($self->IsPoweredOn())
+    {
+      $ErrMessage = "The VM is still active";
+    }
+  }
+  $ErrMessage ||= $self->UpdateStatus($Domain) if (!$NoStatus);
+  return undef if (!defined $ErrMessage);
+  return join("", "Could not power off ", $self->Name, ": ", $ErrMessage);
 }
 
 sub GetAgent($)




More information about the wine-cvs mailing list