[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [test-API][PATCH] Add env check function for memory_params_live



On 05/23/2013 04:20 PM, Guannan Ren wrote:
On 05/22/2013 05:34 PM, Wayne Sun wrote:
In this case, domain memory cgroup path is hardcoded and fail the
case after cgroup path changed recently. To avoid such failure, add
check function for lscgroup command before run this case, if check
fail then skip this case.

Signed-off-by: Wayne Sun <gsun redhat com>
---
repos/domain/memory_params_live.py | 36 ++++++++++++++++++++++++++++++------
  1 file changed, 30 insertions(+), 6 deletions(-)

diff --git a/repos/domain/memory_params_live.py b/repos/domain/memory_params_live.py
index 44fb8b4..280792a 100644
--- a/repos/domain/memory_params_live.py
+++ b/repos/domain/memory_params_live.py
@@ -4,6 +4,7 @@
    import os
  import math
+import commands
  from xml.dom import minidom
    import libvirt
@@ -15,27 +16,35 @@ required_params = ('guestname', 'hard_limit', 'soft_limit', 'swap_hard_limit', )
  optional_params = {}
    UNLIMITED = 9007199254740991
-CGROUP_PATH = "/cgroup/memory/libvirt/qemu"
+CGROUP_PATH = "/cgroup/"
    def get_cgroup_setting(guestname):
      """get domain memory parameters in cgroup
      """
      if os.path.exists(CGROUP_PATH):
-        cgroup_path = "%s/%s" % (CGROUP_PATH, guestname)
+        cgroup_path = CGROUP_PATH
      else:
-        cgroup_path = "/sys/fs%s/%s" % (CGROUP_PATH, guestname)
+        cgroup_path = "/sys/fs%s" % CGROUP_PATH
  -    f = open("%s/memory.limit_in_bytes" % cgroup_path)
+    cmd = "lscgroup | grep %s | grep memory:" % guestname
+    ret, out = commands.getstatusoutput(cmd)
+    if ret:
+        logger.error(out)
+        return 1
+    else:
+        mem_cgroup_path = "%s%s" % (cgroup_path, out.replace(':', ''))
+

   Hi Wayne,

The changes here is good for new cgroup layout, but it failed to test libvirt version with
     *old* cgroup layout.
     new: ${controller-patch}/machine/${guestname}.libvirt-qemu
     old :  ${controller-patch}/libvirt/qemu/${guestname}

can we use lscgroup | grep ${guestname} to get the path for new and old cgroup layout
     both at the same time.


   it seems your code did so, I missed "grep" line.
   ACK and pushed.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]