diff mbox series

[v2] xen/console: print Xen version via keyhandler

Message ID 20250213082639.119796-1-dmkhn@proton.me (mailing list archive)
State Superseded
Headers show
Series [v2] xen/console: print Xen version via keyhandler | expand

Commit Message

Denis Mukhin Feb. 13, 2025, 8:28 a.m. UTC
From: Denis Mukhin <dmukhin@ford.com>

Add Xen version printout to 'h' keyhandler output.

That is useful for debugging systems that have been left intact for a long
time.

Signed-off-by: Denis Mukhin <dmukhin@ford.com>
---
Changes since v1:
- Moved version printout to 'h' keyhandler
- Kept the build-id reporting past Xen version printout during console
  initialization
---
 xen/common/keyhandler.c    |  5 +++++
 xen/common/version.c       | 20 ++++++++++++++++++--
 xen/drivers/char/console.c |  8 +++-----
 xen/include/xen/version.h  |  3 +++
 4 files changed, 29 insertions(+), 7 deletions(-)

Comments

Jan Beulich Feb. 13, 2025, 9:10 a.m. UTC | #1
On 13.02.2025 09:28, dmkhn@proton.me wrote:
> --- a/xen/include/xen/version.h
> +++ b/xen/include/xen/version.h
> @@ -29,4 +29,7 @@ int xen_build_id_check(const Elf_Note *n, unsigned int n_sz,
>  static inline void xen_build_init(void) {};
>  #endif
>  
> +void xen_print_version(void);
> +void xen_print_build_id(void);

Hmm, I'm sorry, as I should have thought of this earlier already: What exactly
is the significance of the xen_ prefixes here? We're in Xen sources after all.

Jan
Denis Mukhin Feb. 13, 2025, 9:42 p.m. UTC | #2
On Thursday, February 13th, 2025 at 1:10 AM, Jan Beulich <jbeulich@suse.com> wrote:

> 
> 
> On 13.02.2025 09:28, dmkhn@proton.me wrote:
> 
> > --- a/xen/include/xen/version.h
> > +++ b/xen/include/xen/version.h
> > @@ -29,4 +29,7 @@ int xen_build_id_check(const Elf_Note *n, unsigned int n_sz,
> > static inline void xen_build_init(void) {};
> > #endif
> > 
> > +void xen_print_version(void);
> > +void xen_print_build_id(void);
> 
> 
> Hmm, I'm sorry, as I should have thought of this earlier already: What exactly
> is the significance of the xen_ prefixes here? We're in Xen sources after all.

I followed the rest of the code in version.{h,c} which has `xen_` prefixes.

I moved new definitions w/o prefix to xen/include/xen/lib.h where most
of the debug tracing facilities are declared in v3.

> 
> Jan

Thanks,
Denis
diff mbox series

Patch

diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c
index 6ea54838d4..a82276c6dc 100644
--- a/xen/common/keyhandler.c
+++ b/xen/common/keyhandler.c
@@ -22,6 +22,7 @@ 
 #include <xen/mm.h>
 #include <xen/watchdog.h>
 #include <xen/init.h>
+#include <xen/version.h>
 #include <asm/div64.h>
 
 static unsigned char keypress_key;
@@ -129,6 +130,10 @@  static void cf_check show_handlers(unsigned char key)
     unsigned int i;
 
     printk("'%c' pressed -> showing installed handlers\n", key);
+
+    xen_print_version();
+    xen_print_build_id();
+
     for ( i = 0; i < ARRAY_SIZE(key_table); i++ )
         if ( key_table[i].fn )
             printk(" key '%c' (ascii '%02x') => %s\n",
diff --git a/xen/common/version.c b/xen/common/version.c
index bc3714b45f..76197a4ef7 100644
--- a/xen/common/version.c
+++ b/xen/common/version.c
@@ -210,9 +210,25 @@  void __init xen_build_init(void)
         }
     }
 #endif /* CONFIG_X86 */
-    if ( !rc )
-        printk(XENLOG_INFO "build-id: %*phN\n", build_id_len, build_id_p);
 }
+
+void xen_print_version(void)
+{
+    printk("Xen version %d.%d%s (%s@%s) (%s) %s %s\n",
+           xen_major_version(), xen_minor_version(), xen_extra_version(),
+           xen_compile_by(), xen_compile_domain(), xen_compiler(),
+           xen_build_info(), xen_compile_date());
+
+    printk("Latest ChangeSet: %s\n", xen_changeset());
+}
+
+void xen_print_build_id(void)
+{
+    BUG_ON(!build_id_p);
+    BUG_ON(!build_id_len);
+    printk(XENLOG_INFO "build-id: %*phN\n", build_id_len, build_id_p);
+}
+
 #endif /* BUILD_ID */
 /*
  * Local variables:
diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index 73d24a7821..2c0b474d53 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -1024,14 +1024,12 @@  void __init console_init_preirq(void)
     nrspin_lock(&console_lock);
     __putstr(xen_banner());
     nrspin_unlock(&console_lock);
-    printk("Xen version %d.%d%s (%s@%s) (%s) %s %s\n",
-           xen_major_version(), xen_minor_version(), xen_extra_version(),
-           xen_compile_by(), xen_compile_domain(), xen_compiler(),
-           xen_build_info(), xen_compile_date());
-    printk("Latest ChangeSet: %s\n", xen_changeset());
+
+    xen_print_version();
 
     /* Locate and print the buildid, if applicable. */
     xen_build_init();
+    xen_print_build_id();
 
     if ( opt_sync_console )
     {
diff --git a/xen/include/xen/version.h b/xen/include/xen/version.h
index 4856ad1b44..4b96c6cc5c 100644
--- a/xen/include/xen/version.h
+++ b/xen/include/xen/version.h
@@ -29,4 +29,7 @@  int xen_build_id_check(const Elf_Note *n, unsigned int n_sz,
 static inline void xen_build_init(void) {};
 #endif
 
+void xen_print_version(void);
+void xen_print_build_id(void);
+
 #endif /* __XEN_VERSION_H__ */