From patchwork Tue Dec 28 15:43:09 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 436621 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 oBSFiIgt022292 for ; Tue, 28 Dec 2010 15:44:18 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754158Ab0L1PoP (ORCPT ); Tue, 28 Dec 2010 10:44:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46883 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754123Ab0L1PoN (ORCPT ); Tue, 28 Dec 2010 10:44:13 -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 oBSFiA3K006080 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 28 Dec 2010 10:44:10 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oBSFiAko028711; Tue, 28 Dec 2010 10:44:10 -0500 Received: from moof.tlv.redhat.com (dhcp-1-185.tlv.redhat.com [10.35.1.185]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id oBSFi39g019837; Tue, 28 Dec 2010 10:44:08 -0500 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish , Eduardo Habkost Subject: [KVM-AUTOTEST PATCH 3/4] KVM test: use the new Env methods instead of the old env_* functions Date: Tue, 28 Dec 2010 17:43:09 +0200 Message-Id: <1293550990-10669-4-git-send-email-mgoldish@redhat.com> In-Reply-To: <1293550990-10669-1-git-send-email-mgoldish@redhat.com> References: <1293550990-10669-1-git-send-email-mgoldish@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, 28 Dec 2010 15:44:19 +0000 (UTC) diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py index 9d942d3..7d7bf55 100644 --- a/client/tests/kvm/kvm.py +++ b/client/tests/kvm/kvm.py @@ -106,7 +106,7 @@ class kvm(test.test): raise # Abort on error logging.info("Aborting job (%s)", e) - for vm in kvm_utils.env_get_all_vms(env): + for vm in env.get_all_vms(): if vm.is_dead(): continue logging.info("VM '%s' is alive.", vm.name) diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py index 25c4e5f..4daafec 100644 --- a/client/tests/kvm/kvm_preprocessing.py +++ b/client/tests/kvm/kvm_preprocessing.py @@ -50,13 +50,13 @@ def preprocess_vm(test, params, env, name): @param name: The name of the VM object. """ logging.debug("Preprocessing VM '%s'..." % name) - vm = kvm_utils.env_get_vm(env, name) + vm = env.get_vm(name) if vm: logging.debug("VM object found in environment") else: logging.debug("VM object does not exist; creating it") vm = kvm_vm.VM(name, params, test.bindir, env.get("address_cache")) - kvm_utils.env_register_vm(env, name, vm) + env.register_vm(name, vm) start_vm = False @@ -122,7 +122,7 @@ def postprocess_vm(test, params, env, name): @param name: The name of the VM object. """ logging.debug("Postprocessing VM '%s'..." % name) - vm = kvm_utils.env_get_vm(env, name) + vm = env.get_vm(name) if vm: logging.debug("VM object found in environment") else: @@ -338,7 +338,7 @@ def postprocess(test, params, env): if params.get("kill_unresponsive_vms") == "yes": logging.debug("'kill_unresponsive_vms' specified; killing all VMs " "that fail to respond to a remote login request...") - for vm in kvm_utils.env_get_all_vms(env): + for vm in env.get_all_vms(): if vm.is_alive(): session = vm.remote_login() if session: @@ -350,7 +350,7 @@ def postprocess(test, params, env): kvm_subprocess.kill_tail_threads() # Terminate tcpdump if no VMs are alive - living_vms = [vm for vm in kvm_utils.env_get_all_vms(env) if vm.is_alive()] + living_vms = [vm for vm in env.get_all_vms() if vm.is_alive()] if not living_vms and "tcpdump" in env: env["tcpdump"].close() del env["tcpdump"] @@ -408,7 +408,7 @@ def _take_screendumps(test, params, env): cache = {} while True: - for vm in kvm_utils.env_get_all_vms(env): + for vm in env.get_all_vms(): if not vm.is_alive(): continue try: diff --git a/client/tests/kvm/kvm_test_utils.py b/client/tests/kvm/kvm_test_utils.py index 6569d3b..7ed3330 100644 --- a/client/tests/kvm/kvm_test_utils.py +++ b/client/tests/kvm/kvm_test_utils.py @@ -35,7 +35,7 @@ def get_living_vm(env, vm_name): @param vm_name: Name of the desired VM object. @return: A VM object. """ - vm = kvm_utils.env_get_vm(env, vm_name) + vm = env.get_vm(vm_name) if not vm: raise error.TestError("VM '%s' not found in environment" % vm_name) if not vm.is_alive(): @@ -275,7 +275,7 @@ def migrate(vm, env=None, mig_timeout=3600, mig_protocol="tcp", # Replace the source VM with the new cloned VM if (dest_host == 'localhost') and (env is not None): - kvm_utils.env_register_vm(env, vm.name, dest_vm) + env.register_vm(vm.name, dest_vm) # Return the new cloned VM if dest_host == 'localhost': diff --git a/client/tests/kvm/tests/ksm_overcommit.py b/client/tests/kvm/tests/ksm_overcommit.py index deadda1..c6368d3 100644 --- a/client/tests/kvm/tests/ksm_overcommit.py +++ b/client/tests/kvm/tests/ksm_overcommit.py @@ -544,7 +544,7 @@ def run_ksm_overcommit(test, params, env): # Creating the first guest kvm_preprocessing.preprocess_vm(test, params, env, vm_name) - lvms.append(kvm_utils.env_get_vm(env, vm_name)) + lvms.append(env.get_vm(vm_name)) if not lvms[0]: raise error.TestError("VM object not found in environment") if not lvms[0].is_alive(): @@ -575,7 +575,7 @@ def run_ksm_overcommit(test, params, env): # Last VM is later used to run more allocators simultaneously lvms.append(lvms[0].clone(vm_name, params)) - kvm_utils.env_register_vm(env, vm_name, lvms[i]) + env.register_vm(vm_name, lvms[i]) params['vms'] += " " + vm_name logging.debug("Booting guest %s" % lvms[i].name) diff --git a/client/tests/kvm/tests/qemu_img.py b/client/tests/kvm/tests/qemu_img.py index 39b7427..6351a84 100644 --- a/client/tests/kvm/tests/qemu_img.py +++ b/client/tests/kvm/tests/qemu_img.py @@ -289,7 +289,7 @@ def run_qemu_img(test, params, env): # Start a new VM, using backing file as its harddisk vm_name = params.get('main_vm') kvm_preprocessing.preprocess_vm(test, params, env, vm_name) - vm = kvm_utils.env_get_vm(env, vm_name) + vm = env.get_vm(vm_name) vm.create() timeout = int(params.get("login_timeout", 360)) session = kvm_test_utils.wait_for_login(vm, timeout=timeout) @@ -317,7 +317,7 @@ def run_qemu_img(test, params, env): # Here, the commit_testfile should not exist vm_name = params.get('main_vm') kvm_preprocessing.preprocess_vm(test, params, env, vm_name) - vm = kvm_utils.env_get_vm(env, vm_name) + vm = env.get_vm(vm_name) vm.create() timeout = int(params.get("login_timeout", 360)) session = kvm_test_utils.wait_for_login(vm, timeout=timeout) @@ -343,7 +343,7 @@ def run_qemu_img(test, params, env): # Start a new VM, using image_name as its harddisk vm_name = params.get('main_vm') kvm_preprocessing.preprocess_vm(test, params, env, vm_name) - vm = kvm_utils.env_get_vm(env, vm_name) + vm = env.get_vm(vm_name) vm.create() timeout = int(params.get("login_timeout", 360)) session = kvm_test_utils.wait_for_login(vm, timeout=timeout) diff --git a/client/tests/kvm/tests/stepmaker.py b/client/tests/kvm/tests/stepmaker.py index ee0ed92..9f6d9b2 100755 --- a/client/tests/kvm/tests/stepmaker.py +++ b/client/tests/kvm/tests/stepmaker.py @@ -337,7 +337,7 @@ class StepMaker(stepeditor.StepMakerWindow): def run_stepmaker(test, params, env): - vm = kvm_utils.env_get_vm(env, params.get("main_vm")) + vm = env.get_vm(params.get("main_vm")) if not vm: raise error.TestError("VM object not found in environment") if not vm.is_alive(): diff --git a/client/tests/kvm/tests/steps.py b/client/tests/kvm/tests/steps.py index 6f782f5..5d4ed25 100644 --- a/client/tests/kvm/tests/steps.py +++ b/client/tests/kvm/tests/steps.py @@ -181,7 +181,7 @@ def barrier_2(vm, words, params, debug_dir, data_scrdump_filename, def run_steps(test, params, env): - vm = kvm_utils.env_get_vm(env, params.get("main_vm")) + vm = env.get_vm(params.get("main_vm")) if not vm: raise error.TestError("VM object not found in environment") if not vm.is_alive(): diff --git a/client/tests/kvm/tests/stress_boot.py b/client/tests/kvm/tests/stress_boot.py index 13dc944..37d853b 100644 --- a/client/tests/kvm/tests/stress_boot.py +++ b/client/tests/kvm/tests/stress_boot.py @@ -36,7 +36,7 @@ def run_stress_boot(tests, params, env): vm_name = "vm" + str(num) vm_params = vm.get_params().copy() curr_vm = vm.clone(vm_name, vm_params) - kvm_utils.env_register_vm(env, vm_name, curr_vm) + env.register_vm(vm_name, curr_vm) logging.info("Booting guest #%d" % num) kvm_preprocessing.preprocess_vm(tests, vm_params, env, vm_name) params['vms'] += " " + vm_name diff --git a/client/tests/kvm/tests/unittest.py b/client/tests/kvm/tests/unittest.py index 67686e3..c724051 100644 --- a/client/tests/kvm/tests/unittest.py +++ b/client/tests/kvm/tests/unittest.py @@ -88,7 +88,7 @@ def run_unittest(test, params, env): try: vm_name = params.get('main_vm') kvm_preprocessing.preprocess_vm(test, params, env, vm_name) - vm = kvm_utils.env_get_vm(env, vm_name) + vm = env.get_vm(vm_name) vm.create() vm.monitor.cmd("cont") logging.info("Waiting for unittest %s to complete, timeout %s, " diff --git a/client/tests/kvm/tests/virtio_console.py b/client/tests/kvm/tests/virtio_console.py index a51e309..fea3685 100644 --- a/client/tests/kvm/tests/virtio_console.py +++ b/client/tests/kvm/tests/virtio_console.py @@ -583,7 +583,7 @@ def run_virtio_console(test, params, env): kvm_preprocessing.preprocess_vm(test, params, env, params.get("main_vm")) - vm = kvm_utils.env_get_vm(env, params.get("main_vm")) + vm = env.get_vm(params.get("main_vm")) session = kvm_test_utils.wait_for_login(vm, 0, float(params.get("boot_timeout", 240)),