[libvirt] [PATCH 1/3] qemu: domain: Restructurate control flow in qemuDomainGetMlockLimitBytes

Andrea Bolognani abologna at redhat.com
Wed Nov 11 12:57:46 UTC 2015


On Wed, 2015-11-11 at 06:57 +0100, Peter Krempa wrote:
> Break early when hard limit is set so that it's not intermixed by other
> logic for determining the limit.
> ---
>  src/qemu/qemu_domain.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index 416ab5b..12517a5 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -3633,14 +3633,18 @@ qemuDomainGetMlockLimitBytes(virDomainDefPtr def)
>  {
>      unsigned long long memKB;
> 
> +    /* prefer the hard limit */
> +    if (virMemoryLimitIsSet(def->mem.hard_limit)) {
> +        memKB = def->mem.hard_limit;
> +        goto done;
> +    }
> +
>      /* VFIO requires all of the guest's memory to be locked resident, plus some
>       * amount for IO space. Alex Williamson suggested adding 1GiB for IO space
>       * just to be safe (some finer tuning might be nice, though). */
> -    if (virMemoryLimitIsSet(def->mem.hard_limit))
> -        memKB = def->mem.hard_limit;
> -    else
> -        memKB = virDomainDefGetMemoryActual(def) + 1024 * 1024;
> +    memKB = virDomainDefGetMemoryActual(def) + 1024 * 1024;
> 
> + done:
>      return memKB << 10;
>  }

ACK - I have the same diff lined up along with the ppc64-specific
algorithm :)

-- 
Andrea Bolognani
Software Engineer - Virtualization Team




More information about the libvir-list mailing list