xen/common: add keyhandler to show Xen command line
PATCH v3 1/1 xen/common: add keyhandler to show Xen command line
From: Denis Mukhin <[email protected]>
Currently there's no way to print Xen command line on the emergency console for debugging purposes when 'xl' is not unavailable.
Add new keyhander 'X' to do command line printout.
---
Changes since v2:
- account for CONFIG_CMDLINE_OVERRIDE case
- use IS_ENABLED()
v2: https://lore.kernel.org/xen-devel/[email protected]/
CI: https://gitlab.com/xen-project/people/dmukhin/xen/-/pipelines/2748655201
--- xen/common/kernel.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
xen/common/kernel.c +20 -0
@@ -5,6 +5,7 @@*/ #include <xen/init.h> +#include <xen/keyhandler.h> #include <xen/lib.h> #include <xen/errno.h> #include <xen/param.h>
@@ -505,6 +506,25 @@ static int __init cf_check param_init(void)__initcall (param_init);#endif +static void cf_check show_hypervisor_info(unsigned char key) +{ +printk ("'%c' pressed -> showing hypervisor information\n" , key); + +if (IS_ENABLED (CONFIG_CMDLINE_OVERRIDE ) ) +printk ("Bootloader command line ignored (CONFIG_CMDLINE_OVERRIDE=y)\n" ); +else +printk ("Command line: %s\n" , saved_cmdline); +} + +static int __init cf_check misc_init(void) +{ +register_keyhandler ('X' , show_hypervisor_info, +"show hypervisor information" ,0 ); + +return 0 ; +} +__initcall (misc_init); +static long xenver_varbuf_op (int cmd,XEN_GUEST_HANDLE_PARAM (void ) arg) {struct xen_varbuf user_str;
Signature · 1 line
2.54.0
Quoted 32 lines · On Mon, Aug 10, 2026 at 04:04:01PM -0700, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Currently there's no way to print Xen command line on the emergency console for debugging purposes when 'xl' is not unavailable.
Add new keyhander 'X' to do command line printout.
Signed-off-by Denis Mukhin <[email protected]>---
Changes since v2:
- account forCONFIG_CMDLINE_OVERRIDEcase
- useIS_ENABLED()v2: https://lore.kernel.org/xen-devel/[email protected]/
CI: https://gitlab.com/xen-project/people/dmukhin/xen/-/pipelines/2748655201--- xen/common/kernel.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)xen/common/kernel.c +1
-0@@ -5,6 +5,7 @@*/ #include <xen/init.h> +#include <xen/keyhandler.h> #include <xen/lib.h> #include <xen/errno.h> #include <xen/param.h>
xen/common/kernel.c static int __init cf_check param_init(void) · line 514
Quoted 9 lines
xen/common/kernel.c +6
-0@@ -505,6 +506,25 @@ static int __init cf_check param_init(void)__initcall (param_init);#endif +static void cf_check show_hypervisor_info(unsigned char key) +{ +printk ("'%c' pressed -> showing hypervisor information\n" , key); + +if (IS_ENABLED (CONFIG_CMDLINE_OVERRIDE ) ) +printk ("Bootloader command line ignored (CONFIG_CMDLINE_OVERRIDE=y)\n" );
Since we are there already, why not print the builtin command line using CONFIG_CMDLINE?
xen/common/kernel.c static int __init cf_check param_init(void) · line 522
Quoted 8 lines
xen/common/kernel.c +8
-0+else +printk ("Command line: %s\n" , saved_cmdline); +} + +static int __init cf_check misc_init(void) +{ +register_keyhandler ('X' , show_hypervisor_info, +"show hypervisor information" ,0 );
"show hypervisor information" seems too generic to me, almost all debug keys could be defined by this sentence TBH. I think this needs to be more specific, but I'm not sure what's the plan regarding this key. Is there an intention to print more stuff here, or just the command line? Knowing the full set of information to be printed might help come up with a better name.
Thanks, Roger.
Thanks for taking a look!
Quoted 36 lines · Roger Pau Monné
Quoted 35 lines · On Mon, Aug 10, 2026 at 04:04:01PM -0700, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Currently there's no way to print Xen command line on the emergency console for debugging purposes when 'xl' is not unavailable.
Add new keyhander 'X' to do command line printout.
Signed-off-by Denis Mukhin <[email protected]>---
Changes since v2:
- account forCONFIG_CMDLINE_OVERRIDEcase
- useIS_ENABLED()v2: https://lore.kernel.org/xen-devel/[email protected]/
CI: https://gitlab.com/xen-project/people/dmukhin/xen/-/pipelines/2748655201--- xen/common/kernel.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)xen/common/kernel.c +1
-0@@ -5,6 +5,7 @@*/ #include <xen/init.h> +#include <xen/keyhandler.h> #include <xen/lib.h> #include <xen/errno.h> #include <xen/param.h> @@ -505,6 +506,25 @@ static int __init cf_check param_init(void)__initcall (param_init);#endif
Quoted 9 lines
xen/common/kernel.c static int __init cf_check param_init(void) · line 514
Quoted 6 lines
xen/common/kernel.c +6
-0+static void cf_check show_hypervisor_info(unsigned char key) +{ +printk ("'%c' pressed -> showing hypervisor information\n" , key); + +if (IS_ENABLED (CONFIG_CMDLINE_OVERRIDE ) ) +printk ("Bootloader command line ignored (CONFIG_CMDLINE_OVERRIDE=y)\n" );Since we are there already, why not print the builtin command line using
CONFIG_CMDLINE?
Will update.
Quoted 16 lines
xen/common/kernel.c static int __init cf_check param_init(void) · line 522
Quoted 9 lines
xen/common/kernel.c +8
-0+else +printk ("Command line: %s\n" , saved_cmdline); +} + +static int __init cf_check misc_init(void) +{ +register_keyhandler ('X' , show_hypervisor_info, +"show hypervisor information" ,0 );"show hypervisor information" seems too generic to me, almost all debug keys could be defined by this sentence TBH. I think this needs to be more specific, but I'm not sure what's the plan regarding this key. Is there an intention to print more stuff here, or just the command line? Knowing the full set of information to be printed might help come up with a better name.
I will update to "show_cmdline" since I originally planed to expose Xen command line only so it is possible to better debug a system when dom0 becomes almost unresponsive.
Quoted 3 lines
Thanks, Roger.
--
Denis
Quoted 14 lines · On 11.08.2026 22:56, [email protected] wrote:
Quoted 12 lines · Roger Pau Monné
xen/common/kernel.c static int __init cf_check param_init(void) · line 522
Quoted 4 lines · On Mon, Aug 10, 2026 at 04:04:01PM -0700, [email protected] wrote:
xen/common/kernel.c +4
-0+static int __init cf_check misc_init(void) +{ +register_keyhandler ('X' , show_hypervisor_info, +"show hypervisor information" ,0 );"show hypervisor information" seems too generic to me, almost all debug keys could be defined by this sentence TBH. I think this needs to be more specific, but I'm not sure what's the plan regarding this key. Is there an intention to print more stuff here, or just the command line? Knowing the full set of information to be printed might help come up with a better name.
Quoted 3 lines
I will update to "
show_cmdline" since I originally planed to expose Xen command line only so it is possible to better debug a system when dom0 becomes almost unresponsive.
Yet as indicated already on v1 (I think) - a precious debug key character for just the command line seems rather wasteful to me. If it's only the command line, and if that _really_ needs exposing via a debug key (i.e. if there are reasonable scenarios where "xl info" cannot be used), perhaps attach it to e.g. the 'h' key output?
Jan
Quoted 19 lines · Jan Beulich
Quoted 14 lines · On 11.08.2026 22:56, [email protected] wrote:
Quoted 12 lines · Roger Pau Monné
xen/common/kernel.c static int __init cf_check param_init(void) · line 522
Quoted 4 lines · On Mon, Aug 10, 2026 at 04:04:01PM -0700, [email protected] wrote:
xen/common/kernel.c +4
-0+static int __init cf_check misc_init(void) +{ +register_keyhandler ('X' , show_hypervisor_info, +"show hypervisor information" ,0 );"show hypervisor information" seems too generic to me, almost all debug keys could be defined by this sentence TBH. I think this needs to be more specific, but I'm not sure what's the plan regarding this key. Is there an intention to print more stuff here, or just the command line? Knowing the full set of information to be printed might help come up with a better name.
Quoted 3 lines
I will update to "
show_cmdline" since I originally planed to expose Xen command line only so it is possible to better debug a system when dom0 becomes almost unresponsive.
Quoted 5 lines
Yet as indicated already on v1 (I think) - a precious debug key character for just the command line seems rather wasteful to me. If it's only the command line, and if that _really_ needs exposing via a debug key (i.e. if there are reasonable scenarios where "xl info" cannot be used), perhaps attach it to e.g. the 'h' key output?
I was going to say that we should not overload the 'h' key with printing a possibly long string, but I see we already print a bunch of information there, like the buildid and the compiler banner.
One option would be to introduce a new debug character, and move the printing of the buildid and the banner to that key, together with the command line. Then 'h' output will be cleaner and just print the list of installed handlers. That would give the new key more content, and help cleanup the output from the 'h' debug key at the same time.
Thanks, Roger.
Quoted 30 lines · Roger Pau Monné
Quoted 19 lines · Jan Beulich
Quoted 14 lines · On 11.08.2026 22:56, [email protected] wrote:
Quoted 12 lines · Roger Pau Monné
xen/common/kernel.c static int __init cf_check param_init(void) · line 522
Quoted 4 lines · On Mon, Aug 10, 2026 at 04:04:01PM -0700, [email protected] wrote:
xen/common/kernel.c +4
-0+static int __init cf_check misc_init(void) +{ +register_keyhandler ('X' , show_hypervisor_info, +"show hypervisor information" ,0 );"show hypervisor information" seems too generic to me, almost all debug keys could be defined by this sentence TBH. I think this needs to be more specific, but I'm not sure what's the plan regarding this key. Is there an intention to print more stuff here, or just the command line? Knowing the full set of information to be printed might help come up with a better name.
Quoted 3 lines
I will update to "
show_cmdline" since I originally planed to expose Xen command line only so it is possible to better debug a system when dom0 becomes almost unresponsive.Quoted 5 lines
Yet as indicated already on v1 (I think) - a precious debug key character for just the command line seems rather wasteful to me. If it's only the command line, and if that _really_ needs exposing via a debug key (i.e. if there are reasonable scenarios where "xl info" cannot be used), perhaps attach it to e.g. the 'h' key output?
I was going to say that we should not overload the 'h' key with printing a possibly long string, but I see we already print a bunch of information there, like the buildid and the compiler banner.
Quoted 5 lines
One option would be to introduce a new debug character, and move the printing of the buildid and the banner to that key, together with the command line. Then 'h' output will be cleaner and just print the list of installed handlers. That would give the new key more content, and help cleanup the output from the 'h' debug key at the same time.
Hmm, yes, that's definitely an option. May I then further suggest to use '?' as the key for this? (Or am I overlooking that key already being in use somewhere?)
Jan
Quoted 37 lines · Jan Beulich
Quoted 30 lines · Roger Pau Monné
Quoted 19 lines · Jan Beulich
Quoted 14 lines · On 11.08.2026 22:56, [email protected] wrote:
Quoted 12 lines · Roger Pau Monné
xen/common/kernel.c static int __init cf_check param_init(void) · line 522
Quoted 4 lines · On Mon, Aug 10, 2026 at 04:04:01PM -0700, [email protected] wrote:
xen/common/kernel.c +4
-0+static int __init cf_check misc_init(void) +{ +register_keyhandler ('X' , show_hypervisor_info, +"show hypervisor information" ,0 );"show hypervisor information" seems too generic to me, almost all debug keys could be defined by this sentence TBH. I think this needs to be more specific, but I'm not sure what's the plan regarding this key. Is there an intention to print more stuff here, or just the command line? Knowing the full set of information to be printed might help come up with a better name.
Quoted 3 lines
I will update to "
show_cmdline" since I originally planed to expose Xen command line only so it is possible to better debug a system when dom0 becomes almost unresponsive.Quoted 5 lines
Yet as indicated already on v1 (I think) - a precious debug key character for just the command line seems rather wasteful to me. If it's only the command line, and if that _really_ needs exposing via a debug key (i.e. if there are reasonable scenarios where "xl info" cannot be used), perhaps attach it to e.g. the 'h' key output?
I was going to say that we should not overload the 'h' key with printing a possibly long string, but I see we already print a bunch of information there, like the buildid and the compiler banner.
Quoted 5 lines
One option would be to introduce a new debug character, and move the printing of the buildid and the banner to that key, together with the command line. Then 'h' output will be cleaner and just print the list of installed handlers. That would give the new key more content, and help cleanup the output from the 'h' debug key at the same time.
Quoted 3 lines
Hmm, yes, that's definitely an option. May I then further suggest to use '?' as the key for this? (Or am I overlooking that key already being in use somewhere?)
I did not find '?' being used, will update the key mapping.
Thanks for the suggestion!
Quoted 3 lines
Jan