[libvirt] [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 <sbhat@linux.vnet.ibm.com> --- src/conf/domain_conf.c | 3 +-- src/qemu/qemu_driver.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6dfcf81..8b0b790 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14674,8 +14674,7 @@ 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); + def->mem.cur_balloon -= ret->size; /* 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 cda85f6..3824e1d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7769,8 +7769,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;

On Thu, Jul 21, 2016 at 15:39:30 +0530, Shivaprasad G Bhat wrote:
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 <sbhat@linux.vnet.ibm.com> --- src/conf/domain_conf.c | 3 +-- src/qemu/qemu_driver.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6dfcf81..8b0b790 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14674,8 +14674,7 @@ 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);
It will be better to move the balloon adjustment to the qemu driver completely since the modification is done just there.
+ def->mem.cur_balloon -= ret->size;
/* fix total memory size of the domain */ virDomainDefSetMemoryTotal(def, memory - ret->size);
For the hotplug case we are fixing this by querying the balloon so no adjustments are necessary there. ACK with the change (I've already made it locally) and I'll push it in a while. Peter
participants (2)
-
Peter Krempa
-
Shivaprasad G Bhat