ia64/xen-unstable

changeset 8158:e6d64c356d63

Added a pages_to_kib function, which converts a page count into a number of
KiB. This allows us to compute the correct amount to balloon out to support
a migration.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Thu Dec 01 03:19:40 2005 +0000 (2005-12-01)
parents 28ce48573771
children fbbb8a2a6013
files tools/python/xen/lowlevel/xc/xc.c
line diff
     1.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Wed Nov 30 19:55:08 2005 +0000
     1.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Thu Dec 01 03:19:40 2005 +0000
     1.3 @@ -576,6 +576,17 @@ static PyObject *pyxc_readconsolering(Xc
     1.4  }
     1.5  
     1.6  
     1.7 +static PyObject *pyxc_pages_to_kib(XcObject *self, PyObject *args)
     1.8 +{
     1.9 +    unsigned long pages;
    1.10 +
    1.11 +    if (!PyArg_ParseTuple(args, "l", &pages))
    1.12 +        return NULL;
    1.13 +
    1.14 +    return PyLong_FromUnsignedLong(pages * (XC_PAGE_SIZE / 1024));
    1.15 +}
    1.16 +
    1.17 +
    1.18  static unsigned long pages_to_mb(unsigned long pages)
    1.19  {
    1.20      return (pages * (XC_PAGE_SIZE / 1024) + 1023) / 1024;
    1.21 @@ -1059,6 +1070,12 @@ static PyMethodDef pyxc_methods[] = {
    1.22        " allow_access [int]: Non-zero means enable access; else disable access\n\n"
    1.23        "Returns: [int] 0 on success; -1 on error.\n" },
    1.24  
    1.25 +    { "pages_to_kib",
    1.26 +      (PyCFunction)pyxc_pages_to_kib,
    1.27 +      METH_VARARGS, "\n"
    1.28 +      "Returns: [int]: The size in KiB of memory spanning the given number "
    1.29 +      "of pages.\n" },
    1.30 +
    1.31      { NULL, NULL, 0, NULL }
    1.32  };
    1.33