ia64/xen-unstable

changeset 19792:407e2e7dca5b

Allow tools to see the hypervisor command line.

This is useful from tools in the same way /proc/cmdline is useful for
the domain 0 kernel.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jun 18 10:20:45 2009 +0100 (2009-06-18)
parents c0d2838fc10f
children 8018f09ef039
files tools/python/xen/lowlevel/xc/xc.c tools/python/xen/xend/XendNode.py tools/python/xen/xm/main.py xen/common/compat/kernel.c xen/common/kernel.c xen/include/public/version.h
line diff
     1.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Thu Jun 18 10:20:17 2009 +0100
     1.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Thu Jun 18 10:20:45 2009 +0100
     1.3 @@ -1132,6 +1132,7 @@ static PyObject *pyxc_xeninfo(XcObject *
     1.4      xen_changeset_info_t xen_chgset;
     1.5      xen_capabilities_info_t xen_caps;
     1.6      xen_platform_parameters_t p_parms;
     1.7 +    xen_commandline_t xen_commandline;
     1.8      long xen_version;
     1.9      long xen_pagesize;
    1.10      char str[128];
    1.11 @@ -1153,13 +1154,16 @@ static PyObject *pyxc_xeninfo(XcObject *
    1.12      if ( xc_version(self->xc_handle, XENVER_platform_parameters, &p_parms) != 0 )
    1.13          return pyxc_error_to_exception();
    1.14  
    1.15 +    if ( xc_version(self->xc_handle, XENVER_commandline, &xen_commandline) != 0 )
    1.16 +        return pyxc_error_to_exception();
    1.17 +
    1.18      snprintf(str, sizeof(str), "virt_start=0x%lx", p_parms.virt_start);
    1.19  
    1.20      xen_pagesize = xc_version(self->xc_handle, XENVER_pagesize, NULL);
    1.21      if (xen_pagesize < 0 )
    1.22          return pyxc_error_to_exception();
    1.23  
    1.24 -    return Py_BuildValue("{s:i,s:i,s:s,s:s,s:i,s:s,s:s,s:s,s:s,s:s,s:s}",
    1.25 +    return Py_BuildValue("{s:i,s:i,s:s,s:s,s:i,s:s,s:s,s:s,s:s,s:s,s:s,s:s}",
    1.26                           "xen_major", xen_version >> 16,
    1.27                           "xen_minor", (xen_version & 0xffff),
    1.28                           "xen_extra", xen_extra,
    1.29 @@ -1167,6 +1171,7 @@ static PyObject *pyxc_xeninfo(XcObject *
    1.30                           "xen_pagesize", xen_pagesize,
    1.31                           "platform_params", str,
    1.32                           "xen_changeset", xen_chgset,
    1.33 +                         "xen_commandline", xen_commandline,
    1.34                           "cc_compiler", xen_cc.compiler,
    1.35                           "cc_compile_by", xen_cc.compile_by,
    1.36                           "cc_compile_domain", xen_cc.compile_domain,
     2.1 --- a/tools/python/xen/xend/XendNode.py	Thu Jun 18 10:20:17 2009 +0100
     2.2 +++ b/tools/python/xen/xend/XendNode.py	Thu Jun 18 10:20:45 2009 +0100
     2.3 @@ -91,6 +91,7 @@ class XendNode:
     2.4          # is directly exposed via XenAPI
     2.5          self.other_config["xen_pagesize"] = self.xeninfo_dict()["xen_pagesize"]
     2.6          self.other_config["platform_params"] = self.xeninfo_dict()["platform_params"]
     2.7 +        self.other_config["xen_commandline"] = self.xeninfo_dict()["xen_commandline"]
     2.8              
     2.9          # load CPU UUIDs
    2.10          saved_cpus = self.state_store.load_state('cpu')
    2.11 @@ -612,7 +613,8 @@ class XendNode:
    2.12              "cc_compile_by":     xeninfo_dict["cc_compile_by"],
    2.13              "cc_compile_domain": xeninfo_dict["cc_compile_domain"],
    2.14              "cc_compile_date":   xeninfo_dict["cc_compile_date"],
    2.15 -            "xen_changeset":     xeninfo_dict["xen_changeset"]
    2.16 +            "xen_changeset":     xeninfo_dict["xen_changeset"],
    2.17 +            "xen_commandline":   xeninfo_dict["xen_commandline"]
    2.18              })
    2.19          
    2.20          return info
    2.21 @@ -888,6 +890,7 @@ class XendNode:
    2.22                        'xen_pagesize',
    2.23                        'platform_params',
    2.24                        'xen_changeset',
    2.25 +                      'xen_commandline',
    2.26                        'cc_compiler',
    2.27                        'cc_compile_by',
    2.28                        'cc_compile_domain',
     3.1 --- a/tools/python/xen/xm/main.py	Thu Jun 18 10:20:17 2009 +0100
     3.2 +++ b/tools/python/xen/xm/main.py	Thu Jun 18 10:20:45 2009 +0100
     3.3 @@ -1757,6 +1757,7 @@ def xm_info(args):
     3.4              "xen_scheduler":     getVal(["sched_policy"]),
     3.5              "xen_pagesize":      getVal(["other_config", "xen_pagesize"]),
     3.6              "platform_params":   getVal(["other_config", "platform_params"]),
     3.7 +            "xen_commandline":   getVal(["other_config", "xen_commandline"]),
     3.8              "xen_changeset":     getVal(["software_version", "xen_changeset"]),
     3.9              "cc_compiler":       getVal(["software_version", "cc_compiler"]),
    3.10              "cc_compile_by":     getVal(["software_version", "cc_compile_by"]),
     4.1 --- a/xen/common/compat/kernel.c	Thu Jun 18 10:20:17 2009 +0100
     4.2 +++ b/xen/common/compat/kernel.c	Thu Jun 18 10:20:45 2009 +0100
     4.3 @@ -15,6 +15,8 @@
     4.4  #include <compat/nmi.h>
     4.5  #include <compat/version.h>
     4.6  
     4.7 +extern xen_commandline_t saved_cmdline;
     4.8 +
     4.9  #define xen_extraversion compat_extraversion
    4.10  #define xen_extraversion_t compat_extraversion_t
    4.11  
     5.1 --- a/xen/common/kernel.c	Thu Jun 18 10:20:17 2009 +0100
     5.2 +++ b/xen/common/kernel.c	Thu Jun 18 10:20:45 2009 +0100
     5.3 @@ -24,6 +24,8 @@
     5.4  
     5.5  int tainted;
     5.6  
     5.7 +xen_commandline_t saved_cmdline;
     5.8 +
     5.9  void cmdline_parse(char *cmdline)
    5.10  {
    5.11      char opt[100], *optval, *optkey, *q;
    5.12 @@ -31,6 +33,8 @@ void cmdline_parse(char *cmdline)
    5.13      struct kernel_param *param;
    5.14      int bool_assert;
    5.15  
    5.16 +    safe_strcpy(saved_cmdline, cmdline);
    5.17 +
    5.18      if ( p == NULL )
    5.19          return;
    5.20  
    5.21 @@ -246,7 +250,14 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDL
    5.22                             ARRAY_SIZE(current->domain->handle)) )
    5.23              return -EFAULT;
    5.24          return 0;
    5.25 -    }    
    5.26 +    }
    5.27 +
    5.28 +    case XENVER_commandline:
    5.29 +    {
    5.30 +        if ( copy_to_guest(arg, saved_cmdline, ARRAY_SIZE(saved_cmdline)) )
    5.31 +            return -EFAULT;
    5.32 +        return 0;
    5.33 +    }
    5.34      }
    5.35  
    5.36      return -ENOSYS;
     6.1 --- a/xen/include/public/version.h	Thu Jun 18 10:20:17 2009 +0100
     6.2 +++ b/xen/include/public/version.h	Thu Jun 18 10:20:45 2009 +0100
     6.3 @@ -78,6 +78,9 @@ typedef struct xen_feature_info xen_feat
     6.4  /* arg == xen_domain_handle_t. */
     6.5  #define XENVER_guest_handle 8
     6.6  
     6.7 +#define XENVER_commandline 9
     6.8 +typedef char xen_commandline_t[1024];
     6.9 +
    6.10  #endif /* __XEN_PUBLIC_VERSION_H__ */
    6.11  
    6.12  /*