WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] tools: use sysfs interface to balloon dri

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] tools: use sysfs interface to balloon driver if present
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 19 Nov 2008 08:10:36 -0800
Delivery-date: Wed, 19 Nov 2008 08:12:23 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1226937271 0
# Node ID 17911073a90a09c0dd781c2f09368d2d8b4c883e
# Parent  2188ed106885586376f7eb428b9ea9f16ec6f7c7
tools: use sysfs interface to balloon driver if present

The pvops dom0 kernel does not expose the balloon driver via
/proc/xen, so use the sysfs interface.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>
---
 tools/python/xen/xend/osdep.py |   29 +++++++++++++++++++++++++++--
 1 files changed, 27 insertions(+), 2 deletions(-)

diff -r 2188ed106885 -r 17911073a90a tools/python/xen/xend/osdep.py
--- a/tools/python/xen/xend/osdep.py    Fri Nov 14 14:33:25 2008 +0000
+++ b/tools/python/xen/xend/osdep.py    Mon Nov 17 15:54:31 2008 +0000
@@ -38,7 +38,10 @@ _vif_script = {
     "SunOS": "vif-vnic"
 }
 
-def _linux_balloon_stat(label):
+PROC_XEN_BALLOON = '/proc/xen/balloon'
+SYSFS_XEN_MEMORY = '/sys/devices/system/xen_memory/xen_memory0'
+
+def _linux_balloon_stat_proc(label):
     """Returns the value for the named label, or None if an error occurs."""
 
     xend2linux_labels = { 'current'      : 'Current allocation',
@@ -47,7 +50,6 @@ def _linux_balloon_stat(label):
                           '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:
@@ -61,6 +63,29 @@ def _linux_balloon_stat(label):
         return None
     finally:
         f.close()
+
+def _linux_balloon_stat_sysfs(label):
+    sysfiles = { 'target'       : 'target_kb',
+                 'current'      : 'info/current_kb',
+                 'low-balloon'  : 'info/low_kb',
+                 'high-balloon' : 'info/high_kb',
+                 'limit'        : 'info/hard_limit_kb' }
+
+    name = os.path.join(SYSFS_XEN_MEMORY, sysfiles[label])
+    f = file(name, 'r')
+
+    val = f.read().strip()
+    if val.isdigit():
+        return int(val)
+    return None
+
+def _linux_balloon_stat(label):
+       if os.access(PROC_XEN_BALLOON, os.F_OK):
+               return _linux_balloon_stat_proc(label)
+       elif os.access(SYSFS_XEN_MEMORY, os.F_OK):
+               return _linux_balloon_stat_sysfs(label)
+
+       return None
 
 def _solaris_balloon_stat(label):
     """Returns the value for the named label, or None if an error occurs."""

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] tools: use sysfs interface to balloon driver if present, Xen patchbot-unstable <=