1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-20 07:59:00 +00:00

* src/virsh.c: applied SetMem cleanup patch from Mark Johnson

Daniel
This commit is contained in:
Daniel Veillard 2007-06-18 08:33:08 +00:00
parent 852f4340f7
commit af933f6ff0
2 changed files with 33 additions and 0 deletions

View File

@ -1,3 +1,7 @@
Mon Jun 18 10:32:14 CEST 2007 Daniel Veillard <veillard@redhat.com>
* src/virsh.c: applied SetMem cleanup patch from Mark Johnson
Fri Jun 15 16:21:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
* configure.in: Solaris header file fixes (Mark Johnson).

View File

@ -1668,6 +1668,7 @@ static int
cmdSetmem(vshControl * ctl, vshCmd * cmd)
{
virDomainPtr dom;
virDomainInfo info;
int kilobytes;
int ret = TRUE;
@ -1684,6 +1685,18 @@ cmdSetmem(vshControl * ctl, vshCmd * cmd)
return FALSE;
}
if (virDomainGetInfo(dom, &info) != 0) {
virDomainFree(dom);
vshError(ctl, FALSE, _("Unable to verify MaxMemorySize"));
return FALSE;
}
if (kilobytes > info.maxMem) {
virDomainFree(dom);
vshError(ctl, FALSE, _("Invalid value of %d for memory size"), kilobytes);
return FALSE;
}
if (virDomainSetMemory(dom, kilobytes) != 0) {
ret = FALSE;
}
@ -1712,6 +1725,7 @@ static int
cmdSetmaxmem(vshControl * ctl, vshCmd * cmd)
{
virDomainPtr dom;
virDomainInfo info;
int kilobytes;
int ret = TRUE;
@ -1728,7 +1742,22 @@ cmdSetmaxmem(vshControl * ctl, vshCmd * cmd)
return FALSE;
}
if (virDomainGetInfo(dom, &info) != 0) {
virDomainFree(dom);
vshError(ctl, FALSE, _("Unable to verify current MemorySize"));
return FALSE;
}
if (kilobytes < info.memory) {
if (virDomainSetMemory(dom, kilobytes) != 0) {
virDomainFree(dom);
vshError(ctl, FALSE, _("Unable to shrink current MemorySize"));
return FALSE;
}
}
if (virDomainSetMaxMemory(dom, kilobytes) != 0) {
vshError(ctl, FALSE, _("Unable to change MaxMemorySize"));
ret = FALSE;
}