mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-22 14:09:22 +00:00
Make virsh setmaxmem balloon only when successful.
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@redhat.com>
This commit is contained in:
parent
4af1817d1d
commit
963a5b7a08
@ -2596,18 +2596,18 @@ cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kilobytes < info.memory) {
|
|
||||||
if (virDomainSetMemory(dom, kilobytes) != 0) {
|
|
||||||
virDomainFree(dom);
|
|
||||||
vshError(ctl, "%s", _("Unable to shrink current MemorySize"));
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainSetMaxMemory(dom, kilobytes) != 0) {
|
if (virDomainSetMaxMemory(dom, kilobytes) != 0) {
|
||||||
vshError(ctl, "%s", _("Unable to change MaxMemorySize"));
|
vshError(ctl, "%s", _("Unable to change MaxMemorySize"));
|
||||||
|
virDomainFree(dom);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (kilobytes < info.memory) {
|
||||||
|
if (virDomainSetMemory(dom, kilobytes) != 0) {
|
||||||
|
vshError(ctl, "%s", _("Unable to shrink current MemorySize"));
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
virDomainFree(dom);
|
virDomainFree(dom);
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user