diff mbox

KVM test: Replace some kvm_subprocess usage with utils.system

Message ID 1265261298-14521-1-git-send-email-lmr@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Lucas Meneghel Rodrigues Feb. 4, 2010, 5:28 a.m. UTC
None
diff mbox

Patch

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)