1
0
mirror of https://gitlab.com/libvirt/libvirt-python.git synced 2025-07-29 19:41:52 +03:00

Fix parsing of 'flags' argument for bulk stats functions

When 'flags' is set to
'libvirt.VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS,
python will report a  error:

OverflowError: signed integer is greater than maximum

as VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS is defined as 1<<31.
This happens as PyArg_ParseTuple's formatting string containing 'i' as a
modifier expects a signed integer.

With python >= 2.3, 'I' means unsigned int and 'i' means int so we
should use 'I' in the formatting string.

See: https://docs.python.org/2/c-api/arg.html

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Luyao Huang
2014-10-21 17:04:41 +08:00
committed by Peter Krempa
parent 7bfe4e3cf6
commit b3aa7da4bb

View File

@ -8090,7 +8090,7 @@ libvirt_virConnectGetAllDomainStats(PyObject *self ATTRIBUTE_UNUSED,
unsigned int flags;
unsigned int stats;
if (!PyArg_ParseTuple(args, (char *)"Oii:virConnectGetAllDomainStats",
if (!PyArg_ParseTuple(args, (char *)"OII:virConnectGetAllDomainStats",
&pyobj_conn, &stats, &flags))
return NULL;
conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
@ -8126,7 +8126,7 @@ libvirt_virDomainListGetStats(PyObject *self ATTRIBUTE_UNUSED,
unsigned int flags;
unsigned int stats;
if (!PyArg_ParseTuple(args, (char *)"OOii:virDomainListGetStats",
if (!PyArg_ParseTuple(args, (char *)"OOII:virDomainListGetStats",
&pyobj_conn, &py_domlist, &stats, &flags))
return NULL;