[PATCH v6] xen/console: print Xen version via keyhandler

dmkhn@proton.me posted 1 patch 8 months, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20250221220925.1391144-1-dmukhin@ford.com
xen/common/keyhandler.c    |  4 ++++
xen/common/version.c       | 23 +++++++++++++++++++++--
xen/drivers/char/console.c |  8 +++-----
xen/include/xen/lib.h      |  3 +++
4 files changed, 31 insertions(+), 7 deletions(-)
[PATCH v6] xen/console: print Xen version via keyhandler
Posted by dmkhn@proton.me 8 months, 1 week ago
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>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
Changes since v5:
- moved new code outside of #ifdef BUILD_ID
---
 xen/common/keyhandler.c    |  4 ++++
 xen/common/version.c       | 23 +++++++++++++++++++++--
 xen/drivers/char/console.c |  8 +++-----
 xen/include/xen/lib.h      |  3 +++
 4 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c
index 6ea54838d4..0bb842ec00 100644
--- a/xen/common/keyhandler.c
+++ b/xen/common/keyhandler.c
@@ -129,6 +129,10 @@ static void cf_check show_handlers(unsigned char key)
     unsigned int i;
 
     printk("'%c' pressed -> showing installed handlers\n", key);
+
+    print_version();
+    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..be3906de79 100644
--- a/xen/common/version.c
+++ b/xen/common/version.c
@@ -210,10 +210,29 @@ void __init xen_build_init(void)
         }
     }
 #endif /* CONFIG_X86 */
-    if ( !rc )
-        printk(XENLOG_INFO "build-id: %*phN\n", build_id_len, build_id_p);
 }
 #endif /* BUILD_ID */
+
+void 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 print_build_id(void)
+{
+    /*
+     * NB: build_id_len may be 0 if XEN_HAS_BUILD_ID=n.
+     * Do not print empty build-id.
+     */
+    if ( build_id_len )
+        printk("build-id: %*phN\n", build_id_len, build_id_p);
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index 07b14b7b3f..2e23910dfa 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -1020,14 +1020,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());
+
+    print_version();
 
     /* Locate and print the buildid, if applicable. */
     xen_build_init();
+    print_build_id();
 
     if ( opt_sync_console )
     {
diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h
index 81b722ea3e..686899a63e 100644
--- a/xen/include/xen/lib.h
+++ b/xen/include/xen/lib.h
@@ -47,6 +47,9 @@ 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_build_id(void);
+
 #ifdef CONFIG_DEBUG_TRACE
 extern void debugtrace_dump(void);
 extern void debugtrace_printk(const char *fmt, ...)
-- 
2.34.1
Re: [PATCH v6] xen/console: print Xen version via keyhandler
Posted by Jan Beulich 8 months, 1 week ago
On 21.02.2025 23:10, dmkhn@proton.me wrote:
> --- a/xen/common/version.c
> +++ b/xen/common/version.c
> @@ -210,10 +210,29 @@ void __init xen_build_init(void)
>          }
>      }
>  #endif /* CONFIG_X86 */
> -    if ( !rc )
> -        printk(XENLOG_INFO "build-id: %*phN\n", build_id_len, build_id_p);
>  }
>  #endif /* BUILD_ID */
> +
> +void 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 print_build_id(void)
> +{
> +    /*
> +     * NB: build_id_len may be 0 if XEN_HAS_BUILD_ID=n.
> +     * Do not print empty build-id.
> +     */
> +    if ( build_id_len )
> +        printk("build-id: %*phN\n", build_id_len, build_id_p);
> +}
> +
>  /*
>   * Local variables:
>   * mode: C

I'm sorry to be picky, but why do you think I said in the v5 reply where
I think the code additions want to go? As it stands, you could as well
have left the editing to me, while committing, as now I will still need
to edit things.

Jan
Re: [PATCH v6] xen/console: print Xen version via keyhandler
Posted by Denis Mukhin 8 months, 1 week ago
On Monday, February 24th, 2025 at 3:03 AM, Jan Beulich <jbeulich@suse.com> wrote:

> 
> 
> On 21.02.2025 23:10, dmkhn@proton.me wrote:
> 
> > --- a/xen/common/version.c
> > +++ b/xen/common/version.c
> > @@ -210,10 +210,29 @@ void __init xen_build_init(void)
> > }
> > }
> > #endif /* CONFIG_X86 */
> > - if ( !rc )
> > - printk(XENLOG_INFO "build-id: %phN\n", build_id_len, build_id_p);
> > }
> > #endif / BUILD_ID /
> > +
> > +void 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 print_build_id(void)
> > +{
> > + /
> > + * NB: build_id_len may be 0 if XEN_HAS_BUILD_ID=n.
> > + * Do not print empty build-id.
> > + */
> > + if ( build_id_len )
> > + printk("build-id: %phN\n", build_id_len, build_id_p);
> > +}
> > +
> > /
> > * Local variables:
> > * mode: C
> 
> 
> I'm sorry to be picky, but why do you think I said in the v5 reply where
> I think the code additions want to go? As it stands, you could as well
> have left the editing to me, while committing, as now I will still need
> to edit things.


Sorry for confusion!


> 
> Jan