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