* [PATCH 2/2] xm info
@ 2005-06-19 14:53 aq
0 siblings, 0 replies; only message in thread
From: aq @ 2005-06-19 14:53 UTC (permalink / raw)
To: xen-devel, Ian Pratt
[-- Attachment #1: Type: text/plain, Size: 1416 bytes --]
This patch gets "xm info" shown some additional information such as
xen version, xen builder, compile time, logical cpus, number of cores
and Hyper threading support (finally works correctly). To do that, the
patch extends the xen_version hypercall and adds a python wrapper for
it.
Here is the ouput of "xm info":
system : Linux
host : ubuntu
xen_release : 3.0-devel
xen_compile_by : root@localdomain
xen_compiler : gcc version 3.3.5 (Debian 1:3.3.5-8ubuntu2)
xen_compile_date : Mon Jun 20 00:57:59 EST 2005
dom0_release : 2.6.11.12-xen0
dom0_version : #2 Mon Jun 20 03:09:24 EST 2005
machine : i686
logical_cpus : 1
cores_per_socket : 1
hyperthreads_per_core : 1
cpu_mhz : 1094
memory : 511
free_memory : 122
Signed-off-by: Nguyen Anh Quynh <aquynh@gmail.com>
# diffstat xminfo3.patch
tools/libxc/xc.h | 11 +++++++++++
tools/libxc/xc_misc.c | 18 ++++++++++++++++++
tools/python/xen/lowlevel/xc/xc.c | 29 +++++++++++++++++++++++++++++
tools/python/xen/xend/XendNode.py | 15 ++++++++++-----
xen/common/kernel.c | 22 ++++++++++++++++++----
xen/include/public/version.h | 22 ++++++++++++++++++++++
6 files changed, 108 insertions(+), 9 deletions(-)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: xminfo3.patch --]
[-- Type: text/x-patch; name="xminfo3.patch", Size: 7452 bytes --]
diff -Nurp -X dontdiff -X dontdiff.xen xeno-today/tools/libxc/xc.h xeno.0611/tools/libxc/xc.h
--- xeno-today/tools/libxc/xc.h 2005-06-09 20:22:20.000000000 -0500
+++ xeno.0611/tools/libxc/xc.h 2005-06-20 00:34:27.000000000 -0500
@@ -25,6 +25,7 @@ typedef int64_t s64;
#include <xen/dom0_ops.h>
#include <xen/event_channel.h>
#include <xen/sched_ctl.h>
+#include <xen/version.h>
/*
* DEFINITIONS FOR CPU BARRIERS
@@ -507,4 +508,14 @@ long xc_get_tot_pages(int xc_handle, u32
/* Execute a privileged dom0 operation. */
int xc_dom0_op(int xc_handle, dom0_op_t *op);
+/* This struct is for libxc to get xen version and extra stuffs. */
+typedef version_op_t xc_version_t;
+
+/**
+ * Get xen version
+ *
+ * @return a long value which encodes XEN_VERSION and XEN_SUBVERSION on success, -1 on failure.
+ */
+long xc_xen_version(int xc_handle, xc_version_t *version);
+
#endif /* __XC_H__ */
diff -Nurp -X dontdiff -X dontdiff.xen xeno-today/tools/libxc/xc_misc.c xeno.0611/tools/libxc/xc_misc.c
--- xeno-today/tools/libxc/xc_misc.c 2005-06-06 11:54:29.000000000 -0500
+++ xeno.0611/tools/libxc/xc_misc.c 2005-06-20 00:34:27.000000000 -0500
@@ -130,3 +130,21 @@ int xc_msr_write(int xc_handle, int cpu_
return rc;
}
+
+long xc_xen_version(int xc_handle, xc_version_t *v)
+{
+ long ret;
+ privcmd_hypercall_t hypercall;
+
+ hypercall.op = __HYPERVISOR_xen_version;
+ hypercall.arg[0] = (unsigned long)v;
+
+ if ((ret = do_xen_hypercall(xc_handle, &hypercall)) < 0)
+ {
+ if (errno == EACCES)
+ PERROR("Could not obtain xen version");
+ return -1;
+ }
+
+ return ret;
+}
diff -Nurp -X dontdiff -X dontdiff.xen xeno-today/tools/python/xen/lowlevel/xc/xc.c xeno.0611/tools/python/xen/lowlevel/xc/xc.c
--- xeno-today/tools/python/xen/lowlevel/xc/xc.c 2005-06-09 20:22:20.000000000 -0500
+++ xeno.0611/tools/python/xen/lowlevel/xc/xc.c 2005-06-20 00:34:27.000000000 -0500
@@ -831,6 +831,29 @@ static PyObject *pyxc_domain_memory_incr
return zero;
}
+static PyObject *pyxc_xen_version(PyObject *self,
+ PyObject *args,
+ PyObject *kwds)
+{
+ xc_version_t v;
+ long ret;
+ XcObject *xc = (XcObject *)self;
+
+ if (!PyArg_ParseTuple(args, ""))
+ return NULL;
+
+ if ((ret = xc_xen_version(xc->xc_handle, &v)) == -1)
+ return PyErr_SetFromErrno(xc_error);
+
+ return Py_BuildValue("{s:i,s:i,s:s,s:s,s:s,s:s,s:s}",
+ "version", ret >> 16,
+ "subversion", ret & 0xFFFF,
+ "extraversion", v.extraversion,
+ "compile_by", v.compile_by,
+ "compile_domain", v.compile_domain,
+ "compiler", v.compiler,
+ "compile_date", v.compile_date);
+}
static PyMethodDef pyxc_methods[] = {
{ "handle",
@@ -1115,6 +1138,12 @@ static PyMethodDef pyxc_methods[] = {
" mem_kb [long]: .\n"
"Returns: [int] 0 on success; -1 on error.\n" },
+ { "xen_version",
+ (PyCFunction)pyxc_xen_version,
+ METH_KEYWORDS, "\n"
+ "Get Xen version\n"
+ "Returns: [dict] xen version and extra stuffs on success; empty list on error.\n" },
+
{ NULL, NULL, 0, NULL }
};
diff -Nurp -X dontdiff -X dontdiff.xen xeno-today/tools/python/xen/xend/XendNode.py xeno.0611/tools/python/xen/xend/XendNode.py
--- xeno-today/tools/python/xen/xend/XendNode.py 2005-05-28 12:19:57.000000000 -0500
+++ xeno.0611/tools/python/xen/xend/XendNode.py 2005-06-20 03:08:30.000000000 -0500
@@ -35,22 +35,27 @@ class XendNode:
def nodeinfo(self):
(sys, host, rel, ver, mch) = os.uname()
+ xen_ver = self.xc.xen_version()
return [['system', sys],
- ['host', host],
- ['release', rel],
- ['version', ver],
+ ['host', host],
+ ['xen_release', "%i.%i%s" %(xen_ver['version'], xen_ver['subversion'], xen_ver['extraversion'])],
+ ['xen_compile_by', "%s@%s" %(xen_ver['compile_by'], xen_ver['compile_domain'])],
+ ['xen_compiler', xen_ver['compiler']],
+ ['xen_compile_date', xen_ver['compile_date']],
+ ['dom0_release', rel],
+ ['dom0_version', ver],
['machine', mch]]
def physinfo(self):
pinfo = self.xc.physinfo()
- info = [['cores', pinfo['cores']],
+ info = [['logical_cpus', pinfo['cores'] * pinfo['ht_per_core']],
+ ['cores_per_socket', pinfo['cores']],
['hyperthreads_per_core', pinfo['ht_per_core']],
['cpu_mhz', pinfo['cpu_khz']/1000],
['memory', pinfo['total_pages']/256],
['free_memory', pinfo['free_pages']/256]]
return info
-
def instance():
global inst
diff -Nurp -X dontdiff -X dontdiff.xen xeno-today/xen/common/kernel.c xeno.0611/xen/common/kernel.c
--- xeno-today/xen/common/kernel.c 2005-06-06 11:54:29.000000000 -0500
+++ xeno.0611/xen/common/kernel.c 2005-06-20 00:34:27.000000000 -0500
@@ -15,6 +15,9 @@
#include <xen/sched.h>
#include <asm/current.h>
+#include <public/version.h>
+#include <xen/string.h>
+
void cmdline_parse(char *cmdline)
{
char opt[100], *optval, *p = cmdline, *q;
@@ -83,11 +86,22 @@ void cmdline_parse(char *cmdline)
* Simple hypercalls.
*/
-long do_xen_version(int cmd)
+long do_xen_version(version_op_t *op)
{
- if ( cmd != 0 )
- return -ENOSYS;
- return (XEN_VERSION<<16) | (XEN_SUBVERSION);
+ version_op_t vop;
+ if (op != NULL) /* return extra stuffs */
+ {
+ if (copy_from_user(&vop, op, sizeof(vop)) != 0)
+ return -EFAULT;
+ strncpy(vop.extraversion, XEN_EXTRAVERSION, sizeof(vop.extraversion));
+ strncpy(vop.compile_by, XEN_COMPILE_BY, sizeof(vop.compile_by));
+ strncpy(vop.compile_domain, XEN_COMPILE_DOMAIN, sizeof(vop.compile_domain));
+ strncpy(vop.compiler, XEN_COMPILER, sizeof(vop.compiler));
+ strncpy(vop.compile_date, XEN_COMPILE_DATE, sizeof(vop.compile_date));
+ if (copy_to_user(op, &vop, sizeof(vop)) != 0)
+ return -EFAULT;
+ }
+ return (XEN_VERSION<<16) | (XEN_SUBVERSION); /* always return version & subversion */
}
long do_vm_assist(unsigned int cmd, unsigned int type)
diff -Nurp -X dontdiff -X dontdiff.xen xeno-today/xen/include/public/version.h xeno.0611/xen/include/public/version.h
--- xeno-today/xen/include/public/version.h 1969-12-31 19:00:00.000000000 -0500
+++ xeno.0611/xen/include/public/version.h 2005-06-20 00:34:27.000000000 -0500
@@ -0,0 +1,22 @@
+/******************************************************************************
+ * version.h
+ *
+ * Xen extraversion and stuffs.
+ *
+ * Copyright (c) 2005, Nguyen Anh Quynh <aquynh@gmail.com>
+ */
+
+#ifndef __XEN_PUBLIC_VERSION_H__
+#define __XEN_PUBLIC_VERSION_H__
+
+/* This struct is for xen hypercall only. Usually you dont need it. */
+typedef struct _version_op_st
+{
+ char extraversion[8]; /* 0 */
+ char compile_by[16]; /* 8 */
+ char compile_domain[32]; /* 24 */
+ char compiler[64]; /* 56 */
+ char compile_date[32]; /* 120 */
+} PACKED version_op_t; /* 152 bytes */
+
+#endif /* __XEN_PUBLIC_VERSION_H__ */
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-06-19 14:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-19 14:53 [PATCH 2/2] xm info aq
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.