Hi The message which a cause of an error is hard to detect is displayed when "virsh setmaxmem" sets the maximum memory of an active domain less than Used Memory. -------------------------------------------------------------------------------- # virsh setmaxmem 0 4096 libvir: Xen error : failed Xen syscall ioctl 8518692 libvir: Xen Daemon error : POST operation failed: (xend.err "(22, 'Invalid argument')") libvir: error : library call virDomainSetMaxMemory failed, possibly not supported -------------------------------------------------------------------------------- This patch displays the message which is easier to detect the cause of an error to a user. -------------------------------------------------------------------------------- # virsh setmaxmem 0 4096 error: 4096 is less than current used memory. -------------------------------------------------------------------------------- Signed-off-by: Masayuki Sunou <fj1826dm@xxxxxxxxxxxxxxxxx> Thanks, Masayuki Sunou. -------------------------------------------------------------------------------- Index: libvirt/src/virsh.c =================================================================== RCS file: /data/cvs/libvirt/src/virsh.c,v retrieving revision 1.67 diff -u -p -r1.67 virsh.c --- libvirt/src/virsh.c 20 Mar 2007 15:31:46 -0000 1.67 +++ libvirt/src/virsh.c 22 Mar 2007 02:27:16 -0000 @@ -1493,6 +1493,7 @@ static int cmdSetmaxmem(vshControl * ctl, vshCmd * cmd) { virDomainPtr dom; + virDomainInfo info; int bytes; int ret = TRUE; @@ -1509,6 +1510,18 @@ cmdSetmaxmem(vshControl * ctl, vshCmd * return FALSE; } + if (virDomainGetID(dom) != ((unsigned int)-1)) { + if (virDomainGetInfo(dom, &info) != 0) { + virDomainFree(dom); + return FALSE; + } + if (bytes < info.memory) { + vshError(ctl, FALSE, _("%d is less than current used memory."), bytes); + virDomainFree(dom); + return FALSE; + } + } + if (virDomainSetMaxMemory(dom, bytes) != 0) { ret = FALSE; } --------------------------------------------------------------------------------