Skip to contentSkip to conversation

Allow tools to see the hypervisor command line.

PATCH Ian Campbell 3 participants 4 messages Jun 17, 2009 Arm/actions semi architecture

lore
Share & tools
lore
#0 lore raw

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

tools/python/xen/lowlevel/xc/xc.c +6 -1
diff -r 2e802c0a5c08 -r b7c94d5e638f tools/python/xen/lowlevel/xc/xc.c
@@ -1132,6 +1132,7 @@
     xen_changeset_info_t xen_chgset;
     xen_capabilities_info_t xen_caps;
     xen_platform_parameters_t p_parms;
+    xen_commandline_t xen_commandline;
     long xen_version;
     long xen_pagesize;
     char str[128];
@@ -1153,13 +1154,16 @@
     if ( xc_version(self->xc_handle, XENVER_platform_parameters, &p_parms) != 0 )
         return pyxc_error_to_exception();
 
+    if ( xc_version(self->xc_handle, XENVER_commandline, &xen_commandline) != 0 )
+        return pyxc_error_to_exception();
+
     snprintf(str, sizeof(str), "virt_start=0x%lx", p_parms.virt_start);
 
     xen_pagesize = xc_version(self->xc_handle, XENVER_pagesize, NULL);
     if (xen_pagesize < 0 )
         return pyxc_error_to_exception();
 
-    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}",
+    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}",
                          "xen_major", xen_version >> 16,
                          "xen_minor", (xen_version & 0xffff),
                          "xen_extra", xen_extra,
@@ -1167,6 +1171,7 @@
                          "xen_pagesize", xen_pagesize,
                          "platform_params", str,
                          "xen_changeset", xen_chgset,
+                         "xen_commandline", xen_commandline,
                          "cc_compiler", xen_cc.compiler,
                          "cc_compile_by", xen_cc.compile_by,
                          "cc_compile_domain", xen_cc.compile_domain,
tools/python/xen/xend/XendNode.py +4 -1
diff -r 2e802c0a5c08 -r b7c94d5e638f tools/python/xen/xend/XendNode.py
@@ -91,6 +91,7 @@
         # is directly exposed via XenAPI
         self.other_config["xen_pagesize"] = self.xeninfo_dict()["xen_pagesize"]
         self.other_config["platform_params"] = self.xeninfo_dict()["platform_params"]
+        self.other_config["xen_commandline"] = self.xeninfo_dict()["xen_commandline"]
             
         # load CPU UUIDs
         saved_cpus = self.state_store.load_state('cpu')
@@ -612,7 +613,8 @@
             "cc_compile_by":     xeninfo_dict["cc_compile_by"],
             "cc_compile_domain": xeninfo_dict["cc_compile_domain"],
             "cc_compile_date":   xeninfo_dict["cc_compile_date"],
-            "xen_changeset":     xeninfo_dict["xen_changeset"]
+            "xen_changeset":     xeninfo_dict["xen_changeset"],
+            "xen_commandline":   xeninfo_dict["xen_commandline"]
             })
         
         return info
@@ -888,6 +890,7 @@
                       'xen_pagesize',
                       'platform_params',
                       'xen_changeset',
+                      'xen_commandline',
                       'cc_compiler',
                       'cc_compile_by',
                       'cc_compile_domain',
tools/python/xen/xm/main.py +1 -0
diff -r 2e802c0a5c08 -r b7c94d5e638f tools/python/xen/xm/main.py
@@ -1757,6 +1757,7 @@
             "xen_scheduler":     getVal(["sched_policy"]),
             "xen_pagesize":      getVal(["other_config", "xen_pagesize"]),
             "platform_params":   getVal(["other_config", "platform_params"]),
+            "xen_commandline":   getVal(["other_config", "xen_commandline"]),
             "xen_changeset":     getVal(["software_version", "xen_changeset"]),
             "cc_compiler":       getVal(["software_version", "cc_compiler"]),
             "cc_compile_by":     getVal(["software_version", "cc_compile_by"]),
xen/common/compat/kernel.c +2 -0
diff -r 2e802c0a5c08 -r b7c94d5e638f xen/common/compat/kernel.c
@@ -14,6 +14,8 @@
 #include <compat/xen.h>
 #include <compat/nmi.h>
 #include <compat/version.h>
+
+extern xen_commandline_t saved_cmdline;
 
 #define xen_extraversion compat_extraversion
 #define xen_extraversion_t compat_extraversion_t
xen/common/kernel.c +12 -1
diff -r 2e802c0a5c08 -r b7c94d5e638f xen/common/kernel.c
@@ -24,12 +24,16 @@
 
 int tainted;
 
