|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH] xl: print runtime info in "xl list -l"
On Wed, 2013-09-04 at 10:04 -0400, Konrad Rzeszutek Wilk wrote:
> - No status in xl list -l when only dom0 is present.
Which bits of status are you interested in?
I'm thinking something like the following, which will include the
content of libxl_dominfo for every domain.
8<----------------------------------
From ee9fb6c41cd53afd4983fd2e21ad0e39f178c066 Mon Sep 17 00:00:00 2001
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Thu, 12 Sep 2013 13:50:33 +0100
Subject: [PATCH] xl: print runtime info in "xl list -l"
Include dom0 runtime information, but not domain config.
Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
tools/libxl/xl_cmdimpl.c | 74 ++++++++++++++++++++++++++++------------------
1 file changed, 46 insertions(+), 28 deletions(-)
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 884f050..46fdafc 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -298,7 +298,8 @@ static void dolog(const char *file, int line, const char
*func, char *fmt, ...)
}
static yajl_gen_status printf_info_one_json(yajl_gen hand, int domid,
- libxl_domain_config *d_config)
+ libxl_domain_config *d_config,
+ libxl_dominfo *d_info)
{
yajl_gen_status s;
@@ -317,13 +318,25 @@ static yajl_gen_status printf_info_one_json(yajl_gen
hand, int domid,
if (s != yajl_gen_status_ok)
goto out;
- s = yajl_gen_string(hand, (const unsigned char *)"config",
- sizeof("config")-1);
- if (s != yajl_gen_status_ok)
- goto out;
- s = libxl_domain_config_gen_json(hand, d_config);
- if (s != yajl_gen_status_ok)
- goto out;
+ if (d_config) {
+ s = yajl_gen_string(hand, (const unsigned char *)"config",
+ sizeof("config")-1);
+ if (s != yajl_gen_status_ok)
+ goto out;
+ s = libxl_domain_config_gen_json(hand, d_config);
+ if (s != yajl_gen_status_ok)
+ goto out;
+ }
+
+ if (d_info) {
+ s = yajl_gen_string(hand, (const unsigned char *)"info",
+ sizeof("info")-1);
+ if (s != yajl_gen_status_ok)
+ goto out;
+ s = libxl_dominfo_gen_json(hand, d_info);
+ if (s != yajl_gen_status_ok)
+ goto out;
+ }
s = yajl_gen_map_close(hand);
if (s != yajl_gen_status_ok)
@@ -350,7 +363,7 @@ static void printf_info(enum output_format output_format,
return;
}
- s = printf_info_one_json(hand, domid, d_config);
+ s = printf_info_one_json(hand, domid, d_config, NULL);
if (s != yajl_gen_status_ok)
goto out;
@@ -2990,7 +3003,7 @@ static void reboot_domain(uint32_t domid,
libxl_evgen_domain_death **deathw,
}
}
-static void list_domains_details(const libxl_dominfo *info, int nb_domain)
+static void list_domains_details(libxl_dominfo *info, int nb_domain)
{
libxl_domain_config d_config;
@@ -3017,26 +3030,31 @@ static void list_domains_details(const libxl_dominfo
*info, int nb_domain)
s = yajl_gen_status_ok;
for (i = 0; i < nb_domain; i++) {
- /* no detailed info available on dom0 */
- if (info[i].domid == 0)
- continue;
- rc = libxl_userdata_retrieve(ctx, info[i].domid, "xl", &data, &len);
- if (rc)
- continue;
- CHK_ERRNO(asprintf(&config_source, "<domid %d data>", info[i].domid));
- libxl_domain_config_init(&d_config);
- parse_config_data(config_source, (char *)data, len, &d_config, NULL);
- if (default_output_format == OUTPUT_FORMAT_JSON)
- s = printf_info_one_json(hand, info[i].domid, &d_config);
- else
+ fprintf(stderr, "dom%d\n", info[i].domid);
+
+ if ( info[i].domid > 0 ) {
+ fprintf(stderr, "parse d_config for dom%d\n", info[i].domid);
+ rc = libxl_userdata_retrieve(ctx, info[i].domid, "xl", &data,
&len);
+ if (rc)
+ continue;
+ CHK_ERRNO(asprintf(&config_source, "<domid %d data>",
info[i].domid));
+ libxl_domain_config_init(&d_config);
+ parse_config_data(config_source, (char *)data, len, &d_config,
NULL);
+ } else { fprintf(stderr, "no d_config\n"); }
+ if (default_output_format == OUTPUT_FORMAT_JSON) {
+ s = printf_info_one_json(hand, info[i].domid,
+ i == 0 ? NULL : &d_config, &info[i]);
+ if (s != yajl_gen_status_ok)
+ goto out;
+ } else
printf_info_sexp(info[i].domid, &d_config);
- libxl_domain_config_dispose(&d_config);
- free(data);
- free(config_source);
- if (s != yajl_gen_status_ok)
- goto out;
- }
+ if ( info[i].domid > 0 ) {
+ libxl_domain_config_dispose(&d_config);
+ free(data);
+ free(config_source);
+ }
+ }
if (default_output_format == OUTPUT_FORMAT_JSON) {
s = yajl_gen_array_close(hand);
if (s != yajl_gen_status_ok)
--
1.7.10.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |