diff --git a/ChangeLog b/ChangeLog index b62efb8a6e798fe689adb6914cf8edb59b25453d..34ac3befd653ed6fa58e058827d9a3f85cee6214 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Mon Jun 18 10:32:14 CEST 2007 Daniel Veillard + + * src/virsh.c: applied SetMem cleanup patch from Mark Johnson + Fri Jun 15 16:21:00 BST 2007 Richard W.M. Jones * configure.in: Solaris header file fixes (Mark Johnson). diff --git a/src/virsh.c b/src/virsh.c index be2af348d4d28fdbb7730f23ecb9492484f545cb..77d4fb6c18ceeaaaca6a2ff474b151e7d1affe63 100644 --- a/src/virsh.c +++ b/src/virsh.c @@ -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; }