Re: [PATCH v1 19/31] qemu: Take NVMe disks into account when calculating memlock limit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 11, 2019 at 17:54:06 +0200, Michal Privoznik wrote:
> 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@xxxxxxxxxx>
> ---
>  src/qemu/qemu_domain.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index f09abc8a73..09e5ee37f4 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c


preceeding hunk


    for (i = 0; i < def->nhostdevs; i++) {
        virDomainHostdevSubsysPtr subsys = &def->hostdevs[i]->source.subsys;

        if (def->hostdevs[i]->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
            (subsys->type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV ||
             (subsys->type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
              subsys->u.pci.backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO))) {
            memKB = virDomainDefGetMemoryTotal(def) + 1024 * 1024;
            goto done;
        }
    }


> @@ -10950,6 +10950,21 @@ qemuDomainGetMemLockLimitBytes(virDomainDefPtr def)
>          }
>      }
>  
> +    for (i = 0; i < def->ndisks; i++) {
> +        virDomainDiskDefPtr disk = def->disks[i];
> +        virStorageSourcePtr n;
> +
> +        if (!disk->src)
> +            continue;
> +
> +        for (n = disk->src; virStorageSourceIsBacking(n); n = n->backingStore) {
> +            if (n->type == VIR_STORAGE_TYPE_NVME) {
> +                memKB = virDomainDefGetMemoryTotal(def) + 1024 * 1024;
> +                goto done;
> +            }
> +        }
> +    }

Please set a booleand such as 'needVFIO' in the above hunk and here and
do the calculation once based on that boolean.

This implementation creates two instancess needing fixing in case when
we'd need to ever change the number.

ACK with that change

Attachment: signature.asc
Description: PGP signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux