From patchwork Mon Dec 20 16:57:33 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: 422461 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 oBL0RA9U011307 for ; Tue, 21 Dec 2010 00:31:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933171Ab0LTU7Q (ORCPT ); Mon, 20 Dec 2010 15:59:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:8235 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933231Ab0LTU7K (ORCPT ); Mon, 20 Dec 2010 15:59:10 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oBKKx9Ox026207 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 20 Dec 2010 15:59:09 -0500 Received: from autotest.virt.bos.redhat.com (autotest.virt.bos.redhat.com [10.16.72.47]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oBKKx7NU021469; Mon, 20 Dec 2010 15:59:09 -0500 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues Subject: [PATCH 4/5] KVM test: Modifications on the migrate utility function Date: Mon, 20 Dec 2010 11:57:33 -0500 Message-Id: <1292864254-6782-4-git-send-email-lmr@redhat.com> In-Reply-To: <1292864254-6782-1-git-send-email-lmr@redhat.com> References: <1292864254-6782-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 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]); Tue, 21 Dec 2010 00:31:17 +0000 (UTC) diff --git a/client/tests/kvm/kvm_test_utils.py b/client/tests/kvm/kvm_test_utils.py index d0f2e6c..2a3a062 100644 --- a/client/tests/kvm/kvm_test_utils.py +++ b/client/tests/kvm/kvm_test_utils.py @@ -134,7 +134,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, offline=False, stable_check=False, - clean=False, save_path=None): + clean=False, save_path=None, dest_host='localhost', mig_port=None): """ Migrate a VM locally and re-register it in the environment. @@ -144,7 +144,10 @@ 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. - @return: The post-migration VM. + @param dest_host: Destination host (defaults to 'localhost'). + @param mig_port: Port that will be used for migration. + @return: The post-migration VM, in case of same host migration, True in + case of multi-host migration. """ def mig_finished(): o = vm.monitor.info("migrate") @@ -182,18 +185,25 @@ 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 stable_check: + if dest_host == 'localhost': + dest_vm = vm.clone() + + if (dest_host == 'localhost') and stable_check: # Pause the dest vm after creation dest_vm.params['extra_params'] = (dest_vm.params.get('extra_params','') + ' -S') - 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: 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 elif mig_protocol == "exec": @@ -212,11 +222,12 @@ def migrate(vm, env=None, mig_timeout=3600, mig_protocol="tcp", raise error.TestFail("Failed to cancel migration") if offline: vm.monitor.cmd("cont") - dest_vm.destroy(gracefully=False) + if dest_host == 'localhost': + dest_vm.destroy(gracefully=False) return vm else: wait_for_migration() - if stable_check: + if (dest_host == 'localhost') and stable_check: save_path = None or "/tmp" save1 = os.path.join(save_path, "src") save2 = os.path.join(save_path, "dst") @@ -231,14 +242,15 @@ def migrate(vm, env=None, mig_timeout=3600, mig_protocol="tcp", raise error.TestFail("Mismatch of VM state before " "and after migration") - if offline: + if (dest_host == 'localhost') and offline: dest_vm.monitor.cmd("cont") except: - dest_vm.destroy() + if dest_host == 'localhost': + dest_vm.destroy() raise finally: - if stable_check and clean: + if (dest_host == 'localhost') and stable_check and clean: logging.debug("Cleaning the state files") if os.path.isfile(save1): os.remove(save1) @@ -253,19 +265,23 @@ def migrate(vm, env=None, mig_timeout=3600, mig_protocol="tcp", else: raise error.TestFail("Migration ended with unknown status") - if "paused" in dest_vm.monitor.info("status"): - logging.debug("Destination VM is paused, resuming it...") - dest_vm.monitor.cmd("cont") + if dest_host == 'localhost': + if "paused" in dest_vm.monitor.info("status"): + logging.debug("Destination VM is paused, resuming it...") + dest_vm.monitor.cmd("cont") # Kill the source VM vm.destroy(gracefully=False) # Replace the source VM with the new cloned VM - if env is not None: + if (dest_host == 'localhost') and (env is not None): kvm_utils.env_register_vm(env, vm.name, dest_vm) # Return the new cloned VM - return dest_vm + if dest_host == 'localhost': + return dest_vm + else: + return vm def stop_windows_service(session, service, timeout=120):