[PATCH v3] xen/common: add keyhandler to show Xen command line

[email protected]
Newsgroups org.xenproject.lists.xen-devel
Message-ID <[email protected]>
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 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(+)

diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index d1bef9ac2b2b..54a7ee6f68e5 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>
@@ -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;
-- 
2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.