As said previously, allowing setting arbitrary variables from command line will not be an accepted behavior. Also the code should be generic enough to allow handling of other platforms if need be but surely without including any unnecessary code for platforms that don't need it. Until there is an agreement on how to handle the arguments, the only patch I would accept is to remove the parser in ieee1275 code On May 11, 2015 11:28 AM, "Olaf Hering" <o...@aepfle.de> wrote:
> If grub is used as the kernel in a Xen PV guest there is no way to pass > information into grub. This includes info like which disk should be used > first when searching for files. > > Up to now the workaround for the host admin is to rebuild grub-xen every > time with grub-mkimage and include a custom script. Such step should be > avoided if possible, the distro provided grub-xen binary should be used. > > With this change the command line (extra= in domU.cfg) will be evaluated > by grub. Each 'name=val' pair will be exported as shell variable, other > strings will be ignored. This makes it possible to provide a generic > grub-xen binary for PV guests. It is now up to the scripts in such > binary to interpret the variables as they see fit. > > It should be noted that some variables may be set by grub itself, > overriding anything provided in the cmdline. This depends on the way > grub-xen is built, which modules are included. > > Signed-off-by: Olaf Hering <o...@aepfle.de> > --- > grub-core/kern/xen/init.c | 73 > +++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 73 insertions(+) > > diff --git a/grub-core/kern/xen/init.c b/grub-core/kern/xen/init.c > index 0559c03..1dbc01f 100644 > --- a/grub-core/kern/xen/init.c > +++ b/grub-core/kern/xen/init.c > @@ -524,6 +524,77 @@ map_all_pages (void) > grub_mm_init_region ((void *) heap_start, heap_end - heap_start); > } > > +/* > + * Find all name=val pairs in the provided cmd_line and export them > + * so that scripts can evaluate the variables for their own purpose. > + */ > +static void > +parse_cmdline (void) > +{ > + grub_size_t i; > + char *p, *name, *val; > + int found; > + > + p = grub_malloc (MAX_GUEST_CMDLINE + 1); > + if (!p) > + return; > + > + grub_memcpy (p, grub_xen_start_page_addr->cmd_line, MAX_GUEST_CMDLINE); > + p[MAX_GUEST_CMDLINE] = '\0'; > + > + for (i = 0; i < MAX_GUEST_CMDLINE && p[i]; i++) > + { > + if (grub_isspace (p[i])) > + continue; > + > + name = &p[i]; > + found = 0; > + do > + { > + if (grub_isspace (p[i])) > + break; > + if (p[i] == '=') > + { > + p[i] = '\0'; > + found = 1; > + break; > + } > + if (!p[i + 1]) > + break; > + i++; > + } > + while (i < MAX_GUEST_CMDLINE); > + > + if (!found) > + continue; > + > + i++; > + val = &p[i]; > + found = 0; > + do > + { > + if (grub_isspace (p[i])) > + { > + p[i] = '\0'; > + found = 1; > + } > + if (!p[i + 1]) > + found = 1; > + if (found) > + break; > + i++; > + } > + while (i < MAX_GUEST_CMDLINE); > + > + if (!found) > + continue; > + > + grub_env_set (name, val); > + grub_env_export (name); > + } > + grub_free (p); > +} > + > extern char _end[]; > > void > @@ -539,6 +610,8 @@ grub_machine_init (void) > > map_all_pages (); > > + parse_cmdline (); > + > grub_console_init (); > > grub_tsc_init (); > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel >
_______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel