[Tools 2/3] testbot: Remove LibvirtDomain::_UpdateStatus().

Francois Gouget fgouget at codeweavers.com
Thu Oct 19 07:54:35 CDT 2017


It was needed to resynchronize the VM status field during the Engine
initialization. However nowadays the Engine delegates this to
LibvirtTool which does not want the VM status to be changed behind this
back and thus bypasses _UpdateStatus().
The bypass is explicit in the case of PowerOff(), $NoStatus=1, and
implicit in the RevertToSnapshot() case: _UpdateStatus() does nothing if
get_state() == STATE_RUNNING (which is the case for our VMs) and
$VM->Status ne "off".

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
 testbot/bin/LibvirtTool.pl               |  4 ++--
 testbot/lib/WineTestBot/LibvirtDomain.pm | 35 ++++----------------------------
 2 files changed, 6 insertions(+), 33 deletions(-)

diff --git a/testbot/bin/LibvirtTool.pl b/testbot/bin/LibvirtTool.pl
index ab972614..51f03b42 100755
--- a/testbot/bin/LibvirtTool.pl
+++ b/testbot/bin/LibvirtTool.pl
@@ -305,7 +305,7 @@ sub PowerOff()
 {
   # Power off VMs no matter what their initial status is
   $CurrentStatus = $VM->Status;
-  my $ErrMessage = $VM->GetDomain()->PowerOff(1);
+  my $ErrMessage = $VM->GetDomain()->PowerOff();
   FatalError("$ErrMessage\n") if (defined $ErrMessage);
 
   return ChangeStatus(undef, "off", "done");
@@ -338,7 +338,7 @@ sub Revert()
   # Some QEmu/KVM versions are buggy and cannot revert a running VM
   Debug(Elapsed($Start), " Powering off the VM\n");
   my $Domain = $VM->GetDomain();
-  my $ErrMessage = $Domain->PowerOff(1);
+  my $ErrMessage = $Domain->PowerOff();
   if (defined $ErrMessage)
   {
     LogMsg "Could not power off $VMKey: $ErrMessage\n";
diff --git a/testbot/lib/WineTestBot/LibvirtDomain.pm b/testbot/lib/WineTestBot/LibvirtDomain.pm
index 1b74315f..f8caffa3 100644
--- a/testbot/lib/WineTestBot/LibvirtDomain.pm
+++ b/testbot/lib/WineTestBot/LibvirtDomain.pm
@@ -151,32 +151,6 @@ sub _GetDomain($)
   return (undef, $Domain);
 }
 
-sub _UpdateStatus($$)
-{
-  my ($self, $Domain) = @_;
-
-  return undef if ($self->{VM}->Status eq "offline");
-
-  my ($State, $Reason);
-  eval { ($State, $Reason) = $Domain->get_state() };
-  return $self->_Reset(_eval_err()) if ($@);
-
-  if ($State == Sys::Virt::Domain::STATE_SHUTDOWN or
-      $State == Sys::Virt::Domain::STATE_SHUTOFF or
-      $State == Sys::Virt::Domain::STATE_CRASHED)
-  {
-    $self->{VM}->Status("off");
-    $self->{VM}->Save();
-  }
-  elsif ($self->{VM}->Status eq "off")
-  {
-    $self->{VM}->Status("dirty");
-    $self->{VM}->Save();
-  }
-
-  return undef;
-}
-
 sub _GetSnapshot($$)
 {
   my ($self, $SnapshotName) = @_;
@@ -233,7 +207,7 @@ sub RevertToSnapshot($)
 
   # Note that if the snapshot was of a powered off domain, this boots it up
   eval { $Snapshot->revert_to(Sys::Virt::DomainSnapshot::REVERT_RUNNING) };
-  return $@ ? $self->_Reset(_eval_err()) : $self->_UpdateStatus($Domain);
+  return $@ ? $self->_Reset(_eval_err()) : undef;
 }
 
 sub CreateSnapshot($)
@@ -279,9 +253,9 @@ sub IsPoweredOn($)
   return ($State == Sys::Virt::Domain::STATE_RUNNING);
 }
 
-sub PowerOff($$)
+sub PowerOff($)
 {
-  my ($self, $NoStatus) = @_;
+  my ($self) = @_;
 
   my ($ErrMessage, $Domain) = $self->_GetDomain();
   return $ErrMessage if (defined $ErrMessage);
@@ -298,9 +272,8 @@ sub PowerOff($$)
       $ErrMessage = "The VM is still active";
     }
   }
-  $ErrMessage ||= $self->_UpdateStatus($Domain) if (!$NoStatus);
-  return undef if (!defined $ErrMessage);
 
+  return undef if (!defined $ErrMessage);
   return $self->_Reset("Could not power off ". $self->{VM}->Name .": $ErrMessage");
 }
 
-- 
2.14.2




More information about the wine-patches mailing list