Francois Gouget : testbot/LibvirtTool: Detect if a VM is booting after a revert.

Alexandre Julliard julliard at winehq.org
Fri Sep 20 15:39:35 CDT 2019


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

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Fri Sep 20 15:04:21 2019 +0200

testbot/LibvirtTool: Detect if a VM is booting after a revert.

And adjust the TestAgent connection timeout accordingly.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 testbot/bin/LibvirtTool.pl               |  6 +++---
 testbot/lib/WineTestBot/LibvirtDomain.pm | 13 +++++++++++--
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/testbot/bin/LibvirtTool.pl b/testbot/bin/LibvirtTool.pl
index dca5a92..60e868e 100755
--- a/testbot/bin/LibvirtTool.pl
+++ b/testbot/bin/LibvirtTool.pl
@@ -366,7 +366,7 @@ sub Revert()
   # Revert the VM (and power it on if necessary)
   my $Domain = $VM->GetDomain();
   Debug(Elapsed($Start), " Reverting $VMKey to ", $VM->IdleSnapshot, "\n");
-  my $ErrMessage = $Domain->RevertToSnapshot();
+  my ($ErrMessage, $Booting) = $Domain->RevertToSnapshot();
   if (defined $ErrMessage)
   {
     # Libvirt/QEmu is buggy and cannot revert a running VM from one hardware
@@ -380,7 +380,7 @@ sub Revert()
     }
 
     Debug(Elapsed($Start), " Reverting $VMKey to ", $VM->IdleSnapshot, "... again\n");
-    $ErrMessage = $Domain->RevertToSnapshot();
+    ($ErrMessage, $Booting) = $Domain->RevertToSnapshot();
   }
   if (defined $ErrMessage)
   {
@@ -394,7 +394,7 @@ sub Revert()
   Debug(Elapsed($Start), " Verifying the TestAgent server\n");
   LogMsg "Verifying the $VMKey TestAgent server\n";
   my $TA = $VM->GetAgent();
-  $TA->SetConnectTimeout(undef, undef, $WaitForBoot);
+  $TA->SetConnectTimeout(undef, undef, $WaitForBoot) if ($Booting);
   my $Success = $TA->Ping();
   $TA->Disconnect();
   if (!$Success)
diff --git a/testbot/lib/WineTestBot/LibvirtDomain.pm b/testbot/lib/WineTestBot/LibvirtDomain.pm
index f0a8c69..bb68bd0 100644
--- a/testbot/lib/WineTestBot/LibvirtDomain.pm
+++ b/testbot/lib/WineTestBot/LibvirtDomain.pm
@@ -313,11 +313,20 @@ sub RevertToSnapshot($)
 
   my $SnapshotName = $self->{VM}->IdleSnapshot;
   my ($ErrMessage, $Domain, $Snapshot) = $self->_GetSnapshot($SnapshotName);
-  return $ErrMessage if (defined $ErrMessage);
+  return ($ErrMessage, undef) if (defined $ErrMessage);
 
   # 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()) : undef;
+  return $self->_Reset(_eval_err(), undef) if ($@);
+
+  my ($State, $Reason) = $Domain->get_state();
+  if ($State != Sys::Virt::Domain::STATE_RUNNING)
+  {
+    return ($self->{VM}->Name ." is not running (".
+            _GetStateDescription($State, $Reason)
+            .") after revert to $SnapshotName", undef);
+  }
+  return (undef, $Reason != Sys::Virt::Domain::STATE_RUNNING_FROM_SNAPSHOT);
 }
 
 sub CreateSnapshot($)




More information about the wine-cvs mailing list