]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Fix unsigned long wraparound in python binding
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 15 Nov 2006 19:40:00 +0000 (19:40 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 15 Nov 2006 19:40:00 +0000 (19:40 +0000)
ChangeLog
python/libvir.c
python/libvirt_wrap.h
python/types.c

index 0084b239d9dcb9253666df39839294e689bc2328..7c17c5d6b43858b1bd49a91ae25994952dc88e39 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
index a7b98dc000d49af89f78efdfbd84f82bc9fc1a74..6d14fb2fe87ab4f22876ede5a09f9b2d228431ee 100644 (file)
@@ -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));
index 906245aeee1b3ab29d0a4d43ef9fb82ebd5e0dc7..8bcfdb3c7f7a998254d08a5e01e13dac80ad0826 100644 (file)
@@ -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);
index b98beef5d6f8f3cf2237655690ce54932486f5e3..4ad4fa595cb38ae7cce1ddb4534f768c1129d1b6 100644 (file)
@@ -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)
 {