From 257ea76fb477024692f6d2c81437f55124b21c59 Mon Sep 17 00:00:00 2001 Message-Id: <257ea76fb477024692f6d2c81437f55124b21c59@dist-git> From: Shivaprasad G Bhat Date: Mon, 17 Jul 2017 12:09:14 +0200 Subject: [PATCH] qemu: Take all PHBs into account while calculating memlock limits Now that the multi-phb support series is in, work on the TODO at qemuDomainGetMemLockLimitBytes() to arrive at the correct memlock limit value. Signed-off-by: Shivaprasad G Bhat Reviewed-by: Andrea Bolognani (cherry picked from commit 210dd0c58d6f7b12fea65ce1fa42b343de4219b6) Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1431193 Signed-off-by: Andrea Bolognani Signed-off-by: Jiri Denemark --- src/qemu/qemu_domain.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 4c3897ba4e..916358ea1e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6660,12 +6660,17 @@ qemuDomainGetMemLockLimitBytes(virDomainDefPtr def) unsigned long long memory; unsigned long long baseLimit; unsigned long long passthroughLimit; - size_t nPCIHostBridges; + size_t nPCIHostBridges = 0; bool usesVFIO = false; - /* TODO: Detect at runtime once we start using more than just - * the default PCI Host Bridge */ - nPCIHostBridges = 1; + for (i = 0; i < def->ncontrollers; i++) { + virDomainControllerDefPtr cont = def->controllers[i]; + + if (!virDomainControllerIsPCIHostBridge(cont)) + continue; + + nPCIHostBridges++; + } for (i = 0; i < def->nhostdevs; i++) { virDomainHostdevDefPtr dev = def->hostdevs[i]; -- 2.13.3