* [PATCHv2 1/4] libxl: extend physinfo structure
2010-04-21 14:17 [PATCHv2 0/4] Add "xl info" command Andre Przywara
@ 2010-04-21 14:17 ` Andre Przywara
2010-04-22 8:03 ` Paolo Bonzini
2010-04-21 14:17 ` [PATCHv2 2/4] libxl: add sched_get_id function Andre Przywara
` (3 subsequent siblings)
4 siblings, 1 reply; 13+ messages in thread
From: Andre Przywara @ 2010-04-21 14:17 UTC (permalink / raw)
To: Ian.Jackson, vincent.hanquez, Keir.Fraser; +Cc: Andre Przywara, xen-devel
The libxl version of the physinfo sysctl does not contain some
fields like nr_nodes or capabilities needed for xl info output.
Add them to the structure and the retrieving function.
Signed-off-by: Andre Przywara <andre.przywara@amd.com>
---
tools/libxl/libxl.c | 4 ++++
tools/libxl/libxl.h | 4 ++++
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index f1fe35d..1ef4325 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -2344,6 +2344,10 @@ int libxl_get_physinfo(struct libxl_ctx *ctx, struct libxl_physinfo *physinfo)
physinfo->total_pages = xcphysinfo.total_pages;
physinfo->free_pages = xcphysinfo.free_pages;
physinfo->scrub_pages = xcphysinfo.scrub_pages;
+ physinfo->nr_nodes = xcphysinfo.nr_nodes;
+ memcpy(physinfo->hw_cap,xcphysinfo.hw_cap, sizeof(physinfo->hw_cap));
+ physinfo->phys_cap = xcphysinfo.capabilities;
+
return 0;
}
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 6236059..8b9d869 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -426,6 +426,10 @@ struct libxl_physinfo {
uint64_t total_pages;
uint64_t free_pages;
uint64_t scrub_pages;
+
+ uint32_t nr_nodes;
+ uint32_t hw_cap[8];
+ uint32_t phys_cap;
};
int libxl_get_physinfo(struct libxl_ctx *ctx, struct libxl_physinfo *physinfo);
--
1.6.4
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCHv2 1/4] libxl: extend physinfo structure
2010-04-21 14:17 ` [PATCHv2 1/4] libxl: extend physinfo structure Andre Przywara
@ 2010-04-22 8:03 ` Paolo Bonzini
2010-04-22 11:14 ` Ian Jackson
0 siblings, 1 reply; 13+ messages in thread
From: Paolo Bonzini @ 2010-04-22 8:03 UTC (permalink / raw)
To: Andre Przywara
Cc: vincent.hanquez, xen-devel, Ian.Jackson, Keir.Fraser,
Stefano Stabellini
On 04/21/2010 04:17 PM, Andre Przywara wrote:
> The libxl version of the physinfo sysctl does not contain some
> fields like nr_nodes or capabilities needed for xl info output.
> Add them to the structure and the retrieving function.
Vincent, Stefano, is it okay to break the ABI?
If so, I suggest adding an initial member to be filled with sizeof() of
the structure, similar to many Win32 APIs like GetVersionEx.
http://msdn.microsoft.com/en-us/library/ms724451%28VS.85%29.aspx
http://msdn.microsoft.com/en-us/library/ms724834%28VS.85%29.aspx
http://msdn.microsoft.com/en-us/library/ms724833%28VS.85%29.aspx
Paolo
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCHv2 1/4] libxl: extend physinfo structure
2010-04-22 8:03 ` Paolo Bonzini
@ 2010-04-22 11:14 ` Ian Jackson
2010-04-22 11:15 ` Ian Jackson
2010-04-22 15:26 ` Stefano Stabellini
0 siblings, 2 replies; 13+ messages in thread
From: Ian Jackson @ 2010-04-22 11:14 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Andre Przywara, xen-devel@lists.xensource.com, Stabellini,
Vincent Hanquez
Paolo Bonzini writes ("Re: [PATCHv2 1/4] libxl: extend physinfo structure"):
> Vincent, Stefano, is it okay to break the ABI?
Yes, it is fine to break the ABI.
> If so, I suggest adding an initial member to be filled with sizeof() of
> the structure, similar to many Win32 APIs like GetVersionEx.
We've basically decided we don't need to do that. Libraries from
different major versions of Xen will not be ABI-compatible and will
have different sonames. We intend that binaries linked to old
libraries will continue to work.
Ian.
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCHv2 1/4] libxl: extend physinfo structure
2010-04-22 11:14 ` Ian Jackson
@ 2010-04-22 11:15 ` Ian Jackson
2010-04-22 15:26 ` Stefano Stabellini
1 sibling, 0 replies; 13+ messages in thread
From: Ian Jackson @ 2010-04-22 11:15 UTC (permalink / raw)
To: Paolo Bonzini, Andre Przywara, Vincent Hanquez, Keir Fraser,
xen-devel
I wrote:
> We've basically decided we don't need to do that. Libraries from
> different major versions of Xen will not be ABI-compatible and will
> have different sonames. We intend that binaries linked to old
> libraries will continue to work.
I mean, will continue to work _with the old library_ but the new
hypervisor/dom0.
Ian.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCHv2 1/4] libxl: extend physinfo structure
2010-04-22 11:14 ` Ian Jackson
2010-04-22 11:15 ` Ian Jackson
@ 2010-04-22 15:26 ` Stefano Stabellini
1 sibling, 0 replies; 13+ messages in thread
From: Stefano Stabellini @ 2010-04-22 15:26 UTC (permalink / raw)
To: Ian Jackson
Cc: Andre Przywara, xen-devel@lists.xensource.com, Stefano Stabellini,
Vincent Hanquez, Keir Fraser, Paolo Bonzini
On Thu, 22 Apr 2010, Ian Jackson wrote:
> Paolo Bonzini writes ("Re: [PATCHv2 1/4] libxl: extend physinfo structure"):
> > Vincent, Stefano, is it okay to break the ABI?
>
> Yes, it is fine to break the ABI.
>
> > If so, I suggest adding an initial member to be filled with sizeof() of
> > the structure, similar to many Win32 APIs like GetVersionEx.
>
> We've basically decided we don't need to do that. Libraries from
> different major versions of Xen will not be ABI-compatible and will
> have different sonames. We intend that binaries linked to old
> libraries will continue to work.
Indeed.
We want to keep the library as simple as possible while providing all
the needed capabilities, and I think this simple schema provides just
that.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCHv2 2/4] libxl: add sched_get_id function
2010-04-21 14:17 [PATCHv2 0/4] Add "xl info" command Andre Przywara
2010-04-21 14:17 ` [PATCHv2 1/4] libxl: extend physinfo structure Andre Przywara
@ 2010-04-21 14:17 ` Andre Przywara
2010-04-21 14:17 ` [PATCHv2 3/4] libxl: add version_info function Andre Przywara
` (2 subsequent siblings)
4 siblings, 0 replies; 13+ messages in thread
From: Andre Przywara @ 2010-04-21 14:17 UTC (permalink / raw)
To: Ian.Jackson, vincent.hanquez, Keir.Fraser; +Cc: Andre Przywara, xen-devel
To get the name of the currently used scheduler, Xen provides a
sched_id sysctl.
Add a libxl wrapper around the libxc function to query this.
Signed-off-by: Andre Przywara <andre.przywara@amd.com>
---
tools/libxl/libxl.c | 13 +++++++++++++
tools/libxl/libxl.h | 2 ++
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 1ef4325..3db4249 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -2421,3 +2421,16 @@ int libxl_set_vcpucount(struct libxl_ctx *ctx, uint32_t domid, uint32_t count)
}
return 0;
}
+
+/*
+ * returns one of the XEN_SCHEDULER_* constants from public/domctl.h
+ * or -1 if an error occured.
+ */
+int libxl_get_sched_id(struct libxl_ctx *ctx)
+{
+ int sched, ret;
+
+ if ((ret = xc_sched_id(ctx->xch, &sched)) != 0)
+ return ret;
+ return sched;
+}
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 8b9d869..b079613 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -438,5 +438,7 @@ struct libxl_vcpuinfo *libxl_list_vcpu(struct libxl_ctx *ctx, uint32_t domid,
int libxl_set_vcpuaffinity(struct libxl_ctx *ctx, uint32_t domid, uint32_t vcpuid,
uint64_t *cpumap, int cpusize);
int libxl_set_vcpucount(struct libxl_ctx *ctx, uint32_t domid, uint32_t count);
+
+int libxl_get_sched_id(struct libxl_ctx *ctx);
#endif /* LIBXL_H */
--
1.6.4
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCHv2 3/4] libxl: add version_info function
2010-04-21 14:17 [PATCHv2 0/4] Add "xl info" command Andre Przywara
2010-04-21 14:17 ` [PATCHv2 1/4] libxl: extend physinfo structure Andre Przywara
2010-04-21 14:17 ` [PATCHv2 2/4] libxl: add sched_get_id function Andre Przywara
@ 2010-04-21 14:17 ` Andre Przywara
2010-04-21 15:01 ` Vincent Hanquez
2010-04-21 14:17 ` [PATCHv2 4/4] xl: add "xl info" command Andre Przywara
2010-04-21 14:56 ` [PATCHv2 0/4] Add " Vincent Hanquez
4 siblings, 1 reply; 13+ messages in thread
From: Andre Przywara @ 2010-04-21 14:17 UTC (permalink / raw)
To: Ian.Jackson, vincent.hanquez, Keir.Fraser; +Cc: Andre Przywara, xen-devel
Xen provides a xen_version hypercall to query the values of several
interesting things (like hypervisor version, commandline used, actual
changeset, etc.). Create a user-friendly and efficient wrapper around
the libxc function to provide values for xl info output.
Since the information is static during the whole runtime, we store
it within the libxl_ctx structure and just deliver the pointer on
subsequent calls.
Signed-off-by: Andre Przywara <andre.przywara@amd.com>
---
tools/libxl/libxl.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
tools/libxl/libxl.h | 18 ++++++++++++++++++
2 files changed, 64 insertions(+), 0 deletions(-)
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index b079613..0d3b767 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -41,6 +41,21 @@ struct libxl_vminfo {
uint32_t domid;
};
+typedef struct {
+ int xen_version_major;
+ int xen_version_minor;
+ char *xen_version_extra;
+ char *compiler;
+ char *compile_by;
+ char *compile_domain;
+ char *compile_date;
+ char *capabilities;
+ char *changeset;
+ unsigned long virt_start;
+ unsigned long pagesize;
+ char *commandline;
+} libxl_version_info;
+
struct libxl_ctx {
int xch;
struct xs_handle *xsh;
@@ -56,8 +71,11 @@ struct libxl_ctx {
* set this after libxl_init and before any other call - or
* may leave them untouched */
int (*waitpid_instead)(pid_t pid, int *status, int flags);
+ libxl_version_info version_info;
};
+const libxl_version_info* libxl_get_version_info(struct libxl_ctx *ctx);
+
typedef struct {
bool hvm;
bool hap;
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 3db4249..2e8d621 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -45,6 +45,7 @@ int libxl_ctx_init(struct libxl_ctx *ctx, int version)
ctx->alloc_ptrs = calloc(ctx->alloc_maxsize, sizeof(void *));
if (!ctx->alloc_ptrs)
return ERROR_NOMEM;
+ memset(&ctx->version_info, 0, sizeof(libxl_version_info));
ctx->xch = xc_interface_open();
if (ctx->xch == -1) {
@@ -2351,6 +2352,51 @@ int libxl_get_physinfo(struct libxl_ctx *ctx, struct libxl_physinfo *physinfo)
return 0;
}
+const libxl_version_info* libxl_get_version_info(struct libxl_ctx *ctx)
+{
+ union {
+ xen_extraversion_t xen_extra;
+ xen_compile_info_t xen_cc;
+ xen_changeset_info_t xen_chgset;
+ xen_capabilities_info_t xen_caps;
+ xen_platform_parameters_t p_parms;
+ xen_commandline_t xen_commandline;
+ } u;
+ long xen_version;
+ libxl_version_info *info = &ctx->version_info;
+
+ if (info->xen_version_extra != NULL)
+ return info;
+
+ xen_version = xc_version(ctx->xch, XENVER_version, NULL);
+ info->xen_version_major = xen_version >> 16;
+ info->xen_version_minor = xen_version & 0xFF;
+ xc_version(ctx->xch, XENVER_extraversion, &u.xen_extra);
+ info->xen_version_extra = libxl_sprintf(ctx, u.xen_extra);
+
+ xc_version(ctx->xch, XENVER_compile_info, &u.xen_cc);
+ info->compiler = libxl_sprintf(ctx, u.xen_cc.compiler);
+ info->compile_by = libxl_sprintf(ctx, u.xen_cc.compile_by);
+ info->compile_domain = libxl_sprintf(ctx, u.xen_cc.compile_domain);
+ info->compile_date = libxl_sprintf(ctx, u.xen_cc.compile_date);
+
+ xc_version(ctx->xch, XENVER_capabilities, &u.xen_caps);
+ info->capabilities = libxl_sprintf(ctx, u.xen_caps);
+
+ xc_version(ctx->xch, XENVER_changeset, &u.xen_chgset);
+ info->changeset = libxl_sprintf(ctx, u.xen_chgset);
+
+ xc_version(ctx->xch, XENVER_platform_parameters, &u.p_parms);
+ info->virt_start = u.p_parms.virt_start;
+
+ info->pagesize = xc_version(ctx->xch, XENVER_pagesize, NULL);
+
+ xc_version(ctx->xch, XENVER_commandline, &u.xen_commandline);
+ info->commandline = libxl_sprintf(ctx, u.xen_commandline);
+
+ return info;
+}
+
struct libxl_vcpuinfo *libxl_list_vcpu(struct libxl_ctx *ctx, uint32_t domid,
int *nb_vcpu, int *cpusize)
{
--
1.6.4
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCHv2 3/4] libxl: add version_info function
2010-04-21 14:17 ` [PATCHv2 3/4] libxl: add version_info function Andre Przywara
@ 2010-04-21 15:01 ` Vincent Hanquez
2010-04-21 19:34 ` [PATCHv2a " Andre Przywara
2010-04-21 19:35 ` [PATCHv2 " Andre Przywara
0 siblings, 2 replies; 13+ messages in thread
From: Vincent Hanquez @ 2010-04-21 15:01 UTC (permalink / raw)
To: Andre Przywara; +Cc: xen-devel@lists.xensource.com
On 21/04/10 15:17, Andre Przywara wrote:
> +
> + xc_version(ctx->xch, XENVER_commandline,&u.xen_commandline);
> + info->commandline = libxl_sprintf(ctx, u.xen_commandline);
oh actually just missed that; it's important to not include a variable
as the format string: if for some reason any of this field end up
containing a %something, it will lead usually to segfault.
can you please replace all:
libxl_sprintf(ctx, ..);
by:
libxl_sprintf(ctx, "%s", ...);
Thanks,
--
Vincent
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCHv2a 3/4] libxl: add version_info function
2010-04-21 15:01 ` Vincent Hanquez
@ 2010-04-21 19:34 ` Andre Przywara
2010-04-21 19:35 ` [PATCHv2 " Andre Przywara
1 sibling, 0 replies; 13+ messages in thread
From: Andre Przywara @ 2010-04-21 19:34 UTC (permalink / raw)
To: vincent.hanquez, Ian.Jackson, Keir.Fraser; +Cc: Andre Przywara, xen-devel
Xen provides a xen_version hypercall to query the values of several
interesting things (like hypervisor version, commandline used, actual
changeset, etc.). Create a user-friendly and efficient wrapper around
the libxc function to provide values for xl info output.
Since the information is static during the whole runtime, we store
it within the libxl_ctx structure and just deliver the pointer on
subsequent calls.
Signed-off-by: Andre Przywara <andre.przywara@amd.com>
---
tools/libxl/libxl.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
tools/libxl/libxl.h | 18 ++++++++++++++++++
2 files changed, 64 insertions(+), 0 deletions(-)
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 3db4249..7cb3a1c 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -45,6 +45,7 @@ int libxl_ctx_init(struct libxl_ctx *ctx, int version)
ctx->alloc_ptrs = calloc(ctx->alloc_maxsize, sizeof(void *));
if (!ctx->alloc_ptrs)
return ERROR_NOMEM;
+ memset(&ctx->version_info, 0, sizeof(libxl_version_info));
ctx->xch = xc_interface_open();
if (ctx->xch == -1) {
@@ -2351,6 +2352,51 @@ int libxl_get_physinfo(struct libxl_ctx *ctx, struct libxl_physinfo *physinfo)
return 0;
}
+const libxl_version_info* libxl_get_version_info(struct libxl_ctx *ctx)
+{
+ union {
+ xen_extraversion_t xen_extra;
+ xen_compile_info_t xen_cc;
+ xen_changeset_info_t xen_chgset;
+ xen_capabilities_info_t xen_caps;
+ xen_platform_parameters_t p_parms;
+ xen_commandline_t xen_commandline;
+ } u;
+ long xen_version;
+ libxl_version_info *info = &ctx->version_info;
+
+ if (info->xen_version_extra != NULL)
+ return info;
+
+ xen_version = xc_version(ctx->xch, XENVER_version, NULL);
+ info->xen_version_major = xen_version >> 16;
+ info->xen_version_minor = xen_version & 0xFF;
+ xc_version(ctx->xch, XENVER_extraversion, &u.xen_extra);
+ info->xen_version_extra = libxl_sprintf(ctx, "%s", u.xen_extra);
+
+ xc_version(ctx->xch, XENVER_compile_info, &u.xen_cc);
+ info->compiler = libxl_sprintf(ctx, "%s", u.xen_cc.compiler);
+ info->compile_by = libxl_sprintf(ctx, "%s", u.xen_cc.compile_by);
+ info->compile_domain = libxl_sprintf(ctx, "%s", u.xen_cc.compile_domain);
+ info->compile_date = libxl_sprintf(ctx, "%s", u.xen_cc.compile_date);
+
+ xc_version(ctx->xch, XENVER_capabilities, &u.xen_caps);
+ info->capabilities = libxl_sprintf(ctx, "%s", u.xen_caps);
+
+ xc_version(ctx->xch, XENVER_changeset, &u.xen_chgset);
+ info->changeset = libxl_sprintf(ctx, "%s", u.xen_chgset);
+
+ xc_version(ctx->xch, XENVER_platform_parameters, &u.p_parms);
+ info->virt_start = u.p_parms.virt_start;
+
+ info->pagesize = xc_version(ctx->xch, XENVER_pagesize, NULL);
+
+ xc_version(ctx->xch, XENVER_commandline, &u.xen_commandline);
+ info->commandline = libxl_sprintf(ctx, "%s", u.xen_commandline);
+
+ return info;
+}
+
struct libxl_vcpuinfo *libxl_list_vcpu(struct libxl_ctx *ctx, uint32_t domid,
int *nb_vcpu, int *cpusize)
{
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index b079613..0d3b767 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -41,6 +41,21 @@ struct libxl_vminfo {
uint32_t domid;
};
+typedef struct {
+ int xen_version_major;
+ int xen_version_minor;
+ char *xen_version_extra;
+ char *compiler;
+ char *compile_by;
+ char *compile_domain;
+ char *compile_date;
+ char *capabilities;
+ char *changeset;
+ unsigned long virt_start;
+ unsigned long pagesize;
+ char *commandline;
+} libxl_version_info;
+
struct libxl_ctx {
int xch;
struct xs_handle *xsh;
@@ -56,8 +71,11 @@ struct libxl_ctx {
* set this after libxl_init and before any other call - or
* may leave them untouched */
int (*waitpid_instead)(pid_t pid, int *status, int flags);
+ libxl_version_info version_info;
};
+const libxl_version_info* libxl_get_version_info(struct libxl_ctx *ctx);
+
typedef struct {
bool hvm;
bool hap;
--
1.6.4
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCHv2 3/4] libxl: add version_info function
2010-04-21 15:01 ` Vincent Hanquez
2010-04-21 19:34 ` [PATCHv2a " Andre Przywara
@ 2010-04-21 19:35 ` Andre Przywara
1 sibling, 0 replies; 13+ messages in thread
From: Andre Przywara @ 2010-04-21 19:35 UTC (permalink / raw)
To: Vincent Hanquez; +Cc: xen-devel@lists.xensource.com
Vincent Hanquez wrote:
> On 21/04/10 15:17, Andre Przywara wrote:
>> +
>> + xc_version(ctx->xch, XENVER_commandline,&u.xen_commandline);
>> + info->commandline = libxl_sprintf(ctx, u.xen_commandline);
>
> oh actually just missed that; it's important to not include a variable
> as the format string: if for some reason any of this field end up
> containing a %something, it will lead usually to segfault.
Of course! I could tell you that I just wanted to know if someone will
find this, but actually I was so keen on just replacing strdup with
libxl_sprintf that I totally overlooked the changed semantic of the call.
>
> can you please replace all:
>
> libxl_sprintf(ctx, ..);
>
> by:
>
> libxl_sprintf(ctx, "%s", ...);
>
Sure! Corrected patch follows!
Thanks for looking carefully!
Andre.
--
Andre Przywara
AMD-Operating System Research Center (OSRC), Dresden, Germany
Tel: +49 351 488-3567-12
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCHv2 4/4] xl: add "xl info" command
2010-04-21 14:17 [PATCHv2 0/4] Add "xl info" command Andre Przywara
` (2 preceding siblings ...)
2010-04-21 14:17 ` [PATCHv2 3/4] libxl: add version_info function Andre Przywara
@ 2010-04-21 14:17 ` Andre Przywara
2010-04-21 14:56 ` [PATCHv2 0/4] Add " Vincent Hanquez
4 siblings, 0 replies; 13+ messages in thread
From: Andre Przywara @ 2010-04-21 14:17 UTC (permalink / raw)
To: Ian.Jackson, vincent.hanquez, Keir.Fraser; +Cc: Andre Przywara, xen-devel
The info subcommand was missing from the xl tool. Use the new libxl
wrapper functions to create a clone of "xm info". The splitting into
several smaller functions is enspired by the implementation in
XendNode.py.
Signed-off-by: Andre Przywara <andre.przywara@amd.com>
---
tools/libxl/xl.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 114 insertions(+), 0 deletions(-)
diff --git a/tools/libxl/xl.c b/tools/libxl/xl.c
index 1486a5e..e1cc529 100644
--- a/tools/libxl/xl.c
+++ b/tools/libxl/xl.c
@@ -30,6 +30,7 @@
#include <sys/socket.h>
#include <sys/select.h>
#include <arpa/inet.h>
+#include <sys/utsname.h> /* for utsname in xl info */
#include <xenctrl.h>
#include <ctype.h>
#include <inttypes.h>
@@ -2636,6 +2637,117 @@ int main_vcpuset(int argc, char **argv)
exit(0);
}
+static void output_xeninfo(void)
+{
+ const libxl_version_info *info;
+ int sched_id;
+
+ info = libxl_get_version_info(&ctx);
+ if ((sched_id = libxl_get_sched_id(&ctx)) < 0) {
+ fprintf(stderr, "get_sched_id sysctl failed.\n");
+ return;
+ }
+
+ printf("xen_major : %d\n", info->xen_version_major);
+ printf("xen_minor : %d\n", info->xen_version_minor);
+ printf("xen_extra : %s\n", info->xen_version_extra);
+ printf("xen_caps : %s\n", info->capabilities);
+ printf("xen_scheduler : %s\n",
+ sched_id == XEN_SCHEDULER_SEDF ? "sedf" :
+ sched_id == XEN_SCHEDULER_CREDIT ? "credit" :
+ sched_id == XEN_SCHEDULER_CREDIT2 ? "credit2" : "unknown");
+ printf("xen_pagesize : %lu\n", info->pagesize);
+ printf("platform_params : virt_start=0x%lx\n", info->virt_start);
+ printf("xen_changeset : %s\n", info->changeset);
+ printf("xen_commandline : %s\n", info->commandline);
+ printf("cc_compiler : %s\n", info->compiler);
+ printf("cc_compile_by : %s\n", info->compile_by);
+ printf("cc_compile_domain : %s\n", info->compile_domain);
+ printf("cc_compile_date : %s\n", info->compile_date);
+
+ return;
+}
+
+static void output_nodeinfo(void)
+{
+ 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);
+
+ return;
+}
+
+static void output_physinfo(void)
+{
+ struct libxl_physinfo info;
+ const libxl_version_info *vinfo;
+ unsigned int i;
+
+ if (libxl_get_physinfo(&ctx, &info) != 0) {
+ fprintf(stderr, "libxl_physinfo failed.\n");
+ return;
+ }
+
+ printf("nr_cpus : %d\n", info.nr_cpus);
+ printf("nr_nodes : %d\n", info.nr_nodes);
+ printf("cores_per_socket : %d\n", info.cores_per_socket);
+ printf("threads_per_core : %d\n", info.threads_per_core);
+ printf("cpu_mhz : %d\n", info.cpu_khz / 1000);
+ printf("hw_caps : ");
+ for (i = 0; i < 8; i++)
+ printf("%08x%c", info.hw_cap[i], i < 7 ? ':' : '\n');
+ printf("virt_caps :");
+ if (info.phys_cap & XEN_SYSCTL_PHYSCAP_hvm)
+ printf(" hvm");
+ if (info.phys_cap & XEN_SYSCTL_PHYSCAP_hvm_directio)
+ 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);
+
+ return;
+}
+
+void info(int verbose)
+{
+ output_nodeinfo();
+
+ output_physinfo();
+
+ output_xeninfo();
+
+ printf("xend_config_format : 4\n");
+
+ return;
+}
+
+void main_info(int argc, char **argv)
+{
+ int opt, verbose;
+
+ verbose = 0;
+ while ((opt = getopt(argc, argv, "h")) != -1) {
+ switch (opt) {
+ case 'h':
+ help("vcpu-list");
+ exit(0);
+ default:
+ fprintf(stderr, "option `%c' not supported.\n", opt);
+ break;
+ }
+ }
+
+ info(verbose);
+ exit(0);
+}
+
int main(int argc, char **argv)
{
if (argc < 2) {
@@ -2696,6 +2808,8 @@ int main(int argc, char **argv)
main_vcpupin(argc - 1, argv + 1);
} else if (!strcmp(argv[1], "vcpu-set")) {
main_vcpuset(argc - 1, argv + 1);
+ } else if (!strcmp(argv[1], "info")) {
+ main_info(argc - 1, argv + 1);
} else if (!strcmp(argv[1], "help")) {
if (argc > 2)
help(argv[2]);
--
1.6.4
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCHv2 0/4] Add "xl info" command
2010-04-21 14:17 [PATCHv2 0/4] Add "xl info" command Andre Przywara
` (3 preceding siblings ...)
2010-04-21 14:17 ` [PATCHv2 4/4] xl: add "xl info" command Andre Przywara
@ 2010-04-21 14:56 ` Vincent Hanquez
4 siblings, 0 replies; 13+ messages in thread
From: Vincent Hanquez @ 2010-04-21 14:56 UTC (permalink / raw)
To: Andre Przywara; +Cc: xen-devel@lists.xensource.com, Ian Jackson, Keir Fraser
On 21/04/10 15:17, Andre Przywara wrote:
> The "info" subcommand is missing from the xl tool.
> The attached patchset adds support for this, extending libxl on the way
> to provide the necessary info only by using own functions.
> On my system the output of xm info and xl info was identical, I omitted
> the recent NUMA additions from xl info for now and will provide the
> necessary patches later.
>
> Reworked version due to comments from Ian and Vincent (thanks for the review!)
> Changes to version 1:
> - use Xen public headers for constants instead of (re-)defining them
> - comment the meaning of the return value of get_sched_id()
> - remove the masking feature for get_version_info
> - make the version_info structure a member of libxl_ctx and fill it
> on demand, omitting the need to free it manually
all patches:
Acked-by: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
Thanks for your contribution !
--
Vincent
^ permalink raw reply [flat|nested] 13+ messages in thread