All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Keir Fraser <keir.fraser@eu.citrix.com>
Cc: Ian Campbell <Ian.Campbell@eu.citrix.com>,
	Xen-devel <xen-devel@lists.xensource.com>
Subject: [PATCH] tools: use sysfs interface to balloon driver if present
Date: Fri, 14 Nov 2008 14:47:20 -0800	[thread overview]
Message-ID: <491DFFF8.50005@goop.org> (raw)

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@citrix.com>
diff -r 1944c39d0007 tools/python/xen/xend/osdep.py
--- a/tools/python/xen/xend/osdep.py	Fri Nov 14 09:57:33 2008 -0800
+++ b/tools/python/xen/xend/osdep.py	Fri Nov 14 12:26:51 2008 -0800
@@ -38,7 +38,10 @@
     "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 @@
                           '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 @@
         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."""

                 reply	other threads:[~2008-11-14 22:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=491DFFF8.50005@goop.org \
    --to=jeremy@goop.org \
    --cc=Ian.Campbell@eu.citrix.com \
    --cc=keir.fraser@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.