All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5] xen/common: add keyhandler to show Xen command line
@ 2026-08-13  3:51 dmukhin
  2026-08-13  6:00 ` Jan Beulich
  0 siblings, 1 reply; 3+ messages in thread
From: dmukhin @ 2026-08-13  3:51 UTC (permalink / raw)
  To: xen-devel
  Cc: andrew.cooper3, anthony.perard, jbeulich, julien, michal.orzel,
	roger, sstabellini, dmukhin

From: Denis Mukhin <dmukhin@ford.com> 

Currently there's no way to print Xen command line on the emergency
console for debugging purposes when 'xl' is unavailable.

Add new keyhander '?' to do command line printout.

To allow built-in command printout, drop __initconst in
'opt_builtin_cmdline' declaration.

Signed-off-by: Denis Mukhin <dmukhin@ford.com>
---
Changes since v4:
- promote opt_builtin_cmdline to __ro_after_init and use it for
  built-in command line reporting
- account for empty saved_cmdline
- adjust register_keyhandler() call - use '?'

Changes since v3:
- print built-in command line too
- change handler to print command line only

Changes since v2:
- account for CONFIG_CMDLINE_OVERRIDE case

v4: https://lore.kernel.org/xen-devel/20260811210956.3806559-2-dmukhin@ford.com/
CI: https://gitlab.com/xen-project/people/dmukhin/xen/-/pipelines/2756104826
---
 xen/common/kernel.c | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index d1bef9ac2b2b..1afda2a68f3e 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -5,6 +5,7 @@
  */
 
 #include <xen/init.h>
+#include <xen/keyhandler.h>
 #include <xen/lib.h>
 #include <xen/errno.h>
 #include <xen/param.h>
@@ -35,7 +36,7 @@ boolean_param("dit", opt_dit);
 #endif
 
 static xen_commandline_t __ro_after_init saved_cmdline;
-static const char __initconst opt_builtin_cmdline[] = CONFIG_CMDLINE;
+static const char opt_builtin_cmdline[] = CONFIG_CMDLINE;
 char __ro_after_init xen_cap_info[128];
 
 static int assign_integer_param(const struct kernel_param *param, uint64_t val)
@@ -505,6 +506,35 @@ static int __init cf_check param_init(void)
 __initcall(param_init);
 #endif
 
+static void cf_check show_cmdline(unsigned char key)
+{
+    const char *cmdline;
+
+    printk("'%c' pressed -> showing hypervisor command line\n", key);
+
+    if ( opt_builtin_cmdline[0] )
+        printk("Built-in command line: %s\n", opt_builtin_cmdline);
+
+    if ( IS_ENABLED(CONFIG_CMDLINE_OVERRIDE) )
+        cmdline = "<ignored> (CONFIG_CMDLINE_OVERRIDE=y)";
+    else if ( saved_cmdline[0] )
+        cmdline = saved_cmdline;
+    else
+        cmdline = NULL;
+
+    if ( cmdline )
+        printk("Command line: %s\n", cmdline);
+}
+
+static int __init cf_check misc_init(void)
+{
+    register_keyhandler('?', show_cmdline,
+                        "show hypervisor command line", false);
+
+    return 0;
+}
+__initcall(misc_init);
+
 static long xenver_varbuf_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
 {
     struct xen_varbuf user_str;
-- 
2.54.0



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

* Re: [PATCH v5] xen/common: add keyhandler to show Xen command line
  2026-08-13  3:51 [PATCH v5] xen/common: add keyhandler to show Xen command line dmukhin
@ 2026-08-13  6:00 ` Jan Beulich
  2026-08-13 18:36   ` dmukhin
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2026-08-13  6:00 UTC (permalink / raw)
  To: dmukhin
  Cc: andrew.cooper3, anthony.perard, julien, michal.orzel, roger,
	sstabellini, xen-devel

On 13.08.2026 05:51, dmukhin@ford.com wrote:
> From: Denis Mukhin <dmukhin@ford.com> 
> 
> Currently there's no way to print Xen command line on the emergency
> console for debugging purposes when 'xl' is unavailable.
> 
> Add new keyhander '?' to do command line printout.
> 
> To allow built-in command printout, drop __initconst in
> 'opt_builtin_cmdline' declaration.
> 
> Signed-off-by: Denis Mukhin <dmukhin@ford.com>
> ---
> Changes since v4:
> - promote opt_builtin_cmdline to __ro_after_init and use it for
>   built-in command line reporting
> - account for empty saved_cmdline
> - adjust register_keyhandler() call - use '?'

This isn't quite what I was expecting, following the feedback you got on
v4. My expectation was that we'd see a 2-patch series, first patch moving
non-help stuff out of the 'h' handler, second patch adding the dumping of
the command line. Naturally the new handler then wouldn't be named
show_cmdline(). I'd then further expect tat no new use of
register_keyhandler() would be necessary: The handler itself would live
in keyhandler.c, and print_version() would then be accompanied by a new
print_cmdline().

Jan


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

* Re: [PATCH v5] xen/common: add keyhandler to show Xen command line
  2026-08-13  6:00 ` Jan Beulich
@ 2026-08-13 18:36   ` dmukhin
  0 siblings, 0 replies; 3+ messages in thread
From: dmukhin @ 2026-08-13 18:36 UTC (permalink / raw)
  To: Jan Beulich
  Cc: dmukhin, andrew.cooper3, anthony.perard, julien, michal.orzel,
	roger, sstabellini, xen-devel

On Thu, Aug 13, 2026 at 08:00:11AM +0200, Jan Beulich wrote:
> On 13.08.2026 05:51, dmukhin@ford.com wrote:
> > From: Denis Mukhin <dmukhin@ford.com> 
> > 
> > Currently there's no way to print Xen command line on the emergency
> > console for debugging purposes when 'xl' is unavailable.
> > 
> > Add new keyhander '?' to do command line printout.
> > 
> > To allow built-in command printout, drop __initconst in
> > 'opt_builtin_cmdline' declaration.
> > 
> > Signed-off-by: Denis Mukhin <dmukhin@ford.com>
> > ---
> > Changes since v4:
> > - promote opt_builtin_cmdline to __ro_after_init and use it for
> >   built-in command line reporting
> > - account for empty saved_cmdline
> > - adjust register_keyhandler() call - use '?'
> 
> This isn't quite what I was expecting, following the feedback you got on
> v4. My expectation was that we'd see a 2-patch series, first patch moving
> non-help stuff out of the 'h' handler, second patch adding the dumping of
> the command line. Naturally the new handler then wouldn't be named
> show_cmdline(). I'd then further expect tat no new use of
> register_keyhandler() would be necessary: The handler itself would live
> in keyhandler.c, and print_version() would then be accompanied by a new
> print_cmdline().

I see, will update.

> 
> Jan
> 


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

end of thread, other threads:[~2026-08-13 18:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-13  3:51 [PATCH v5] xen/common: add keyhandler to show Xen command line dmukhin
2026-08-13  6:00 ` Jan Beulich
2026-08-13 18:36   ` dmukhin

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.