Add memory size checking for xm create/mem-set command
PATCH 1/1 Add memory size checking for xm create/mem-set command
Hi,
The "xm create" command does not check the value of memory size now. The "xm mem-set" command does not check, too. When I tested the "xm create" and the "xm mem-set" command by setting an obviously wrong value to the memory size, the results were as follows.
# xm create /xen/vm1.conf memory=0 Using config file "/xen/vm1.conf". Error: (22, 'Invalid argument')
# xm create /xen/vm1.conf memory=-1 Using config file "/xen/vm1.conf". Error: (22, 'Invalid argument')
# xm list Name ID Mem(MiB) VCPUs State Time(s) Domain-0 0 506 2 r----- 108.4 vm1 5 128 1 -b---- 31.3 # xm mem-set vm1 0 # xm list Name ID Mem(MiB) VCPUs State Time(s) Domain-0 0 506 2 r----- 109.2 vm1 5 27 1 -b---- 31.8 *The following message was output to the console of domU. Out of Memory: Kill process 2 (migration/0) score 0 and children.
# xm list Name ID Mem(MiB) VCPUs State Time(s) Domain-0 0 506 2 r----- 159.2 vm1 7 128 1 -b---- 31.6 # xm mem-set vm1 -1 # xm list Name ID Mem(MiB) VCPUs State Time(s) Domain-0 0 506 2 r----- 159.9 vm1 7 -1 1 -b---- 31.6
I think that the xm/xend should check the obviously wrong memory size, and should show an error message.
This patch adds the checking of obviously wrong memory size about the "xm create" and "xm mem-set" command.
# xm create /xen/vm1.conf memory=0 Using config file "/xen/vm1.conf". Error: invalid memory size # xm create /xen/vm1.conf memory=-1 Using config file "/xen/vm1.conf". Error: invalid memory size
# xm mem-set vm1 0 Error: Invalid memory size # xm mem-set vm1 -1 Error: Invalid memory size
Best regards,
Kan
tools/python/xen/xend/XendDomainInfo.py +5 -0
@@ -596,6 +596,8 @@ class XendDomainInfo: if self.info['memory'] == 0: if self.infoIsSet('mem_kb'): self.info['memory'] = (self.info['mem_kb'] + 1023) / 1024 + if self.info['memory'] <= 0: + raise VmError('invalid memory size') if self.info['maxmem'] < self.info['memory']: self.info['maxmem'] = self.info['memory']
@@ -1001,6 +1003,9 @@ class XendDomainInfo: """Set the memory target of this domain. @param target In MiB. """ + if target <= 0: + raise XendError("Invalid memory size") + log.debug("Setting memory target of domain %s (%d) to %d MiB.", self.info['name'], self.domid, target)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 4 lines · Masaki Kanno
I think that the xm/xend should check the obviously wrong memory size, and should show an error message.
This patch adds the checking of obviously wrong memory size about the "xm create" and "xm mem-set" command.
[snip..]
Thanks for the patch. Applied to xen-unstable.
Cheers,
Alastair