[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v5] xen: Allow a default compiled-in command line using Kconfig



>>> On 18.03.17 at 07:31, <blackskygg@xxxxxxxxx> wrote:
> --- a/xen/common/Kconfig
> +++ b/xen/common/Kconfig
> @@ -237,4 +237,26 @@ config FAST_SYMBOL_LOOKUP
>         The only user of this is Live patching.
>  
>         If unsure, say Y.
> +
> +config CMDLINE
> +     string "Built-in hypervisor command string"
> +     default ""
> +     depends on EXPERT = "y"
> +     ---help---
> +       Enter arguments here that should be compiled into the hypervisor
> +       image and used at boot time. When the system boots, this string
> +       will be parsed prior to the bootloader command line. So if a
> +       non-cumulative option is set both in this string and in the
> +       bootloader command line, only the latter one will take effect.
> +
> +config CMDLINE_OVERRIDE
> +     bool "Built-in command line overrides bootloader arguments"
> +     default n
> +     depends on EXPERT = "y" && CMDLINE != ""

The CMDLINE part is sufficient here, as it can't be other than empty
when EXPERT <> "y".

> --- a/xen/common/kernel.c
> +++ b/xen/common/kernel.c
> @@ -23,6 +23,7 @@
>  enum system_state system_state = SYS_STATE_early_boot;
>  
>  xen_commandline_t saved_cmdline;
> +const char opt_builtin_cmdline[] = CONFIG_CMDLINE;

static and __initconst.

> @@ -46,7 +47,7 @@ static void __init assign_integer_param(
>      }
>  }
>  
> -void __init cmdline_parse(const char *cmdline)
> +static void __init do_cmdline_parse(const char *cmdline)
>  {

Please omit the "do".

> @@ -56,8 +57,6 @@ void __init cmdline_parse(const char *cmdline)
>      if ( cmdline == NULL )
>          return;
>  
> -    safe_strcpy(saved_cmdline, cmdline);
> -
>      for ( ; ; )
>      {
>          /* Skip whitespace. */
> @@ -147,6 +146,25 @@ void __init cmdline_parse(const char *cmdline)
>      }
>  }
>  
> +/**
> + *    cmdline_parse -- parses the xen command line.
> + * If CONFIG_CMDLINE is set, it would be parsed prior to @cmdline.
> + * But if CONFIG_CMDLINE_OVERRIDE is set to y, @cmdline will be ignored.
> + */
> +void __init cmdline_parse(const char *cmdline)
> +{
> +    if ( strlen(opt_builtin_cmdline) )

This can be had cheaper with just checking the first byte.

> +    {
> +        printk("Built-in command line: %s\n", opt_builtin_cmdline);
> +        do_cmdline_parse(opt_builtin_cmdline);
> +    }
> +
> +#ifndef CONFIG_CMDLINE_OVERRIDE
> +    safe_strcpy(saved_cmdline, cmdline);

Note how the original placement was after a NULL check.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.