Skip to contentSkip to conversation

kernel command line extension

PATCH New Jan Beulich 1 participant 1 message Jun 19, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kernel command line extension

In order to allow appending to the dom0 command line even with boot loaders that only allow editing the kernel (i.e. Xen in our case) command line, support a '--' separator option.

xen/arch/x86/setup.c +15 -7
Index: 2007-06-18/xen/arch/x86/setup.c
===================================================================
@@ -405,7 +405,7 @@ void init_done(void)
 void __init __start_xen(unsigned long mbi_p)
 {
     char *memmap_type = NULL;
-    char __cmdline[] = "", *cmdline = __cmdline;
+    char __cmdline[] = "", *cmdline = __cmdline, *kextra;
     unsigned long _initrd_start = 0, _initrd_len = 0;
     unsigned int initrdidx = 1;
     char *_policy_start = NULL;
@@ -425,7 +425,7 @@ void __init __start_xen(multiboot_info_t
     /* Parse the command-line options. */
     if ( (mbi->flags & MBI_CMDLINE) && (mbi->cmdline != 0) )
         cmdline = __va(mbi->cmdline);
-    cmdline_parse(cmdline);
+    kextra = cmdline_parse(cmdline);
 
     parse_video_info();
 
@@ -1005,19 +1005,27 @@ void __init __start_xen(multiboot_info_t
 
     /* Grab the DOM0 command line. */
     cmdline = (char *)(mod[0].string ? __va(mod[0].string) : NULL);
-    if ( cmdline != NULL )
+    if ( cmdline != NULL || kextra != NULL )
     {
         static char dom0_cmdline[MAX_GUEST_CMDLINE];
 
-        /* Skip past the image name and copy to a local buffer. */
-        while ( *cmdline == ' ' ) cmdline++;
-        if ( (cmdline = strchr(cmdline, ' ')) != NULL )
+        if ( cmdline != NULL )
         {
+            /* Skip past the image name and copy to a local buffer. */
             while ( *cmdline == ' ' ) cmdline++;
-            safe_strcpy(dom0_cmdline, cmdline);
+            if ( (cmdline = strchr(cmdline, ' ')) != NULL )
+            {
+                while ( *cmdline == ' ' ) cmdline++;
+                safe_strcpy(dom0_cmdline, cmdline);
+            }
         }
+        else
+            dom0_cmdline[0] = '\0';
 
         /* Append any extra parameters. */
+        if ( kextra != NULL )
+            /* Note that kextra already includes a leading space. */
+            safe_strcat(dom0_cmdline, kextra);
         if ( skip_ioapic_setup && !strstr(dom0_cmdline, "noapic") )
             safe_strcat(dom0_cmdline, " noapic");
         if ( acpi_skip_timer_override &&
xen/common/kernel.c +8 -3
Index: 2007-06-18/xen/common/kernel.c
===================================================================
@@ -24,20 +24,20 @@
 
 int tainted;
 
-void cmdline_parse(char *cmdline)
+char *cmdline_parse(char *cmdline)
 {
     char opt[100], *optval, *q;
     const char *p = cmdline;
     struct kernel_param *param;
     
     if ( p == NULL )
-        return;
+        return (char *)p;
 
     /* Skip whitespace and the image name. */
     while ( *p == ' ' )
         p++;
     if ( (p = strchr(p, ' ')) == NULL )
-        return;
+        return (char *)p;
 
     for ( ; ; )
     {
@@ -57,6 +57,9 @@ void cmdline_parse(char *cmdline)
         }
         *q = '\0';
 
+        if ( strcmp(opt, "--") == 0 )
+            return (char *)p;
+
         /* Search for value part of a key=value option. */
         optval = strchr(opt, '=');
         if ( optval != NULL )
@@ -87,6 +90,8 @@ void cmdline_parse(char *cmdline)
             }
         }
     }
+
+    return NULL;
 }
 
 /**
xen/include/xen/lib.h +1 -1
Index: 2007-06-18/xen/include/xen/lib.h
===================================================================
@@ -43,7 +43,7 @@ do {                                    
 
 struct domain;
 
-void cmdline_parse(char *cmdline);
+char *cmdline_parse(char *cmdline);
 
 /*#define DEBUG_TRACE_DUMP*/
 #ifdef DEBUG_TRACE_DUMP