From: "Jan Beulich" Subject: [PATCH] kernel command line extension Date: Tue, 19 Jun 2007 11:32:28 +0100 Message-ID: <4677CCDC.76E4.0078.0@novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org 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. Signed-off-by: Jan Beulich Index: 2007-06-18/xen/arch/x86/setup.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2007-06-18.orig/xen/arch/x86/setup.c 2007-06-19 11:13:50.0000000= 00 +0200 +++ 2007-06-18/xen/arch/x86/setup.c 2007-06-19 11:26:17.000000000 = +0200 @@ -405,7 +405,7 @@ void init_done(void) void __init __start_xen(unsigned long mbi_p) { char *memmap_type =3D NULL; - char __cmdline[] =3D "", *cmdline =3D __cmdline; + char __cmdline[] =3D "", *cmdline =3D __cmdline, *kextra; unsigned long _initrd_start =3D 0, _initrd_len =3D 0; unsigned int initrdidx =3D 1; char *_policy_start =3D NULL; @@ -425,7 +425,7 @@ void __init __start_xen(multiboot_info_t /* Parse the command-line options. */ if ( (mbi->flags & MBI_CMDLINE) && (mbi->cmdline !=3D 0) ) cmdline =3D __va(mbi->cmdline); - cmdline_parse(cmdline); + kextra =3D cmdline_parse(cmdline); =20 parse_video_info(); =20 @@ -1005,19 +1005,27 @@ void __init __start_xen(multiboot_info_t =20 /* Grab the DOM0 command line. */ cmdline =3D (char *)(mod[0].string ? __va(mod[0].string) : NULL); - if ( cmdline !=3D NULL ) + if ( cmdline !=3D NULL || kextra !=3D NULL ) { static char dom0_cmdline[MAX_GUEST_CMDLINE]; =20 - /* Skip past the image name and copy to a local buffer. */ - while ( *cmdline =3D=3D ' ' ) cmdline++; - if ( (cmdline =3D strchr(cmdline, ' ')) !=3D NULL ) + if ( cmdline !=3D NULL ) { + /* Skip past the image name and copy to a local buffer. */ while ( *cmdline =3D=3D ' ' ) cmdline++; - safe_strcpy(dom0_cmdline, cmdline); + if ( (cmdline =3D strchr(cmdline, ' ')) !=3D NULL ) + { + while ( *cmdline =3D=3D ' ' ) cmdline++; + safe_strcpy(dom0_cmdline, cmdline); + } } + else + dom0_cmdline[0] =3D '\0'; =20 /* Append any extra parameters. */ + if ( kextra !=3D 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 && Index: 2007-06-18/xen/common/kernel.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2007-06-18.orig/xen/common/kernel.c 2007-06-18 12:03:19.000000000 = +0200 +++ 2007-06-18/xen/common/kernel.c 2007-06-18 12:15:35.000000000 = +0200 @@ -24,20 +24,20 @@ =20 int tainted; =20 -void cmdline_parse(char *cmdline) +char *cmdline_parse(char *cmdline) { char opt[100], *optval, *q; const char *p =3D cmdline; struct kernel_param *param; =20 if ( p =3D=3D NULL ) - return; + return (char *)p; =20 /* Skip whitespace and the image name. */ while ( *p =3D=3D ' ' ) p++; if ( (p =3D strchr(p, ' ')) =3D=3D NULL ) - return; + return (char *)p; =20 for ( ; ; ) { @@ -57,6 +57,9 @@ void cmdline_parse(char *cmdline) } *q =3D '\0'; =20 + if ( strcmp(opt, "--") =3D=3D 0 ) + return (char *)p; + /* Search for value part of a key=3Dvalue option. */ optval =3D strchr(opt, '=3D'); if ( optval !=3D NULL ) @@ -87,6 +90,8 @@ void cmdline_parse(char *cmdline) } } } + + return NULL; } =20 /** Index: 2007-06-18/xen/include/xen/lib.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2007-06-18.orig/xen/include/xen/lib.h 2007-06-19 11:25:18.0000000= 00 +0200 +++ 2007-06-18/xen/include/xen/lib.h 2007-06-18 12:15:35.000000000 = +0200 @@ -43,7 +43,7 @@ do { =20 =20 struct domain; =20 -void cmdline_parse(char *cmdline); +char *cmdline_parse(char *cmdline); =20 /*#define DEBUG_TRACE_DUMP*/ #ifdef DEBUG_TRACE_DUMP