ia64/xen-unstable

changeset 6567:d6752f193ffa

extends xm info with xen version and various others information.
exports version hypercall to userspace

Signed-off-by: Vincent Hanquez <vincent@xensource.com>
author vh249@arcadians.cl.cam.ac.uk
date Wed Aug 31 10:39:53 2005 +0000 (2005-08-31)
parents 6d4c0bfc3c1c
children a51e78a2a01a
files tools/libxc/xc_private.c tools/libxc/xc_private.h tools/libxc/xenctrl.h tools/python/xen/lowlevel/xc/xc.c tools/python/xen/xend/XendNode.py xen/common/kernel.c xen/include/public/version.h
line diff
     1.1 --- a/tools/libxc/xc_private.c	Wed Aug 31 10:24:43 2005 +0000
     1.2 +++ b/tools/libxc/xc_private.c	Wed Aug 31 10:39:53 2005 +0000
     1.3 @@ -422,3 +422,8 @@ int xc_dom0_op(int xc_handle, dom0_op_t 
     1.4  {
     1.5      return do_dom0_op(xc_handle, op);
     1.6  }
     1.7 +
     1.8 +int xc_version(int xc_handle, int cmd, void *arg)
     1.9 +{
    1.10 +    return do_xen_version(xc_handle, cmd, arg);
    1.11 +}
     2.1 --- a/tools/libxc/xc_private.h	Wed Aug 31 10:24:43 2005 +0000
     2.2 +++ b/tools/libxc/xc_private.h	Wed Aug 31 10:39:53 2005 +0000
     2.3 @@ -59,6 +59,17 @@ static inline int do_xen_hypercall(int x
     2.4                        (unsigned long)hypercall);
     2.5  }
     2.6  
     2.7 +static inline int do_xen_version(int xc_handle, int cmd, void *dest)
     2.8 +{
     2.9 +    privcmd_hypercall_t hypercall;
    2.10 +
    2.11 +    hypercall.op     = __HYPERVISOR_xen_version;
    2.12 +    hypercall.arg[0] = (unsigned long) cmd;
    2.13 +    hypercall.arg[1] = (unsigned long) dest;
    2.14 +    
    2.15 +    return do_xen_hypercall(xc_handle, &hypercall);
    2.16 +}
    2.17 +
    2.18  static inline int do_dom0_op(int xc_handle, dom0_op_t *op)
    2.19  {
    2.20      int ret = -1;
     3.1 --- a/tools/libxc/xenctrl.h	Wed Aug 31 10:24:43 2005 +0000
     3.2 +++ b/tools/libxc/xenctrl.h	Wed Aug 31 10:39:53 2005 +0000
     3.3 @@ -23,6 +23,7 @@ typedef int64_t            s64;
     3.4  #include <sys/ptrace.h>
     3.5  #include <xen/xen.h>
     3.6  #include <xen/dom0_ops.h>
     3.7 +#include <xen/version.h>
     3.8  #include <xen/event_channel.h>
     3.9  #include <xen/sched_ctl.h>
    3.10  #include <xen/acm.h>
    3.11 @@ -497,6 +498,8 @@ long xc_get_tot_pages(int xc_handle, u32
    3.12  /* Execute a privileged dom0 operation. */
    3.13  int xc_dom0_op(int xc_handle, dom0_op_t *op);
    3.14  
    3.15 +int xc_version(int xc_handle, int cmd, void *arg);
    3.16 +
    3.17  /* Initializes the store (for dom0)
    3.18     remote_port should be the remote end of a bound interdomain channel between
    3.19     the store and dom0.
     4.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Wed Aug 31 10:24:43 2005 +0000
     4.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Wed Aug 31 10:39:53 2005 +0000
     4.3 @@ -707,6 +707,39 @@ static PyObject *pyxc_physinfo(PyObject 
     4.4                           "cpu_khz",          info.cpu_khz);
     4.5  }
     4.6  
     4.7 +static PyObject *pyxc_xeninfo(PyObject *self,
     4.8 +                              PyObject *args,
     4.9 +                              PyObject *kwds)
    4.10 +{
    4.11 +    XcObject *xc = (XcObject *)self;
    4.12 +    xen_extraversion_t xen_extra;
    4.13 +    xen_compile_info_t xen_cc;
    4.14 +    xen_changeset_info_t xen_chgset;
    4.15 +    long xen_version;
    4.16 +
    4.17 +    xen_version = xc_version(xc->xc_handle, XENVER_version, NULL);
    4.18 +
    4.19 +    if ( xc_version(xc->xc_handle, XENVER_extraversion, &xen_extra) != 0 )
    4.20 +        return PyErr_SetFromErrno(xc_error);
    4.21 +
    4.22 +    if ( xc_version(xc->xc_handle, XENVER_compile_info, &xen_cc) != 0 )
    4.23 +        return PyErr_SetFromErrno(xc_error);
    4.24 +
    4.25 +    if ( xc_version(xc->xc_handle, XENVER_changeset, &xen_chgset) != 0 )
    4.26 +        return PyErr_SetFromErrno(xc_error);
    4.27 +
    4.28 +    return Py_BuildValue("{s:i,s:i,s:s,s:s,s:s,s:s,s:s,s:s}",
    4.29 +                         "xen_major", xen_version >> 16,
    4.30 +                         "xen_minor", (xen_version & 0xffff),
    4.31 +                         "xen_extra", xen_extra,
    4.32 +                         "xen_changeset", xen_chgset,
    4.33 +                         "cc_compiler", xen_cc.compiler,
    4.34 +                         "cc_compile_by", xen_cc.compile_by,
    4.35 +                         "cc_compile_domain", xen_cc.compile_domain,
    4.36 +                         "cc_compile_date", xen_cc.compile_date);
    4.37 +}
    4.38 +
    4.39 +
    4.40  static PyObject *pyxc_sedf_domain_set(PyObject *self,
    4.41                                           PyObject *args,
    4.42                                           PyObject *kwds)
    4.43 @@ -1089,6 +1122,13 @@ static PyMethodDef pyxc_methods[] = {
    4.44        "Returns [dict]: information about the hardware"
    4.45        "        [None]: on failure.\n" },
    4.46  
    4.47 +    { "xeninfo",
    4.48 +      (PyCFunction)pyxc_xeninfo,
    4.49 +      METH_VARARGS, "\n"
    4.50 +      "Get information about the Xen host\n"
    4.51 +      "Returns [dict]: information about Xen"
    4.52 +      "        [None]: on failure.\n" },
    4.53 +
    4.54      { "shadow_control", 
    4.55        (PyCFunction)pyxc_shadow_control, 
    4.56        METH_VARARGS | METH_KEYWORDS, "\n"
     5.1 --- a/tools/python/xen/xend/XendNode.py	Wed Aug 31 10:24:43 2005 +0000
     5.2 +++ b/tools/python/xen/xend/XendNode.py	Wed Aug 31 10:39:53 2005 +0000
     5.3 @@ -46,7 +46,7 @@ class XendNode:
     5.4          return self.xc.bvtsched_global_get()
     5.5      
     5.6      def info(self):
     5.7 -        return self.nodeinfo() + self.physinfo()
     5.8 +        return self.nodeinfo() + self.physinfo() + self.xeninfo()
     5.9  
    5.10      def nodeinfo(self):
    5.11          (sys, host, rel, ver, mch) = os.uname()
    5.12 @@ -65,7 +65,16 @@ class XendNode:
    5.13                  ['free_memory', pinfo['free_pages']/256]]
    5.14          return info
    5.15          
    5.16 -        
    5.17 +    def xeninfo(self):
    5.18 +        xinfo = self.xc.xeninfo()
    5.19 +	return [['xen_major', xinfo['xen_major']],
    5.20 +	        ['xen_minor', xinfo['xen_minor']],
    5.21 +	        ['xen_extra', xinfo['xen_extra']],
    5.22 +		['xen_changeset', xinfo['xen_changeset']],
    5.23 +		['cc_compiler', xinfo['cc_compiler']],
    5.24 +                ['cc_compile_by', xinfo['cc_compile_by']],
    5.25 +                ['cc_compile_domain', xinfo['cc_compile_domain']],
    5.26 +                ['cc_compile_date', xinfo['cc_compile_date']]]
    5.27  
    5.28  def instance():
    5.29      global inst
     6.1 --- a/xen/common/kernel.c	Wed Aug 31 10:24:43 2005 +0000
     6.2 +++ b/xen/common/kernel.c	Wed Aug 31 10:39:53 2005 +0000
     6.3 @@ -110,6 +110,27 @@ long do_xen_version(int cmd, void *arg)
     6.4              return -EFAULT;
     6.5          return 0;
     6.6      }
     6.7 +
     6.8 +    case XENVER_capabilities:
     6.9 +    {
    6.10 +        struct xen_capabilities_info info;
    6.11 +        
    6.12 +        /* FIXME */
    6.13 +        info.arch = 0;
    6.14 +        info.pae = 0;
    6.15 +        if ( copy_to_user(arg, &info, sizeof(info)) )
    6.16 +            return -EFAULT;
    6.17 +        return 0;
    6.18 +    }
    6.19 +    
    6.20 +    case XENVER_changeset:
    6.21 +    {
    6.22 +        xen_changeset_info_t chgset;
    6.23 +        safe_strcpy(chgset, XEN_CHANGESET);
    6.24 +        if ( copy_to_user(arg, chgset, sizeof(chgset)) )
    6.25 +            return -EFAULT;
    6.26 +        return 0;
    6.27 +    }
    6.28      }
    6.29  
    6.30      return -ENOSYS;
     7.1 --- a/xen/include/public/version.h	Wed Aug 31 10:24:43 2005 +0000
     7.2 +++ b/xen/include/public/version.h	Wed Aug 31 10:39:53 2005 +0000
     7.3 @@ -28,4 +28,13 @@ typedef struct xen_compile_info {
     7.4      char compile_date[32];
     7.5  } xen_compile_info_t;
     7.6  
     7.7 +#define XENVER_capabilities 3
     7.8 +typedef struct xen_capabilities_info {
     7.9 +    int pae;
    7.10 +    int arch;
    7.11 +} xen_capabilities_info_t;
    7.12 +
    7.13 +#define XENVER_changeset 4
    7.14 +typedef char xen_changeset_info_t[64];
    7.15 +
    7.16  #endif /* __XEN_PUBLIC_VERSION_H__ */