On 07/07/10 - 05:35:39PM, Chris Lalancette wrote:
After playing around with virsh setmaxmem for a bit,
I ran into some surprising behavior; if a hypervisor does
not support the virDomainSetMaxMemory() API, but the value
specified for setmaxmem is less than the current amount
of memory in the domain, the domain would be ballooned
down *before* an error was reported.
To make this more consistent, run virDomainSetMaxMemory()
before trying to shrink; that way, if an error is thrown,
no changes to the running domain are made.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
ping, any review on this?
---
tools/virsh.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 0631590..97bfa20 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -2529,19 +2529,19 @@ cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd)
return FALSE;
}
+ if (virDomainSetMaxMemory(dom, kilobytes) != 0) {
+ vshError(ctl, "%s", _("Unable to change MaxMemorySize"));
+ virDomainFree(dom);
+ return FALSE;
+ }
+
if (kilobytes < info.memory) {
if (virDomainSetMemory(dom, kilobytes) != 0) {
- virDomainFree(dom);
vshError(ctl, "%s", _("Unable to shrink current
MemorySize"));
- return FALSE;
+ ret = FALSE;
}
}
- if (virDomainSetMaxMemory(dom, kilobytes) != 0) {
- vshError(ctl, "%s", _("Unable to change MaxMemorySize"));
- ret = FALSE;
- }
-
virDomainFree(dom);
return ret;
}
--
1.6.6.1
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
--
--
Chris Lalancette