All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Prevent changing a memory size of Domain-0 even if users make a careless mistake
@ 2008-04-04 10:06 Masaki Kanno
  2008-04-04 10:13 ` Keir Fraser
  2008-04-04 10:20 ` [PATCH] Prevent changing a memory size of Domain-0 evenif " Jan Beulich
  0 siblings, 2 replies; 14+ messages in thread
From: Masaki Kanno @ 2008-04-04 10:06 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Mail message body --]
[-- Type: text/plain, Size: 1106 bytes --]

Hi,

If users accidentally change a memory size of Domain-0 to very small 
memory size by xm mem-set command, users will be not able to operate 
Domain-0.  I think that Domain-0 is important for Xen, so I'd like to 
prevent the accident by xm mem-set command. 

This patch prevents changing the memory size of Domain-0 by xm mem-set 
command if specified memory size is smaller than dom0-min-mem in 
xend-config.sxp. 

 # cat /etc/xen/xend-config.sxp | grep "(dom0-min-mem"
 (dom0-min-mem 384)
 # xm list Domain-0
 Name                                        ID   Mem VCPUs      State   Time(s)
 Domain-0                                     0   941     2     r-----     62.6
 # xm mem-set Domain-0 1
 Error: memory_dynamic_max cannot be changed for safety reasons
 Usage: xm mem-set <Domain> <Mem>
 
 Set the current memory usage for a domain.
 # xm list Domain-0
 Name                                        ID   Mem VCPUs      State   Time(s)
 Domain-0                                     0   941     2     r-----     63.6


Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>

Best regards,
 Kan


[-- Attachment #2: safe_xm_memset.patch --]
[-- Type: application/octet-stream, Size: 848 bytes --]

diff -r db943e8d1051 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py	Tue Apr 01 10:09:33 2008 +0100
+++ b/tools/python/xen/xend/XendDomainInfo.py	Fri Apr 04 13:43:55 2008 +0900
@@ -986,6 +986,14 @@ class XendDomainInfo:
                   self.info['name_label'], str(self.domid), target)
         
         MiB = 1024 * 1024
+
+        if self.domid == 0:
+            dom0_min_mem = xoptions.get_dom0_min_mem()
+            memory_cur = self.get_memory_dynamic_max() / MiB
+            if target < memory_cur:
+                if dom0_min_mem == 0 or dom0_min_mem > target:
+                    raise XendError("memory_dynamic_max cannot be changed for safety reasons")
+
         self._safe_set_memory('memory_dynamic_min', target * MiB)
         self._safe_set_memory('memory_dynamic_max', target * MiB)
 

[-- 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	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2008-04-07  2:54 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-04 10:06 [PATCH] Prevent changing a memory size of Domain-0 even if users make a careless mistake Masaki Kanno
2008-04-04 10:13 ` Keir Fraser
2008-04-04 11:12   ` [PATCH] Prevent changing a memory size ofDomain-0 " Masaki Kanno
2008-04-05 18:36   ` [PATCH] Prevent changing a memory size of Domain-0 " Mark Williamson
2008-04-07  0:38     ` [PATCH] Prevent changing a memory size of Domain-0even " Masaki Kanno
2008-04-07  0:56       ` Mark Williamson
2008-04-07  2:54         ` Masaki Kanno
2008-04-04 10:20 ` [PATCH] Prevent changing a memory size of Domain-0 evenif " Jan Beulich
2008-04-04 10:27   ` Keir Fraser
2008-04-04 10:50     ` [PATCH] Prevent changing a memory size ofDomain-0 " Jan Beulich
2008-04-04 10:51       ` Keir Fraser
2008-04-05 18:45     ` [PATCH] Prevent changing a memory size of Domain-0 " Mark Williamson
2008-04-04 11:58   ` John Levon
2008-04-04 15:06   ` Jeremy Fitzhardinge

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.