All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v7] xen: Allow a default compiled-in command line using Kconfig
@ 2017-03-21  8:43 Zhongze Liu
  2017-03-21  8:59 ` Dario Faggioli
  2017-03-21  9:37 ` Jan Beulich
  0 siblings, 2 replies; 7+ messages in thread
From: Zhongze Liu @ 2017-03-21  8:43 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, Zhongze Liu, George Dunlap,
	Andrew Cooper, Ian Jackson, Tim Deegan, Jan Beulich

This allows downstreams to set their defaults without modifying the source code
all over the place. Also probably useful for the embedded space.
(See Also: https://xenproject.atlassian.net/browse/XEN-41)

Added 2 new config entries in common/Kconfig:
    CMDLINE and CMDLINE_OVERRIDE
Modified common/kernel.c:cmdline_parse().

The 2 new entries enable an embedded command line to be compiled
in the hypervisor. CMDLINE depends on EXPERT = "y", and CMDLINE_OVERRIDE
depends on CMDLINE != "".

If CMDLINE is set, it will be parsed prior to the bootloader command line.
This order of parsing implies that if any non-cumulative options are set in
both CMDLINE and the bootloader command line, only the ones in the latter will
take effect. Furthermore, if CMDLINE_OVERRIDE is set to y, the whole
bootloader command line will be ignored, which will be useful to work around
broken bootloaders. A wrapper to the original common/kernel.c:cmdline_parse()
was introduced to complete this task.

Signed-off-by: Zhongze Liu <blackskygg@gmail.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Tim Deegan <tim@xen.org>
Cc: Wei Liu <wei.liu2@citrix.com>
---
Changed since v6:
  * Adjusted the ordering of paragraphs in the commit message, with the
    motivation of this patch being the first paragraph now.
  * Fixed some typos in the commit message.
---
 xen/common/Kconfig  | 22 ++++++++++++++++++++++
 xen/common/kernel.c | 30 ++++++++++++++++++++++++------
 2 files changed, 46 insertions(+), 6 deletions(-)

diff --git a/xen/common/Kconfig b/xen/common/Kconfig
index f2ecbc43d6..e1c90b739a 100644
--- 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 CMDLINE != ""
+	---help---
+	  Set this option to 'Y' to have the hypervisor ignore the bootloader
+	  command line, and use ONLY the built-in command line.
+
+	  This is used to work around broken bootloaders. This should
+	  be set to 'N' under normal conditions.
 endmenu
diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index 4b87c60845..64920e8304 100644
--- 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;
+static const char __initconst opt_builtin_cmdline[] = CONFIG_CMDLINE;
 
 static void __init assign_integer_param(
     const struct kernel_param *param, uint64_t val)
@@ -46,18 +47,13 @@ static void __init assign_integer_param(
     }
 }
 
