From: Jonathon Jongsma Date: Tue, 30 May 2023 20:53:38 +0000 (-0500) Subject: qemu: consider vdpa block devices for memlock limits X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=2efa9ba66a248a1a7ecc1bcc2decfcdbbf2c6b5d;p=libvirt.git qemu: consider vdpa block devices for memlock limits 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 Reviewed-by: Peter Krempa --- diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c7d64e1b5c..52ea8f649d 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9652,7 +9652,7 @@ qemuDomainGetNumNVMeDisks(const virDomainDef *def) static int -qemuDomainGetNumVDPANetDevices(const virDomainDef *def) +qemuDomainGetNumVDPADevices(const virDomainDef *def) { size_t i; int n = 0; @@ -9662,6 +9662,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; } @@ -9704,7 +9712,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. *