c401cc
From 5d233742fe4494c4bca1fd0813da56965c22fa23 Mon Sep 17 00:00:00 2001
c401cc
Message-Id: <5d233742fe4494c4bca1fd0813da56965c22fa23.1386932211.git.jdenemar@redhat.com>
c401cc
From: Martin Kletzander <mkletzan@redhat.com>
c401cc
Date: Tue, 10 Dec 2013 10:03:56 +0100
c401cc
Subject: [PATCH] qemu: Report VIR_DOMAIN_MEMORY_PARAM_UNLIMITED properly
c401cc
c401cc
https://bugzilla.redhat.com/show_bug.cgi?id=1024272
c401cc
c401cc
For dead domains that have no memtune limits, we return 0 instead of
c401cc
"unlimited", this patch fixes it to return PARAM_UNLIMITED.
c401cc
c401cc
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
c401cc
(cherry picked from commit 0c2fdd7b14cbfc6ced77ed2a24f01f07a8a2f657)
c401cc
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c401cc
---
c401cc
 src/qemu/qemu_driver.c | 25 +++++++++++++------------
c401cc
 1 file changed, 13 insertions(+), 12 deletions(-)
c401cc
c401cc
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
c401cc
index 4466489..939c8a0 100644
c401cc
--- a/src/qemu/qemu_driver.c
c401cc
+++ b/src/qemu/qemu_driver.c
c401cc
@@ -8315,29 +8315,30 @@ qemuDomainGetMemoryParameters(virDomainPtr dom,
c401cc
     if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
c401cc
         for (i = 0; i < *nparams && i < QEMU_NB_MEM_PARAM; i++) {
c401cc
             virMemoryParameterPtr param = &params[i];
c401cc
+            unsigned long long value;
c401cc
 
c401cc
             switch (i) {
c401cc
             case 0: /* fill memory hard limit here */
c401cc
-                if (virTypedParameterAssign(param,
c401cc
-                                            VIR_DOMAIN_MEMORY_HARD_LIMIT,
c401cc
-                                            VIR_TYPED_PARAM_ULLONG,
c401cc
-                                            persistentDef->mem.hard_limit) < 0)
c401cc
+                value = persistentDef->mem.hard_limit;
c401cc
+                value = value ? value : VIR_DOMAIN_MEMORY_PARAM_UNLIMITED;
c401cc
+                if (virTypedParameterAssign(param, VIR_DOMAIN_MEMORY_HARD_LIMIT,
c401cc
+                                            VIR_TYPED_PARAM_ULLONG, value) < 0)
c401cc
                     goto cleanup;
c401cc
                 break;
c401cc
 
c401cc
             case 1: /* fill memory soft limit here */
c401cc
-                if (virTypedParameterAssign(param,
c401cc
-                                            VIR_DOMAIN_MEMORY_SOFT_LIMIT,
c401cc
-                                            VIR_TYPED_PARAM_ULLONG,
c401cc
-                                            persistentDef->mem.soft_limit) < 0)
c401cc
+                value = persistentDef->mem.soft_limit;
c401cc
+                value = value ? value : VIR_DOMAIN_MEMORY_PARAM_UNLIMITED;
c401cc
+                if (virTypedParameterAssign(param, VIR_DOMAIN_MEMORY_SOFT_LIMIT,
c401cc
+                                            VIR_TYPED_PARAM_ULLONG, value) < 0)
c401cc
                     goto cleanup;
c401cc
                 break;
c401cc
 
c401cc
             case 2: /* fill swap hard limit here */
c401cc
-                if (virTypedParameterAssign(param,
c401cc
-                                            VIR_DOMAIN_MEMORY_SWAP_HARD_LIMIT,
c401cc
-                                            VIR_TYPED_PARAM_ULLONG,
c401cc
-                                            persistentDef->mem.swap_hard_limit) < 0)
c401cc
+                value = persistentDef->mem.swap_hard_limit;
c401cc
+                value = value ? value : VIR_DOMAIN_MEMORY_PARAM_UNLIMITED;
c401cc
+                if (virTypedParameterAssign(param, VIR_DOMAIN_MEMORY_SWAP_HARD_LIMIT,
c401cc
+                                            VIR_TYPED_PARAM_ULLONG, value) < 0)
c401cc
                     goto cleanup;
c401cc
                 break;
c401cc
 
c401cc
-- 
c401cc
1.8.5.1
c401cc