[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] xend balloon: portability cleanup



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1216724106 -3600
# Node ID 0bf73f557f417f7649304cca41d177fb1f36b332
# Parent  770ca32e192523c00bbb0ae76342c1ac577b3465
xend balloon: portability cleanup

Move the linux specific labels to osdep where they
belong. Modification on Solaris code ok'd by SUN (Ryan Scott).

Signed-off-by: Christoph Egger <Christoph.Egger@xxxxxxx>
---
 tools/python/xen/xend/balloon.py |   14 +++++++-------
 tools/python/xen/xend/osdep.py   |   18 ++++++++++++------
 2 files changed, 19 insertions(+), 13 deletions(-)

diff -r 770ca32e1925 -r 0bf73f557f41 tools/python/xen/xend/balloon.py
--- a/tools/python/xen/xend/balloon.py  Tue Jul 22 08:01:56 2008 +0100
+++ b/tools/python/xen/xend/balloon.py  Tue Jul 22 11:55:06 2008 +0100
@@ -39,11 +39,11 @@ SLEEP_TIME_GROWTH = 0.1
 
 # A mapping between easy-to-remember labels and the more verbose
 # label actually shown in the PROC_XEN_BALLOON file.
-labels = { 'current'      : 'Current allocation',
-           'target'       : 'Requested target',
-           'low-balloon'  : 'Low-mem balloon',
-           'high-balloon' : 'High-mem balloon',
-           'limit'        : 'Xen hard limit' }
+#labels = { 'current'      : 'Current allocation',
+#           'target'       : 'Requested target',
+#           'low-balloon'  : 'Low-mem balloon',
+#           'high-balloon' : 'High-mem balloon',
+#           'limit'        : 'Xen hard limit' }
 
 def _get_proc_balloon(label):
     """Returns the value for the named label.  Returns None if the label was
@@ -54,7 +54,7 @@ def get_dom0_current_alloc():
 def get_dom0_current_alloc():
     """Returns the current memory allocation (in KiB) of dom0."""
 
-    kb = _get_proc_balloon(labels['current'])
+    kb = _get_proc_balloon('current')
     if kb == None:
         raise VmError('Failed to query current memory allocation of dom0.')
     return kb
@@ -62,7 +62,7 @@ def get_dom0_target_alloc():
 def get_dom0_target_alloc():
     """Returns the target memory allocation (in KiB) of dom0."""
 
-    kb = _get_proc_balloon(labels['target'])
+    kb = _get_proc_balloon('target')
     if kb == None:
         raise VmError('Failed to query target memory allocation of dom0.')
     return kb
diff -r 770ca32e1925 -r 0bf73f557f41 tools/python/xen/xend/osdep.py
--- a/tools/python/xen/xend/osdep.py    Tue Jul 22 08:01:56 2008 +0100
+++ b/tools/python/xen/xend/osdep.py    Tue Jul 22 11:55:06 2008 +0100
@@ -41,12 +41,18 @@ def _linux_balloon_stat(label):
 def _linux_balloon_stat(label):
     """Returns the value for the named label, or None if an error occurs."""
 
+    xend2linux_labels = { 'current'      : 'Current allocation',
+                          'target'       : 'Requested target',
+                          'low-balloon'  : 'Low-mem balloon',
+                          'high-balloon' : 'High-mem balloon',
+                          'limit'        : 'Xen hard limit' }
+
     PROC_XEN_BALLOON = '/proc/xen/balloon'
     f = file(PROC_XEN_BALLOON, 'r')
     try:
         for line in f:
             keyvalue = line.split(':')
-            if keyvalue[0] == label:
+            if keyvalue[0] == xend2linux_labels[label]:
                 values = keyvalue[1].split()
                 if values[0].isdigit():
                     return int(values[0])
@@ -67,11 +73,11 @@ def _solaris_balloon_stat(label):
     BLN_IOCTL_LOW = 0x42410003
     BLN_IOCTL_HIGH = 0x42410004
     BLN_IOCTL_LIMIT = 0x42410005
-    label_to_ioctl = { 'Current allocation' : BLN_IOCTL_CURRENT,
-                       'Requested target'   : BLN_IOCTL_TARGET,
-                       'Low-mem balloon'    : BLN_IOCTL_LOW,
-                       'High-mem balloon'   : BLN_IOCTL_HIGH,
-                       'Xen hard limit'     : BLN_IOCTL_LIMIT }
+    label_to_ioctl = { 'current'      : BLN_IOCTL_CURRENT,
+                       'target'       : BLN_IOCTL_TARGET,
+                       'low-balloon'  : BLN_IOCTL_LOW,
+                       'high-balloon' : BLN_IOCTL_HIGH,
+                       'limit'        : BLN_IOCTL_LIMIT }
 
     f = file(DEV_XEN_BALLOON, 'r')
     try:

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.