[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v6 1/2] xen/common: add keyhandler to show Xen command line


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: dmukhin@xxxxxxxx
  • Date: Thu, 13 Aug 2026 18:02:05 -0700
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 148.163.138.245) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=ford.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ford.com; dkim=pass (signature was verified) header.d=saarlouis.ford.com; dkim=pass (signature was verified) header.d=ford.com; arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=B2CeXgWbeWAKBBRE8vrqNf21nSh2X7vYMlI+F7Op07I=; b=ZbNfVtC5vD7aR7A6N0Bj5TUEJwbm4uXsaUsf9cEVAZvEPXus6LJ8ju8Dm5kZ1UeVbms+5CAp+62bY8CIkb/I022dHr7ANjMWJm3RN8GQdWopIcO1wqJ4DQaR4dXL1kh1sz169W0z10cSJeKYOcY8fFXKkaGNFnl7aLD/gUodN2rjkulOGLL+J8JIE8dlJbuRWB85g4erlQaWdzfP1EPlL20EIwyY8uQ3BKIIB6dBtoE9m8AUncfoz378lJZGeoVa5DArCIhul+YqC8+aTjcgP4hvIXclrPQur2CLZpYHHlj7rao9kiiybXHeFyIB7SrRsZkxBhwQ0wugLQNtad5bRw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EjFM+bMEyrFxLUd3oSCaI6+dQZPuHW6+xagaOk7xHj95parbIESanvfM6gB3xsMvv5VQCvh2pb3STeRJSFZGPDg1UM8qjcUPO4mKcYSG8yGRROFQ+DiMcB2g267t4ya5sFI6QPqICn93+VLb3wFC5z/+vyItkdcRpTVbzgMQPrsljVFuW1BxZEksmmGcAxcZd4rXvMcHWSIoH90IMLxdzFBgOMR7qBPrWYCRxOKyG3XUKy9/VWSUaFiRenF+EEEhny99Mxf5t/Er7G8nvkNunlfZH4USs0w2ZmiHiOUgbYB8LH9jOp456e1ncx+cYkcRKEVET1Ymb3/0AQhS/hiftA==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=ppford header.d=ford.com header.i="@ford.com" header.h="Cc:Content-Transfer-Encoding:Content-Type:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"; dkim=pass header.s=selector2-azureford-onmicrosoft-com header.d=azureford.onmicrosoft.com header.i="@azureford.onmicrosoft.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"; dkim=pass header.s=ppserprodsaar header.d=saarlouis.ford.com header.i="@saarlouis.ford.com" header.h="Cc:Content-Transfer-Encoding:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"; dkim=pass header.s=ppfserpocford header.d=ford.com header.i="@ford.com" header.h="Cc:Content-Transfer-Encoding:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"
  • Cc: andrew.cooper3@xxxxxxxxxx, anthony.perard@xxxxxxxxxx, jbeulich@xxxxxxxx, julien@xxxxxxx, michal.orzel@xxxxxxx, roger@xxxxxxxxxxxxxx, sstabellini@xxxxxxxxxx, dmukhin@xxxxxxxx
  • Delivery-date: Fri, 14 Aug 2026 01:02:31 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Pser-m365-app: SER-APP

From: Denis Mukhin <dmukhin@xxxxxxxx> 

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

Add new print_cmdline() function to print both built-in and run-time
command lines on the console.

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

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

Signed-off-by: Denis Mukhin <dmukhin@xxxxxxxx>
---
Changes since v5:
- drop version printout from 'h'
- add new handler for system information

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
---
 xen/common/kernel.c     | 20 +++++++++++++++++++-
 xen/common/keyhandler.c | 10 +++++++++-
 xen/include/xen/lib.h   |  1 +
 3 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index d1bef9ac2b2b..f4bbd8818fa8 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -35,7 +35,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)
@@ -758,6 +758,24 @@ long do_xen_version(int cmd, XEN_GUEST_HANDLE_PARAM(void) 
arg)
     return -ENOSYS;
 }
 
+void print_cmdline(void)
+{
+    const char *cmdline;
+
+    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);
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c
index cb6df2823b00..92b0573d8b3a 100644
--- a/xen/common/keyhandler.c
+++ b/xen/common/keyhandler.c
@@ -28,7 +28,7 @@ static unsigned char keypress_key;
 static bool alt_key_handling;
 
 static keyhandler_fn_t cf_check show_handlers, cf_check dump_hwdom_registers,
-    cf_check dump_domains, cf_check read_clocks;
+    cf_check dump_domains, cf_check read_clocks, cf_check show_system_info;
 static irq_keyhandler_fn_t cf_check do_toggle_alt_key, cf_check dump_registers,
     cf_check reboot_machine, cf_check run_all_keyhandlers;
 
@@ -58,6 +58,7 @@ static struct keyhandler {
         KEYHANDLER('t', read_clocks, "display multi-cpu clock info", 1),
         KEYHANDLER('0', dump_hwdom_registers, "dump Dom0 registers", 1),
     IRQ_KEYHANDLER('*', run_all_keyhandlers, "print all diagnostics", 0),
+        KEYHANDLER('?', show_system_info, "show system information", false),
 
 #ifdef CONFIG_PERF_COUNTERS
     KEYHANDLER('p', perfc_printall, "print performance counters", 1),
@@ -138,6 +139,13 @@ static void cf_check show_handlers(unsigned char key)
                    isprint(i) ? i : ' ', i, key_table[i].desc);
 }
 
+static void cf_check show_system_info(unsigned char key)
+{
+    printk("'%c' pressed -> showing system information\n", key);
+
+    print_cmdline();
+}
+
 static cpumask_t dump_execstate_mask;
 
 void cf_check dump_execstate(const struct cpu_user_regs *regs)
diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h
index 3c545ff33c61..618e37b920e3 100644
--- a/xen/include/xen/lib.h
+++ b/xen/include/xen/lib.h
@@ -48,6 +48,7 @@ int parse_signed_integer(const char *name, const char *s, 
const char *e,
 int cmdline_strcmp(const char *frag, const char *name);
 
 void print_version(void);
+void print_cmdline(void);
 
 #ifdef CONFIG_DEBUG_TRACE
 extern void debugtrace_dump(void);
-- 
2.54.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.