Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu_stats.positive_test.paused_option cgroups breakage #1083

Open
cevich opened this issue Nov 18, 2013 · 4 comments
Open

cpu_stats.positive_test.paused_option cgroups breakage #1083

cevich opened this issue Nov 18, 2013 · 4 comments

Comments

@cevich
Copy link
Member

cevich commented Nov 18, 2013

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
Copy link
Member Author

cevich commented Nov 18, 2013

@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
Copy link
Contributor

jferlan commented Nov 21, 2013

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
Copy link
Contributor

phrdina commented Nov 22, 2013

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
Copy link
Contributor

jferlan commented Nov 25, 2013

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants