From patchwork Thu Feb 4 05:28:18 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: 76896 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o145SR3Y024007 for ; Thu, 4 Feb 2010 05:28:29 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751421Ab0BDF2Z (ORCPT ); Thu, 4 Feb 2010 00:28:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:27437 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751220Ab0BDF2Y (ORCPT ); Thu, 4 Feb 2010 00:28:24 -0500 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o145SNNp018784 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 4 Feb 2010 00:28:23 -0500 Received: from localhost.localdomain (vpn-10-106.rdu.redhat.com [10.11.10.106]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o145SLmf030626; Thu, 4 Feb 2010 00:28:22 -0500 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, mgoldish@redhat.com, Lucas Meneghel Rodrigues Subject: [PATCH] KVM test: Replace some kvm_subprocess usage with utils.system Date: Thu, 4 Feb 2010 03:28:18 -0200 Message-Id: <1265261298-14521-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 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 (demeter.kernel.org [140.211.167.41]); Thu, 04 Feb 2010 05:28:29 +0000 (UTC) diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py index 53fa2cb..8a0c151 100644 --- a/client/tests/kvm/kvm_preprocessing.py +++ b/client/tests/kvm/kvm_preprocessing.py @@ -1,5 +1,5 @@ import sys, os, time, commands, re, logging, signal, glob -from autotest_lib.client.bin import test +from autotest_lib.client.bin import test, utils from autotest_lib.client.common_lib import error import kvm_vm, kvm_utils, kvm_subprocess, ppm_utils try: @@ -142,17 +142,14 @@ def process_command(test, params, env, command, command_timeout, for k in params.keys(): os.putenv("KVM_TEST_%s" % k, str(params[k])) # Execute command - logging.info("Executing command '%s'..." % command) - (status, output) = kvm_subprocess.run_fg("cd %s; %s" % (test.bindir, - command), - logging.debug, "(command) ", - timeout=command_timeout) - if status != 0: - logging.warn("Custom processing command failed: '%s'; Output is: %s" % - (command, output)) + try: + utils.system("cd %s; %s" % (test.bindir, command)) + except error.CmdError, e: + logging.warn("Custom processing command '%s' failed, output is: %s", + command, str(e)) if not command_noncritical: raise error.TestError("Custom processing command failed: %s" % - output) + str(e)) def process(test, params, env, image_func, vm_func): diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py index db903a0..d7b3608 100755 --- a/client/tests/kvm/kvm_vm.py +++ b/client/tests/kvm/kvm_vm.py @@ -7,6 +7,9 @@ Utility classes and functions to handle Virtual Machine creation using qemu. import time, socket, os, logging, fcntl, re, commands import kvm_utils, kvm_subprocess +import common +from autotest_lib.client.common_lib import error +from autotest_lib.client.bin import utils def get_image_filename(params, root_dir): @@ -53,20 +56,13 @@ def create_image(params, root_dir): size = params.get("image_size", "10G") qemu_img_cmd += " %s" % size - logging.debug("Running qemu-img command:\n%s" % qemu_img_cmd) - (status, output) = kvm_subprocess.run_fg(qemu_img_cmd, logging.debug, - "(qemu-img) ", timeout=120) - - if status is None: - logging.error("Timeout elapsed while waiting for qemu-img command " - "to complete:\n%s" % qemu_img_cmd) - return None - elif status != 0: - logging.error("Could not create image; " - "qemu-img command failed:\n%s" % qemu_img_cmd) - logging.error("Status: %s" % status) - logging.error("Output:" + kvm_utils.format_str_for_message(output)) + try: + utils.system(qemu_img_cmd) + except error.CmdError, e: + logging.error("Could not create image; qemu-img command failed:\n%s", + str(e)) return None + if not os.path.exists(image_filename): logging.error("Image could not be created for some reason; " "qemu-img command:\n%s" % qemu_img_cmd)