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>
This commit is contained in:
emellor@leeni.uk.xensource.com committed 2005-12-01 03:19:40 +00:00
1 parent f814d1f288
commit 5bc6f1ef3d
1 file changed
+17
+17
View File
@@ -576,6 +576,17 @@ static PyObject *pyxc_readconsolering(XcObject *self,
}
static PyObject *pyxc_pages_to_kib(XcObject *self, PyObject *args)
{
unsigned long pages;
if (!PyArg_ParseTuple(args, "l", &pages))
return NULL;
return PyLong_FromUnsignedLong(pages * (XC_PAGE_SIZE / 1024));
}
static unsigned long pages_to_mb(unsigned long pages)
{
return (pages * (XC_PAGE_SIZE / 1024) + 1023) / 1024;
@@ -1059,6 +1070,12 @@ static PyMethodDef pyxc_methods[] = {
" allow_access [int]: Non-zero means enable access; else disable access\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "pages_to_kib",
(PyCFunction)pyxc_pages_to_kib,
METH_VARARGS, "\n"
"Returns: [int]: The size in KiB of memory spanning the given number "
"of pages.\n" },
{ NULL, NULL, 0, NULL }
};
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.