mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemu: Take NVMe disks into account when calculating memlock limit
We have this beautiful function that does crystal ball divination. The function is named qemuDomainGetMemLockLimitBytes() and it calculates the upper limit of how much locked memory is given guest going to need. The function bases its guess on devices defined for a domain. For instance, if there is a VFIO hostdev defined then it adds 1GiB to the guessed maximum. Since NVMe disks are pretty much VFIO hostdevs (but not quite), we have to do the same sorcery. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> ACKed-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
8943ca11b2
commit
d3f06dcdb5
@ -12881,6 +12881,9 @@ getPPC64MemLockLimitBytes(virDomainDefPtr def)
|
||||
}
|
||||
}
|
||||
|
||||
if (virDomainDefHasNVMeDisk(def))
|
||||
usesVFIO = true;
|
||||
|
||||
memory = virDomainDefGetMemoryTotal(def);
|
||||
|
||||
if (def->mem.max_memory)
|
||||
@ -12979,6 +12982,7 @@ unsigned long long
|
||||
qemuDomainGetMemLockLimitBytes(virDomainDefPtr def)
|
||||
{
|
||||
unsigned long long memKB = 0;
|
||||
bool usesVFIO = false;
|
||||
size_t i;
|
||||
|
||||
/* prefer the hard limit */
|
||||
@ -13019,11 +13023,17 @@ qemuDomainGetMemLockLimitBytes(virDomainDefPtr def)
|
||||
for (i = 0; i < def->nhostdevs; i++) {
|
||||
if (virHostdevIsVFIODevice(def->hostdevs[i]) ||
|
||||
virHostdevIsMdevDevice(def->hostdevs[i])) {
|
||||
memKB = virDomainDefGetMemoryTotal(def) + 1024 * 1024;
|
||||
goto done;
|
||||
usesVFIO = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (virDomainDefHasNVMeDisk(def))
|
||||
usesVFIO = true;
|
||||
|
||||
if (usesVFIO)
|
||||
memKB = virDomainDefGetMemoryTotal(def) + 1024 * 1024;
|
||||
|
||||
done:
|
||||
return memKB << 10;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user