+xen_commandline_t saved_cmdline;
+
 void cmdline_parse(char *cmdline)
 {
     char opt[100], *optval, *optkey, *q;
     const char *p = cmdline;
     struct kernel_param *param;
     int bool_assert;
+
+    safe_strcpy(saved_cmdline, cmdline);
 
     if ( p == NULL )
         return;
@@ -246,7 +250,14 @@
                            ARRAY_SIZE(current->domain->handle)) )
             return -EFAULT;
         return 0;
-    }    
+    }
+
+    case XENVER_commandline:
+    {
+        if ( copy_to_guest(arg, saved_cmdline, ARRAY_SIZE(saved_cmdline)) )
+            return -EFAULT;
+        return 0;
+    }
     }
 
     return -ENOSYS;
xen/include/public/version.h +3 -0
diff -r 2e802c0a5c08 -r b7c94d5e638f xen/include/public/version.h
@@ -78,6 +78,9 @@
 /* arg == xen_domain_handle_t. */
 #define XENVER_guest_handle 8
 
+#define XENVER_commandline 9
+typedef char xen_commandline_t[1024];
+
 #endif /* __XEN_PUBLIC_VERSION_H__ */
 
 /*
#1 lore raw
Quoted 2 lines · On Wednesday 17 June 2009 17:32:25 Ian Campbell wrote:

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

On NetBSD Dom0, this is sysctl machdep.booted_kernel. Current implementation doesn't work properly, since Xen throws away the first argument at startup.
Is it possible to not kill it ?

Christoph

Quoted 153 lines

diff -r 2e802c0a5c08 -r b7c94d5e638f tools/python/xen/lowlevel/xc/xc.c

tools/python/xen/lowlevel/xc/xc.c +5 -1
@@ -1132,6 +1132,7 @@
     xen_changeset_info_t xen_chgset;
     xen_capabilities_info_t xen_caps;
     xen_platform_parameters_t p_parms;
+    xen_commandline_t xen_commandline;
     long xen_version;
     long xen_pagesize;
     char str[128];
@@ -1153,13 +1154,16 @@
     if ( xc_version(self->xc_handle, XENVER_platform_parameters, &p_parms)
 != 0 ) return pyxc_error_to_exception();
 
+    if ( xc_version(self->xc_handle, XENVER_commandline, &xen_commandline)
 != 0 ) +        return pyxc_error_to_exception();
+
     snprintf(str, sizeof(str), "virt_start=0x%lx", p_parms.virt_start);
 
     xen_pagesize = xc_version(self->xc_handle, XENVER_pagesize, NULL);
     if (xen_pagesize < 0 )
         return pyxc_error_to_exception();
 
-    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}",
+    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}",
 "xen_major", xen_version >> 16,
                          "xen_minor", (xen_version & 0xffff),
                          "xen_extra", xen_extra,
@@ -1167,6 +1171,7 @@
                          "xen_pagesize", xen_pagesize,
                          "platform_params", str,
                          "xen_changeset", xen_chgset,
+                         "xen_commandline", xen_commandline,
                          "cc_compiler", xen_cc.compiler,
                          "cc_compile_by", xen_cc.compile_by,
                          "cc_compile_domain", xen_cc.compile_domain,

diff -r 2e802c0a5c08 -r b7c94d5e638f tools/python/xen/xend/XendNode.py

tools/python/xen/xend/XendNode.py +0 -0
@@ -91,6 +91,7 @@
         # is directly exposed via XenAPI
         self.other_config["xen_pagesize"] =

self.xeninfo_dict()["xen_pagesize"] self.other_config["platform_params"] = self.xeninfo_dict()["platform_params"] + self.other_config["xen_commandline"] = self.xeninfo_dict()["xen_commandline"]

         # load CPU UUIDs
         saved_cpus = self.state_store.load_state('cpu')
tools/python/xen/xend/XendNode.py +3 -1
@@ -612,7 +613,8 @@
             "cc_compile_by":     xeninfo_dict["cc_compile_by"],
             "cc_compile_domain": xeninfo_dict["cc_compile_domain"],
             "cc_compile_date":   xeninfo_dict["cc_compile_date"],
-            "xen_changeset":     xeninfo_dict["xen_changeset"]
+            "xen_changeset":     xeninfo_dict["xen_changeset"],
+            "xen_commandline":   xeninfo_dict["xen_commandline"]
             })
 
         return info
@@ -888,6 +890,7 @@
                       'xen_pagesize',
                       'platform_params',
                       'xen_changeset',
+                      'xen_commandline',
                       'cc_compiler',
                       'cc_compile_by',
                       'cc_compile_domain',

diff -r 2e802c0a5c08 -r b7c94d5e638f tools/python/xen/xm/main.py

tools/python/xen/xm/main.py +0 -0
@@ -1757,6 +1757,7 @@
             "xen_scheduler":     getVal(["sched_policy"]),
             "xen_pagesize":      getVal(["other_config", "xen_pagesize"]),
             "platform_params":   getVal(["other_config",

"platform_params"]), + "xen_commandline":
getVal(["other_config", "xen_commandline"]), "xen_changeset":
getVal(["software_version", "xen_changeset"]), "cc_compiler":
getVal(["software_version", "cc_compiler"]), "cc_compile_by":
getVal(["software_version", "cc_compile_by"]), diff -r 2e802c0a5c08 -r b7c94d5e638f xen/common/compat/kernel.c

xen/common/compat/kernel.c +2 -0
@@ -14,6 +14,8 @@
 #include <compat/xen.h>
 #include <compat/nmi.h>
 #include <compat/version.h>
+
+extern xen_commandline_t saved_cmdline;
 
 #define xen_extraversion compat_extraversion
 #define xen_extraversion_t compat_extraversion_t

diff -r 2e802c0a5c08 -r b7c94d5e638f xen/common/kernel.c

xen/common/kernel.c +11 -1
@@ -24,12 +24,16 @@
 
 int tainted;
 
+xen_commandline_t saved_cmdline;
+
 void cmdline_parse(char *cmdline)
 {
     char opt[100], *optval, *optkey, *q;
     const char *p = cmdline;
     struct kernel_param *param;
     int bool_assert;
+
+    safe_strcpy(saved_cmdline, cmdline);
 
     if ( p == NULL )
         return;
@@ -246,7 +250,14 @@
                            ARRAY_SIZE(current->domain->handle)) )
             return -EFAULT;
         return 0;
-    }
+    }
+
+    case XENVER_commandline:
+    {
+        if ( copy_to_guest(arg, saved_cmdline, ARRAY_SIZE(saved_cmdline))
 ) +            return -EFAULT;
+        return 0;
+    }
     }
 
     return -ENOSYS;

diff -r 2e802c0a5c08 -r b7c94d5e638f xen/include/public/version.h

xen/include/public/version.h +3 -0
@@ -78,6 +78,9 @@
 /* arg == xen_domain_handle_t. */
 #define XENVER_guest_handle 8
 
