All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Disallow setting maxmem to higher value than total physical memory size
@ 2010-09-01 12:31 Michal Novotny
  2010-09-01 12:44 ` Ian Campbell
  0 siblings, 1 reply; 19+ messages in thread
From: Michal Novotny @ 2010-09-01 12:31 UTC (permalink / raw)
  To: 'xen-devel@lists.xensource.com'

[-- Attachment #1: Type: text/plain, Size: 1637 bytes --]

Hi,
this is the patch to disallow changing the maxmem value to higher value 
than total physical memory size since without this patch I was able to 
set dom0 maxmem to higher (invalid) value which is not correct. The 
check for total memory size using the xc.physinfo()['total_mem'] has 
been implemented in this patch and also the check for negative or zero 
value in setMemoryMaximum() has been added. When user enters an invalid 
value (no matter whether negative/zero or higher than total physical 
memory size) an error is returned saying that the memory size is invalid 
since no domain (no matter whether dom0 or domU) can have memory higher 
than maxmem and this prevents maxmem value to be higher than total 
physical memory installed on dom0. Also, on dom0/domU start the domain 
maxmem is being checked against whether it doesn't exceed the total 
physical memory configuration and if it does the value is being reduced 
the the physical memory size to disallow possibility to set to some 
higher value.

You can check the patch by `xm list -l | grep maxmem` command which now 
returns the dom0 physical size on dom0 boot up and when you try to set 
maximum memory of both dom0 and domU you can't set this to higher value 
than dom0 total physical memory size. Since there's a sanity check on 
setting up new memory on domain you'll get "Error: memory_dynamic_max 
must be less than or equal to memory_static_max" when trying to set to 
higher value than domain's maxmem.

Michal

Signed-off-by: Michal Novotny <minovotn@redhat.com>

-- 
Michal Novotny<minovotn@redhat.com>, RHCE
Virtualization Team (xen userspace), Red Hat


[-- Attachment #2: xen-disallow-setting-max-mem-higher-than-total-phys-mem.patch --]
[-- Type: text/x-patch, Size: 1230 bytes --]

diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py
index 4360ce2..b38b418 100644
--- a/tools/python/xen/xend/XendDomainInfo.py
+++ b/tools/python/xen/xend/XendDomainInfo.py
@@ -152,6 +152,11 @@ def recreate(info, priv):
 
     assert not info['dying']
 
+    # Validate domain maxmem value not to be higher than dom0 physical memory
+    total_mem = int(xc.physinfo()['total_memory'])
+    if info['maxmem_kb'] > total_mem:
+        info['maxmem_kb'] = total_mem
+
     xeninfo = XendConfig.XendConfig(dominfo = info)
     xeninfo['is_control_domain'] = priv
     xeninfo['is_a_template'] = False
@@ -1490,6 +1495,13 @@ class XendDomainInfo:
         """Set the maximum memory limit of this domain
         @param limit: In MiB.
         """
+        # Get total memory and convert to MiB
+        total_mem = int(xc.physinfo()['total_memory'] / 1024)
+
+        if limit <= 0 or limit > total_mem:
+            raise XendError('Invalid memory size, only positive values '
+                            'up to %s MiB are valid' % total_mem)
+
         log.debug("Setting memory maximum of domain %s (%s) to %d MiB.",
                   self.info['name_label'], str(self.domid), limit)
 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2010-09-02  5:43 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-01 12:31 [PATCH] Disallow setting maxmem to higher value than total physical memory size Michal Novotny
2010-09-01 12:44 ` Ian Campbell
2010-09-01 13:01   ` Michal Novotny
2010-09-01 13:37     ` Ian Campbell
2010-09-01 14:18       ` Michal Novotny
2010-09-01 14:21         ` Michal Novotny
2010-09-01 14:26         ` Jan Beulich
2010-09-01 14:50           ` Michal Novotny
2010-09-01 15:00             ` Jan Beulich
2010-09-01 15:10               ` Michal Novotny
2010-09-01 15:14                 ` Jan Beulich
2010-09-01 15:20         ` Ian Campbell
2010-09-01 15:34           ` Michal Novotny
2010-09-01 16:53   ` Jeremy Fitzhardinge
2010-09-01 17:56     ` Ian Campbell
2010-09-01 18:15       ` Jeremy Fitzhardinge
2010-09-01 18:53         ` Ian Campbell
2010-09-01 21:10           ` Jeremy Fitzhardinge
2010-09-02  5:43             ` Ian Campbell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.