-void __init cmdline_parse(const char *cmdline)
+static void __init _cmdline_parse(const char *cmdline)
 {
     char opt[100], *optval, *optkey, *q;
     const char *p = cmdline;
     const struct kernel_param *param;
     int bool_assert;
 
-    if ( cmdline == NULL )
-        return;
-
-    safe_strcpy(saved_cmdline, cmdline);
-
     for ( ; ; )
     {
         /* Skip whitespace. */
@@ -147,6 +143,28 @@ 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 ( opt_builtin_cmdline[0] )
+    {
+        printk("Built-in command line: %s\n", opt_builtin_cmdline);
+        _cmdline_parse(opt_builtin_cmdline);
+    }
+
+#ifndef CONFIG_CMDLINE_OVERRIDE
+    if ( cmdline == NULL )
+        return;
+
+    safe_strcpy(saved_cmdline, cmdline);
+    _cmdline_parse(cmdline);
+#endif
+}
+
 int __init parse_bool(const char *s)
 {
     if ( !strcmp("no", s) ||
-- 
2.12.0


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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v7] xen: Allow a default compiled-in command line using Kconfig
  2017-03-21  8:43 [PATCH v7] xen: Allow a default compiled-in command line using Kconfig Zhongze Liu
@ 2017-03-21  8:59 ` Dario Faggioli
  2017-03-21  9:17   ` Zhongze Liu
  2017-03-21  9:37 ` Jan Beulich
  1 sibling, 1 reply; 7+ messages in thread
From: Dario Faggioli @ 2017-03-21  8:59 UTC (permalink / raw)
  To: Zhongze Liu, xen-devel
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Jan Beulich


[-- Attachment #1.1: Type: text/plain, Size: 1308 bytes --]

On Tue, 2017-03-21 at 16:43 +0800, Zhongze Liu wrote:
> This allows downstreams to set their defaults without modifying the
> source code
> all over the place. Also probably useful for the embedded space.
> (See Also: https://xenproject.atlassian.net/browse/XEN-41)
> 
> Added 2 new config entries in common/Kconfig:
>     CMDLINE and CMDLINE_OVERRIDE
> Modified common/kernel.c:cmdline_parse().
> 
> The 2 new entries enable an embedded command line to be compiled
> in the hypervisor. CMDLINE depends on EXPERT = "y", and
> CMDLINE_OVERRIDE
> depends on CMDLINE != "".
> 
Well, Jan also said:

"albeit I think the commit message should have what is now the 4th
paragraph first, with what are currently 1st and 2nd paragraphs
dropped altogether."

And those "1st and 2nd paragraphs" refers to, in this version, the text
that goes from "Added 2 new..." to "...depends on CMDLINE != """,
which, for what is worth, I agree does not add much and should be
dropped.

Although it's probably not a super big deal...

Dario
-- 
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 127 bytes --]

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v7] xen: Allow a default compiled-in command line using Kconfig
  2017-03-21  8:59 ` Dario Faggioli
@ 2017-03-21  9:17   ` Zhongze Liu
  2017-03-21  9:30     ` Dario Faggioli
  0 siblings, 1 reply; 7+ messages in thread
From: Zhongze Liu @ 2017-03-21  9:17 UTC (permalink / raw)
  To: Dario Faggioli
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Jan Beulich, xen-devel

2017-03-21 16:59 GMT+08:00 Dario Faggioli <dario.faggioli@citrix.com>:
> On Tue, 2017-03-21 at 16:43 +0800, Zhongze Liu wrote:
>> This allows downstreams to set their defaults without modifying the
>> source code
>> all over the place. Also probably useful for the embedded space.
>> (See Also: https://xenproject.atlassian.net/browse/XEN-41)
>>
>> Added 2 new config entries in common/Kconfig:
>>     CMDLINE and CMDLINE_OVERRIDE
>> Modified common/kernel.c:cmdline_parse().
>>
>> The 2 new entries enable an embedded command line to be compiled
>> in the hypervisor. CMDLINE depends on EXPERT = "y", and
>> CMDLINE_OVERRIDE
>> depends on CMDLINE != "".
>>
> Well, Jan also said:
>
> "albeit I think the commit message should have what is now the 4th
> paragraph first, with what are currently 1st and 2nd paragraphs
> dropped altogether."
>
> And those "1st and 2nd paragraphs" refers to, in this version, the text
> that goes from "Added 2 new..." to "...depends on CMDLINE != """,
> which, for what is worth, I agree does not add much and should be
> dropped.
>
> Although it's probably not a super big deal...
>

I thought these two paragraphs help people reading this message
understand more clearly what has been touched and what has been
done.
Although, as you put it, this is really not a super big dea, I'll try to make
my commit message more concise in my later patches.

Cheers.

Zhongze Liu

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v7] xen: Allow a default compiled-in command line using Kconfig
  2017-03-21  9:17   ` Zhongze Liu
@ 2017-03-21  9:30     ` Dario Faggioli
  2017-03-21 10:58       ` Zhongze Liu
  0 siblings, 1 reply; 7+ messages in thread
From: Dario Faggioli @ 2017-03-21  9:30 UTC (permalink / raw)
  To: Zhongze Liu
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Jan Beulich, xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 2311 bytes --]

On Tue, 2017-03-21 at 17:17 +0800, Zhongze Liu wrote:
:
> > On Tue, 2017-03-21 at 16:43 +0800, Zhongze Liu wrote:
> > > 
> Added 2 new config entries in common/Kconfig:
> > >     CMDLINE and CMDLINE_OVERRIDE
> > > Modified common/kernel.c:cmdline_parse().
> > > 
> > > The 2 new entries enable an embedded command line to be compiled
> > > in the hypervisor. CMDLINE depends on EXPERT = "y", and
> > > CMDLINE_OVERRIDE
> > > depends on CMDLINE != "".
> > > 
> > 
> > And those "1st and 2nd paragraphs" refers to, in this version, the
> > text
> > that goes from "Added 2 new..." to "...depends on CMDLINE != """,
> > which, for what is worth, I agree does not add much and should be
> > dropped.
> > 
> I thought these two paragraphs help people reading this message
> understand more clearly what has been touched and what has been
> done.
>
Right. And in fact, coming up with good changelogs is definitely not
the easiest part of preparing a patch. :-)

It's, therefore, quite difficult to come up with rules that can be
called truly general. In this specific case, all the information
conveyed by those paragraphs is already there, e.g., by looking at the
diffstat (during the review process) and at the code.

And the purpose of the commit message is not to explain *what* the code
does (or, let's say, not at this level of details), but other things,
such as:
 - why there were the need for the patch;
 - why the code does what it does in the specific way it does it. :-)

It's certainly not straightforward to draw a line, and even people that
 are doing this for ages not always get it right at the first time, and
there's always room for learning and improving... That's why we often
mention things like this. :-D

> Although, as you put it, this is really not a super big dea, I'll try
> to make
> my commit message more concise in my later patches.
> 
It's not necessarily a matter of length. Much more so a matter of
redundancy and of what kind of information is there.

Regards,
Dario
-- 
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 127 bytes --]

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v7] xen: Allow a default compiled-in command line using Kconfig
  2017-03-21  8:43 [PATCH v7] xen: Allow a default compiled-in command line using Kconfig Zhongze Liu
  2017-03-21  8:59 ` Dario Faggioli
@ 2017-03-21  9:37 ` Jan Beulich
  2017-03-21 11:10   ` Zhongze Liu
  1 sibling, 1 reply; 7+ messages in thread
From: Jan Beulich @ 2017-03-21  9:37 UTC (permalink / raw)
  To: Zhongze Liu
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, xen-devel

>>> On 21.03.17 at 09:43, <blackskygg@gmail.com> wrote:
> Added 2 new config entries in common/Kconfig:
>     CMDLINE and CMDLINE_OVERRIDE
> Modified common/kernel.c:cmdline_parse().
> 
> The 2 new entries enable an embedded command line to be compiled
> in the hypervisor. CMDLINE depends on EXPERT = "y", and CMDLINE_OVERRIDE
> depends on CMDLINE != "".

I'm slightly confused: Didn't you agree to my suggestion to drop
these two paragraphs altogether? My intention is still to purge
them while committing.

Jan


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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v7] xen: Allow a default compiled-in command line using Kconfig
  2017-03-21  9:30     ` Dario Faggioli
@ 2017-03-21 10:58       ` Zhongze Liu
  0 siblings, 0 replies; 7+ messages in thread
From: Zhongze Liu @ 2017-03-21 10:58 UTC (permalink / raw)
  To: Dario Faggioli
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Jan Beulich, xen-devel

2017-03-21 17:30 GMT+08:00 Dario Faggioli <dario.faggioli@citrix.com>:
> On Tue, 2017-03-21 at 17:17 +0800, Zhongze Liu wrote:
> :
>> > On Tue, 2017-03-21 at 16:43 +0800, Zhongze Liu wrote:
>> > >
>> Added 2 new config entries in common/Kconfig:
>> > >     CMDLINE and CMDLINE_OVERRIDE
>> > > Modified common/kernel.c:cmdline_parse().
>> > >
>> > > The 2 new entries enable an embedded command line to be compiled
>> > > in the hypervisor. CMDLINE depends on EXPERT = "y", and
>> > > CMDLINE_OVERRIDE
>> > > depends on CMDLINE != "".
>> > >
>> >
>> > And those "1st and 2nd paragraphs" refers to, in this version, the
>> > text
>> > that goes from "Added 2 new..." to "...depends on CMDLINE != """,
>> > which, for what is worth, I agree does not add much and should be
>> > dropped.
>> >
>> I thought these two paragraphs help people reading this message
>> understand more clearly what has been touched and what has been
>> done.
>>
> Right. And in fact, coming up with good changelogs is definitely not
> the easiest part of preparing a patch. :-)
>
> It's, therefore, quite difficult to come up with rules that can be
> called truly general. In this specific case, all the information
> conveyed by those paragraphs is already there, e.g., by looking at the
> diffstat (during the review process) and at the code.
>
> And the purpose of the commit message is not to explain *what* the code
> does (or, let's say, not at this level of details), but other things,
> such as:
>  - why there were the need for the patch;
>  - why the code does what it does in the specific way it does it. :-)
>
> It's certainly not straightforward to draw a line, and even people that
>  are doing this for ages not always get it right at the first time, and
> there's always room for learning and improving... That's why we often
> mention things like this. :-D
>
>> Although, as you put it, this is really not a super big dea, I'll try
>> to make
>> my commit message more concise in my later patches.
>>
> It's not necessarily a matter of length. Much more so a matter of
> redundancy and of what kind of information is there.
>

