mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
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:
1 parent
f814d1f288
commit
5bc6f1ef3d
1 file changed
+17
@@ -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 }
|
||||
};
|
||||
|
||||
|
||||