From: Yu Zhiguo <yuzg@cn.fujitsu.com>
To: Andre Przywara <andre.przywara@amd.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
Keir Fraser <keir.fraser@eu.citrix.com>
Subject: [PATCH] xl: sanity check for 'xl info'
Date: Wed, 28 Apr 2010 11:35:17 +0800 [thread overview]
Message-ID: <4BD7ACF5.1050600@cn.fujitsu.com> (raw)
In-Reply-To: <4BD570D2.2060204@amd.com>
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@cn.fujitsu.com>
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;
}
prev parent reply other threads:[~2010-04-28 3:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-26 9:16 [PATCH] xl: Don't output a broken result if error occurs in 'xl info' Yu Zhiguo
2010-04-26 10:54 ` Andre Przywara
2010-04-28 3:35 ` Yu Zhiguo [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BD7ACF5.1050600@cn.fujitsu.com \
--to=yuzg@cn.fujitsu.com \
--cc=andre.przywara@amd.com \
--cc=keir.fraser@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.