WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] xl: sanity check for 'xl info'

To: Andre Przywara <andre.przywara@xxxxxxx>
Subject: [Xen-devel] [PATCH] xl: sanity check for 'xl info'
From: Yu Zhiguo <yuzg@xxxxxxxxxxxxxx>
Date: Wed, 28 Apr 2010 11:35:17 +0800
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>, Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Delivery-date: Tue, 27 Apr 2010 20:35:21 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <4BD570D2.2060204@xxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <4BD559E1.6030102@xxxxxxxxxxxxxx> <4BD570D2.2060204@xxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 3.0a1 (Windows/2008050715)
Andre Przywara wrote:
> Yu Zhiguo wrote:
>> If error occurs in 'xl info', we'd better output an error message
>> rather than a broken result.
> Do you consider an incomplete output as broken? If I got this right, you
> want to make sure that you output everything or nothing with this patch.
> Wouldn't it be sufficient to just add the missing check for utsname()
> and output the other infos regardless? Was there a scenario where broken
> output was generated? So far I only see missing Xen support or missing
> privileges to cause errors.

It seems that xm will always output all or nothing, so I think we'd better
compatible with xm. But it isn't so important, just add sanity check now.

Regards
Yu Zhiguo

--------------------------------------

Add sanity check for 'xl info'.

Signed-off-by: Yu Zhiguo <yuzg@xxxxxxxxxxxxxx>

diff -r c87ec146229a -r c4a684b35c7b tools/libxl/xl.c
--- a/tools/libxl/xl.c  Fri Apr 23 15:04:26 2010 +0100
+++ b/tools/libxl/xl.c  Wed Apr 28 19:24:13 2010 +0800
@@ -2647,7 +2647,10 @@
     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;
@@ -2677,12 +2680,12 @@
 {
     struct utsname utsbuf;
 
-    uname(&utsbuf);
-
-    printf("host                   : %s\n", utsbuf.nodename);
-    printf("release                : %s\n", utsbuf.release);
-    printf("version                : %s\n", utsbuf.version);
-    printf("machine                : %s\n", utsbuf.machine);
+    if (uname(&utsbuf) != -1) {
+        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;
 }
@@ -2713,9 +2716,11 @@
         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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>