mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-09-09 01:04:59 +00:00
qemu: Fix balloon size handling with memory hot(un)plug
Since libvirt doesn't call to update the new balloon size in qemu add code that will handle tweaking of the size of the current balloon statistic until qemu reports the new size using the event.
This commit is contained in:
parent
de03b1ddde
commit
2f37362e44
@ -8373,6 +8373,9 @@ qemuDomainAttachDeviceConfig(virQEMUCapsPtr qemuCaps,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (vmdef->mem.cur_balloon == virDomainDefGetMemoryActual(vmdef))
|
||||
vmdef->mem.cur_balloon += dev->data.memory->size;
|
||||
|
||||
if (virDomainMemoryInsert(vmdef, dev->data.memory) < 0)
|
||||
return -1;
|
||||
dev->data.memory = NULL;
|
||||
|
@ -1726,6 +1726,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
|
||||
const char *backendType;
|
||||
virJSONValuePtr props = NULL;
|
||||
virObjectEventPtr event;
|
||||
bool fix_balloon = false;
|
||||
int id;
|
||||
int ret = -1;
|
||||
|
||||
@ -1741,6 +1742,9 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
|
||||
if (virAsprintf(&objalias, "mem%s", mem->info.alias) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (vm->def->mem.cur_balloon == virDomainDefGetMemoryActual(vm->def))
|
||||
fix_balloon = true;
|
||||
|
||||
if (!(devstr = qemuBuildMemoryDeviceStr(mem, vm->def, priv->qemuCaps)))
|
||||
goto cleanup;
|
||||
|
||||
@ -1779,6 +1783,10 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
|
||||
if (event)
|
||||
qemuDomainEventQueue(driver, event);
|
||||
|
||||
/* fix the balloon size if it was set to maximum */
|
||||
if (fix_balloon)
|
||||
vm->def->mem.cur_balloon += mem->size;
|
||||
|
||||
/* mem is consumed by vm->def */
|
||||
mem = NULL;
|
||||
|
||||
@ -2896,6 +2904,8 @@ qemuDomainRemoveMemoryDevice(virQEMUDriverPtr driver,
|
||||
if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
|
||||
goto error;
|
||||
|
||||
vm->def->mem.cur_balloon -= mem->size;
|
||||
|
||||
if ((idx = virDomainMemoryFindByDef(vm->def, mem)) >= 0)
|
||||
virDomainMemoryRemove(vm->def, idx);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user