On 11/24/2016 04:55 AM, Nitesh Konkar wrote:
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(a)linux.vnet.ibm.com>
---
src/conf/domain_conf.c | 6 ++++++
1 file changed, 6 insertions(+)
It seems there are some similarities to Viktor's series:
http://www.redhat.com/archives/libvir-list/2016-November/msg01320.html
at least with respect to creating an accessor function (in patch 1)
virHostCPUHasBitmap that will hide that virHostCPUGetOnlineBitmap call
and the ugly #ifdef __linux__ in the domain_conf.c file.
Using virHostCPUHasBitmap will hide the need for the #ifdef...
Secondary, should there be a fallback in the event that a NULL is
returned from virHostCPUGetOnlineBitmap?
Finally, does there need to be a similar call to like what Viktor did
w/r/t virProcessGetAffinity and making sure the bitmaps are equal?
John
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e7517d9..f25cf63 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -56,6 +56,7 @@
#include "virstring.h"
#include "virnetdev.h"
#include "virhostdev.h"
+#include "virhostcpu.h"
#define VIR_FROM_THIS VIR_FROM_DOMAIN
@@ -1549,10 +1550,15 @@ virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
if (hostcpus < 0)
return -1;
+#ifdef __linux__
+ if (!(allcpumap = virHostCPUGetOnlineBitmap()))
+ return -1;
+#else
if (!(allcpumap = virBitmapNew(hostcpus)))
return -1;
virBitmapSetAll(allcpumap);
+#endif
for (i = 0; i < maxvcpus && i < ncpumaps; i++) {
virDomainVcpuDefPtr vcpu = virDomainDefGetVcpu(def, i);