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

[Xen-changelog] [xen-unstable] xl: Add some return-code sanity checks to 'xl info'.



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1272970586 -3600
# Node ID df85c12d3c7f5773847e51cdcbf1de9558294527
# Parent  9f1e938261a40548c5403ed4ff92d2183e8d424d
xl: Add some return-code sanity checks to 'xl info'.

Signed-off-by: Yu Zhiguo <yuzg@xxxxxxxxxxxxxx>
---
 tools/libxl/xl_cmdimpl.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff -r 9f1e938261a4 -r df85c12d3c7f tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Tue May 04 11:49:46 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Tue May 04 11:56:26 2010 +0100
@@ -2640,7 +2640,11 @@ static void output_xeninfo(void)
     const libxl_version_info *info;
     int sched_id;
 
-    info = libxl_get_version_info(&ctx);
+    if (!(info = libxl_get_version_info(&ctx))) {
+        fprintf(stderr, "libxl_get_version_info failed.\n");
+        return;
+    }
+
     if ((sched_id = libxl_get_sched_id(&ctx)) < 0) {
         fprintf(stderr, "get_sched_id sysctl failed.\n");
         return;
@@ -2670,14 +2674,13 @@ static void output_nodeinfo(void)
 {
     struct utsname utsbuf;
 
-    uname(&utsbuf);
+    if (uname(&utsbuf) < 0)
+        return;
 
     printf("host                   : %s\n", utsbuf.nodename);
     printf("release                : %s\n", utsbuf.release);
     printf("version                : %s\n", utsbuf.version);
     printf("machine                : %s\n", utsbuf.machine);
-
-    return;
 }
 
 static void output_physinfo(void)
@@ -2706,9 +2709,11 @@ static void output_physinfo(void)
         printf(" hvm_directio");
     printf("\n");
     vinfo = libxl_get_version_info(&ctx);
-    i = (1 << 20) / vinfo->pagesize;
-    printf("total_memory           : %lu\n", info.total_pages / i);
-    printf("free_memory            : %lu\n", info.free_pages / i);
+    if (vinfo) {
+        i = (1 << 20) / vinfo->pagesize;
+        printf("total_memory           : %lu\n", info.total_pages / i);
+        printf("free_memory            : %lu\n", info.free_pages / i);
+    }
 
     return;
 }

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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