libxc/libxl: sanitize error handling in *_get_max_{cpus, nodes}

In libxc, make xc_get_max_{cpus,node}() always return either a
positive number or -1, and change all the callers to deal with
that.

In libxl, make libxl_get_max_{cpus,nodes}() always return either a
positive number or a libxl error code. Thanks to that, it is also
possible to fix loggig for libxl_{cpu,node}_bitmap_alloc(), which
now happens inside the functions themselves, more accurately
reporting what happened.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
This commit is contained in:
Dario Faggioli authored and Ian Campbell committed 2013-12-09 15:20:12 +00:00
1 parent 5ad07f45da
commit 2e82c18cd8
4 files changed
+70 -29

No files matched your search

+3 -3
View File
@@ -233,7 +233,7 @@ static PyObject *pyxc_vcpu_setaffinity(XcObject *self,
return NULL;
nr_cpus = xc_get_max_cpus(self->xc_handle);
if ( nr_cpus == 0 )
if ( nr_cpus < 0 )
return pyxc_error_to_exception(self->xc_handle);
cpumap = xc_cpumap_alloc(self->xc_handle);
@@ -392,7 +392,7 @@ static PyObject *pyxc_vcpu_getinfo(XcObject *self,
return NULL;
nr_cpus = xc_get_max_cpus(self->xc_handle);
if ( nr_cpus == 0 )
if ( nr_cpus < 0 )
return pyxc_error_to_exception(self->xc_handle);
rc = xc_vcpu_getinfo(self->xc_handle, dom, vcpu, &info);
@@ -1923,7 +1923,7 @@ static PyObject *cpumap_to_cpulist(XcObject *self, xc_cpumap_t cpumap)
int nr_cpus;
nr_cpus = xc_get_max_cpus(self->xc_handle);
if ( nr_cpus == 0 )
if ( nr_cpus < 0 )
return pyxc_error_to_exception(self->xc_handle);
cpulist = PyList_New(0);
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.