xc Python ext lib: Xen 4.6 Unable to start a 2T guest without OverflowError
PATCH 1/1 xc Python ext lib: Xen 4.6 Unable to start a 2T guest without OverflowError
Starting a vm with memory over 2T resulted in an overflow error.
memory = 2097152 defined as number of megabytes returns the error "OverflowError: signed integer is greater than maximum"
The error is the result of the python extension argument translator defining max_memkb as a signed int instead of an unsigned int. So PyArg_ParseTuple(args, "ii", &dom, &maxmem_kb) overflowed by one with 2147483648 kb.
The other issue is that max_memkb is defined as uint64_t in the subsequent domctl target api so the xc lib and its python C extension should use uint64_t as well.
/* XEN_DOMCTL_max_mem */
struct xen_domctl_max_mem {
/* IN variables. */
uint64_aligned_t max_memkb;
};--- tools/libxc/include/xenctrl.h | 2 +- tools/libxc/xc_domain.c | 2 +- tools/python/xen/lowlevel/xc/xc.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
tools/libxc/include/xenctrl.h +1 -1
@@ -1253,7 +1253,7 @@ int xc_getcpuinfo(xc_interface *xch, int max_cpus,int xc_domain_setmaxmem (xc_interface *xch,uint32_t domid, -unsigned int max_memkb); +uint64_t max_memkb); int xc_domain_set_memmap_limit(xc_interface *xch, uint32_t domid,
tools/libxc/xc_domain.c +1 -1
@@ -630,7 +630,7 @@ int xc_shadow_control(xc_interface *xch,int xc_domain_setmaxmem (xc_interface *xch,uint32_t domid, -unsigned int max_memkb) +uint64_t max_memkb) {DECLARE_DOMCTL ; domctl.cmd = XEN_DOMCTL_max_mem;
tools/python/xen/lowlevel/xc/xc.c +2 -2
@@ -1658,9 +1658,9 @@ static PyObject *pyxc_sched_credit2_domain_get(XcObject *self, PyObject *args)static PyObject *pyxc_domain_setmaxmem (XcObject *self,PyObject *args) {uint32_t dom; -unsigned int maxmem_kb; +uint64_t maxmem_kb; -if (!PyArg_ParseTuple (args,"ii" , &dom, &maxmem_kb)) +if (!PyArg_ParseTuple (args,"ik" , &dom, &maxmem_kb))return NULL ;if (xc_domain_setmaxmem (self->xc_handle, dom, maxmem_kb) !=0 )
Signature · 1 line
1.7.1
Quoted 13 lines · Cathy Avery
Starting a vm with memory over 2T resulted in an overflow error.
memory = 2097152 defined as number of megabytes returns the error "OverflowError: signed integer is greater than maximum"
The error is the result of the python extension argument translator defining
max_memkbas a signed int instead of an unsigned int. SoPyArg_ParseTuple(args, "ii", &dom, &maxmem_kb)overflowed by one with 2147483648 kb.The other issue is that
max_memkbis defined asuint64_tin the subsequent domctl target api so the xc lib and its python C extension should useuint64_tas well.
Quoted 7 lines
/*
XEN_DOMCTL_max_mem*/struct xen_domctl_max_mem { /* IN variables. */ uint64_aligned_t max_memkb; };Signed-off-by Cathy Avery <[email protected]>
Quoted 56 lines
--- tools/libxc/include/xenctrl.h | 2 +- tools/libxc/xc_domain.c | 2 +- tools/python/xen/lowlevel/xc/xc.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)tools/libxc/include/xenctrl.h +1
-1@@ -1253,7 +1253,7 @@ int xc_getcpuinfo(xc_interface *xch, int max_cpus,int xc_domain_setmaxmem (xc_interface *xch,uint32_t domid, -unsigned int max_memkb); +uint64_t max_memkb); int xc_domain_set_memmap_limit(xc_interface *xch, uint32_t domid,tools/libxc/xc_domain.c +1
-1@@ -630,7 +630,7 @@ int xc_shadow_control(xc_interface *xch,int xc_domain_setmaxmem (xc_interface *xch,uint32_t domid, -unsigned int max_memkb) +uint64_t max_memkb) {DECLARE_DOMCTL ; domctl.cmd = XEN_DOMCTL_max_mem;tools/python/xen/lowlevel/xc/xc.c +2
-2@@ -1658,9 +1658,9 @@ static PyObject *pyxc_sched_credit2_domain_get(XcObject *self, PyObject *args)static PyObject *pyxc_domain_setmaxmem (XcObject *self,PyObject *args) {uint32_t dom; -unsigned int maxmem_kb; +uint64_t maxmem_kb; -if (!PyArg_ParseTuple (args,"ii" , &dom, &maxmem_kb)) +if (!PyArg_ParseTuple (args,"ik" , &dom, &maxmem_kb))return NULL ;if (xc_domain_setmaxmem (self->xc_handle, dom, maxmem_kb) !=0 )Signature · 7 lines
1.7.1 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel