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. --- src/qemu/qemu_driver.c | 3 +++ src/qemu/qemu_hotplug.c | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d6e7570..187145a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8379,6 +8379,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; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 613b728..c3b3efb 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1727,6 +1727,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver, const char *backendType; virJSONValuePtr props = NULL; virObjectEventPtr event; + bool fix_balloon = false; int id; int ret = -1; @@ -1742,6 +1743,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; @@ -1780,6 +1784,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; @@ -2897,6 +2905,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); -- 2.3.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list