Follow-up to the IOThread review on CPU affinity map manipulation: http://www.redhat.com/archives/libvir-list/2015-March/msg00294.html indicates that the GetEmulatorPinInfo could use similar algorithm adjustments which is what this patch does. Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- src/qemu/qemu_driver.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 85387a8..b95f5ac 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5364,10 +5364,12 @@ qemuDomainGetEmulatorPinInfo(virDomainPtr dom, virDomainObjPtr vm = NULL; virDomainDefPtr targetDef = NULL; int ret = -1; - int maxcpu, hostcpus, pcpu; + int hostcpus; virBitmapPtr cpumask = NULL; - bool pinned; + virBitmapPtr bitmap = NULL; virCapsPtr caps = NULL; + unsigned char *tmpmap = NULL; + int tmpmaplen; virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG, -1); @@ -5394,36 +5396,30 @@ qemuDomainGetEmulatorPinInfo(virDomainPtr dom, if ((hostcpus = nodeGetCPUCount()) < 0) goto cleanup; - maxcpu = maplen * 8; - if (maxcpu > hostcpus) - maxcpu = hostcpus; - - /* initialize cpumaps */ - memset(cpumaps, 0xff, maplen); - if (maxcpu % 8) - cpumaps[maplen - 1] &= (1 << maxcpu % 8) - 1; - if (targetDef->cputune.emulatorpin) { cpumask = targetDef->cputune.emulatorpin->cpumask; } else if (targetDef->cpumask) { cpumask = targetDef->cpumask; } else { - ret = 0; - goto cleanup; - } - - for (pcpu = 0; pcpu < maxcpu; pcpu++) { - if (virBitmapGetBit(cpumask, pcpu, &pinned) < 0) + if (!(bitmap = virBitmapNew(hostcpus))) goto cleanup; - if (!pinned) - VIR_UNUSE_CPU(cpumaps, pcpu); + virBitmapSetAll(bitmap); + cpumask = bitmap; } + if (virBitmapToData(cpumask, &tmpmap, &tmpmaplen) < 0) + goto cleanup; + if (tmpmaplen > maplen) + tmpmaplen = maplen; + memcpy(cpumaps, tmpmap, tmpmaplen); + VIR_FREE(tmpmap); + ret = 1; cleanup: qemuDomObjEndAPI(&vm); virObjectUnref(caps); + virBitmapFree(bitmap); return ret; } -- 2.1.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list