+#define XENVER_commandline 9
+typedef char xen_commandline_t[1024];
+
 #endif /* __XEN_PUBLIC_VERSION_H__ */
 
 /*

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Thomas M. McCoy, Giuliano Meroni
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
#2 lore raw
Quoted 8 lines · Christoph Egger
Quoted 2 lines · On Wednesday 17 June 2009 17:32:25 Ian Campbell wrote:

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

On NetBSD Dom0, this is sysctl machdep.booted_kernel. Current implementation doesn't work properly, since Xen throws away the first argument at startup.
Is it possible to not kill it ?

You mean "module /boot/netsd foo=bar baz=1" becomes just "foo=bar baz=1" on the command line which the kernel sees but on native netbsd it would be "/boot/netsd foo=bar baz=1"? This patch wouldn't make any difference to that (I guess you are just bringing it up as an aside).

Changing Xen's behaviour here would be interesting -- Linux for example doesn't expect to get the extra element on the command line, not sure what it would do with it, similarly for other existing dom0 guests. It would also be inconsistent with how PV domU's are launched.

Ian.

#3 lore raw
Quoted 5 lines · On Wednesday 17 June 2009 17:49:41 Ian Campbell wrote:
Quoted 4 lines · Christoph Egger
Quoted 2 lines · On Wednesday 17 June 2009 17:32:25 Ian Campbell wrote:

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

Quoted 8 lines
Quoted 4 lines

On NetBSD Dom0, this is sysctl machdep.booted_kernel. Current implementation doesn't work properly, since Xen throws away the first argument at startup.
Is it possible to not kill it ?

You mean "module /boot/netsd foo=bar baz=1" becomes just "foo=bar baz=1" on the command line which the kernel sees but on native netbsd it would be "/boot/netsd foo=bar baz=1"?

Correct. On NetBSD, the system tools accessing kernel virtual space need the kernel name to find the correct one since the kernel can be anywere and can have any name (though there's a default name and default place).

You can also place the linux kernel anywhere and have any name for it. GRUB doesn't care about it, right ? (Though there's a default name and a default place as well)

Quoted 2 lines

This patch wouldn't make any difference
to that (I guess you are just bringing it up as an aside).

I supposed so.

Quoted 4 lines

Changing Xen's behaviour here would be interesting -- Linux for example doesn't expect to get the extra element on the command line, not sure what it would do with it, similarly for other existing dom0 guests. It would also be inconsistent with how PV domU's are launched.

I suppose, Xen throws the first argument away for historical reasons with the assumption that noone needs it because Linux has no use for it.

Christoph

Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Thomas M. McCoy, Giuliano Meroni
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632