diff mbox

[v2,52/52] xen: make some console related parameters settable at runtime

Message ID 20170814070849.20986-53-jgross@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jürgen Groß Aug. 14, 2017, 7:08 a.m. UTC
Support modifying conswitch, console_timestamps, loglvl and
guest_loglvl at runtime.

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>
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
---
 docs/misc/xen-command-line.markdown |  8 ++++++++
 xen/drivers/char/console.c          | 14 +++++++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)

Comments

Jan Beulich Aug. 15, 2017, 3:45 p.m. UTC | #1
>>> On 14.08.17 at 09:08, <jgross@suse.com> wrote:
> --- a/xen/drivers/char/console.c
> +++ b/xen/drivers/char/console.c
> @@ -41,6 +41,7 @@ string_param("console", opt_console);
>  /*         boots. Any other value, or omitting the char, enables auto-switch 
> */
>  static unsigned char __read_mostly opt_conswitch[3] = "a";
>  string_param("conswitch", opt_conswitch);
> +string_param_runtime("conswitch", opt_conswitch);

Do you envision parameters which can only be set at runtime?
Otherwise, to avoid the two going out of sync (as well as the
redundancy) wouldn't it make sense for xyz_param_runtime()
to do what it does now _and_ invoke xyz_param()?

Jan
Jürgen Groß Aug. 15, 2017, 3:52 p.m. UTC | #2
On 15/08/17 17:45, Jan Beulich wrote:
>>>> On 14.08.17 at 09:08, <jgross@suse.com> wrote:
>> --- a/xen/drivers/char/console.c
>> +++ b/xen/drivers/char/console.c
>> @@ -41,6 +41,7 @@ string_param("console", opt_console);
>>  /*         boots. Any other value, or omitting the char, enables auto-switch 
>> */
>>  static unsigned char __read_mostly opt_conswitch[3] = "a";
>>  string_param("conswitch", opt_conswitch);
>> +string_param_runtime("conswitch", opt_conswitch);
> 
> Do you envision parameters which can only be set at runtime?
> Otherwise, to avoid the two going out of sync (as well as the
> redundancy) wouldn't it make sense for xyz_param_runtime()
> to do what it does now _and_ invoke xyz_param()?

There might be params requiring another handler (e.g. taking a lock,
allocating some memory, ...).

Having a macro for doing both (like above case) seems appropriate.
Any naming ideas? E.g.:

string_param_anytime() ?

Not sure whether I should add ;-)


Juergen
Jan Beulich Aug. 15, 2017, 3:59 p.m. UTC | #3
>>> On 15.08.17 at 17:52, <jgross@suse.com> wrote:
> On 15/08/17 17:45, Jan Beulich wrote:
>>>>> On 14.08.17 at 09:08, <jgross@suse.com> wrote:
>>> --- a/xen/drivers/char/console.c
>>> +++ b/xen/drivers/char/console.c
>>> @@ -41,6 +41,7 @@ string_param("console", opt_console);
>>>  /*         boots. Any other value, or omitting the char, enables 
> auto-switch 
>>> */
>>>  static unsigned char __read_mostly opt_conswitch[3] = "a";
>>>  string_param("conswitch", opt_conswitch);
>>> +string_param_runtime("conswitch", opt_conswitch);
>> 
>> Do you envision parameters which can only be set at runtime?
>> Otherwise, to avoid the two going out of sync (as well as the
>> redundancy) wouldn't it make sense for xyz_param_runtime()
>> to do what it does now _and_ invoke xyz_param()?
> 
> There might be params requiring another handler (e.g. taking a lock,
> allocating some memory, ...).
> 
> Having a macro for doing both (like above case) seems appropriate.
> Any naming ideas? E.g.:
> 
> string_param_anytime() ?

How about xyz_param_runtime_only() to cover the case where
you really need separate handlers? Yet even then one would have
to specify the string twice, i.e. the name you suggest might be
good to use when it takes two handler arguments.

> Not sure whether I should add ;-)

;-)

Jan
Jürgen Groß Aug. 15, 2017, 4:10 p.m. UTC | #4
On 15/08/17 17:59, Jan Beulich wrote:
>>>> On 15.08.17 at 17:52, <jgross@suse.com> wrote:
>> On 15/08/17 17:45, Jan Beulich wrote:
>>>>>> On 14.08.17 at 09:08, <jgross@suse.com> wrote:
>>>> --- a/xen/drivers/char/console.c
>>>> +++ b/xen/drivers/char/console.c
>>>> @@ -41,6 +41,7 @@ string_param("console", opt_console);
>>>>  /*         boots. Any other value, or omitting the char, enables 
>> auto-switch 
>>>> */
>>>>  static unsigned char __read_mostly opt_conswitch[3] = "a";
>>>>  string_param("conswitch", opt_conswitch);
>>>> +string_param_runtime("conswitch", opt_conswitch);
>>>
>>> Do you envision parameters which can only be set at runtime?
>>> Otherwise, to avoid the two going out of sync (as well as the
>>> redundancy) wouldn't it make sense for xyz_param_runtime()
>>> to do what it does now _and_ invoke xyz_param()?
>>
>> There might be params requiring another handler (e.g. taking a lock,
>> allocating some memory, ...).
>>
>> Having a macro for doing both (like above case) seems appropriate.
>> Any naming ideas? E.g.:
>>
>> string_param_anytime() ?
> 
> How about xyz_param_runtime_only() to cover the case where
> you really need separate handlers? Yet even then one would have
> to specify the string twice, i.e. the name you suggest might be
> good to use when it takes two handler arguments.

I think for now we could use *_param_runtime() for boot- and
runtime-changes. We can add another set of macros if we need them.


Juergen
diff mbox

Patch

diff --git a/docs/misc/xen-command-line.markdown b/docs/misc/xen-command-line.markdown
index 4002eab08b..9797c8db2d 100644
--- a/docs/misc/xen-command-line.markdown
+++ b/docs/misc/xen-command-line.markdown
@@ -391,6 +391,8 @@  makes sense on its own.
 
 > Default: `none`
 
+> Can be modified at runtime
+
 Specify which timestamp format Xen should use for each console line.
 
 * `none`: No timestamps
@@ -417,6 +419,8 @@  into the console ring buffer.
 
 > Default: `conswitch=a`
 
+> Can be modified at runtime
+
 Specify which character should be used to switch serial input between
 Xen and dom0.  The required sequence is CTRL-&lt;switch char&gt; three
 times.
@@ -898,6 +902,8 @@  maximum number of maptrack frames domain.
 
 > Default: `guest_loglvl=none/warning`
 
+> Can be modified at runtime
+
 Set the logging level for Xen guests.  Any log message with equal more
 more importance will be printed.
 
@@ -1164,6 +1170,8 @@  if left disabled by the BIOS.
 
 > Default: `loglvl=warning`
 
+> Can be modified at runtime
+
 Set the logging level for Xen.  Any log message with equal more more
 importance will be printed.
 
diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index daf0e1878d..283bd3ac6c 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -41,6 +41,7 @@  string_param("console", opt_console);
 /*         boots. Any other value, or omitting the char, enables auto-switch */
 static unsigned char __read_mostly opt_conswitch[3] = "a";
 string_param("conswitch", opt_conswitch);
+string_param_runtime("conswitch", opt_conswitch);
 
 /* sync_console: force synchronous console output (useful for debugging). */
 static bool_t __initdata opt_sync_console;
@@ -69,6 +70,7 @@  static enum con_timestamp_mode __read_mostly opt_con_timestamp_mode = TSM_NONE;
 
 static int parse_console_timestamps(char *s);
 custom_param("console_timestamps", parse_console_timestamps);
+custom_param_runtime("console_timestamps", parse_console_timestamps);
 
 /* conring_size: allows a large console ring than default (16kB). */
 static uint32_t __initdata opt_conring_size;
@@ -136,6 +138,8 @@  static int parse_guest_loglvl(char *s);
  */
 custom_param("loglvl", parse_loglvl);
 custom_param("guest_loglvl", parse_guest_loglvl);
+custom_param_runtime("loglvl", parse_loglvl);
+custom_param_runtime("guest_loglvl", parse_guest_loglvl);
 
 static atomic_t print_everything = ATOMIC_INIT(0);
 
@@ -145,7 +149,7 @@  static atomic_t print_everything = ATOMIC_INIT(0);
         return (lvlnum);                                \
     }
 
-static int __init __parse_loglvl(char *s, char **ps)
+static int __parse_loglvl(char *s, char **ps)
 {
     ___parse_loglvl(s, ps, "none",    0);
     ___parse_loglvl(s, ps, "error",   1);
@@ -156,7 +160,7 @@  static int __init __parse_loglvl(char *s, char **ps)
     return 2; /* sane fallback */
 }
 
-static int __init _parse_loglvl(char *s, int *lower, int *upper)
+static int _parse_loglvl(char *s, int *lower, int *upper)
 {
     *lower = *upper = __parse_loglvl(s, &s);
     if ( *s == '/' )
@@ -167,12 +171,12 @@  static int __init _parse_loglvl(char *s, int *lower, int *upper)
     return *s ? -EINVAL : 0;
 }
 
-static int __init parse_loglvl(char *s)
+static int parse_loglvl(char *s)
 {
     return _parse_loglvl(s, &xenlog_lower_thresh, &xenlog_upper_thresh);
 }
 
-static int __init parse_guest_loglvl(char *s)
+static int parse_guest_loglvl(char *s)
 {
     return _parse_loglvl(s, &xenlog_guest_lower_thresh,
                          &xenlog_guest_upper_thresh);
@@ -606,7 +610,7 @@  static int printk_prefix_check(char *p, char **pp)
             ((loglvl < upper_thresh) && printk_ratelimit()));
 } 
 
-static int __init parse_console_timestamps(char *s)
+static int parse_console_timestamps(char *s)
 {
     switch ( parse_bool(s) )
     {