From 707063efa86a8cab3ee7d64ad203f2e517b82bce Mon Sep 17 00:00:00 2001 From: Shivaprasad G Bhat Date: Thu, 21 Jul 2016 15:39:30 +0530 Subject: [PATCH] qemu: Adjust the cur_ballon on coldplug/unplug of dimms The cur_balloon also increases/decreases with dimm hotplug/unplug. To be consistent, adjust the value for coldplug too. This was inconsistently taken care when cur_ballon != memory to begin with. The patch fixes it irrespective of that. Signed-off-by: Shivaprasad G Bhat Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 4 ---- src/qemu/qemu_driver.c | 9 +++++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 13e5dc9792..c1ddb5a09d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14623,10 +14623,6 @@ virDomainMemoryRemove(virDomainDefPtr def, VIR_DELETE_ELEMENT(def->mems, idx, def->nmems); - /* fix up balloon size */ - if (def->mem.cur_balloon > virDomainDefGetMemoryTotal(def)) - def->mem.cur_balloon = virDomainDefGetMemoryTotal(def); - /* fix total memory size of the domain */ virDomainDefSetMemoryTotal(def, memory - ret->size); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0501003e2e..f07526f143 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7768,8 +7768,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, return -1; } - if (vmdef->mem.cur_balloon == virDomainDefGetMemoryTotal(vmdef)) - vmdef->mem.cur_balloon += dev->data.memory->size; + vmdef->mem.cur_balloon += dev->data.memory->size; if (virDomainMemoryInsert(vmdef, dev->data.memory) < 0) return -1; @@ -7826,6 +7825,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, virDomainControllerDefPtr cont, det_cont; virDomainChrDefPtr chr; virDomainFSDefPtr fs; + virDomainMemoryDefPtr mem; int idx; switch ((virDomainDeviceType) dev->type) { @@ -7923,8 +7923,9 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, _("matching memory device was not found")); return -1; } - - virDomainMemoryDefFree(virDomainMemoryRemove(vmdef, idx)); + mem = virDomainMemoryRemove(vmdef, idx); + vmdef->mem.cur_balloon -= mem->size; + virDomainMemoryDefFree(mem); break; case VIR_DOMAIN_DEVICE_REDIRDEV: