render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
38f2fd
From edd55b5cb27f6b1f5738a354f59624795a049d73 Mon Sep 17 00:00:00 2001
38f2fd
Message-Id: <edd55b5cb27f6b1f5738a354f59624795a049d73@dist-git>
38f2fd
From: Peter Krempa <pkrempa@redhat.com>
38f2fd
Date: Thu, 12 Nov 2015 08:40:44 +0100
38f2fd
Subject: [PATCH] qemu: domain: Restructurate control flow in
38f2fd
 qemuDomainGetMlockLimitBytes
38f2fd
38f2fd
https://bugzilla.redhat.com/show_bug.cgi?id=1280420
38f2fd
38f2fd
Break early when hard limit is set so that it's not intermixed by other
38f2fd
logic for determining the limit.
38f2fd
38f2fd
(cherry picked from commit e7b91c510e9831b2741469809465bb68a87c8362)
38f2fd
38f2fd
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
38f2fd
---
38f2fd
 src/qemu/qemu_domain.c | 12 ++++++++----
38f2fd
 1 file changed, 8 insertions(+), 4 deletions(-)
38f2fd
38f2fd
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
38f2fd
index 1f206fa..fd4449d 100644
38f2fd
--- a/src/qemu/qemu_domain.c
38f2fd
+++ b/src/qemu/qemu_domain.c
38f2fd
@@ -3439,14 +3439,18 @@ qemuDomainGetMlockLimitBytes(virDomainDefPtr def)
38f2fd
 {
38f2fd
     unsigned long long memKB;
38f2fd
 
38f2fd
+    /* prefer the hard limit */
38f2fd
+    if (virMemoryLimitIsSet(def->mem.hard_limit)) {
38f2fd
+        memKB = def->mem.hard_limit;
38f2fd
+        goto done;
38f2fd
+    }
38f2fd
+
38f2fd
     /* VFIO requires all of the guest's memory to be locked resident, plus some
38f2fd
      * amount for IO space. Alex Williamson suggested adding 1GiB for IO space
38f2fd
      * just to be safe (some finer tuning might be nice, though). */
38f2fd
-    if (virMemoryLimitIsSet(def->mem.hard_limit))
38f2fd
-        memKB = def->mem.hard_limit;
38f2fd
-    else
38f2fd
-        memKB = virDomainDefGetMemoryActual(def) + 1024 * 1024;
38f2fd
+    memKB = virDomainDefGetMemoryActual(def) + 1024 * 1024;
38f2fd
 
38f2fd
+ done:
38f2fd
     return memKB << 10;
38f2fd
 }
38f2fd
 
38f2fd
-- 
38f2fd
2.6.3
38f2fd