vcpupin: fix cpu affinity setting bug of qemu driver

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

 



There is the case where cpu affinites for vcpu of qemu doesn't work
correctly.
For example, if only one vcpupin setting entry is provided and its setting
is
not for vcpu0, it doesn't work.

   # virsh dumpxml VM
   ...
   <vcpu>4</vcpu>
   <cputune>
     <vcpupin vcpu='3' cpuset='9-11'/>
   </cputune>
   ...

   # virsh start VM
   Domain VM started

   # virsh vcpuinfo VM
   VCPU:           0
   CPU:            31
   State:          running
   CPU time:       2.5s
   CPU Affinity:   yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
   
   VCPU:           1
   CPU:            12
   State:          running
   CPU time:       0.9s
   CPU Affinity:   yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
   
   VCPU:           2
   CPU:            30
   State:          running
   CPU time:       1.5s
   CPU Affinity:   yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
   
   VCPU:           3
   CPU:            13
   State:          running
   CPU time:       1.7s
   CPU Affinity:   yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy


This patch fixes this problem.

Signed-off-by: Taku Izumi <izumi.taku@xxxxxxxxxxxxxx>
---
 src/qemu/qemu_process.c |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

Index: libvirt/src/qemu/qemu_process.c
===================================================================
--- libvirt.orig/src/qemu/qemu_process.c
+++ libvirt/src/qemu/qemu_process.c
@@ -1194,7 +1194,7 @@ qemuProcessSetVcpuAffinites(virConnectPt
     virNodeInfo nodeinfo;
     pid_t vcpupid;
     unsigned char *cpumask;
-    int vcpu, cpumaplen, hostcpus, maxcpu;
+    int vcpu, cpumaplen, hostcpus, maxcpu, n;
     unsigned char *cpumap = NULL;
     int ret = -1;
 
@@ -1223,14 +1223,12 @@ qemuProcessSetVcpuAffinites(virConnectPt
         return -1;
     }
 
-    for (vcpu = 0; vcpu < def->cputune.nvcpupin; vcpu++) {
-        if (vcpu != def->cputune.vcpupin[vcpu]->vcpuid)
-            continue;
-
+    for (n = 0; n < def->cputune.nvcpupin; n++) {
         int i;
+        vcpu =  def->cputune.vcpupin[n]->vcpuid;
 
         memset(cpumap, 0, cpumaplen);
-        cpumask = (unsigned char *)def->cputune.vcpupin[vcpu]->cpumask;
+        cpumask = (unsigned char *)def->cputune.vcpupin[n]->cpumask;
         vcpupid = priv->vcpupids[vcpu];
 
         /* Convert cpumask to bitmap here. */


--
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]