[libvirt PATCH 4/5] qemu: consider vdpa block devices for memlock limits

Jonathon Jongsma posted 5 patches 2 years, 8 months ago
There is a newer version of this series
[libvirt PATCH 4/5] qemu: consider vdpa block devices for memlock limits
Posted by Jonathon Jongsma 2 years, 8 months ago
vDPA block devices will also need the same consideration for memlock
limits as other vdpa devices, so consider these devices when calculating
memlock limits.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
---
 src/qemu/qemu_domain.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 8f77e8fc58..2f6b32e394 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -9564,7 +9564,7 @@ qemuDomainGetNumNVMeDisks(const virDomainDef *def)
 
 
 static int
-qemuDomainGetNumVDPANetDevices(const virDomainDef *def)
+qemuDomainGetNumVDPADevices(const virDomainDef *def)
 {
     size_t i;
     int n = 0;
@@ -9574,6 +9574,14 @@ qemuDomainGetNumVDPANetDevices(const virDomainDef *def)
             n++;
     }
 
+    for (i = 0; i < def->ndisks; i++) {
+        virStorageSource *src;
+        for (src = def->disks[i]->src; src; src = src->backingStore) {
+            if (src->type == VIR_STORAGE_TYPE_VHOST_VDPA)
+                n++;
+        }
+    }
+
     return n;
 }
 
@@ -9616,7 +9624,7 @@ qemuDomainGetMemLockLimitBytes(virDomainDef *def)
 
     nvfio = qemuDomainGetNumVFIOHostdevs(def);
     nnvme = qemuDomainGetNumNVMeDisks(def);
-    nvdpa = qemuDomainGetNumVDPANetDevices(def);
+    nvdpa = qemuDomainGetNumVDPADevices(def);
     /* For device passthrough using VFIO the guest memory and MMIO memory
      * regions need to be locked persistent in order to allow DMA.
      *
-- 
2.40.1
Re: [libvirt PATCH 4/5] qemu: consider vdpa block devices for memlock limits
Posted by Peter Krempa 2 years, 8 months ago
On Tue, Jun 06, 2023 at 16:11:03 -0500, Jonathon Jongsma wrote:
> vDPA block devices will also need the same consideration for memlock
> limits as other vdpa devices, so consider these devices when calculating
> memlock limits.
> 
> Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
> ---
>  src/qemu/qemu_domain.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)

Reviewed-by: Peter Krempa <pkrempa@redhat.com>