aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Campbell <Ian.Campbell@citrix.com>2012-10-26 16:40:18 +0100
committerIan Campbell <Ian.Campbell@citrix.com>2012-10-26 16:40:18 +0100
commitcb39184766909b388b0c432dbea7e3cb2741df6c (patch)
tree083895f847a26e7d289c90c8ca2c4deb9caca7b8
parentb5c1f3d5af8ef0e5f7e74904b18c8ebfb1f2694e (diff)
downloadxen-cb39184766909b388b0c432dbea7e3cb2741df6c.tar.gz
xen-cb39184766909b388b0c432dbea7e3cb2741df6c.tar.bz2
xen-cb39184766909b388b0c432dbea7e3cb2741df6c.zip
libxl: handle errors from xc_sharing_* info functions
On a 32 bit hypervisor xl info currently reports: sharing_freed_memory : 72057594037927935 sharing_used_memory : 72057594037927935 Eat the ENOSYS and turn it into 0. Log and propagate other errors. I don't have a 32 bit system handy, so tested on x86_64 with a libxc hacked to return -ENOSYS and -EINVAL. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Andres Lagar-Cavilla <andres@lagarcavilla.org> Committed-by: Ian Campbell <ian.campbell@citrix.com> xen-unstable changeset: 25894:95a971c8058f Backport-requested-by: Ian Campbell <Ian.Campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
-rw-r--r--tools/libxl/libxl.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 0857c48aee..5d26483073 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -3622,6 +3622,7 @@ int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo)
{
xc_physinfo_t xcphysinfo = { 0 };
int rc;
+ long l;
rc = xc_physinfo(ctx->xch, &xcphysinfo);
if (rc != 0) {
@@ -3636,8 +3637,24 @@ int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo)
physinfo->total_pages = xcphysinfo.total_pages;
physinfo->free_pages = xcphysinfo.free_pages;
physinfo->scrub_pages = xcphysinfo.scrub_pages;
- physinfo->sharing_freed_pages = xc_sharing_freed_pages(ctx->xch);
- physinfo->sharing_used_frames = xc_sharing_used_frames(ctx->xch);
+ 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;
+ }
+ 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;
+ }
+ physinfo->sharing_used_frames = l;
physinfo->nr_nodes = xcphysinfo.nr_nodes;
memcpy(physinfo->hw_cap,xcphysinfo.hw_cap, sizeof(physinfo->hw_cap));