Signed-off-by: Gu Yanhua <guyanhua-f...@cn.fujitsu.com>
---
  client/virt/libvirt_vm.py |   21 +++++++++++++++++++--
  1 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/client/virt/libvirt_vm.py b/client/virt/libvirt_vm.py
index d97ac0c..d07ddce 100644
--- a/client/virt/libvirt_vm.py
+++ b/client/virt/libvirt_vm.py
@@ -86,7 +86,7 @@ def service_libvirtd_control(action):
          raise error.TestError("Unknown action: %s" % action)


-def virsh_cmd(cmd, uri="", ignore_status=False):
+def virsh_cmd(cmd, uri="", ignore_status=False, print_info=False):
      """
      Append cmd to 'virsh' and execute, optionally return full results.

@@ -101,7 +101,16 @@ def virsh_cmd(cmd, uri="", ignore_status=False):
      if uri:
          uri_arg = "-c " + uri
      cmd = "%s %s %s" % (VIRSH_EXEC, uri_arg, cmd)
-    return utils.run(cmd, verbose=DEBUG, ignore_status=ignore_status)
+    if print_info:
+        logging.debug("Running command: %s" % cmd)
+
+    ret = utils.run(cmd, verbose=DEBUG, ignore_status=ignore_status)
+
+    if print_info:
+        logging.debug("status: %s" % ret.exit_status)
+        logging.debug("stdout: %s" % ret.stdout.strip())
+        logging.debug("stderr: %s" % ret.stderr.strip())
+    return ret

  def virsh_nodeinfo(uri = "", ignore_status=False, extra = ""):
      """
@@ -111,6 +120,14 @@ def virsh_nodeinfo(uri = "", ignore_status=False, extra = 
""):
      cmd_nodeinfo = "nodeinfo %s" % extra
      return virsh_cmd(cmd_nodeinfo, uri, ignore_status)

+
+def virsh_freecell(uri = "", ignore_status=False, extra = "", 
print_info=False):
+    """
+    Prints the available amount of memory on the machine or within a NUMA cell.
+    """
+    cmd_freecell = "freecell %s" % extra
+    return virsh_cmd(cmd_freecell, uri, ignore_status, print_info)
+
  def virsh_uri(uri=""):
      """
      Return the hypervisor canonical URI.
--
1.7.1


_______________________________________________
Autotest mailing list
Autotest@test.kernel.org
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to