public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [KVM-AUTOTEST PATCH 1/4] KVM test: kvm_vm.py: add status and output to VMDeadError
@ 2011-01-11 18:33 Michael Goldish
  2011-01-11 18:33 ` [KVM-AUTOTEST PATCH 2/4] KVM test: kvm_utils.Thread.join(): allow suppressing the exception Michael Goldish
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Michael Goldish @ 2011-01-11 18:33 UTC (permalink / raw)
  To: autotest, kvm

Signed-off-by: Michael Goldish <mgoldish@redhat.com>
---
 client/tests/kvm/kvm_vm.py |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index 0403569..a69a191 100755
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -86,7 +86,14 @@ class VMKVMInitError(VMPostCreateError):
 
 
 class VMDeadError(VMError):
-    pass
+    def __init__(self, status, output):
+        VMError.__init__(self, status, output)
+        self.status = status
+        self.output = output
+
+    def __str__(self):
+        return ("VM process is dead    (status: %s,    output: %r)" %
+                (self.status, self.output))
 
 
 class VMAddressError(VMError):
@@ -1016,7 +1023,8 @@ class VM:
         @raise: Various monitor exceptions if the monitor is unresponsive
         """
         if self.is_dead():
-            raise VMDeadError("VM is dead")
+            raise VMDeadError(self.process.get_status(),
+                              self.process.get_output())
         if self.monitors:
             self.monitor.verify_responsive()
 
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [KVM-AUTOTEST PATCH 2/4] KVM test: kvm_utils.Thread.join(): allow suppressing the exception
  2011-01-11 18:33 [KVM-AUTOTEST PATCH 1/4] KVM test: kvm_vm.py: add status and output to VMDeadError Michael Goldish
@ 2011-01-11 18:33 ` Michael Goldish
  2011-01-11 18:33 ` [KVM-AUTOTEST PATCH 3/4] KVM test: don't re-raise a background exception if something went wrong in the main thread Michael Goldish
  2011-01-11 18:33 ` [KVM-AUTOTEST PATCH 4/4] KVM test: VM.migrate(): make sure the VM is alive after migration Michael Goldish
  2 siblings, 0 replies; 4+ messages in thread
From: Michael Goldish @ 2011-01-11 18:33 UTC (permalink / raw)
  To: autotest, kvm

If suppress_exception is True, the exception raised in the thread will not be
re-raised.

Signed-off-by: Michael Goldish <mgoldish@redhat.com>
---
 client/tests/kvm/kvm_utils.py |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py
index 8e6cef1..d55594c 100644
--- a/client/tests/kvm/kvm_utils.py
+++ b/client/tests/kvm/kvm_utils.py
@@ -1188,22 +1188,24 @@ class Thread(threading.Thread):
             del self._target, self._args, self._kwargs
 
 
-    def join(self, timeout=None):
+    def join(self, timeout=None, suppress_exception=False):
         """
         Join the thread.  If target raised an exception, re-raise it.
         Otherwise, return the value returned by target.
 
         @param timeout: Timeout value to pass to threading.Thread.join().
+        @param suppress_exception: If True, don't re-raise the exception.
         """
         threading.Thread.join(self, timeout)
         try:
             if self._e:
-                # Because the exception was raised in another thread, we need
-                # to explicitly insert the current context into it
-                s = error.exception_context(self._e[1])
-                s = error.join_contexts(error.get_context(), s)
-                error.set_exception_context(self._e[1], s)
-                raise self._e[0], self._e[1], self._e[2]
+                if not suppress_exception:
+                    # Because the exception was raised in another thread, we
+                    # need to explicitly insert the current context into it
+                    s = error.exception_context(self._e[1])
+                    s = error.join_contexts(error.get_context(), s)
+                    error.set_exception_context(self._e[1], s)
+                    raise self._e[0], self._e[1], self._e[2]
             else:
                 return self._retval
         finally:
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [KVM-AUTOTEST PATCH 3/4] KVM test: don't re-raise a background exception if something went wrong in the main thread
  2011-01-11 18:33 [KVM-AUTOTEST PATCH 1/4] KVM test: kvm_vm.py: add status and output to VMDeadError Michael Goldish
  2011-01-11 18:33 ` [KVM-AUTOTEST PATCH 2/4] KVM test: kvm_utils.Thread.join(): allow suppressing the exception Michael Goldish
@ 2011-01-11 18:33 ` Michael Goldish
  2011-01-11 18:33 ` [KVM-AUTOTEST PATCH 4/4] KVM test: VM.migrate(): make sure the VM is alive after migration Michael Goldish
  2 siblings, 0 replies; 4+ messages in thread
From: Michael Goldish @ 2011-01-11 18:33 UTC (permalink / raw)
  To: autotest, kvm

Signed-off-by: Michael Goldish <mgoldish@redhat.com>
---
 .../kvm/tests/migration_with_file_transfer.py      |    7 ++++++-
 client/tests/kvm/tests/migration_with_reboot.py    |    7 ++++++-
 client/tests/kvm/tests/vmstop.py                   |    5 +----
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/client/tests/kvm/tests/migration_with_file_transfer.py b/client/tests/kvm/tests/migration_with_file_transfer.py
index 4064b4a..734fe35 100644
--- a/client/tests/kvm/tests/migration_with_file_transfer.py
+++ b/client/tests/kvm/tests/migration_with_file_transfer.py
@@ -46,7 +46,12 @@ def run_migration_with_file_transfer(test, params, env):
                     logging.info("File transfer not ended, starting a round of "
                                  "migration...")
                     vm.migrate(mig_timeout, mig_protocol, mig_cancel_delay)
-            finally:
+            except:
+                # If something bad happened in the main thread, ignore
+                # exceptions raised in the background thread
+                bg.join(suppress_exception=True)
+                raise
+            else:
                 bg.join()
 
         error.context("transferring file to guest while migrating",
diff --git a/client/tests/kvm/tests/migration_with_reboot.py b/client/tests/kvm/tests/migration_with_reboot.py
index 671f1ef..0688282 100644
--- a/client/tests/kvm/tests/migration_with_reboot.py
+++ b/client/tests/kvm/tests/migration_with_reboot.py
@@ -35,7 +35,12 @@ def run_migration_with_reboot(test, params, env):
         try:
             while bg.is_alive():
                 vm.migrate(mig_timeout, mig_protocol, mig_cancel_delay)
-        finally:
+        except:
+            # If something bad happened in the main thread, ignore exceptions
+            # raised in the background thread
+            bg.join(suppress_exception=True)
+            raise
+        else:
             session = bg.join()
     finally:
         session.close()
diff --git a/client/tests/kvm/tests/vmstop.py b/client/tests/kvm/tests/vmstop.py
index 4d47471..1dd6dcf 100644
--- a/client/tests/kvm/tests/vmstop.py
+++ b/client/tests/kvm/tests/vmstop.py
@@ -70,10 +70,7 @@ def run_vmstop(test, params, env):
             if md5_save1 != md5_save2:
                 raise error.TestFail("The produced state files differ")
         finally:
-            try:
-                bg.join()
-            except:
-                pass
+            bg.join(suppress_exception=True)
 
     finally:
         session.close()
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [KVM-AUTOTEST PATCH 4/4] KVM test: VM.migrate(): make sure the VM is alive after migration
  2011-01-11 18:33 [KVM-AUTOTEST PATCH 1/4] KVM test: kvm_vm.py: add status and output to VMDeadError Michael Goldish
  2011-01-11 18:33 ` [KVM-AUTOTEST PATCH 2/4] KVM test: kvm_utils.Thread.join(): allow suppressing the exception Michael Goldish
  2011-01-11 18:33 ` [KVM-AUTOTEST PATCH 3/4] KVM test: don't re-raise a background exception if something went wrong in the main thread Michael Goldish
@ 2011-01-11 18:33 ` Michael Goldish
  2 siblings, 0 replies; 4+ messages in thread
From: Michael Goldish @ 2011-01-11 18:33 UTC (permalink / raw)
  To: autotest, kvm

Also add a context() call to make the VMDeadError exception more descriptive.

Signed-off-by: Michael Goldish <mgoldish@redhat.com>
---
 client/tests/kvm/kvm_vm.py |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index a69a191..18d10ef 100755
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -1499,6 +1499,11 @@ class VM:
             # and self is the destination VM that will remain alive.  If this
             # is remote migration, self is a dead VM object.
 
+            error.context("after migration")
+            if local:
+                time.sleep(1)
+                self.verify_alive()
+
             if local and stable_check:
                 try:
                     save1 = os.path.join(save_path, "src-" + clone.instance)
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-01-11 18:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-11 18:33 [KVM-AUTOTEST PATCH 1/4] KVM test: kvm_vm.py: add status and output to VMDeadError Michael Goldish
2011-01-11 18:33 ` [KVM-AUTOTEST PATCH 2/4] KVM test: kvm_utils.Thread.join(): allow suppressing the exception Michael Goldish
2011-01-11 18:33 ` [KVM-AUTOTEST PATCH 3/4] KVM test: don't re-raise a background exception if something went wrong in the main thread Michael Goldish
2011-01-11 18:33 ` [KVM-AUTOTEST PATCH 4/4] KVM test: VM.migrate(): make sure the VM is alive after migration Michael Goldish

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox