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>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Shivaprasad G Bhat 2016-07-21 15:39:30 +05:30 committed by Peter Krempa
parent c5d0a2a385
commit 707063efa8
2 changed files with 5 additions and 8 deletions

View File

@ -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);

View File

@ -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: