mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemu_domain: Increase memlock limit for NVMe disks
When starting QEMU, or when hotplugging a PCI device QEMU might
lock some memory. How much? Well, that's an undecidable problem.
But despite that, we try to guess. And it more or less works,
until there's a counter example. This time, it's a guest with
both <hostdev/> and an NVMe <disk/>. I've started a simple guest
with 4GiB of memory:
# virsh dominfo fedora
Max memory: 4194304 KiB
Used memory: 4194304 KiB
And here are the amounts of memory that QEMU tried to lock,
obtained via:
grep VmLck /proc/$(pgrep qemu-kvm)/status
1) with just one <hostdev/>
VmLck: 4194308 kB
2) with just one NVMe <disk/>
VmLck: 4328544 kB
3) with one <hostdev/> and one NVMe <disk/>
VmLck: 8522852 kB
Now, what's surprising is case 2) where the locked memory exceeds
the VM memory. It almost resembles VDPA. Therefore, treat is as
such.
Unfortunately, I don't have a box with two or more spare NVMe-s
so I can't tell for sure. But setting limit too tight means QEMU
refuses to start.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2014030
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
24
tests/qemumemlockdata/qemumemlock-pc-hostdev-nvme.xml
Normal file
24
tests/qemumemlockdata/qemumemlock-pc-hostdev-nvme.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<domain type='kvm'>
|
||||
<name>guest</name>
|
||||
<memory unit='KiB'>1048576</memory>
|
||||
<vcpu placement='static'>1</vcpu>
|
||||
<os>
|
||||
<type arch='x86_64' machine='pc'>hvm</type>
|
||||
</os>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-system-x86_64</emulator>
|
||||
<disk type='nvme' device='disk'>
|
||||
<driver name='qemu' type='raw'/>
|
||||
<source type='pci' managed='yes' namespace='1'>
|
||||
<address domain='0x0003' bus='0x02' slot='0x00' function='0x0'/>
|
||||
</source>
|
||||
<target dev='vda' bus='virtio'/>
|
||||
</disk>
|
||||
<hostdev mode='subsystem' type='pci' managed='yes'>
|
||||
<driver name='vfio'/>
|
||||
<source>
|
||||
<address domain='0x0001' bus='0x01' slot='0x00' function='0x0'/>
|
||||
</source>
|
||||
</hostdev>
|
||||
</devices>
|
||||
</domain>
|
||||
@@ -97,6 +97,7 @@ mymain(void)
|
||||
DO_TEST("pc-hardlimit", 2147483648);
|
||||
DO_TEST("pc-locked", VIR_DOMAIN_MEMORY_PARAM_UNLIMITED);
|
||||
DO_TEST("pc-hostdev", 2147483648);
|
||||
DO_TEST("pc-hostdev-nvme", 3221225472);
|
||||
|
||||
DO_TEST("pc-hardlimit+locked", 2147483648);
|
||||
DO_TEST("pc-hardlimit+hostdev", 2147483648);
|
||||
|
||||
Reference in New Issue
Block a user