All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@amd.com>
To: Keir Fraser <keir.fraser@eu.citrix.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	Ian.Jackson@eu.citrix.com
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: [PATCH 3/4] libxl: add version_info function
Date: Sun, 18 Apr 2010 23:26:54 +0200	[thread overview]
Message-ID: <4BCB791E.7000204@amd.com> (raw)
In-Reply-To: <4BCB76FD.1020103@amd.com>

[-- Attachment #1: Type: text/plain, Size: 428 bytes --]

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.

Signed-off-by: Andre Przywara <andre.przywara@amd.com>

-- 
Andre Przywara
AMD-Operating System Research Center (OSRC), Dresden, Germany
Tel: +49 351 488-3567-12

[-- Attachment #2: libxl_version_info.patch --]
[-- Type: text/plain, Size: 4609 bytes --]

diff -r 7ee8bb40200a tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Thu Apr 15 19:11:16 2010 +0100
+++ b/tools/libxl/libxl.c	Sun Apr 18 14:41:48 2010 +0200
@@ -2351,6 +2351,92 @@
     return 0;
 }
 
+int libxl_get_version_info(struct libxl_ctx *ctx,
+                           libxl_version_info *info,
+                           uint32_t query_mask)
+{
+    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;
+
+    if (query_mask & LIBXL_VERSION_VERSION_MASK) {
+        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 = strdup(u.xen_extra);
+    } else {
+        info->xen_version_major = 0;
+        info->xen_version_minor = 0;
+        info->xen_version_extra = NULL;
+    }
+
+    if (query_mask & LIBXL_VERSION_COMPILER_MASK) {
+        xc_version(ctx->xch, XENVER_compile_info, &u.xen_cc);
+        info->compiler = strdup(u.xen_cc.compiler);
+        info->compile_by = strdup(u.xen_cc.compile_by);
+        info->compile_domain = strdup(u.xen_cc.compile_domain);
+        info->compile_date = strdup(u.xen_cc.compile_date);
+    } else {
+        info->compiler = NULL;
+        info->compile_by = NULL;
+        info->compile_domain = NULL;
+        info->compile_date = NULL;
+    }
+
+    if (query_mask & LIBXL_VERSION_CAPS_MASK) {
+        xc_version(ctx->xch, XENVER_capabilities, &u.xen_caps);
+        info->capabilities = strdup(u.xen_caps);
+    } else
+        info->capabilities = NULL;
+
+    if (query_mask & LIBXL_VERSION_CHANGESET_MASK) {
+        xc_version(ctx->xch, XENVER_changeset, &u.xen_chgset);
+        info->changeset = strdup(u.xen_chgset);
+    } else 
+        info->changeset = NULL;
+
+    if (query_mask & LIBXL_VERSION_VIRT_START_MASK) {
+        xc_version(ctx->xch, XENVER_platform_parameters, &u.p_parms);
+        info->virt_start = u.p_parms.virt_start;
+    } else
+        info->virt_start = 0;
+
+    if (query_mask & LIBXL_VERSION_PAGESIZE_MASK)
+        info->pagesize = xc_version(ctx->xch, XENVER_pagesize, NULL);
+    else
+        info->pagesize = 0;
+
+    if (query_mask & LIBXL_VERSION_COMMANDLINE_MASK) {
+        xc_version(ctx->xch, XENVER_commandline, &u.xen_commandline);
+        info->commandline = strdup(u.xen_commandline);
+    } else 
+        info->commandline = NULL;
+
+    return 0;
+}
+
+#define FREE_IF_NOT_ZERO(ptr) if((ptr) != NULL) {free(ptr); ptr = NULL;}
+
+void libxl_free_version_info(libxl_version_info *info)
+{
+    FREE_IF_NOT_ZERO(info->xen_version_extra)
+    FREE_IF_NOT_ZERO(info->compiler)
+    FREE_IF_NOT_ZERO(info->compile_by)
+    FREE_IF_NOT_ZERO(info->compile_domain)
+    FREE_IF_NOT_ZERO(info->compile_date)
+    FREE_IF_NOT_ZERO(info->capabilities)
+    FREE_IF_NOT_ZERO(info->changeset)
+    FREE_IF_NOT_ZERO(info->commandline)
+}
+#undef FREE_IF_NOT_ZERO
+
 struct libxl_vcpuinfo *libxl_list_vcpu(struct libxl_ctx *ctx, uint32_t domid,
                                        int *nb_vcpu, int *cpusize)
 {
diff -r 7ee8bb40200a tools/libxl/libxl.h
--- a/tools/libxl/libxl.h	Thu Apr 15 19:11:16 2010 +0100
+++ b/tools/libxl/libxl.h	Sun Apr 18 14:41:48 2010 +0200
@@ -59,6 +59,35 @@
 };
 
 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;
+
+#define LIBXL_VERSION_VERSION_MASK       (1 <<  0)
+#define LIBXL_VERSION_COMPILER_MASK      (1 <<  1)
+#define LIBXL_VERSION_CAPS_MASK          (1 <<  2)
+#define LIBXL_VERSION_CHANGESET_MASK     (1 <<  3)
+#define LIBXL_VERSION_VIRT_START_MASK    (1 <<  4)
+#define LIBXL_VERSION_PAGESIZE_MASK      (1 <<  5)
+#define LIBXL_VERSION_COMMANDLINE_MASK   (1 <<  6)
+#define LIBXL_VERSION_ALL_MASK          ((1 <<  7) - 1)
+
+int libxl_get_version_info(struct libxl_ctx *ctx,
+                           libxl_version_info *info,
+                           uint32_t query_mask);
+void libxl_free_version_info(libxl_version_info *info);
+
+typedef struct {
     bool hvm;
     bool hap;
     int ssidref;

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

  parent reply	other threads:[~2010-04-18 21:26 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-18 21:17 [PATCH 0/4] Add "xl info" command Andre Przywara
2010-04-18 21:23 ` [PATCH 1/4] libxl: extend physinfo structure Andre Przywara
2010-04-19  7:50   ` Vincent Hanquez
2010-04-19 15:27     ` [PATCH 1/4] libxl: extend physinfo structure [and 1 more messages] Ian Jackson
2010-04-18 21:25 ` [PATCH 2/4] libxl: add sched_get_id function Andre Przywara
2010-04-19  7:50   ` Vincent Hanquez
2010-04-19 15:29     ` [PATCH 2/4] libxl: add sched_get_id function [and 1 more messages] Ian Jackson
2010-04-18 21:26 ` Andre Przywara [this message]
2010-04-19  8:08   ` [PATCH 3/4] libxl: add version_info function Vincent Hanquez
2010-04-19 15:36     ` [PATCH 3/4] libxl: add version_info function [and 1 more messages] Ian Jackson
2010-04-19 16:07       ` Vincent Hanquez
2010-04-19 16:21         ` Ian Jackson
2010-04-19 16:41           ` Vincent Hanquez
2010-04-19 20:43       ` Andre Przywara
2010-04-20  8:36         ` Vincent Hanquez
2010-04-21 12:10           ` Andre Przywara
2010-04-21 12:53             ` Vincent Hanquez
2010-04-18 21:28 ` [PATCH 4/4] xl: add "xl info" command Andre Przywara
2010-04-19 15:38   ` Ian Jackson

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=4BCB791E.7000204@amd.com \
    --to=andre.przywara@amd.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=keir.fraser@eu.citrix.com \
    --cc=stefano.stabellini@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.