mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
libxl: Refactor libxlDomainGetVcpuPinInfo
Reuse the approach in qemuDomainGetVcpuPinInfo.
This commit is contained in:
parent
df55ed4bc0
commit
f35b9b7898
@ -2307,10 +2307,8 @@ libxlDomainGetVcpuPinInfo(virDomainPtr dom, int ncpumaps,
|
|||||||
libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
|
libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
|
||||||
virDomainObjPtr vm = NULL;
|
virDomainObjPtr vm = NULL;
|
||||||
virDomainDefPtr targetDef = NULL;
|
virDomainDefPtr targetDef = NULL;
|
||||||
virDomainPinDefPtr *vcpupin_list;
|
int hostcpus, vcpu, ret = -1;
|
||||||
virBitmapPtr cpumask = NULL;
|
virBitmapPtr allcpumap = NULL;
|
||||||
int maxcpu, hostcpus, vcpu, pcpu, n, ret = -1;
|
|
||||||
unsigned char *cpumap;
|
|
||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
|
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
|
||||||
VIR_DOMAIN_AFFECT_CONFIG, -1);
|
VIR_DOMAIN_AFFECT_CONFIG, -1);
|
||||||
@ -2338,33 +2336,33 @@ libxlDomainGetVcpuPinInfo(virDomainPtr dom, int ncpumaps,
|
|||||||
if ((hostcpus = libxl_get_max_cpus(cfg->ctx)) < 0)
|
if ((hostcpus = libxl_get_max_cpus(cfg->ctx)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
maxcpu = maplen * 8;
|
if (!(allcpumap = virBitmapNew(hostcpus)))
|
||||||
if (maxcpu > hostcpus)
|
goto cleanup;
|
||||||
maxcpu = hostcpus;
|
|
||||||
|
virBitmapSetAll(allcpumap);
|
||||||
|
|
||||||
|
memset(cpumaps, 0x00, maplen * ncpumaps);
|
||||||
|
|
||||||
/* initialize cpumaps */
|
|
||||||
memset(cpumaps, 0xff, maplen * ncpumaps);
|
|
||||||
if (maxcpu % 8) {
|
|
||||||
for (vcpu = 0; vcpu < ncpumaps; vcpu++) {
|
for (vcpu = 0; vcpu < ncpumaps; vcpu++) {
|
||||||
cpumap = VIR_GET_CPUMAP(cpumaps, maplen, vcpu);
|
virDomainPinDefPtr pininfo;
|
||||||
cpumap[maplen - 1] &= (1 << maxcpu % 8) - 1;
|
virBitmapPtr bitmap = NULL;
|
||||||
}
|
|
||||||
|
pininfo = virDomainPinFind(targetDef->cputune.vcpupin,
|
||||||
|
targetDef->cputune.nvcpupin,
|
||||||
|
vcpu);
|
||||||
|
|
||||||
|
if (pininfo && pininfo->cpumask)
|
||||||
|
bitmap = pininfo->cpumask;
|
||||||
|
else
|
||||||
|
bitmap = allcpumap;
|
||||||
|
|
||||||
|
virBitmapToDataBuf(bitmap, VIR_GET_CPUMAP(cpumaps, maplen, vcpu), maplen);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if vcpupin setting exists, there may be unused pcpus */
|
|
||||||
for (n = 0; n < targetDef->cputune.nvcpupin; n++) {
|
|
||||||
vcpupin_list = targetDef->cputune.vcpupin;
|
|
||||||
vcpu = vcpupin_list[n]->id;
|
|
||||||
cpumask = vcpupin_list[n]->cpumask;
|
|
||||||
cpumap = VIR_GET_CPUMAP(cpumaps, maplen, vcpu);
|
|
||||||
for (pcpu = 0; pcpu < maxcpu; pcpu++) {
|
|
||||||
if (!virBitmapIsBitSet(cpumask, pcpu))
|
|
||||||
VIR_UNUSE_CPU(cpumap, pcpu);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ret = ncpumaps;
|
ret = ncpumaps;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
virBitmapFree(allcpumap);
|
||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
|
Loading…
Reference in New Issue
Block a user