]> xenbits.xensource.com Git - people/vhanquez/xen.git/commitdiff
xm: Fix xm vcpu-pin to complain for CPU numbers out of range.
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 21 Feb 2008 15:15:02 +0000 (15:15 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 21 Feb 2008 15:15:02 +0000 (15:15 +0000)
Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
xen-unstable changeset:   17092:511ab2b89ced1e190c6c76139b60049b69be69ef
xen-unstable date:        Wed Feb 20 17:42:12 2008 +0000

tools/python/xen/lowlevel/xc/xc.c

index ac230f326ed89b50decdd1445275d0ade154e18a..275c3173c6a75fff39b1090da5a11158c2093350 100644 (file)
@@ -226,7 +226,16 @@ static PyObject *pyxc_vcpu_setaffinity(XcObject *self,
     {
         cpumap = 0ULL;
         for ( i = 0; i < PyList_Size(cpulist); i++ ) 
-            cpumap |= (uint64_t)1 << PyInt_AsLong(PyList_GetItem(cpulist, i));
+        {
+            long cpu = PyInt_AsLong(PyList_GetItem(cpulist, i));
+            if ( cpu >= 64 )
+            {
+                errno = EINVAL;
+                PyErr_SetFromErrno(xc_error_obj);
+                return NULL;
+            }
+            cpumap |= (uint64_t)1 << cpu;
+        }
     }
   
     if ( xc_vcpu_setaffinity(self->xc_handle, dom, vcpu, cpumap) != 0 )