mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
Fix unsigned long wraparound in python binding
This commit is contained in:
parent
6d8b20ce85
commit
a3cf19e62a
@ -1,3 +1,9 @@
|
||||
Wed Nov 15 15:42:01 EST 2006 Daniel Berrange <berrange@redhat.com>
|
||||
|
||||
* python/libvir.c, python/libvirt_wrap.h, python/types.h: Ensure
|
||||
that unsigned longs are marshalled to python Long type instead
|
||||
of Int, to avoid 32-bit integer wraparound
|
||||
|
||||
Tue Nov 14 18:42:01 EST 2006 Daniel Berrange <berrange@redhat.com>
|
||||
|
||||
* src/xend_internal.c: Added support for parsing non-bridge style
|
||||
|
@ -261,8 +261,8 @@ libvirt_virDomainGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
|
||||
}
|
||||
py_retval = PyList_New(5);
|
||||
PyList_SetItem(py_retval, 0, libvirt_intWrap((int) info.state));
|
||||
PyList_SetItem(py_retval, 1, libvirt_longWrap((long) info.maxMem));
|
||||
PyList_SetItem(py_retval, 2, libvirt_longWrap((long) info.memory));
|
||||
PyList_SetItem(py_retval, 1, libvirt_ulongWrap(info.maxMem));
|
||||
PyList_SetItem(py_retval, 2, libvirt_ulongWrap(info.memory));
|
||||
PyList_SetItem(py_retval, 3, libvirt_intWrap((int) info.nrVirtCpu));
|
||||
PyList_SetItem(py_retval, 4,
|
||||
libvirt_longlongWrap((unsigned long long) info.cpuTime));
|
||||
|
@ -41,6 +41,7 @@ typedef struct {
|
||||
|
||||
PyObject * libvirt_intWrap(int val);
|
||||
PyObject * libvirt_longWrap(long val);
|
||||
PyObject * libvirt_ulongWrap(unsigned long val);
|
||||
PyObject * libvirt_longlongWrap(long long val);
|
||||
PyObject * libvirt_charPtrWrap(char *str);
|
||||
PyObject * libvirt_constcharPtrWrap(const char *str);
|
||||
|
@ -33,6 +33,18 @@ libvirt_longWrap(long val)
|
||||
return (ret);
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libvirt_ulongWrap(unsigned long val)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("libvirt_ulongWrap: val = %lu\n", val);
|
||||
#endif
|
||||
ret = PyLong_FromLong(val);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libvirt_longlongWrap(long long val)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user