2011-03-21 17:47:37 +01:00
|
|
|
Index: xen-4.1.0-testing/tools/python/xen/xend/XendNode.py
|
2007-01-16 00:42:10 +01:00
|
|
|
===================================================================
|
2011-03-21 17:47:37 +01:00
|
|
|
--- xen-4.1.0-testing.orig/tools/python/xen/xend/XendNode.py
|
|
|
|
+++ xen-4.1.0-testing/tools/python/xen/xend/XendNode.py
|
|
|
|
@@ -949,10 +949,33 @@ class XendNode:
|
2007-12-20 16:46:41 +01:00
|
|
|
|
2007-01-16 00:42:10 +01:00
|
|
|
info['cpu_mhz'] = info['cpu_khz'] / 1000
|
2007-04-26 01:53:07 +02:00
|
|
|
|
|
|
|
- # physinfo is in KiB, need it in MiB
|
2007-01-16 00:42:10 +01:00
|
|
|
- info['total_memory'] = info['total_memory'] / 1024
|
|
|
|
- info['free_memory'] = info['free_memory'] / 1024
|
2011-03-21 17:47:37 +01:00
|
|
|
- info['free_cpus'] = len(XendCPUPool.unbound_cpus())
|
2007-04-26 01:53:07 +02:00
|
|
|
+ configured_floor = xendoptions().get_dom0_min_mem() * 1024
|
2007-01-16 00:42:10 +01:00
|
|
|
+ from xen.xend import balloon
|
|
|
|
+ try:
|
|
|
|
+ kernel_floor = balloon.get_dom0_min_target()
|
|
|
|
+ except:
|
|
|
|
+ kernel_floor = 0
|
|
|
|
+ dom0_min_mem = max(configured_floor, kernel_floor)
|
|
|
|
+ dom0_mem = balloon.get_dom0_current_alloc()
|
|
|
|
+ extra_mem = 0
|
|
|
|
+ if dom0_min_mem > 0 and dom0_mem > dom0_min_mem:
|
|
|
|
+ extra_mem = dom0_mem - dom0_min_mem
|
|
|
|
+ info['free_memory'] = info['free_memory'] + info['scrub_memory']
|
|
|
|
+ info['max_free_memory'] = info['free_memory'] + extra_mem
|
|
|
|
+
|
|
|
|
+ # Convert KiB to MiB, rounding down to be conservative
|
|
|
|
+ info['total_memory'] = info['total_memory'] / 1024
|
|
|
|
+ info['free_memory'] = info['free_memory'] / 1024
|
|
|
|
+ info['max_free_memory'] = info['max_free_memory'] / 1024
|
2011-03-21 17:47:37 +01:00
|
|
|
+
|
2007-01-16 00:42:10 +01:00
|
|
|
+ # FIXME: These are hard-coded to be the inverse of the getXenMemory
|
|
|
|
+ # functions in image.py. Find a cleaner way.
|
|
|
|
+ info['max_para_memory'] = info['max_free_memory'] - 4
|
|
|
|
+ if info['max_para_memory'] < 0:
|
|
|
|
+ info['max_para_memory'] = 0
|
|
|
|
+ info['max_hvm_memory'] = int((info['max_free_memory']-12) * (1-2.4/1024))
|
|
|
|
+ if info['max_hvm_memory'] < 0:
|
|
|
|
+ info['max_hvm_memory'] = 0
|
2011-03-21 17:47:37 +01:00
|
|
|
|
2007-01-16 00:42:10 +01:00
|
|
|
ITEM_ORDER = ['nr_cpus',
|
|
|
|
'nr_nodes',
|
2011-03-21 17:47:37 +01:00
|
|
|
@@ -964,6 +987,9 @@ class XendNode:
|
2007-01-16 00:42:10 +01:00
|
|
|
'total_memory',
|
|
|
|
'free_memory',
|
2011-03-21 17:47:37 +01:00
|
|
|
'free_cpus',
|
2007-01-16 00:42:10 +01:00
|
|
|
+ 'max_free_memory',
|
|
|
|
+ 'max_para_memory',
|
|
|
|
+ 'max_hvm_memory',
|
2011-03-21 17:47:37 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
if show_numa != 0:
|
|
|
|
Index: xen-4.1.0-testing/tools/python/xen/xend/balloon.py
|
2007-01-16 00:42:10 +01:00
|
|
|
===================================================================
|
2011-03-21 17:47:37 +01:00
|
|
|
--- xen-4.1.0-testing.orig/tools/python/xen/xend/balloon.py
|
|
|
|
+++ xen-4.1.0-testing/tools/python/xen/xend/balloon.py
|
2010-01-16 01:12:54 +01:00
|
|
|
@@ -43,6 +43,8 @@ SLEEP_TIME_GROWTH = 0.1
|
2007-01-16 00:42:10 +01:00
|
|
|
# label actually shown in the PROC_XEN_BALLOON file.
|
2008-08-18 00:24:29 +02:00
|
|
|
#labels = { 'current' : 'Current allocation',
|
|
|
|
# 'target' : 'Requested target',
|
|
|
|
+# 'min-target' : 'Minimum target',
|
|
|
|
+# 'max-target' : 'Maximum target',
|
|
|
|
# 'low-balloon' : 'Low-mem balloon',
|
|
|
|
# 'high-balloon' : 'High-mem balloon',
|
|
|
|
# 'limit' : 'Xen hard limit' }
|
2010-01-16 01:12:54 +01:00
|
|
|
@@ -69,6 +71,23 @@ def get_dom0_target_alloc():
|
2007-01-16 00:42:10 +01:00
|
|
|
raise VmError('Failed to query target memory allocation of dom0.')
|
|
|
|
return kb
|
|
|
|
|
|
|
|
+def get_dom0_min_target():
|
|
|
|
+ """Returns the minimum amount of memory (in KiB) that dom0 will accept."""
|
|
|
|
+
|
|
|
|
+ kb = _get_proc_balloon(labels['min-target'])
|
|
|
|
+ if kb == None:
|
|
|
|
+ raise VmError('Failed to query minimum target memory allocation of dom0.')
|
|
|
|
+ return kb
|
|
|
|
+
|
|
|
|
+def get_dom0_max_target():
|
|
|
|
+ """Returns the maximum amount of memory (in KiB) that is potentially
|
|
|
|
+ visible to dom0."""
|
|
|
|
+
|
|
|
|
+ kb = _get_proc_balloon(labels['max-target'])
|
|
|
|
+ if kb == None:
|
|
|
|
+ raise VmError('Failed to query maximum target memory allocation of dom0.')
|
|
|
|
+ return kb
|
|
|
|
+
|
2009-05-04 18:38:09 +02:00
|
|
|
def free(need_mem, dominfo):
|
2007-01-16 00:42:10 +01:00
|
|
|
"""Balloon out memory from the privileged domain so that there is the
|
|
|
|
specified required amount (in KiB) free.
|
2011-03-21 17:47:37 +01:00
|
|
|
Index: xen-4.1.0-testing/tools/python/xen/xend/XendDomainInfo.py
|
2007-01-16 00:42:10 +01:00
|
|
|
===================================================================
|
2011-03-21 17:47:37 +01:00
|
|
|
--- xen-4.1.0-testing.orig/tools/python/xen/xend/XendDomainInfo.py
|
|
|
|
+++ xen-4.1.0-testing/tools/python/xen/xend/XendDomainInfo.py
|
|
|
|
@@ -1459,6 +1459,27 @@ class XendDomainInfo:
|
2010-01-16 01:12:54 +01:00
|
|
|
pci_conf = self.info['devices'][dev_uuid][1]
|
|
|
|
return map(pci_dict_to_bdf_str, pci_conf['devs'])
|
2007-01-16 00:42:10 +01:00
|
|
|
|
|
|
|
+ def capAndSetMemoryTarget(self, target):
|
|
|
|
+ """Potentially lowers the requested target to the largest possible
|
|
|
|
+ value (i.e., caps it), and then sets the memory target of this domain
|
|
|
|
+ to that value.
|
|
|
|
+ @param target in MiB.
|
|
|
|
+ """
|
|
|
|
+ max_target = 0
|
|
|
|
+ if self.domid == 0:
|
|
|
|
+ try:
|
|
|
|
+ from balloon import get_dom0_max_target
|
|
|
|
+ max_target = get_dom0_max_target() / 1024
|
|
|
|
+ except:
|
|
|
|
+ # It's nice to cap the max at sane values, but harmless to set
|
|
|
|
+ # them high. Carry on.
|
|
|
|
+ pass
|
|
|
|
+ if max_target and target > max_target:
|
|
|
|
+ log.debug("Requested memory target %d MiB; maximum reasonable is %d MiB.",
|
|
|
|
+ target, max_target)
|
|
|
|
+ target = max_target
|
|
|
|
+ self.setMemoryTarget(target)
|
|
|
|
+
|
|
|
|
def setMemoryTarget(self, target):
|
|
|
|
"""Set the memory target of this domain.
|
2007-02-11 11:48:10 +01:00
|
|
|
@param target: In MiB.
|
2011-03-21 17:47:37 +01:00
|
|
|
Index: xen-4.1.0-testing/tools/python/xen/xend/server/SrvDomain.py
|
2007-01-16 00:42:10 +01:00
|
|
|
===================================================================
|
2011-03-21 17:47:37 +01:00
|
|
|
--- xen-4.1.0-testing.orig/tools/python/xen/xend/server/SrvDomain.py
|
|
|
|
+++ xen-4.1.0-testing/tools/python/xen/xend/server/SrvDomain.py
|
|
|
|
@@ -187,7 +187,7 @@ class SrvDomain(SrvDir):
|
2007-01-16 00:42:10 +01:00
|
|
|
|
|
|
|
|
|
|
|
def op_mem_target_set(self, _, req):
|
|
|
|
- return self.call(self.dom.setMemoryTarget,
|
|
|
|
+ return self.call(self.dom.capAndSetMemoryTarget,
|
|
|
|
[['target', 'int']],
|
|
|
|
req)
|
|
|
|
|