6ae9ed
From 55801bed29ad9b57d8deca92be44e436c3b60b5e Mon Sep 17 00:00:00 2001
6ae9ed
Message-Id: <55801bed29ad9b57d8deca92be44e436c3b60b5e@dist-git>
6ae9ed
From: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
6ae9ed
Date: Tue, 16 Aug 2016 16:26:38 +0200
6ae9ed
Subject: [PATCH] qemu: Adjust the cur_ballon on coldplug/unplug of dimms
6ae9ed
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1220702
6ae9ed
6ae9ed
The cur_balloon also increases/decreases with dimm hotplug/unplug.
6ae9ed
To be consistent, adjust the value for coldplug too. This was inconsistently
6ae9ed
taken care when cur_ballon != memory to begin with. The patch fixes it
6ae9ed
irrespective of that.
6ae9ed
6ae9ed
Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
6ae9ed
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
6ae9ed
(cherry picked from commit 707063efa86a8cab3ee7d64ad203f2e517b82bce)
6ae9ed
---
6ae9ed
 src/conf/domain_conf.c | 4 ----
6ae9ed
 src/qemu/qemu_driver.c | 9 +++++----
6ae9ed
 2 files changed, 5 insertions(+), 8 deletions(-)
6ae9ed
6ae9ed
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
6ae9ed
index 715ca2b..33954f7 100644
6ae9ed
--- a/src/conf/domain_conf.c
6ae9ed
+++ b/src/conf/domain_conf.c
6ae9ed
@@ -14668,10 +14668,6 @@ virDomainMemoryRemove(virDomainDefPtr def,
6ae9ed
 
6ae9ed
     VIR_DELETE_ELEMENT(def->mems, idx, def->nmems);
6ae9ed
 
6ae9ed
-    /* fix up balloon size */
6ae9ed
-    if (def->mem.cur_balloon > virDomainDefGetMemoryTotal(def))
6ae9ed
-        def->mem.cur_balloon = virDomainDefGetMemoryTotal(def);
6ae9ed
-
6ae9ed
     /* fix total memory size of the domain */
6ae9ed
     virDomainDefSetMemoryTotal(def, memory - ret->size);
6ae9ed
 
6ae9ed
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
6ae9ed
index 2fe217d..9c6c1cf 100644
6ae9ed
--- a/src/qemu/qemu_driver.c
6ae9ed
+++ b/src/qemu/qemu_driver.c
6ae9ed
@@ -7788,8 +7788,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
6ae9ed
             return -1;
6ae9ed
         }
6ae9ed
 
6ae9ed
-        if (vmdef->mem.cur_balloon == virDomainDefGetMemoryTotal(vmdef))
6ae9ed
-            vmdef->mem.cur_balloon += dev->data.memory->size;
6ae9ed
+        vmdef->mem.cur_balloon += dev->data.memory->size;
6ae9ed
 
6ae9ed
         if (virDomainMemoryInsert(vmdef, dev->data.memory) < 0)
6ae9ed
             return -1;
6ae9ed
@@ -7846,6 +7845,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
6ae9ed
     virDomainControllerDefPtr cont, det_cont;
6ae9ed
     virDomainChrDefPtr chr;
6ae9ed
     virDomainFSDefPtr fs;
6ae9ed
+    virDomainMemoryDefPtr mem;
6ae9ed
     int idx;
6ae9ed
 
6ae9ed
     switch ((virDomainDeviceType) dev->type) {
6ae9ed
@@ -7943,8 +7943,9 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
6ae9ed
                            _("matching memory device was not found"));
6ae9ed
             return -1;
6ae9ed
         }
6ae9ed
-
6ae9ed
-        virDomainMemoryDefFree(virDomainMemoryRemove(vmdef, idx));
6ae9ed
+        mem = virDomainMemoryRemove(vmdef, idx);
6ae9ed
+        vmdef->mem.cur_balloon -= mem->size;
6ae9ed
+        virDomainMemoryDefFree(mem);
6ae9ed
         break;
6ae9ed
 
6ae9ed
     case VIR_DOMAIN_DEVICE_REDIRDEV:
6ae9ed
-- 
6ae9ed
2.9.2
6ae9ed