public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Michael Goldish <mgoldish@redhat.com>
To: autotest@test.kernel.org, kvm@vger.kernel.org
Subject: [KVM-AUTOTEST PATCH 3/4] KVM test: don't re-raise a background exception if something went wrong in the main thread
Date: Tue, 11 Jan 2011 20:33:21 +0200	[thread overview]
Message-ID: <1294770802-1501-3-git-send-email-mgoldish@redhat.com> (raw)
In-Reply-To: <1294770802-1501-1-git-send-email-mgoldish@redhat.com>

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

  parent reply	other threads:[~2011-01-11 18:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2011-01-11 18:33 ` [KVM-AUTOTEST PATCH 4/4] KVM test: VM.migrate(): make sure the VM is alive after migration Michael Goldish

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1294770802-1501-3-git-send-email-mgoldish@redhat.com \
    --to=mgoldish@redhat.com \
    --cc=autotest@test.kernel.org \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox