From patchwork Mon Sep 14 08:46:45 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 47256 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8E8nvNp022020 for ; Mon, 14 Sep 2009 08:49:57 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754810AbZINItw (ORCPT ); Mon, 14 Sep 2009 04:49:52 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754734AbZINItv (ORCPT ); Mon, 14 Sep 2009 04:49:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43423 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754671AbZINItv (ORCPT ); Mon, 14 Sep 2009 04:49:51 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8E8nrHD028726; Mon, 14 Sep 2009 04:49:53 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n8E8nq9T027857; Mon, 14 Sep 2009 04:49:53 -0400 Received: from localhost.localdomain (dhcp-1-188.tlv.redhat.com [10.35.1.188]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n8E8nocJ018130; Mon, 14 Sep 2009 04:49:50 -0400 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH 1/4] KVM test: migration test: destroy dest_vm if test fails Date: Mon, 14 Sep 2009 11:46:45 +0300 Message-Id: <1252918008-2742-1-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_tests.py | 94 ++++++++++++++++++++++------------------- 1 files changed, 50 insertions(+), 44 deletions(-) diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py index b61d98c..446b415 100644 --- a/client/tests/kvm/kvm_tests.py +++ b/client/tests/kvm/kvm_tests.py @@ -129,46 +129,54 @@ def run_migration(test, params, env): dest_vm = vm.clone() dest_vm.create(for_migration=True) - # Define the migration command - cmd = "migrate -d tcp:localhost:%d" % dest_vm.migration_port - logging.debug("Migration command: %s" % cmd) - - # Migrate - s, o = vm.send_monitor_cmd(cmd) - if s: - logging.error("Migration command failed (command: %r, output: %r)" % - (cmd, o)) - raise error.TestFail("Migration command failed") - - # Define some helper functions - def mig_finished(): - s, o = vm.send_monitor_cmd("info migrate") - return s == 0 and not "Migration status: active" in o - - def mig_succeeded(): - s, o = vm.send_monitor_cmd("info migrate") - return s == 0 and "Migration status: completed" in o - - def mig_failed(): - s, o = vm.send_monitor_cmd("info migrate") - return s == 0 and "Migration status: failed" in o - - # Wait for migration to finish - if not kvm_utils.wait_for(mig_finished, 90, 2, 2, - "Waiting for migration to finish..."): - raise error.TestFail("Timeout elapsed while waiting for migration to " - "finish") - - # Report migration status - if mig_succeeded(): - logging.info("Migration finished successfully") - elif mig_failed(): - raise error.TestFail("Migration failed") - else: - raise error.TestFail("Migration ended with unknown status") + try: + # Define the migration command + cmd = "migrate -d tcp:localhost:%d" % dest_vm.migration_port + logging.debug("Migration command: %s" % cmd) + + # Migrate + s, o = vm.send_monitor_cmd(cmd) + if s: + logging.error("Migration command failed (command: %r, output: %r)" + % (cmd, o)) + raise error.TestFail("Migration command failed") + + # Define some helper functions + def mig_finished(): + s, o = vm.send_monitor_cmd("info migrate") + return s == 0 and not "Migration status: active" in o + + def mig_succeeded(): + s, o = vm.send_monitor_cmd("info migrate") + return s == 0 and "Migration status: completed" in o + + def mig_failed(): + s, o = vm.send_monitor_cmd("info migrate") + return s == 0 and "Migration status: failed" in o + + # Wait for migration to finish + if not kvm_utils.wait_for(mig_finished, 90, 2, 2, + "Waiting for migration to finish..."): + raise error.TestFail("Timeout elapsed while waiting for migration " + "to finish") + + # Report migration status + if mig_succeeded(): + logging.info("Migration finished successfully") + elif mig_failed(): + raise error.TestFail("Migration failed") + else: + raise error.TestFail("Migration ended with unknown status") - # Kill the source VM - vm.destroy(gracefully=False) + # Kill the source VM + vm.destroy(gracefully=False) + + # Replace the source VM with the new cloned VM + kvm_utils.env_register_vm(env, params.get("main_vm"), dest_vm) + + except: + dest_vm.destroy(gracefully=False) + raise # Log into guest and get the output of migration_test_command logging.info("Logging into guest after migration...") @@ -189,13 +197,11 @@ def run_migration(test, params, env): logging.info("Command: %s" % params.get("migration_test_command")) logging.info("Output before:" + kvm_utils.format_str_for_message(reference_output)) - logging.info("Output after:" + kvm_utils.format_str_for_message(output)) + logging.info("Output after:" + + kvm_utils.format_str_for_message(output)) raise error.TestFail("Command produced different output before and " "after migration") - # Replace the main VM with the new cloned VM - kvm_utils.env_register_vm(env, params.get("main_vm"), dest_vm) - def run_autotest(test, params, env): """