[PATCH v3 1/2] conf: List only online cpus for virsh vcpupin

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

 



Currently when the vcpu placement is static
and cpuset is not specified, CPU Affinity
under virsh vcpupin shows 0..CPUMAX. This
patchset will result in display of only
online CPU's under CPU Affinity on linux.

Signed-off-by: Nitesh Konkar <nitkon12@xxxxxxxxxxxxxxxxxx>
---
 src/conf/domain_conf.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 74efe8c..6f81903 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -55,6 +55,7 @@
 #include "virtpm.h"
 #include "virstring.h"
 #include "virnetdev.h"
+#include "virhostcpu.h"
 
 #define VIR_FROM_THIS VIR_FROM_DOMAIN
 
@@ -1543,8 +1544,13 @@ virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
 {
     int maxvcpus = virDomainDefGetVcpusMax(def);
     virBitmapPtr allcpumap = NULL;
+    virBitmapPtr staticCpuset = NULL;
     size_t i;
 
+#ifdef __linux__
+    staticCpuset = virHostCPUGetOnlineBitmap();
+#endif
+
     if (hostcpus < 0)
         return -1;
 
@@ -1562,6 +1568,9 @@ virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
         else if (def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO &&
                  autoCpuset)
             bitmap = autoCpuset;
+        else if (def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC &&
+                 staticCpuset)
+            bitmap = staticCpuset;
         else if (def->cpumask)
             bitmap = def->cpumask;
         else
@@ -1571,6 +1580,7 @@ virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
     }
 
     virBitmapFree(allcpumap);
+    virBitmapFree(staticCpuset);
     return i;
 }
 
-- 
2.1.0

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