The routine qemuDomainGetMemLockLimitBytes() has a couple tests
to determine what the maximum limit of locked memory should be.
If I start a domain without any vfio stuff, /proc/$PID/limits says
the limit is 64KiB. If I start a guest with a vfio-ccw hostdev,
the limit is now $GUEST_MEMORY + 1GiB. It doesn't matter if I
have one hostdev or a thousand; it's always 1GiB more than the
configured amount of guest memory.
If I start a guest without any vfio devices, and hotplug that same
vfio-ccw hostdev, the limit remains at 64KiB and I start getting
I/O errors in the guest. This makes sense, since some of the I/O
chains are long enough to exceed that page limit, and the host
starts throwing errors.
There is already code that adjusts this limit during the hotplug
of vfio-pci devices, so patch 1 refactors that code so that it
can be re-used on the mdev hotplug path in patch 3.
Patch 2, meanwhile, adds some cleanup that I think is missing in
the vfio-pci path, based on my read of the mdev path.
$ grep locked /proc/83543/limits
Max locked memory 65536 65536 bytes
$ virsh attach-device guest scratch-ca8b.xml
Device attached successfully
$ grep locked /proc/83543/limits
Max locked memory 3221225472 3221225472 bytes
Eric Farman (3):
qemu: Refactor the max memlock routine
qemu: Reset the maximum locked memory on hotplug fail
qemu: Adjust max memlock on mdev hotplug
src/qemu/qemu_domain.c | 30 ++++++++++++++++++++++++++++++
src/qemu/qemu_domain.h | 2 ++
src/qemu/qemu_hotplug.c | 22 ++++++++++++----------
3 files changed, 44 insertions(+), 10 deletions(-)
--
2.17.1