This patch will change utils.system() to utils.system_output()
to get command output.
Also use error.context in create() function.

BZID:
https://bugzilla.redhat.com/show_bug.cgi?id=845174

Change from v1:
Delete debug logging.info.
Change from v2:
As we discuss before, we want log command to info file.
So in this version, will disable command log in utils.system_output()
and log the command in error.context.
Hope we can reach an internal consensus,  then will send these
 patch to upstream.
Also add a new patch to control log command in utils.system() and
utils.system_output() or not.
[PATCH 3/3] KVM Test: Add verbose parameter to utils.system to control
 log cmd or not

Signed-off-by: Feng Yang <[email protected]>
Acked-by: Yiqiao Pu <[email protected]>
---
 client/virt/kvm_storage.py |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/client/virt/kvm_storage.py b/client/virt/kvm_storage.py
index 918717d..a99a2b0 100644
--- a/client/virt/kvm_storage.py
+++ b/client/virt/kvm_storage.py
@@ -27,7 +27,7 @@ class QemuImg(virt_storage.QemuImg):
         self.image_cmd = virt_utils.get_path(root_dir,
                                  params.get("qemu_img_binary","qemu-img"))
 
-
+    @error.context_aware
     def create(self, params):
         """
         Create an image using qemu_img or dd.
@@ -91,7 +91,9 @@ class QemuImg(virt_storage.QemuImg):
 
         check_output = params.get("check_output") == "yes"
         try:
-            result = utils.system(qemu_img_cmd)
+            msg = "Create image by command: %s" % qemu_img_cmd
+            error.context(msg, logging.info)
+            result = utils.system_output(qemu_img_cmd, verbose=False)
         except error.CmdError, e:
             logging.error("Could not create image, failed with error message:"
                             "%s", str(e))
-- 
1.7.7.6

_______________________________________________
Autotest-kernel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/autotest-kernel

Reply via email to