aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Jackson <Ian.Jackson@eu.citrix.com>2012-11-01 17:42:44 +0000
committerIan Jackson <Ian.Jackson@eu.citrix.com>2012-11-01 17:42:44 +0000
commit1918a6f3cbd20db6d37ad13af859348f6c7a1520 (patch)
tree58c319a29a241cee77c21384f7a8a234fe4a6d98
parent1825a707b71957773891c7c6c861b56721cd3535 (diff)
downloadxen-1918a6f3cbd20db6d37ad13af859348f6c7a1520.tar.gz
xen-1918a6f3cbd20db6d37ad13af859348f6c7a1520.tar.bz2
xen-1918a6f3cbd20db6d37ad13af859348f6c7a1520.zip
libxl: properly handle errors from page sharing hypercalls
25886:051e2a30e3fb (25894:95a971c8058f in xen-unstable) is wrong because it assumes that xc_sharing_freed_pages etc. return -errnoval on error. However, like other libxc calls they return -1 setting errno. Correct this, checking for l<0 and then testing errno against ENOSYS, and also log the correct errno value. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
-rw-r--r--tools/libxl/libxl.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 64e4c079ec..25b9f41962 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -3653,21 +3653,25 @@ int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo)
physinfo->free_pages = xcphysinfo.free_pages;
physinfo->scrub_pages = xcphysinfo.scrub_pages;
l = xc_sharing_freed_pages(ctx->xch);
- if (l == -ENOSYS) {
- l = 0;
- } else if (l < 0) {
- LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, l,
- "getting sharing freed pages");
- return ERROR_FAIL;
+ if (l < 0) {
+ if (errno == ENOSYS) {
+ l = 0;
+ } else {
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
+ "getting sharing freed pages");
+ return ERROR_FAIL;
+ }
}
physinfo->sharing_freed_pages = l;
l = xc_sharing_used_frames(ctx->xch);
- if (l == -ENOSYS) {
- l = 0;
- } else if (l < 0) {
- LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, l,
- "getting sharing used frames");
- return ERROR_FAIL;
+ if (l < 0) {
+ if (errno == ENOSYS) {
+ l = 0;
+ } else {
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
+ "getting sharing used frames");
+ return ERROR_FAIL;
+ }
}
physinfo->sharing_used_frames = l;
physinfo->nr_nodes = xcphysinfo.nr_nodes;