mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemu: Use qemuDomainAdjustMaxMemLock()
Replace all uses of the qemuDomainRequiresMlock/virProcessSetMaxMemLock combination with the equivalent qemuDomainAdjustMaxMemLock() call.
This commit is contained in:
parent
ac7e4df4f4
commit
65909c7996
@ -1282,18 +1282,15 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Temporarily add the hostdev to the domain definition. This is needed
|
/* Temporarily add the hostdev to the domain definition. This is needed
|
||||||
* because qemuDomainRequiresMlock() and qemuDomainGetMlockLimitBytes()
|
* because qemuDomainAdjustMaxMemLock() requires the hostdev to be already
|
||||||
* require the hostdev to be already part of the domain definition, but
|
* part of the domain definition, but other functions like
|
||||||
* other functions like qemuAssignDeviceHostdevAlias() used below expect
|
* qemuAssignDeviceHostdevAlias() used below expect it *not* to be there.
|
||||||
* it *not* to be there. A better way to handle this would be nice */
|
* A better way to handle this would be nice */
|
||||||
vm->def->hostdevs[vm->def->nhostdevs++] = hostdev;
|
vm->def->hostdevs[vm->def->nhostdevs++] = hostdev;
|
||||||
if (qemuDomainRequiresMlock(vm->def)) {
|
if (qemuDomainAdjustMaxMemLock(vm) < 0) {
|
||||||
if (virProcessSetMaxMemLock(vm->pid,
|
|
||||||
qemuDomainGetMlockLimitBytes(vm->def)) < 0) {
|
|
||||||
vm->def->hostdevs[--(vm->def->nhostdevs)] = NULL;
|
vm->def->hostdevs[--(vm->def->nhostdevs)] = NULL;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
vm->def->hostdevs[--(vm->def->nhostdevs)] = NULL;
|
vm->def->hostdevs[--(vm->def->nhostdevs)] = NULL;
|
||||||
|
|
||||||
if (qemuSetupHostdevCgroup(vm, hostdev) < 0)
|
if (qemuSetupHostdevCgroup(vm, hostdev) < 0)
|
||||||
@ -1778,7 +1775,6 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
|
|||||||
virJSONValuePtr props = NULL;
|
virJSONValuePtr props = NULL;
|
||||||
virObjectEventPtr event;
|
virObjectEventPtr event;
|
||||||
bool fix_balloon = false;
|
bool fix_balloon = false;
|
||||||
bool mlock = false;
|
|
||||||
int id;
|
int id;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
@ -1810,12 +1806,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
mlock = qemuDomainRequiresMlock(vm->def);
|
if (qemuDomainAdjustMaxMemLock(vm) < 0) {
|
||||||
|
|
||||||
if (mlock &&
|
|
||||||
virProcessSetMaxMemLock(vm->pid,
|
|
||||||
qemuDomainGetMlockLimitBytes(vm->def)) < 0) {
|
|
||||||
mlock = false;
|
|
||||||
virJSONValueFree(props);
|
virJSONValueFree(props);
|
||||||
goto removedef;
|
goto removedef;
|
||||||
}
|
}
|
||||||
@ -1876,13 +1867,10 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
|
|||||||
mem = NULL;
|
mem = NULL;
|
||||||
|
|
||||||
/* reset the mlock limit */
|
/* reset the mlock limit */
|
||||||
if (mlock) {
|
|
||||||
virErrorPtr err = virSaveLastError();
|
virErrorPtr err = virSaveLastError();
|
||||||
ignore_value(virProcessSetMaxMemLock(vm->pid,
|
ignore_value(qemuDomainAdjustMaxMemLock(vm));
|
||||||
qemuDomainGetMlockLimitBytes(vm->def)));
|
|
||||||
virSetError(err);
|
virSetError(err);
|
||||||
virFreeError(err);
|
virFreeError(err);
|
||||||
}
|
|
||||||
|
|
||||||
goto audit;
|
goto audit;
|
||||||
}
|
}
|
||||||
@ -2976,9 +2964,7 @@ qemuDomainRemoveMemoryDevice(virQEMUDriverPtr driver,
|
|||||||
virDomainMemoryDefFree(mem);
|
virDomainMemoryDefFree(mem);
|
||||||
|
|
||||||
/* decrease the mlock limit after memory unplug if necessary */
|
/* decrease the mlock limit after memory unplug if necessary */
|
||||||
if (qemuDomainRequiresMlock(vm->def))
|
ignore_value(qemuDomainAdjustMaxMemLock(vm));
|
||||||
ignore_value(virProcessSetMaxMemLock(vm->pid,
|
|
||||||
qemuDomainGetMlockLimitBytes(vm->def)));
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user