From patchwork Wed Dec 1 02:54:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 369531 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oB12sVQJ019684 for ; Wed, 1 Dec 2010 02:54:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754201Ab0LACy2 (ORCPT ); Tue, 30 Nov 2010 21:54:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:20390 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754200Ab0LACy1 (ORCPT ); Tue, 30 Nov 2010 21:54:27 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oB12sQwr001280 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 30 Nov 2010 21:54:26 -0500 Received: from freedom.redhat.com (vpn-11-100.rdu.redhat.com [10.11.11.100]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oB12sMIZ008171; Tue, 30 Nov 2010 21:54:25 -0500 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues Subject: [PATCH 4/4] KVM test: Modifications on the migrate utility function Date: Wed, 1 Dec 2010 00:54:20 -0200 Message-Id: <1291172060-14413-2-git-send-email-lmr@redhat.com> In-Reply-To: <1291172060-14413-1-git-send-email-lmr@redhat.com> References: <1291172060-14413-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Wed, 01 Dec 2010 02:54:31 +0000 (UTC) diff --git a/client/tests/kvm/kvm_test_utils.py b/client/tests/kvm/kvm_test_utils.py index 2269cd7..cdad442 100644 --- a/client/tests/kvm/kvm_test_utils.py +++ b/client/tests/kvm/kvm_test_utils.py @@ -133,7 +133,7 @@ def reboot(vm, session, method="shell", sleep_before_reset=10, nic_index=0, def migrate(vm, env=None, mig_timeout=3600, mig_protocol="tcp", - mig_cancel=False): + mig_cancel=False, dest_host='localhost', mig_port=None): """ Migrate a VM locally and re-register it in the environment. @@ -143,6 +143,8 @@ def migrate(vm, env=None, mig_timeout=3600, mig_protocol="tcp", @param mig_timeout: timeout value for migration. @param mig_protocol: migration protocol @param mig_cancel: Test migrate_cancel or not when protocol is tcp. + @param dest_host: Destination host (defaults to 'localhost'). + @param mig_port: Port that will be used for migration. @return: The post-migration VM. """ def mig_finished(): @@ -181,7 +183,8 @@ def migrate(vm, env=None, mig_timeout=3600, mig_protocol="tcp", raise error.TestFail("Timeout expired while waiting for migration " "to finish") - dest_vm = vm.clone() + if dest_host == 'localhost': + dest_vm = vm.clone() if mig_protocol == "exec": # Exec is a little different from other migrate methods - first we @@ -196,9 +199,11 @@ def migrate(vm, env=None, mig_timeout=3600, mig_protocol="tcp", vm.monitor.migrate(uri) wait_for_migration() - if not dest_vm.create(migration_mode=mig_protocol, - migration_exec_cmd=exec_cmd, mac_source=vm): - raise error.TestError("Could not create dest VM") + if dest_host == 'localhost': + if not dest_vm.create(migration_mode=mig_protocol, + migration_exec_cmd=exec_cmd, + mac_source=vm): + raise error.TestError("Could not create dest VM") finally: logging.debug("Removing migration file %s", exec_file) try: @@ -206,11 +211,15 @@ def migrate(vm, env=None, mig_timeout=3600, mig_protocol="tcp", except OSError: pass else: - if not dest_vm.create(migration_mode=mig_protocol, mac_source=vm): - raise error.TestError("Could not create dest VM") + if dest_host == 'localhost': + if not dest_vm.create(migration_mode=mig_protocol, mac_source=vm): + raise error.TestError("Could not create dest VM") try: if mig_protocol == "tcp": - uri = "tcp:localhost:%d" % dest_vm.migration_port + if dest_host == 'localhost': + uri = "tcp:localhost:%d" % dest_vm.migration_port + else: + uri = 'tcp:%s:%d' % (dest_host, mig_port) elif mig_protocol == "unix": uri = "unix:%s" % dest_vm.migration_file vm.monitor.migrate(uri) @@ -222,12 +231,14 @@ def migrate(vm, env=None, mig_timeout=3600, mig_protocol="tcp", "Waiting for migration " "cancellation"): raise error.TestFail("Failed to cancel migration") - dest_vm.destroy(gracefully=False) + if dest_host == 'localhost': + dest_vm.destroy(gracefully=False) return vm else: wait_for_migration() except: - dest_vm.destroy() + if dest_host == 'localhost': + dest_vm.destroy() raise # Report migration status