[libvirt-test-api][PATCH 2/2] Modify the checking method via passing the vcpu thread id

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

 



modified:   repos/domain/cpu_affinity.py
---
 repos/domain/cpu_affinity.py | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/repos/domain/cpu_affinity.py b/repos/domain/cpu_affinity.py
index e710968..8246938 100644
--- a/repos/domain/cpu_affinity.py
+++ b/repos/domain/cpu_affinity.py
@@ -142,16 +142,18 @@ def vcpu_affinity_check(domain_name, vcpu, expected_pinned_cpu, hypervisor):
             logger.error("failed to get the pid of \
                           the running virtual machine process")
             return 1
-        if 'el6' in host_kernel_version:
-            cmd_get_task_list = "grep Cpus_allowed_list /proc/%s/task/*/status" % pid
+        if 'el6' or 'el7' in host_kernel_version:
+            cmd_vcpu_task_id = "virsh qemu-monitor-command %s --hmp info cpus|grep '#%s'|cut -d '=' -f3"\
+                                % (domain_name,vcpu)
+            status, output = commands.getstatusoutput(cmd_vcpu_task_id)
+            vcpu_task_id = output[:output.find("^")]
+            logger.debug("vcpu id %s:" % vcpu_task_id)
+            cmd_get_task_list = "grep Cpus_allowed_list /proc/%s/task/%s/status" % (pid , vcpu_task_id)
             status, output = commands.getstatusoutput(cmd_get_task_list)
-
             logger.debug("the output of command 'grep Cpus_allowed_list \
-                          /proc/%s/task/*/status' is %s" % (pid, output))
+                          /proc/%s/task/%s/status' is %s" % (pid,vcpu_task_id,output))
+            actual_pinned_cpu = int(output.split('\t')[1])

-            task_list = output.split('\n')[1:]
-            vcpu_task = task_list[int(vcpu)]
-            actual_pinned_cpu = int(vcpu_task.split('\t')[1])
         elif 'el5' in host_kernel_version:
             cmd_get_task_list = "grep Cpus_allowed /proc/%s/task/*/status" % pid
             status, output = commands.getstatusoutput(cmd_get_task_list)
-- 
1.9.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]