[PATCH 2/4] testbot: Check the current snapshot in LibvirtTool monitor.

Francois Gouget fgouget at codeweavers.com
Tue Feb 27 18:54:45 CST 2018


If the snapshot does not match when the hypervisor domain becomes
accessible again, then don't try to power if off and just mark the
VM instance as off.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
 testbot/bin/LibvirtTool.pl | 44 ++++++++++++++++++++++++++++++--------------
 1 file changed, 30 insertions(+), 14 deletions(-)

diff --git a/testbot/bin/LibvirtTool.pl b/testbot/bin/LibvirtTool.pl
index 12eaa669f..0293baeb7 100755
--- a/testbot/bin/LibvirtTool.pl
+++ b/testbot/bin/LibvirtTool.pl
@@ -277,23 +277,39 @@ sub Monitor()
       return 0;
     }
 
-    my $IsPoweredOn = $VM->GetDomain()->IsPoweredOn();
-    if ($IsPoweredOn)
+    my ($ErrMessage, $SnapshotName) = $VM->GetDomain()->GetSnapshotName();
+    if (defined $ErrMessage)
     {
-      my $ErrMessage = $VM->GetDomain()->PowerOff();
-      if (defined $ErrMessage)
-      {
-        Error "$ErrMessage\n";
-        $IsPoweredOn = undef;
-      }
+      Error "$ErrMessage\n";
     }
-    if (defined $IsPoweredOn)
+    else
     {
-      return 1 if (ChangeStatus("offline", "off", "done"));
-      NotifyAdministrator("The $VMKey VM is working again",
-                          "The $VMKey VM started working again after ".
-                          Elapsed($Start) ." seconds.");
-      return 0;
+      my $IsPoweredOn;
+      if (!defined $SnapshotName or $SnapshotName ne $VM->IdleSnapshot)
+      {
+        $IsPoweredOn = 0;
+      }
+      else
+      {
+        $IsPoweredOn = $VM->GetDomain()->IsPoweredOn();
+        if ($IsPoweredOn)
+        {
+          $ErrMessage = $VM->GetDomain()->PowerOff();
+          if (defined $ErrMessage)
+          {
+            Error "$ErrMessage\n";
+            $IsPoweredOn = undef;
+          }
+        }
+      }
+      if (defined $IsPoweredOn)
+      {
+        return 1 if (ChangeStatus("offline", "off", "done"));
+        NotifyAdministrator("The $VMKey VM is working again",
+                            "The $VMKey VM started working again after ".
+                            Elapsed($Start) ." seconds.");
+        return 0;
+      }
     }
 
     Debug(Elapsed($Start), " $VMKey is still unreachable\n");
-- 
2.16.1




More information about the wine-devel mailing list