Open cevich opened 10 years ago
@kylazhang would you mind taking a look at this? IIRC There were some changes in the autotest cgroups stuff recently and this test never got updated. I'd fix it if I knew more about cgroups :S
I think perhaps @Antique had made a change to this at one time for "local" libvirt team consumption that didn't get propagated... In any case, here's a diff that is close to what I grabbed... The only difference between this and what I got originally is the usage of get_cgroup_mountpoint() instead of a constant path.
John
diff --git a/libvirt/tests/src/virsh_cmd/domain/virsh_cpu_stats.py b/libvirt/tes
index 240545a..fa3b600 100644
--- a/libvirt/tests/src/virsh_cmd/domain/virsh_cpu_stats.py
+++ b/libvirt/tests/src/virsh_cmd/domain/virsh_cpu_stats.py
@@ -1,9 +1,15 @@
import re
import commands
import logging
+import os
from autotest.client.shared import error
from virttest import virsh
+try:
+ from autotest.client.shared import utils_cgroup
+except ImportError:
+ from virttest.staging import utils_cgroup
+
def run_virsh_cpu_stats(test, params, env):
"""
@@ -72,9 +78,21 @@ def run_virsh_cpu_stats(test, params, env):
else:
# Get cgroup cpu_time
if not get_totalonly:
- cgcpu = "cat /cgroup/cpuacct/libvirt/qemu/" + vm_name + \
- "/cpuacct.usage_percpu"
- cgtime = commands.getoutput(cgcpu).strip().split()
+ try:
+ ctl_mount = utils_cgroup.get_cgroup_mountpoint("cpuacct")
+ except IndexError:
+ raise error.TestFail("Cannot find cpuacct cgroup")
+
+ cgroup_path = os.path.join(ctl_mount, "libvirt/qemu",
+ vm_name, "cpuacct.usage_percpu")
+ if not os.path.exists(cgroup_path):
+ cgroup_path = os.path.join(ctl_mount, "machine", vm_name
+ + ".libvirt-qemu",
+ "cpuacct.usage_percpu")
+ if not os.path.exists(cgroup_path):
+ raise error.TestNAError("Unknown path to cgroups")
+ get_value_cmd = "cat %s" % cgroup_path
+ cgtime = commands.getoutput(get_value_cmd).strip().split()
logging.debug("cgtime get is %s", cgtime)
# Cut CPUs from output and format to list
Hi, this should be done different way. This was my first attempt to fix this bug, but right now I've got a better way to do it. I'll maybe today create a pull-request with proper fix.
Whatever is done to change here would also need to be done to replicated for the emulatorpin issue: #1021
This test is failing on F19 system (four host CPUs) with: