[libvirt] [PATCH 4/6] qemu: Reduce memlock limit after detaching hostdev

Peter Krempa pkrempa at redhat.com
Wed Nov 18 15:17:54 UTC 2015


On Wed, Nov 18, 2015 at 15:13:18 +0100, Andrea Bolognani wrote:
> We increase the limit before plugging in a PCI hostdev or a memory
> module because some memory might need to be locked due to eg. VFIO.
> 
> Of course we should do the opposite after unplugging a device: this
> was already the case for memory modules, but not for hostdevs.
> ---
>  src/qemu/qemu_hotplug.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
> index 0bd88ce..2a16f89 100644
> --- a/src/qemu/qemu_hotplug.c
> +++ b/src/qemu/qemu_hotplug.c
> @@ -3084,6 +3084,14 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
>          networkReleaseActualDevice(vm->def, net);
>          virDomainNetDefFree(net);
>      }
> +
> +    /* QEMU might no longer need to lock as much memory, eg. we just detached
> +     * a VFIO device, so adjust the limit here */
> +    if (qemuDomainRequiresMlock(vm->def))
> +        if (virProcessSetMaxMemLock(vm->pid,
> +                                    qemuDomainGetMlockLimitBytes(vm->def)) < 0)
> +        VIR_WARN("Failed to adjust locked memory limit");
> +

Hmmm, looks like we should reset it to default (64KiB afaik) if it was
required before and is not required any more. Otherwise we would not
decrease the limit after unplugging the last VFIO device (on x86).

Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20151118/7c97a13d/attachment-0001.sig>


More information about the libvir-list mailing list