[libvirt] [PATCH] lxc: fix setmem effect on a running LXC machine

When user calls setmem on a running LXC machine, we do update its cgroup entry (which is in odds with the original bug report, possibly resolved by later versions), however we neither update domain's runtime XML nor we update our internal structures and this patch fixes it. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1131919 --- src/lxc/lxc_driver.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index b3e506f..03a00a9 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -749,6 +749,10 @@ static int lxcDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem, "%s", _("Failed to set memory for domain")); goto cleanup; } + + vm->def->mem.cur_balloon = newmem; + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) + goto cleanup; } if (flags & VIR_DOMAIN_AFFECT_CONFIG) { -- 1.9.3

-----Original Message----- From: libvir-list-bounces@redhat.com [mailto:libvir-list-bounces@redhat.com] On Behalf Of Erik Skultety Sent: Friday, October 24, 2014 5:17 PM To: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH] lxc: fix setmem effect on a running LXC machine
When user calls setmem on a running LXC machine, we do update its cgroup entry (which is in odds with the original bug report, possibly resolved by later versions), however we neither update domain's runtime XML nor we update our internal structures and this patch fixes it.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1131919 --- src/lxc/lxc_driver.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index b3e506f..03a00a9 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -749,6 +749,10 @@ static int lxcDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem, "%s", _("Failed to set memory for domain")); goto cleanup; } + + vm->def->mem.cur_balloon = newmem; + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) + goto cleanup; }
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
Looks good to me. Reviewed-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com> Thanks, - Chen

On 24.10.2014 11:17, Erik Skultety wrote:
When user calls setmem on a running LXC machine, we do update its cgroup entry (which is in odds with the original bug report, possibly resolved by later versions), however we neither update domain's runtime XML nor we update our internal structures and this patch fixes it.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1131919 --- src/lxc/lxc_driver.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index b3e506f..03a00a9 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -749,6 +749,10 @@ static int lxcDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem, "%s", _("Failed to set memory for domain")); goto cleanup; } + + vm->def->mem.cur_balloon = newmem; + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) + goto cleanup; }
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
I guess the qemu driver suffers the same bug, doesn't it? Michal

On 10/29/2014 05:26 AM, Michal Privoznik wrote:
On 24.10.2014 11:17, Erik Skultety wrote:
When user calls setmem on a running LXC machine, we do update its cgroup entry (which is in odds with the original bug report, possibly resolved by later versions), however we neither update domain's runtime XML nor we update our internal structures and this patch fixes it.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1131919 --- src/lxc/lxc_driver.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index b3e506f..03a00a9 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -749,6 +749,10 @@ static int lxcDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem, "%s", _("Failed to set memory for domain")); goto cleanup; } + + vm->def->mem.cur_balloon = newmem; + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) + goto cleanup; }
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
I guess the qemu driver suffers the same bug, doesn't it?
Michal Well, I tried that and it does work fine with fedora 20 and RHEL-6 guests, however it doesn't with RHEL-7.1 nightly guest, no balloon event is emitted by monitor in the latter, not sure why.
Erik

On 10/24/2014 11:17 AM, Erik Skultety wrote:
When user calls setmem on a running LXC machine, we do update its cgroup entry
(which is in odds with the original bug report, possibly resolved
by later versions),
I removed this note as the reporter missed the different units.
however we neither update domain's runtime XML nor we update our internal structures and this patch fixes it.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1131919 --- src/lxc/lxc_driver.c | 4 ++++ 1 file changed, 4 insertions(+)
ACK and pushed. Jan
participants (4)
-
Chen, Hanxiao
-
Erik Skultety
-
Ján Tomko
-
Michal Privoznik