153 lines
4.6 KiB
Diff
153 lines
4.6 KiB
Diff
Index: xen-3.0.3-testing/tools/python/xen/lowlevel/xc/xc.c
|
|
===================================================================
|
|
--- xen-3.0.3-testing.orig/tools/python/xen/lowlevel/xc/xc.c
|
|
+++ xen-3.0.3-testing/tools/python/xen/lowlevel/xc/xc.c
|
|
@@ -23,6 +23,13 @@
|
|
#define PyMODINIT_FUNC DL_EXPORT(void)
|
|
#endif
|
|
|
|
+/* Needed for Python versions earlier than 2.5, due to PEP353 */
|
|
+#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
|
|
+typedef int Py_ssize_t;
|
|
+#define PY_SSIZE_T_MAX INT_MAX
|
|
+#define PY_SSIZE_T_MIN INT_MIN
|
|
+#endif
|
|
+
|
|
#define PKG "xen.lowlevel.xc"
|
|
#define CLS "xc"
|
|
|
|
@@ -65,9 +72,12 @@ static PyObject *pyxc_domain_create(XcOb
|
|
PyObject *args,
|
|
PyObject *kwds)
|
|
{
|
|
- uint32_t dom = 0;
|
|
- int ret, i;
|
|
- uint32_t ssidref = 0;
|
|
+ uint32_t dom;
|
|
+ Py_ssize_t _dom = 0;
|
|
+ uint32_t ssidref;
|
|
+ Py_ssize_t _ssidref = 0;
|
|
+ Py_ssize_t i;
|
|
+ int ret;
|
|
PyObject *pyhandle = NULL;
|
|
xen_domain_handle_t handle = {
|
|
0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef,
|
|
@@ -76,8 +86,10 @@ static PyObject *pyxc_domain_create(XcOb
|
|
static char *kwd_list[] = { "dom", "ssidref", "handle", NULL };
|
|
|
|
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|iiO", kwd_list,
|
|
- &dom, &ssidref, &pyhandle))
|
|
+ &_dom, &_ssidref, &pyhandle))
|
|
return NULL;
|
|
+ dom = Py_SAFE_DOWNCAST(_dom, Py_ssize_t, uint32_t);
|
|
+ ssidref = Py_SAFE_DOWNCAST(_ssidref, Py_ssize_t, uint32_t);
|
|
|
|
if ( pyhandle != NULL )
|
|
{
|
|
@@ -140,7 +152,8 @@ static PyObject *pyxc_vcpu_setaffinity(X
|
|
PyObject *kwds)
|
|
{
|
|
uint32_t dom;
|
|
- int vcpu = 0, i;
|
|
+ int vcpu = 0;
|
|
+ Py_ssize_t i;
|
|
uint64_t cpumap = ~0ULL;
|
|
PyObject *cpulist = NULL;
|
|
|
|
@@ -186,7 +199,7 @@ static PyObject *pyxc_domain_setcpuweigh
|
|
|
|
static PyObject *pyxc_domain_sethandle(XcObject *self, PyObject *args)
|
|
{
|
|
- int i;
|
|
+ Py_ssize_t i;
|
|
uint32_t dom;
|
|
PyObject *pyhandle;
|
|
xen_domain_handle_t handle;
|
|
Index: xen-3.0.3-testing/tools/python/xen/lowlevel/xs/xs.c
|
|
===================================================================
|
|
--- xen-3.0.3-testing.orig/tools/python/xen/lowlevel/xs/xs.c
|
|
+++ xen-3.0.3-testing/tools/python/xen/lowlevel/xs/xs.c
|
|
@@ -21,6 +21,13 @@
|
|
|
|
#include <Python.h>
|
|
|
|
+/* Needed for Python versions earlier than 2.5, due to PEP353 */
|
|
+#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
|
|
+typedef int Py_ssize_t;
|
|
+#define PY_SSIZE_T_MAX INT_MAX
|
|
+#define PY_SSIZE_T_MIN INT_MIN
|
|
+#endif
|
|
+
|
|
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
@@ -320,6 +327,7 @@ static PyObject *xspy_set_permissions(Xs
|
|
int i, result;
|
|
struct xs_permissions *xsperms = NULL;
|
|
int xsperms_n;
|
|
+ Py_ssize_t _xsperms_n;
|
|
PyObject *tuple0 = NULL;
|
|
|
|
xs_transaction_t th;
|
|
@@ -336,7 +344,9 @@ static PyObject *xspy_set_permissions(Xs
|
|
xs_set_error(EINVAL);
|
|
goto exit;
|
|
}
|
|
- xsperms_n = PyList_Size(perms);
|
|
+ _xsperms_n = PyList_Size(perms);
|
|
+ /* Should never overflow an int, since xs interface uses int */
|
|
+ xsperms_n = Py_SAFE_DOWNCAST(_xsperms_n, Py_ssize_t, int);
|
|
xsperms = calloc(xsperms_n, sizeof(struct xs_permissions));
|
|
if (!xsperms) {
|
|
xs_set_error(ENOMEM);
|
|
@@ -393,7 +403,7 @@ static PyObject *xspy_watch(XsHandle *se
|
|
PyObject *token;
|
|
char token_str[MAX_STRLEN(unsigned long) + 1];
|
|
int result;
|
|
- int i;
|
|
+ Py_ssize_t i;
|
|
|
|
if (!xh)
|
|
return NULL;
|
|
@@ -439,7 +449,7 @@ static PyObject *xspy_read_watch(XsHandl
|
|
PyObject *val = NULL;
|
|
char **xsval;
|
|
PyObject *token;
|
|
- int i;
|
|
+ Py_ssize_t i;
|
|
unsigned int num;
|
|
|
|
if (!xh)
|
|
@@ -658,7 +668,7 @@ static PyObject *xspy_release_domain(XsH
|
|
static PyObject *xspy_close(XsHandle *self)
|
|
{
|
|
struct xs_handle *xh = xshandle(self);
|
|
- int i;
|
|
+ Py_ssize_t i;
|
|
|
|
if (!xh)
|
|
return NULL;
|
|
@@ -716,7 +726,7 @@ static PyObject *xspy_get_domain_path(Xs
|
|
*/
|
|
static void remove_watch(XsHandle *self, PyObject *token)
|
|
{
|
|
- int i;
|
|
+ Py_ssize_t i;
|
|
|
|
for (i = 0; i < PyList_Size(self->watches); i++) {
|
|
if (PyList_GetItem(self->watches, i) == token) {
|
|
Index: xen-3.0.3-testing/tools/Makefile
|
|
===================================================================
|
|
--- xen-3.0.3-testing.orig/tools/Makefile
|
|
+++ xen-3.0.3-testing/tools/Makefile
|
|
@@ -22,7 +22,8 @@ SUBDIRS-y += blktap
|
|
# These don't cross-compile
|
|
ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH))
|
|
SUBDIRS-y += python
|
|
-SUBDIRS-y += pygrub
|
|
+# pygrub is unsupported by SUSE, and does not build cleanly with Python 2.5
|
|
+#SUBDIRS-y += pygrub
|
|
endif
|
|
|
|
.PHONY: all
|