mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
vcpupin: Fix returning of arrays from virDomainVcpuPinAdd
virDomainVcpuPinAdd does a realloc on vcpupin_list if the new vcpu pin definition doesn't fit into the array. The list is an array of pointers but the function definition didn't support returning the changed pointer to the caller if it was realloced. This caused segfaults if realloc would change the base pointer.
This commit is contained in:
parent
40dfb52517
commit
077e7bf51f
@ -11037,7 +11037,7 @@ cleanup:
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
int virDomainVcpuPinAdd(virDomainVcpuPinDefPtr *vcpupin_list,
|
||||
int virDomainVcpuPinAdd(virDomainVcpuPinDefPtr **vcpupin_list,
|
||||
int *nvcpupin,
|
||||
unsigned char *cpumap,
|
||||
int maplen,
|
||||
@ -11052,7 +11052,7 @@ int virDomainVcpuPinAdd(virDomainVcpuPinDefPtr *vcpupin_list,
|
||||
if ((cpumask = bitmapFromBytemap(cpumap, maplen)) == NULL)
|
||||
return -1;
|
||||
|
||||
vcpupin = virDomainVcpuPinFindByVcpu(vcpupin_list,
|
||||
vcpupin = virDomainVcpuPinFindByVcpu(*vcpupin_list,
|
||||
*nvcpupin,
|
||||
vcpu);
|
||||
if (vcpupin) {
|
||||
@ -11073,14 +11073,14 @@ int virDomainVcpuPinAdd(virDomainVcpuPinDefPtr *vcpupin_list,
|
||||
vcpupin->cpumask = cpumask;
|
||||
|
||||
|
||||
if (VIR_REALLOC_N(vcpupin_list, *nvcpupin + 1) < 0) {
|
||||
if (VIR_REALLOC_N(*vcpupin_list, *nvcpupin + 1) < 0) {
|
||||
virReportOOMError();
|
||||
VIR_FREE(cpumask);
|
||||
VIR_FREE(vcpupin);
|
||||
return -1;
|
||||
}
|
||||
|
||||
vcpupin_list[(*nvcpupin)++] = vcpupin;
|
||||
(*vcpupin_list)[(*nvcpupin)++] = vcpupin;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1885,7 +1885,7 @@ int virDomainCpuSetParse(const char *str,
|
||||
char *virDomainCpuSetFormat(char *cpuset,
|
||||
int maxcpu);
|
||||
|
||||
int virDomainVcpuPinAdd(virDomainVcpuPinDefPtr *vcpupin_list,
|
||||
int virDomainVcpuPinAdd(virDomainVcpuPinDefPtr **vcpupin_list,
|
||||
int *nvcpupin,
|
||||
unsigned char *cpumap,
|
||||
int maplen,
|
||||
|
@ -2461,7 +2461,7 @@ libxlDomainPinVcpu(virDomainPtr dom, unsigned int vcpu, unsigned char *cpumap,
|
||||
}
|
||||
vm->def->cputune.nvcpupin = 0;
|
||||
}
|
||||
if (virDomainVcpuPinAdd(vm->def->cputune.vcpupin,
|
||||
if (virDomainVcpuPinAdd(&vm->def->cputune.vcpupin,
|
||||
&vm->def->cputune.nvcpupin,
|
||||
cpumap,
|
||||
maplen,
|
||||
|
@ -3782,7 +3782,7 @@ qemudDomainPinVcpuFlags(virDomainPtr dom,
|
||||
newVcpuPinNum = 0;
|
||||
}
|
||||
|
||||
if (virDomainVcpuPinAdd(newVcpuPin, &newVcpuPinNum, cpumap, maplen, vcpu) < 0) {
|
||||
if (virDomainVcpuPinAdd(&newVcpuPin, &newVcpuPinNum, cpumap, maplen, vcpu) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("failed to update vcpupin"));
|
||||
virDomainVcpuPinDefFree(newVcpuPin, newVcpuPinNum);
|
||||
@ -3849,7 +3849,7 @@ qemudDomainPinVcpuFlags(virDomainPtr dom,
|
||||
}
|
||||
persistentDef->cputune.nvcpupin = 0;
|
||||
}
|
||||
if (virDomainVcpuPinAdd(persistentDef->cputune.vcpupin,
|
||||
if (virDomainVcpuPinAdd(&persistentDef->cputune.vcpupin,
|
||||
&persistentDef->cputune.nvcpupin,
|
||||
cpumap,
|
||||
maplen,
|
||||
@ -4042,7 +4042,7 @@ qemudDomainPinEmulator(virDomainPtr dom,
|
||||
newVcpuPinNum = 0;
|
||||
}
|
||||
|
||||
if (virDomainVcpuPinAdd(newVcpuPin, &newVcpuPinNum, cpumap, maplen, -1) < 0) {
|
||||
if (virDomainVcpuPinAdd(&newVcpuPin, &newVcpuPinNum, cpumap, maplen, -1) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("failed to update vcpupin"));
|
||||
virDomainVcpuPinDefFree(newVcpuPin, newVcpuPinNum);
|
||||
|
@ -2303,7 +2303,7 @@ xenDaemonDomainPinVcpu(virDomainPtr domain, unsigned int vcpu,
|
||||
}
|
||||
def->cputune.nvcpupin = 0;
|
||||
}
|
||||
if (virDomainVcpuPinAdd(def->cputune.vcpupin,
|
||||
if (virDomainVcpuPinAdd(&def->cputune.vcpupin,
|
||||
&def->cputune.nvcpupin,
|
||||
cpumap,
|
||||
maplen,
|
||||
|
Loading…
x
Reference in New Issue
Block a user