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 #include #include +#include /* * 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 #include +#include +#include + 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 + */ + +#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__ */