ia64/xen-unstable

changeset 18129:0bf73f557f41

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@amd.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jul 22 11:55:06 2008 +0100 (2008-07-22)
parents 770ca32e1925
children fc44e35b3913
files tools/python/xen/xend/balloon.py tools/python/xen/xend/osdep.py
line diff
     1.1 --- a/tools/python/xen/xend/balloon.py	Tue Jul 22 08:01:56 2008 +0100
     1.2 +++ b/tools/python/xen/xend/balloon.py	Tue Jul 22 11:55:06 2008 +0100
     1.3 @@ -39,11 +39,11 @@ SLEEP_TIME_GROWTH = 0.1
     1.4  
     1.5  # A mapping between easy-to-remember labels and the more verbose
     1.6  # label actually shown in the PROC_XEN_BALLOON file.
     1.7 -labels = { 'current'      : 'Current allocation',
     1.8 -           'target'       : 'Requested target',
     1.9 -           'low-balloon'  : 'Low-mem balloon',
    1.10 -           'high-balloon' : 'High-mem balloon',
    1.11 -           'limit'        : 'Xen hard limit' }
    1.12 +#labels = { 'current'      : 'Current allocation',
    1.13 +#           'target'       : 'Requested target',
    1.14 +#           'low-balloon'  : 'Low-mem balloon',
    1.15 +#           'high-balloon' : 'High-mem balloon',
    1.16 +#           'limit'        : 'Xen hard limit' }
    1.17  
    1.18  def _get_proc_balloon(label):
    1.19      """Returns the value for the named label.  Returns None if the label was
    1.20 @@ -54,7 +54,7 @@ def _get_proc_balloon(label):
    1.21  def get_dom0_current_alloc():
    1.22      """Returns the current memory allocation (in KiB) of dom0."""
    1.23  
    1.24 -    kb = _get_proc_balloon(labels['current'])
    1.25 +    kb = _get_proc_balloon('current')
    1.26      if kb == None:
    1.27          raise VmError('Failed to query current memory allocation of dom0.')
    1.28      return kb
    1.29 @@ -62,7 +62,7 @@ def get_dom0_current_alloc():
    1.30  def get_dom0_target_alloc():
    1.31      """Returns the target memory allocation (in KiB) of dom0."""
    1.32  
    1.33 -    kb = _get_proc_balloon(labels['target'])
    1.34 +    kb = _get_proc_balloon('target')
    1.35      if kb == None:
    1.36          raise VmError('Failed to query target memory allocation of dom0.')
    1.37      return kb
     2.1 --- a/tools/python/xen/xend/osdep.py	Tue Jul 22 08:01:56 2008 +0100
     2.2 +++ b/tools/python/xen/xend/osdep.py	Tue Jul 22 11:55:06 2008 +0100
     2.3 @@ -41,12 +41,18 @@ import os
     2.4  def _linux_balloon_stat(label):
     2.5      """Returns the value for the named label, or None if an error occurs."""
     2.6  
     2.7 +    xend2linux_labels = { 'current'      : 'Current allocation',
     2.8 +                          'target'       : 'Requested target',
     2.9 +                          'low-balloon'  : 'Low-mem balloon',
    2.10 +                          'high-balloon' : 'High-mem balloon',
    2.11 +                          'limit'        : 'Xen hard limit' }
    2.12 +
    2.13      PROC_XEN_BALLOON = '/proc/xen/balloon'
    2.14      f = file(PROC_XEN_BALLOON, 'r')
    2.15      try:
    2.16          for line in f:
    2.17              keyvalue = line.split(':')
    2.18 -            if keyvalue[0] == label:
    2.19 +            if keyvalue[0] == xend2linux_labels[label]:
    2.20                  values = keyvalue[1].split()
    2.21                  if values[0].isdigit():
    2.22                      return int(values[0])
    2.23 @@ -67,11 +73,11 @@ def _solaris_balloon_stat(label):
    2.24      BLN_IOCTL_LOW = 0x42410003
    2.25      BLN_IOCTL_HIGH = 0x42410004
    2.26      BLN_IOCTL_LIMIT = 0x42410005
    2.27 -    label_to_ioctl = { 'Current allocation' : BLN_IOCTL_CURRENT,
    2.28 -                       'Requested target'   : BLN_IOCTL_TARGET,
    2.29 -                       'Low-mem balloon'    : BLN_IOCTL_LOW,
    2.30 -                       'High-mem balloon'   : BLN_IOCTL_HIGH,
    2.31 -                       'Xen hard limit'     : BLN_IOCTL_LIMIT }
    2.32 +    label_to_ioctl = { 'current'      : BLN_IOCTL_CURRENT,
    2.33 +                       'target'       : BLN_IOCTL_TARGET,
    2.34 +                       'low-balloon'  : BLN_IOCTL_LOW,
    2.35 +                       'high-balloon' : BLN_IOCTL_HIGH,
    2.36 +                       'limit'        : BLN_IOCTL_LIMIT }
    2.37  
    2.38      f = file(DEV_XEN_BALLOON, 'r')
    2.39      try: