Masaki Kanno
2007-Feb-19 14:04 UTC
[Xen-devel] A strange behavior by the xm vcpu-pin command
Hi all, I found a strange behavior by the xm vcpu-pin command. My machine has two physical CPUs. When I specified "64" to physical CPU number, the CPU affinity was "0". When I specified "65" to physical CPU number, the CPU affinity was "1". When I specified "66" to physical CPU number, the xm vcpu-pin command was error. # xm vcpu-list vm1 Name ID VCPU CPU State Time(s) CPU Affinity vm1 2 0 1 --- 19.0 any cpu # xm vcpu-pin vm1 0 64 # xm vcpu-list vm1 Name ID VCPU CPU State Time(s) CPU Affinity vm1 2 0 0 -b- 21.0 0 # xm vcpu-pin vm1 0 65 # xm vcpu-list vm1 Name ID VCPU CPU State Time(s) CPU Affinity vm1 2 0 1 -b- 22.6 1 # xm vcpu-pin vm1 0 66 Error: (22, ''Invalid argument'') Usage: xm vcpu-pin <Domain> <VCPU> <CPUs> Set which CPUs a VCPU can use. # xm vcpu-list vm1 Name ID VCPU CPU State Time(s) CPU Affinity vm1 2 0 1 -b- 24.6 1 I thought that the cause is in line 201 of pyxc_vcpu_setaffinity(). But I think that the value of cpumap is 0 when shifting by the value of 64 or more. If the valus of cpumap is 0, I think that the strange behavior does not occur. Where is a true cause? 182 static PyObject *pyxc_vcpu_setaffinity(XcObject *self, 183 PyObject *args, 184 PyObject *kwds) 185 { 186 uint32_t dom; 187 int vcpu = 0, i; 188 uint64_t cpumap = ~0ULL; 189 PyObject *cpulist = NULL; 190 191 static char *kwd_list[] = { "domid", "vcpu", "cpumap", NULL }; 192 193 if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|iO", kwd_list, 194 &dom, &vcpu, &cpulist) ) 195 return NULL; 196 197 if ( (cpulist != NULL) && PyList_Check(cpulist) ) 198 { 199 cpumap = 0ULL; 200 for ( i = 0; i < PyList_Size(cpulist); i++ ) 201 cpumap |= (uint64_t)1 << PyInt_AsLong(PyList_GetItem(cpulist, i)); 202 } 203 204 if ( xc_vcpu_setaffinity(self->xc_handle, dom, vcpu, cpumap) != 0 ) 205 return pyxc_error_to_exception(); 206 207 Py_INCREF(zero); 208 return zero; 209 } Best regards, Kan _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel