From patchwork Mon Dec 27 16:01:32 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 434331 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 oBRKCV9T025997 for ; Mon, 27 Dec 2010 20:16:52 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754340Ab0L0QCN (ORCPT ); Mon, 27 Dec 2010 11:02:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:19679 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754335Ab0L0QCM (ORCPT ); Mon, 27 Dec 2010 11:02:12 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oBRG2BOd024046 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 27 Dec 2010 11:02:11 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oBRG2BML030517; Mon, 27 Dec 2010 11:02:11 -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 oBRG1rFr017175; Mon, 27 Dec 2010 11:02:10 -0500 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH 05/28] KVM test: vmstop: use kvm_utils.Thread Date: Mon, 27 Dec 2010 18:01:32 +0200 Message-Id: <1293465715-16599-5-git-send-email-mgoldish@redhat.com> In-Reply-To: <1293465715-16599-1-git-send-email-mgoldish@redhat.com> References: <1293465715-16599-1-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 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]); Mon, 27 Dec 2010 20:16:52 +0000 (UTC) diff --git a/client/tests/kvm/tests/vmstop.py b/client/tests/kvm/tests/vmstop.py index 703c881..876c3ef 100644 --- a/client/tests/kvm/tests/vmstop.py +++ b/client/tests/kvm/tests/vmstop.py @@ -29,55 +29,54 @@ def run_vmstop(test, params, env): guest_path = params.get("guest_path", "/tmp") file_size = params.get("file_size", "1000") - bg = None try: utils.run("dd if=/dev/zero of=/tmp/file bs=1M count=%s" % file_size) # Transfer file from host to guest, we didn't expect the finish of # transfer, we just let it to be a kind of stress in guest. - bg = kvm_test_utils.BackgroundTest(vm.copy_files_to, - ("/tmp/file", guest_path, - 0, 60)) + bg = kvm_utils.Thread(vm.copy_files_to, ("/tmp/file", + guest_path, 0, 60)) logging.info("Start the background transfer") bg.start() - # wait for the transfer start - time.sleep(5) - logging.info("Stop the VM") - vm.monitor.cmd("stop") + try: + # wait for the transfer start + time.sleep(5) + logging.info("Stop the VM") + vm.monitor.cmd("stop") - # check with monitor - logging.info("Check the status through monitor") - if "paused" not in vm.monitor.info("status"): - raise error.TestFail("Guest did not pause after sending stop") + # check with monitor + logging.info("Check the status through monitor") + if "paused" not in vm.monitor.info("status"): + raise error.TestFail("Guest did not pause after sending stop") - # check through session - logging.info("Check the session") - if session.is_responsive(): - raise error.TestFail("Session still alive after sending stop") + # check through session + logging.info("Check the session") + if session.is_responsive(): + raise error.TestFail("Session still alive after sending stop") - # Check with the migration file - logging.info("Save and check the state files") - for p in [save1, save2]: - vm.save_to_file(p) - time.sleep(1) - if not os.path.isfile(p): - raise error.TestFail("VM failed to save state file %s" % p) + # Check with the migration file + logging.info("Save and check the state files") + for p in [save1, save2]: + vm.save_to_file(p) + time.sleep(1) + if not os.path.isfile(p): + raise error.TestFail("VM failed to save state file %s" % p) - # Fail if we see deltas - md5_save1 = utils.hash_file(save1) - md5_save2 = utils.hash_file(save2) - if md5_save1 != md5_save2: - raise error.TestFail("The produced state files differ") + # Fail if we see deltas + md5_save1 = utils.hash_file(save1) + md5_save2 = utils.hash_file(save2) + if md5_save1 != md5_save2: + raise error.TestFail("The produced state files differ") + finally: + bg.join() finally: + session.close() if clean_save: logging.debug("Clean the state files") if os.path.isfile(save1): os.remove(save1) if os.path.isfile(save2): os.remove(save2) - if bg: - bg.join() vm.monitor.cmd("cont") - session.close()