[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] libxl: handle errors from xc_sharing_* info functions



On Wed, 2012-09-05 at 15:52 +0100, Ian Campbell wrote:
> I'll respin with this approach, it's less mad.

8<-------------------------------------

# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1347294326 -3600
# Node ID e2a8f423ed64c696a61dec88fe8e1976939a7193
# Parent  b02d3fdfab4295c4da3594444cabed898fcc90f7
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@xxxxxxxxxx>
Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Acked-by: Andres Lagar-Cavilla <andres@xxxxxxxxxxxxxxxx>

diff -r b02d3fdfab42 -r e2a8f423ed64 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Mon Sep 10 17:22:01 2012 +0100
+++ b/tools/libxl/libxl.c       Mon Sep 10 17:25:26 2012 +0100
@@ -3622,6 +3622,7 @@ int libxl_get_physinfo(libxl_ctx *ctx, l
 {
     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, l
     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));
 



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.