The preprocessing command and qemu-img command are currently ran using kvm_subprocess. However, those commands have no need to use that API, considering that we don't need to interact with those commands or make them persist between tests. Using utils.system() instead of kvm_subprocess speeds up the command execution, and simplifies the code a bit. Signed-off-by: Lucas Meneghel Rodrigues <lmr@xxxxxxxxxx> --- client/tests/kvm/kvm_preprocessing.py | 17 +++++++---------- client/tests/kvm/kvm_vm.py | 28 ++++++++++++---------------- 2 files changed, 19 insertions(+), 26 deletions(-) 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) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html