autotest / virt-test

Linux Virtualization Tests
Other
97 stars 140 forks source link

cpu_stats.positive_test.paused_option cgroups breakage #1083

Open cevich opened 10 years ago

cevich commented 10 years ago

This test is failing on F19 system (four host CPUs) with:

12:33:58 DEBUG| stderr: 
12:33:58 DEBUG| cgtime get is ['cat:', '/cgroup/cpuacct/libvirt/qemu/virt-tests-vm1/cpuacct.usage_percpu:', 'No', 'such', 'file', 'or', 'directory']
12:33:58 DEBUG| Check total cpu_time 310998583 >= user + system cpu_time 250000000
12:33:58 DEBUG| start_num 0, end_num 4
12:33:58 DEBUG| Check CPU0 exist
12:33:59 DEBUG| Checking image file /usr/local/autotest/client/tests/virt/shared/data/images/jeos-19-64.qcow2
12:33:59 DEBUG| Running '/bin/qemu-img info /usr/local/autotest/client/tests/virt/shared/data/images/jeos-19-64.qcow2'
12:33:59 DEBUG| Running '/bin/qemu-img check /usr/local/autotest/client/tests/virt/shared/data/images/jeos-19-64.qcow2'
12:33:59 ERROR| 
12:33:59 ERROR| Traceback (most recent call last):
12:33:59 ERROR|   File "/usr/local/autotest/client/tests/virt/virttest/standalone_test.py", line 192, in run_once
12:33:59 ERROR|     run_func(self, params, env)
12:33:59 ERROR|   File "/usr/local/autotest/client/tests/virt/libvirt/tests/src/virsh_cmd/domain/virsh_cpu_stats.py", line 130, in run_virsh_cpu_stats
12:33:59 ERROR|     sum_cgtime += int(cgtime[i])
12:33:59 ERROR| ValueError: invalid literal for int() with base 10: 'cat:'
12:33:59 ERROR| 
12:33:59 ERROR| FAIL type_specific.virsh.cpu_stats.positive_test.paused_option -> ValueError: invalid literal for int() with base 10: 'cat:'
cevich commented 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

jferlan commented 10 years ago

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
phrdina commented 10 years ago

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.

jferlan commented 10 years ago

Whatever is done to change here would also need to be done to replicated for the emulatorpin issue: #1021