Thanks for your kind words. Having thoroughly read your comment,
I think I now understand why these two paragraphs are redundant.
Thanks for teaching me about that. I'll surely try my best to learn
more
about how to write a good commit message. And I think the best way is
to observe what others do and try to develop a good "taste" of it.

Cheers.

Zhongze Liu.

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v7] xen: Allow a default compiled-in command line using Kconfig
  2017-03-21  9:37 ` Jan Beulich
@ 2017-03-21 11:10   ` Zhongze Liu
  0 siblings, 0 replies; 7+ messages in thread
From: Zhongze Liu @ 2017-03-21 11:10 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, xen-devel

2017-03-21 17:37 GMT+08:00 Jan Beulich <JBeulich@suse.com>:
>>>> On 21.03.17 at 09:43, <blackskygg@gmail.com> wrote:
>> Added 2 new config entries in common/Kconfig:
>>     CMDLINE and CMDLINE_OVERRIDE
>> Modified common/kernel.c:cmdline_parse().
>>
>> The 2 new entries enable an embedded command line to be compiled
>> in the hypervisor. CMDLINE depends on EXPERT = "y", and CMDLINE_OVERRIDE
>> depends on CMDLINE != "".
>
> I'm slightly confused: Didn't you agree to my suggestion to drop
> these two paragraphs altogether? My intention is still to purge
> them while committing.
>
Sorry Jan, I didn't mean to confuse you. I think I should have said:
"partly agree" and
explain why. my fault, sorry. Having read through Dario's words, I now
understand
what your concerns are. And now I'm trying to develop a good taste of
commit messages.

I'm still learning things, so please do continue to point out my
problems if you find any. I
sincerely appreciate all the things I've learned here so far. Thanks.

Cheers.

Zhongze Liu.

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-03-21 11:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-21  8:43 [PATCH v7] xen: Allow a default compiled-in command line using Kconfig Zhongze Liu
2017-03-21  8:59 ` Dario Faggioli
2017-03-21  9:17   ` Zhongze Liu
2017-03-21  9:30     ` Dario Faggioli
2017-03-21 10:58       ` Zhongze Liu
2017-03-21  9:37 ` Jan Beulich
2017-03-21 11:10   ` Zhongze Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.