mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
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:
1 parent
5ad07f45da
commit
2e82c18cd8
4 files changed
+70
-29
No files matched your search
@@ -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);
|
||||
|
||||