提交 2f37362e 编写于 作者: P Peter Krempa

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.
上级 de03b1dd
...@@ -8373,6 +8373,9 @@ qemuDomainAttachDeviceConfig(virQEMUCapsPtr qemuCaps, ...@@ -8373,6 +8373,9 @@ qemuDomainAttachDeviceConfig(virQEMUCapsPtr qemuCaps,
return -1; return -1;
} }
if (vmdef->mem.cur_balloon == virDomainDefGetMemoryActual(vmdef))
vmdef->mem.cur_balloon += dev->data.memory->size;
if (virDomainMemoryInsert(vmdef, dev->data.memory) < 0) if (virDomainMemoryInsert(vmdef, dev->data.memory) < 0)
return -1; return -1;
dev->data.memory = NULL; dev->data.memory = NULL;
......
...@@ -1726,6 +1726,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver, ...@@ -1726,6 +1726,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
const char *backendType; const char *backendType;
virJSONValuePtr props = NULL; virJSONValuePtr props = NULL;
virObjectEventPtr event; virObjectEventPtr event;
bool fix_balloon = false;
int id; int id;
int ret = -1; int ret = -1;
...@@ -1741,6 +1742,9 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver, ...@@ -1741,6 +1742,9 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
if (virAsprintf(&objalias, "mem%s", mem->info.alias) < 0) if (virAsprintf(&objalias, "mem%s", mem->info.alias) < 0)
goto cleanup; goto cleanup;
if (vm->def->mem.cur_balloon == virDomainDefGetMemoryActual(vm->def))
fix_balloon = true;
if (!(devstr = qemuBuildMemoryDeviceStr(mem, vm->def, priv->qemuCaps))) if (!(devstr = qemuBuildMemoryDeviceStr(mem, vm->def, priv->qemuCaps)))
goto cleanup; goto cleanup;
...@@ -1779,6 +1783,10 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver, ...@@ -1779,6 +1783,10 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
if (event) if (event)
qemuDomainEventQueue(driver, 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 is consumed by vm->def */
mem = NULL; mem = NULL;
...@@ -2896,6 +2904,8 @@ qemuDomainRemoveMemoryDevice(virQEMUDriverPtr driver, ...@@ -2896,6 +2904,8 @@ qemuDomainRemoveMemoryDevice(virQEMUDriverPtr driver,
if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
goto error; goto error;
vm->def->mem.cur_balloon -= mem->size;
if ((idx = virDomainMemoryFindByDef(vm->def, mem)) >= 0) if ((idx = virDomainMemoryFindByDef(vm->def, mem)) >= 0)
virDomainMemoryRemove(vm->def, idx); virDomainMemoryRemove(vm->def, idx);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册