xen/console: updates to diagnostic messages prefixes
v3 cover xen/console: updates to diagnostic messages prefixes
Patch 1 is purely cosmetic change, adds a symbol for hypervisor's messages.
Patch 2 updates the logic how the domain prefix is formed for guest messages sent over emulated UART.
[1] Link to v2: https://lore.kernel.org/xen-devel/[email protected]/
[2] Link to CI: https://gitlab.com/xen-project/people/dmukhin/xen/-/pipelines/1857923457
Denis Mukhin (2):
xen/console: introduce CONSOLE_PREFIX xen/console: unify printout behavior for UART emulators
xen/arch/arm/vpl011.c | 6 +++--- xen/arch/arm/vuart.c | 2 +- xen/drivers/char/console.c | 30 ++++++++++++++++++++++++++---- 3 files changed, 30 insertions(+), 8 deletions(-)
Signature · 1 line
2.34.1
PATCH v3 1/2 xen/console: introduce CONSOLE_PREFIX
From: Denis Mukhin <[email protected]>
Add CONSOLE_PREFIX symbol to keep the prefix of the hypervisor's diagnostic messages.
No functional change.
---
Changes since v2:
- n/a
--- xen/drivers/char/console.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
xen/drivers/char/console.c +5 -2
@@ -61,6 +61,9 @@ enum { CONSOLE_ALL = CONSOLE_DEFAULT | CONSOLE_RING, }; +/* Prefix for hypervisor's diagnostic console messages. */ +#define CONSOLE_PREFIX "(XEN) " +static void console_send (const char *str,size_t len,unsigned int flags);/* console: comma-separated list of console outputs. */
@@ -1017,7 +1020,7 @@ static void vprintk_common(const char *fmt, va_list args, const char *prefix)void vprintk (const char *fmt,va_list args) { -vprintk_common (fmt, args,"(XEN) " ); +vprintk_common (fmt, args,CONSOLE_PREFIX ); }void printk (const char *fmt, ...)
@@ -1288,7 +1291,7 @@ int __printk_ratelimit(int ratelimit_ms, int ratelimit_burst)snprintf (lost_str,sizeof (lost_str),"%d" , lost);/* console_lock may already be acquired by printk(). */ rspin_lock (&console_lock); -printk_start_of_line ("(XEN) " ); +printk_start_of_line (CONSOLE_PREFIX );__putstr ("printk: " );__putstr (lost_str);__putstr (" messages suppressed.\n" );
Signature · 1 line
2.34.1
Re: [PATCH v3 1/2] xen/console: introduce CONSOLE_PREFIX
Quoted 8 lines · On Fri, 6 Jun 2025, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Add
CONSOLE_PREFIXsymbol to keep the prefix of the hypervisor's diagnostic messages.No functional change.
Signed-off-by Denis Mukhin <[email protected]>
Quoted 43 lines
---
Changes since v2:
- n/a--- xen/drivers/char/console.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)xen/drivers/char/console.c +5
-2@@ -61,6 +61,9 @@ enum { CONSOLE_ALL = CONSOLE_DEFAULT | CONSOLE_RING, }; +/* Prefix for hypervisor's diagnostic console messages. */ +#define CONSOLE_PREFIX "(XEN) " +static void console_send (const char *str,size_t len,unsigned int flags);/* console: comma-separated list of console outputs. */ @@ -1017,7 +1020,7 @@ static void vprintk_common(const char *fmt, va_list args, const char *prefix)void vprintk (const char *fmt,va_list args) { -vprintk_common (fmt, args,"(XEN) " ); +vprintk_common (fmt, args,CONSOLE_PREFIX ); }void printk (const char *fmt, ...)@@ -1288,7 +1291,7 @@ int __printk_ratelimit(int ratelimit_ms, int ratelimit_burst)snprintf (lost_str,sizeof (lost_str),"%d" , lost);/* console_lock may already be acquired by printk(). */ rspin_lock (&console_lock); -printk_start_of_line ("(XEN) " ); +printk_start_of_line (CONSOLE_PREFIX );__putstr ("printk: " );__putstr (lost_str);__putstr (" messages suppressed.\n" );Signature · 1 line
2.34.1
PATCH v3 2/2 xen/console: unify printout behavior for UART emulators
In reply to [email protected]From: Denis Mukhin <[email protected]>
If virtual UART from domain X prints on the physical console, the behavior is updated to (see [1]):
- console focus in domain X: do not prefix messages;
- no console focus in domain X: prefix all messages with "(dX)".
Use guest_printk() in all current in-hypervisor UART emulators. That aligns the behavior with debug I/O port 0xe9 handler on x86 and slightly improves the logging since guest_printk() already prints the domain ID. guest_printk() was modified to account for console focus ownership.
Modify guest_console_write() for hardware domain case by adding domain ID to the message when hwdom does not have console focus.
---
Changes since v2:
- dropped rate-limiting change for vuart
--- xen/arch/arm/vpl011.c | 6 +++--- xen/arch/arm/vuart.c | 2 +- xen/drivers/char/console.c | 23 +++++++++++++++++++++-- 3 files changed, 25 insertions(+), 6 deletions(-)
xen/arch/arm/vpl011.c +3 -3
@@ -87,7 +87,7 @@ static void vpl011_write_data_xen(struct domain *d, uint8_t data) {if ( intf->out_prod ==1 ) { -printk ("%c" , data); +guest_printk (d,"%c" , data); intf->out_prod =0 ; }else
@@ -95,7 +95,7 @@ static void vpl011_write_data_xen(struct domain *d, uint8_t data)if ( data !='\n' ) intf->out[intf->out_prod++] ='\n' ; intf->out[intf->out_prod++] ='\0' ; -printk ("%s" , intf->out); +guest_printk (d,"%s" , intf->out); intf->out_prod =0 ; } }
@@ -107,7 +107,7 @@ static void vpl011_write_data_xen(struct domain *d, uint8_t data)if ( data !='\n' ) intf->out[intf->out_prod++] ='\n' ; intf->out[intf->out_prod++] ='\0' ; -printk ("DOM%u: %s" , d->domain_id, intf->out); +guest_printk (d,"%s" , intf->out); intf->out_prod =0 ; } }
xen/arch/arm/vuart.c +1 -1
@@ -89,7 +89,7 @@ static void vuart_print_char(struct vcpu *v, char c)if ( c !='\n' ) uart->buf[uart->idx++] ='\n' ; uart->buf[uart->idx] ='\0' ; -printk (XENLOG_G_DEBUG "DOM%u: %s" , d->domain_id, uart->buf); +guest_printk (d,XENLOG_G_DEBUG "%s" , uart->buf); uart->idx =0 ; }spin_unlock (&uart->lock);
xen/drivers/char/console.c +21 -2
@@ -740,7 +740,17 @@ static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer,if (is_hardware_domain (cd) ) {/* Use direct console output as it could be interactive */ +char prefix[16 ] ="" ; +struct domain *consd; + + consd =console_get_domain (); +if ( consd != cd ) +snprintf (prefix,sizeof (prefix),"(d%d) " , cd->domain_id); +console_put_domain (consd); +nrspin_lock_irq (&console_lock); +if ( prefix[0 ] !='\0' ) +console_send (prefix,strlen (prefix), flags);console_send (kbuf, kcount, flags);nrspin_unlock_irq (&console_lock); }
@@ -1032,12 +1042,21 @@ void printk(const char *fmt, ...)va_end (args); } +/* +* Print message from the guest on the diagnostic console. +* Prefixes all messages w/ "(dX)" if domain X does not own physical console +* focus. +*/ void guest_printk (const struct domain *d,const char *fmt, ...) {va_list args; -char prefix[16 ]; +char prefix[16 ] ="" ; +struct domain *consd; -snprintf (prefix,sizeof (prefix),"(d%d) " , d->domain_id); + consd =console_get_domain (); +if ( consd != d ) +snprintf (prefix,sizeof (prefix),"(d%d) " , d->domain_id); +console_put_domain (consd);va_start (args, fmt);vprintk_common (fmt, args, prefix);
Signature · 1 line
2.34.1
Re: [PATCH v3 2/2] xen/console: unify printout behavior for UART emulators
Quoted 6 lines · On 06.06.2025 22:11, [email protected] wrote:
From: Denis Mukhin <[email protected]>
If virtual UART from domain X prints on the physical console, the behavior is updated to (see [1]):
- console focus in domain X: do not prefix messages;
- no console focus in domain X: prefix all messages with "(dX)".
While, as indicated (much) earlier, I can see why omitting the prefix may make sense for the domain having input focus, ...
Quoted 10 lines
xen/drivers/char/console.c +4
-0@@ -740,7 +740,17 @@ static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer,if (is_hardware_domain (cd) ) {/* Use direct console output as it could be interactive */ +char prefix[16 ] ="" ; +struct domain *consd; + + consd =console_get_domain ();
xen/drivers/char/console.c static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer, · line 756
Quoted 10 lines
xen/drivers/char/console.c +6
-0+if ( consd != cd ) +snprintf (prefix,sizeof (prefix),"(d%d) " , cd->domain_id); +console_put_domain (consd); +nrspin_lock_irq (&console_lock); +if ( prefix[0 ] !='\0' ) +console_send (prefix,strlen (prefix), flags);console_send (kbuf, kcount, flags);nrspin_unlock_irq (&console_lock); }
... this, aiui, is a behavioral change for the non-dom0less case, where Dom0 output will suddenly also gain the prefix. Which I don't think is
wanted: Switching focus between Xen and Dom0 should remain unaffected in this regard.
Jan
Re: [PATCH v3 2/2] xen/console: unify printout behavior for UART emulators
Quoted 28 lines · Jan Beulich
Quoted 6 lines · On 06.06.2025 22:11, [email protected] wrote:
From: Denis Mukhin <[email protected]>
If virtual UART from domain X prints on the physical console, the behavior is updated to (see [1]):
- console focus in domain X: do not prefix messages;
- no console focus in domain X: prefix all messages with "(dX)".While, as indicated (much) earlier, I can see why omitting the prefix may make sense for the domain having input focus, ...
Quoted 17 lines
xen/drivers/char/console.c +10
-0@@ -740,7 +740,17 @@ static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer,if (is_hardware_domain (cd) ) {/* Use direct console output as it could be interactive */ +char prefix[16 ] ="" ; +struct domain *consd; + + consd =console_get_domain (); +if ( consd != cd ) +snprintf (prefix,sizeof (prefix),"(d%d) " , cd->domain_id); +console_put_domain (consd); +nrspin_lock_irq (&console_lock); +if ( prefix[0 ] !='\0' ) +console_send (prefix,strlen (prefix), flags);
Quoted 8 lines
xen/drivers/char/console.c static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer, · line 756
Quoted 3 lines
xen/drivers/char/console.c +0
-0console_send (kbuf, kcount, flags);nrspin_unlock_irq (&console_lock); }... this, aiui, is a behavioral change for the non-dom0less case, where Dom0 output will suddenly also gain the prefix. Which I don't think is
wanted: Switching focus between Xen and Dom0 should remain unaffected in this regard.
This change ensures that dom0 traces aren't mixed with domU traces when domU has input focus, or with Xen traces when the administrator is in the diagnostic console.
Also, this can be used in the non-interactive tests (e.g. XTF).
Quoted 3 lines
Jan
Re: [PATCH v3 2/2] xen/console: unify printout behavior for UART emulators
Quoted 38 lines · On 11.06.2025 02:07, [email protected] wrote:
Quoted 28 lines · Jan Beulich
Quoted 6 lines · On 06.06.2025 22:11, [email protected] wrote:
From: Denis Mukhin <[email protected]>
If virtual UART from domain X prints on the physical console, the behavior is updated to (see [1]):
- console focus in domain X: do not prefix messages;
- no console focus in domain X: prefix all messages with "(dX)".While, as indicated (much) earlier, I can see why omitting the prefix may make sense for the domain having input focus, ...
Quoted 17 lines
xen/drivers/char/console.c +10
-0@@ -740,7 +740,17 @@ static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer,if (is_hardware_domain (cd) ) {/* Use direct console output as it could be interactive */ +char prefix[16 ] ="" ; +struct domain *consd; + + consd =console_get_domain (); +if ( consd != cd ) +snprintf (prefix,sizeof (prefix),"(d%d) " , cd->domain_id); +console_put_domain (consd); +nrspin_lock_irq (&console_lock); +if ( prefix[0 ] !='\0' ) +console_send (prefix,strlen (prefix), flags);Quoted 8 lines
xen/drivers/char/console.c static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer, · line 756
Quoted 3 lines
xen/drivers/char/console.c +0
-0console_send (kbuf, kcount, flags);nrspin_unlock_irq (&console_lock); }... this, aiui, is a behavioral change for the non-dom0less case, where Dom0 output will suddenly also gain the prefix. Which I don't think is
wanted: Switching focus between Xen and Dom0 should remain unaffected in this regard.
Quoted 3 lines
This change ensures that dom0 traces aren't mixed with domU traces when domU has input focus, or with Xen traces when the administrator is in the diagnostic console.
That's what the description also tries to describe, yet I still regard it as a behavioral regression in (at least) the described scenario. The hardware domain presently not having (d0) prefixed to its output is deliberate imo, not accidental.
Jan
Re: [PATCH v3 2/2] xen/console: unify printout behavior for UART emulators
Quoted 39 lines · Jan Beulich
Quoted 38 lines · On 11.06.2025 02:07, [email protected] wrote:
Quoted 36 lines · Jan Beulich
Quoted 6 lines · On 06.06.2025 22:11, [email protected] wrote:
From: Denis Mukhin <[email protected]>
If virtual UART from domain X prints on the physical console, the behavior is updated to (see [1]):
- console focus in domain X: do not prefix messages;
- no console focus in domain X: prefix all messages with "(dX)".While, as indicated (much) earlier, I can see why omitting the prefix may make sense for the domain having input focus, ...
Quoted 10 lines
xen/drivers/char/console.c +4
-0@@ -740,7 +740,17 @@ static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer,if (is_hardware_domain (cd) ) {/* Use direct console output as it could be interactive */ +char prefix[16 ] ="" ; +struct domain *consd; + + consd =console_get_domain ();xen/drivers/char/console.c static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer, · line 756
Quoted 10 lines
xen/drivers/char/console.c +6
-0+if ( consd != cd ) +snprintf (prefix,sizeof (prefix),"(d%d) " , cd->domain_id); +console_put_domain (consd); +nrspin_lock_irq (&console_lock); +if ( prefix[0 ] !='\0' ) +console_send (prefix,strlen (prefix), flags);console_send (kbuf, kcount, flags);nrspin_unlock_irq (&console_lock); }... this, aiui, is a behavioral change for the non-dom0less case, where Dom0 output will suddenly also gain the prefix. Which I don't think is
wanted: Switching focus between Xen and Dom0 should remain unaffected in this regard.
Quoted 8 lines
Quoted 3 lines
This change ensures that dom0 traces aren't mixed with domU traces when domU has input focus, or with Xen traces when the administrator is in the diagnostic console.
That's what the description also tries to describe, yet I still regard it as a behavioral regression in (at least) the described scenario. The hardware domain presently not having (d0) prefixed to its output is deliberate imo, not accidental.
If we only consider the classic dom0 and dom0less usage models, then what you wrote makes perfect sense. In the classic dom0 case, it is best for dom0 to have no prefix, which is the current behavior.
However, things become more complex with dom0less. As we have discussed previously, it has already become desirable on both ARM and x86 to align on the same behavior. During our last discussion, the preference was to add a '(d0)' prefix to clearly differentiate output from dom0 and other domains.
Up to now, we could easily detect the two different cases depending on the boot configuration. The problem arises with Denis' patches, which add the ability for dynamically created guests via xl to access an emulated NS16550 UART that prints to the console. Because these guests are created dynamically, it is not clear how we are going to handle this case.
If we follow the dom0less preference, then we would need a '(d0)' prefix for dom0. If we follow the classic dom0 model, then dom0 would remain without a prefix, and the new domUs would have a prefix. This would cause an inconsistency. However, this is what we have today on ARM with dom0less.
If Jan feels strongly that we should retain no prefix for the classic dom0 case, which is understandable, then I believe the best course of action would be to change our stance on dom0less on both ARM and x86 and also use no prefix for dom0 in the dom0less case (which is the current state on ARM).
Re: [PATCH v3 2/2] xen/console: unify printout behavior for UART emulators
Quoted 59 lines · Stefano Stabellini
Quoted 39 lines · Jan Beulich
Quoted 38 lines · On 11.06.2025 02:07, [email protected] wrote:
Quoted 36 lines · Jan Beulich
Quoted 6 lines · On 06.06.2025 22:11, [email protected] wrote:
From: Denis Mukhin <[email protected]>
If virtual UART from domain X prints on the physical console, the behavior is updated to (see [1]):
- console focus in domain X: do not prefix messages;
- no console focus in domain X: prefix all messages with "(dX)".While, as indicated (much) earlier, I can see why omitting the prefix may make sense for the domain having input focus, ...
Quoted 10 lines
xen/drivers/char/console.c +4
-0@@ -740,7 +740,17 @@ static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer,if (is_hardware_domain (cd) ) {/* Use direct console output as it could be interactive */ +char prefix[16 ] ="" ; +struct domain *consd; + + consd =console_get_domain ();xen/drivers/char/console.c static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer, · line 756
Quoted 10 lines
xen/drivers/char/console.c +6
-0+if ( consd != cd ) +snprintf (prefix,sizeof (prefix),"(d%d) " , cd->domain_id); +console_put_domain (consd); +nrspin_lock_irq (&console_lock); +if ( prefix[0 ] !='\0' ) +console_send (prefix,strlen (prefix), flags);console_send (kbuf, kcount, flags);nrspin_unlock_irq (&console_lock); }... this, aiui, is a behavioral change for the non-dom0less case, where Dom0 output will suddenly also gain the prefix. Which I don't think is
wanted: Switching focus between Xen and Dom0 should remain unaffected in this regard.Quoted 8 lines
Quoted 3 lines
This change ensures that dom0 traces aren't mixed with domU traces when domU has input focus, or with Xen traces when the administrator is in the diagnostic console.
That's what the description also tries to describe, yet I still regard it as a behavioral regression in (at least) the described scenario. The hardware domain presently not having (d0) prefixed to its output is deliberate imo, not accidental.
If we only consider the classic dom0 and dom0less usage models, then what you wrote makes perfect sense. In the classic dom0 case, it is best for dom0 to have no prefix, which is the current behavior.
However, things become more complex with dom0less. As we have discussed previously, it has already become desirable on both ARM and x86 to align on the same behavior. During our last discussion, the preference was to add a '(d0)' prefix to clearly differentiate output from dom0 and other domains.
Quoted 6 lines
Up to now, we could easily detect the two different cases depending on the boot configuration. The problem arises with Denis' patches, which add the ability for dynamically created guests via
xlto access an emulated NS16550 UART that prints to the console. Because these guests are created dynamically, it is not clear how we are going to handle this case.
Why would this be not clear? We already prefix their output with "(d<N>)" when going the traditional way. The same would then apply to output coming through the emulated UART.
Quoted 11 lines
If we follow the dom0less preference, then we would need a '(d0)' prefix for dom0. If we follow the classic dom0 model, then dom0 would remain without a prefix, and the new domUs would have a prefix. This would cause an inconsistency. However, this is what we have today on ARM with dom0less.
If Jan feels strongly that we should retain no prefix for the classic dom0 case, which is understandable, then I believe the best course of action would be to change our stance on dom0less on both ARM and x86 and also use no prefix for dom0 in the dom0less case (which is the current state on ARM).
Leaving aside that "dom0 in the dom0less" ought to really be not-a-thing, I disagree. Present behavior of not prefixing the domain's output which has input focus continues to make sense. That requires Dom0 to have a prefix whenever it doesn't have input focus.
Jan
Re: [PATCH v3 2/2] xen/console: unify printout behavior for UART emulators
Quoted 83 lines · Jan Beulich
Quoted 59 lines · Stefano Stabellini
Quoted 39 lines · Jan Beulich
Quoted 38 lines · On 11.06.2025 02:07, [email protected] wrote:
Quoted 36 lines · Jan Beulich
Quoted 6 lines · On 06.06.2025 22:11, [email protected] wrote:
From: Denis Mukhin <[email protected]>
If virtual UART from domain X prints on the physical console, the behavior is updated to (see [1]):
- console focus in domain X: do not prefix messages;
- no console focus in domain X: prefix all messages with "(dX)".While, as indicated (much) earlier, I can see why omitting the prefix may make sense for the domain having input focus, ...
Quoted 10 lines
xen/drivers/char/console.c +4
-0@@ -740,7 +740,17 @@ static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer,if (is_hardware_domain (cd) ) {/* Use direct console output as it could be interactive */ +char prefix[16 ] ="" ; +struct domain *consd; + + consd =console_get_domain ();xen/drivers/char/console.c static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer, · line 756
Quoted 10 lines
xen/drivers/char/console.c +6
-0+if ( consd != cd ) +snprintf (prefix,sizeof (prefix),"(d%d) " , cd->domain_id); +console_put_domain (consd); +nrspin_lock_irq (&console_lock); +if ( prefix[0 ] !='\0' ) +console_send (prefix,strlen (prefix), flags);console_send (kbuf, kcount, flags);nrspin_unlock_irq (&console_lock); }... this, aiui, is a behavioral change for the non-dom0less case, where Dom0 output will suddenly also gain the prefix. Which I don't think is
wanted: Switching focus between Xen and Dom0 should remain unaffected in this regard.Quoted 8 lines
Quoted 3 lines
This change ensures that dom0 traces aren't mixed with domU traces when domU has input focus, or with Xen traces when the administrator is in the diagnostic console.
That's what the description also tries to describe, yet I still regard it as a behavioral regression in (at least) the described scenario. The hardware domain presently not having (d0) prefixed to its output is deliberate imo, not accidental.
If we only consider the classic dom0 and dom0less usage models, then what you wrote makes perfect sense. In the classic dom0 case, it is best for dom0 to have no prefix, which is the current behavior.
However, things become more complex with dom0less. As we have discussed previously, it has already become desirable on both ARM and x86 to align on the same behavior. During our last discussion, the preference was to add a '(d0)' prefix to clearly differentiate output from dom0 and other domains.
Quoted 6 lines
Up to now, we could easily detect the two different cases depending on the boot configuration. The problem arises with Denis' patches, which add the ability for dynamically created guests via
xlto access an emulated NS16550 UART that prints to the console. Because these guests are created dynamically, it is not clear how we are going to handle this case.Why would this be not clear? We already prefix their output with "(d<N>)" when going the traditional way. The same would then apply to output coming through the emulated UART.
Quoted 11 lines
If we follow the dom0less preference, then we would need a '(d0)' prefix for dom0. If we follow the classic dom0 model, then dom0 would remain without a prefix, and the new domUs would have a prefix. This would cause an inconsistency. However, this is what we have today on ARM with dom0less.
If Jan feels strongly that we should retain no prefix for the classic dom0 case, which is understandable, then I believe the best course of action would be to change our stance on dom0less on both ARM and x86 and also use no prefix for dom0 in the dom0less case (which is the current state on ARM).
Quoted 4 lines
Leaving aside that "dom0 in the dom0less" ought to really be not-a-thing, I disagree. Present behavior of not prefixing the domain's output which has input focus continues to make sense. That requires Dom0 to have a prefix whenever it doesn't have input focus.
If I understood correctly I like your proposal. Let me rephrase it to make sure we are aligned. You are suggesting that:
- domains without input focus will print with a (d<N>) prefix
- the domain with input focus will print without a (d<N>) prefix
- this applies to both DomUs and Dom0
- this applies to both predefined domains and also dynamic domains
I am OK with that. I believe this is not the current behavior on ARM but I can appreciate the simple consistency of it.
Re: [PATCH v3 2/2] xen/console: unify printout behavior for UART emulators
Quoted 89 lines · Stefano Stabellini
Quoted 83 lines · Jan Beulich
Quoted 59 lines · Stefano Stabellini
Quoted 39 lines · Jan Beulich
Quoted 38 lines · On 11.06.2025 02:07, [email protected] wrote:
Quoted 36 lines · Jan Beulich
Quoted 6 lines · On 06.06.2025 22:11, [email protected] wrote:
From: Denis Mukhin <[email protected]>
If virtual UART from domain X prints on the physical console, the behavior is updated to (see [1]):
- console focus in domain X: do not prefix messages;
- no console focus in domain X: prefix all messages with "(dX)".While, as indicated (much) earlier, I can see why omitting the prefix may make sense for the domain having input focus, ...
Quoted 10 lines
xen/drivers/char/console.c +4
-0@@ -740,7 +740,17 @@ static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer,if (is_hardware_domain (cd) ) {/* Use direct console output as it could be interactive */ +char prefix[16 ] ="" ; +struct domain *consd; + + consd =console_get_domain ();xen/drivers/char/console.c static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer, · line 756
Quoted 10 lines
xen/drivers/char/console.c +6
-0+if ( consd != cd ) +snprintf (prefix,sizeof (prefix),"(d%d) " , cd->domain_id); +console_put_domain (consd); +nrspin_lock_irq (&console_lock); +if ( prefix[0 ] !='\0' ) +console_send (prefix,strlen (prefix), flags);console_send (kbuf, kcount, flags);nrspin_unlock_irq (&console_lock); }... this, aiui, is a behavioral change for the non-dom0less case, where Dom0 output will suddenly also gain the prefix. Which I don't think is
wanted: Switching focus between Xen and Dom0 should remain unaffected in this regard.Quoted 8 lines
Quoted 3 lines
This change ensures that dom0 traces aren't mixed with domU traces when domU has input focus, or with Xen traces when the administrator is in the diagnostic console.
That's what the description also tries to describe, yet I still regard it as a behavioral regression in (at least) the described scenario. The hardware domain presently not having (d0) prefixed to its output is deliberate imo, not accidental.
If we only consider the classic dom0 and dom0less usage models, then what you wrote makes perfect sense. In the classic dom0 case, it is best for dom0 to have no prefix, which is the current behavior.
However, things become more complex with dom0less. As we have discussed previously, it has already become desirable on both ARM and x86 to align on the same behavior. During our last discussion, the preference was to add a '(d0)' prefix to clearly differentiate output from dom0 and other domains.
Quoted 6 lines
Up to now, we could easily detect the two different cases depending on the boot configuration. The problem arises with Denis' patches, which add the ability for dynamically created guests via
xlto access an emulated NS16550 UART that prints to the console. Because these guests are created dynamically, it is not clear how we are going to handle this case.Why would this be not clear? We already prefix their output with "(d<N>)" when going the traditional way. The same would then apply to output coming through the emulated UART.
Quoted 11 lines
If we follow the dom0less preference, then we would need a '(d0)' prefix for dom0. If we follow the classic dom0 model, then dom0 would remain without a prefix, and the new domUs would have a prefix. This would cause an inconsistency. However, this is what we have today on ARM with dom0less.
If Jan feels strongly that we should retain no prefix for the classic dom0 case, which is understandable, then I believe the best course of action would be to change our stance on dom0less on both ARM and x86 and also use no prefix for dom0 in the dom0less case (which is the current state on ARM).
Quoted 4 lines
Leaving aside that "dom0 in the dom0less" ought to really be not-a-thing, I disagree. Present behavior of not prefixing the domain's output which has input focus continues to make sense. That requires Dom0 to have a prefix whenever it doesn't have input focus.
Quoted 6 lines
If I understood correctly I like your proposal. Let me rephrase it to make sure we are aligned. You are suggesting that:
- domains without input focus will print with a (d<N>) prefix
- the domain with input focus will print without a (d<N>) prefix
- this applies to both DomUs and Dom0
Except in the non-dom0less case, at least up and until there's at least one other domain. I.e. I'd like to keep Dom0 boot output as it is today, regardless of the presence of e.g. "conswitch=".
Jan
Quoted 4 lines
- this applies to both predefined domains and also dynamic domains
I am OK with that. I believe this is not the current behavior on ARM but I can appreciate the simple consistency of it.
Re: [PATCH v3 2/2] xen/console: unify printout behavior for UART emulators
Quoted 93 lines · Jan Beulich
Quoted 92 lines · Stefano Stabellini
Quoted 83 lines · Jan Beulich
Quoted 59 lines · Stefano Stabellini
Quoted 39 lines · Jan Beulich
Quoted 38 lines · On 11.06.2025 02:07, [email protected] wrote:
Quoted 36 lines · Jan Beulich
Quoted 6 lines · On 06.06.2025 22:11, [email protected] wrote:
From: Denis Mukhin <[email protected]>
If virtual UART from domain X prints on the physical console, the behavior is updated to (see [1]):
- console focus in domain X: do not prefix messages;
- no console focus in domain X: prefix all messages with "(dX)".While, as indicated (much) earlier, I can see why omitting the prefix may make sense for the domain having input focus, ...
Quoted 10 lines
xen/drivers/char/console.c +4
-0@@ -740,7 +740,17 @@ static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer,if (is_hardware_domain (cd) ) {/* Use direct console output as it could be interactive */ +char prefix[16 ] ="" ; +struct domain *consd; + + consd =console_get_domain ();xen/drivers/char/console.c static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer, · line 756
Quoted 10 lines
xen/drivers/char/console.c +6
-0+if ( consd != cd ) +snprintf (prefix,sizeof (prefix),"(d%d) " , cd->domain_id); +console_put_domain (consd); +nrspin_lock_irq (&console_lock); +if ( prefix[0 ] !='\0' ) +console_send (prefix,strlen (prefix), flags);console_send (kbuf, kcount, flags);nrspin_unlock_irq (&console_lock); }... this, aiui, is a behavioral change for the non-dom0less case, where Dom0 output will suddenly also gain the prefix. Which I don't think is
wanted: Switching focus between Xen and Dom0 should remain unaffected in this regard.Quoted 8 lines
Quoted 3 lines
This change ensures that dom0 traces aren't mixed with domU traces when domU has input focus, or with Xen traces when the administrator is in the diagnostic console.
That's what the description also tries to describe, yet I still regard it as a behavioral regression in (at least) the described scenario. The hardware domain presently not having (d0) prefixed to its output is deliberate imo, not accidental.
If we only consider the classic dom0 and dom0less usage models, then what you wrote makes perfect sense. In the classic dom0 case, it is best for dom0 to have no prefix, which is the current behavior.
However, things become more complex with dom0less. As we have discussed previously, it has already become desirable on both ARM and x86 to align on the same behavior. During our last discussion, the preference was to add a '(d0)' prefix to clearly differentiate output from dom0 and other domains.
Quoted 6 lines
Up to now, we could easily detect the two different cases depending on the boot configuration. The problem arises with Denis' patches, which add the ability for dynamically created guests via
xlto access an emulated NS16550 UART that prints to the console. Because these guests are created dynamically, it is not clear how we are going to handle this case.Why would this be not clear? We already prefix their output with "(d<N>)" when going the traditional way. The same would then apply to output coming through the emulated UART.
Quoted 11 lines
If we follow the dom0less preference, then we would need a '(d0)' prefix for dom0. If we follow the classic dom0 model, then dom0 would remain without a prefix, and the new domUs would have a prefix. This would cause an inconsistency. However, this is what we have today on ARM with dom0less.
If Jan feels strongly that we should retain no prefix for the classic dom0 case, which is understandable, then I believe the best course of action would be to change our stance on dom0less on both ARM and x86 and also use no prefix for dom0 in the dom0less case (which is the current state on ARM).
Quoted 4 lines
Leaving aside that "dom0 in the dom0less" ought to really be not-a-thing, I disagree. Present behavior of not prefixing the domain's output which has input focus continues to make sense. That requires Dom0 to have a prefix whenever it doesn't have input focus.
If I understood correctly I like your proposal. Let me rephrase it to make sure we are aligned. You are suggesting that:
Quoted 7 lines
Quoted 3 lines
- domains without input focus will print with a (d<N>) prefix
- the domain with input focus will print without a (d<N>) prefix
- this applies to both DomUs and Dom0Except in the non-dom0less case, at least up and until there's at least one other domain. I.e. I'd like to keep Dom0 boot output as it is today, regardless of the presence of e.g. "conswitch=".
In the non-dom0less case, since dom0 has focus, it would naturally be without (d<N>) prefix. Unless the user passes "conswitch=". Honestly, I wouldn't special-case conswitch= that way and would prefer keep things simple and consistent without corner cases. I don't think conswitch= is so widely used that it is worth the complexity to special-case it.
I am not going to insist though.
Quoted 5 lines
Quoted 4 lines
- this applies to both predefined domains and also dynamic domains
I am OK with that. I believe this is not the current behavior on ARM but I can appreciate the simple consistency of it.
Re: [PATCH v3 2/2] xen/console: unify printout behavior for UART emulators
Quoted 102 lines · Stefano Stabellini
Quoted 93 lines · Jan Beulich
Quoted 92 lines · Stefano Stabellini
Quoted 83 lines · Jan Beulich
Quoted 59 lines · Stefano Stabellini
Quoted 39 lines · Jan Beulich
Quoted 38 lines · On 11.06.2025 02:07, [email protected] wrote:
Quoted 36 lines · Jan Beulich
Quoted 6 lines · On 06.06.2025 22:11, [email protected] wrote:
From: Denis Mukhin <[email protected]>
If virtual UART from domain X prints on the physical console, the behavior is updated to (see [1]):
- console focus in domain X: do not prefix messages;
- no console focus in domain X: prefix all messages with "(dX)".While, as indicated (much) earlier, I can see why omitting the prefix may make sense for the domain having input focus, ...
Quoted 10 lines
xen/drivers/char/console.c +4
-0@@ -740,7 +740,17 @@ static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer,if (is_hardware_domain (cd) ) {/* Use direct console output as it could be interactive */ +char prefix[16 ] ="" ; +struct domain *consd; + + consd =console_get_domain ();xen/drivers/char/console.c static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer, · line 756
Quoted 10 lines
xen/drivers/char/console.c +6
-0+if ( consd != cd ) +snprintf (prefix,sizeof (prefix),"(d%d) " , cd->domain_id); +console_put_domain (consd); +nrspin_lock_irq (&console_lock); +if ( prefix[0 ] !='\0' ) +console_send (prefix,strlen (prefix), flags);console_send (kbuf, kcount, flags);nrspin_unlock_irq (&console_lock); }... this, aiui, is a behavioral change for the non-dom0less case, where Dom0 output will suddenly also gain the prefix. Which I don't think is
wanted: Switching focus between Xen and Dom0 should remain unaffected in this regard.Quoted 8 lines
Quoted 3 lines
This change ensures that dom0 traces aren't mixed with domU traces when domU has input focus, or with Xen traces when the administrator is in the diagnostic console.
That's what the description also tries to describe, yet I still regard it as a behavioral regression in (at least) the described scenario. The hardware domain presently not having (d0) prefixed to its output is deliberate imo, not accidental.
If we only consider the classic dom0 and dom0less usage models, then what you wrote makes perfect sense. In the classic dom0 case, it is best for dom0 to have no prefix, which is the current behavior.
However, things become more complex with dom0less. As we have discussed previously, it has already become desirable on both ARM and x86 to align on the same behavior. During our last discussion, the preference was to add a '(d0)' prefix to clearly differentiate output from dom0 and other domains.
Quoted 6 lines
Up to now, we could easily detect the two different cases depending on the boot configuration. The problem arises with Denis' patches, which add the ability for dynamically created guests via
xlto access an emulated NS16550 UART that prints to the console. Because these guests are created dynamically, it is not clear how we are going to handle this case.Why would this be not clear? We already prefix their output with "(d<N>)" when going the traditional way. The same would then apply to output coming through the emulated UART.
Quoted 11 lines
If we follow the dom0less preference, then we would need a '(d0)' prefix for dom0. If we follow the classic dom0 model, then dom0 would remain without a prefix, and the new domUs would have a prefix. This would cause an inconsistency. However, this is what we have today on ARM with dom0less.
If Jan feels strongly that we should retain no prefix for the classic dom0 case, which is understandable, then I believe the best course of action would be to change our stance on dom0less on both ARM and x86 and also use no prefix for dom0 in the dom0less case (which is the current state on ARM).
Quoted 4 lines
Leaving aside that "dom0 in the dom0less" ought to really be not-a-thing, I disagree. Present behavior of not prefixing the domain's output which has input focus continues to make sense. That requires Dom0 to have a prefix whenever it doesn't have input focus.
If I understood correctly I like your proposal. Let me rephrase it to make sure we are aligned. You are suggesting that:
Quoted 7 lines
Quoted 3 lines
- domains without input focus will print with a (d<N>) prefix
- the domain with input focus will print without a (d<N>) prefix
- this applies to both DomUs and Dom0Except in the non-dom0less case, at least up and until there's at least one other domain. I.e. I'd like to keep Dom0 boot output as it is today, regardless of the presence of e.g. "conswitch=".
Quoted 5 lines
In the non-dom0less case, since dom0 has focus, it would naturally be without (d<N>) prefix. Unless the user passes "conswitch=". Honestly, I wouldn't special-case conswitch= that way and would prefer keep things simple and consistent without corner cases. I don't think conswitch= is so widely used that it is worth the complexity to special-case it.
Widely used or not - _I_ use it all the time in debug configs where serial is available.
Jan
Re: [PATCH v3 2/2] xen/console: unify printout behavior for UART emulators
Quoted 103 lines · Jan Beulich
Quoted 102 lines · Stefano Stabellini
Quoted 100 lines · Jan Beulich
Quoted 89 lines · Stefano Stabellini
Quoted 83 lines · Jan Beulich
Quoted 59 lines · Stefano Stabellini
Quoted 39 lines · Jan Beulich
Quoted 38 lines · On 11.06.2025 02:07, [email protected] wrote:
Quoted 36 lines · Jan Beulich
Quoted 6 lines · On 06.06.2025 22:11, [email protected] wrote:
From: Denis Mukhin <[email protected]>
If virtual UART from domain X prints on the physical console, the behavior is updated to (see [1]):
- console focus in domain X: do not prefix messages;
- no console focus in domain X: prefix all messages with "(dX)".While, as indicated (much) earlier, I can see why omitting the prefix may make sense for the domain having input focus, ...
Quoted 10 lines
xen/drivers/char/console.c +4
-0@@ -740,7 +740,17 @@ static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer,if (is_hardware_domain (cd) ) {/* Use direct console output as it could be interactive */ +char prefix[16 ] ="" ; +struct domain *consd; + + consd =console_get_domain ();xen/drivers/char/console.c static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer, · line 756
Quoted 10 lines
xen/drivers/char/console.c +6
-0+if ( consd != cd ) +snprintf (prefix,sizeof (prefix),"(d%d) " , cd->domain_id); +console_put_domain (consd); +nrspin_lock_irq (&console_lock); +if ( prefix[0 ] !='\0' ) +console_send (prefix,strlen (prefix), flags);console_send (kbuf, kcount, flags);nrspin_unlock_irq (&console_lock); }... this, aiui, is a behavioral change for the non-dom0less case, where Dom0 output will suddenly also gain the prefix. Which I don't think is
wanted: Switching focus between Xen and Dom0 should remain unaffected in this regard.Quoted 8 lines
Quoted 3 lines
This change ensures that dom0 traces aren't mixed with domU traces when domU has input focus, or with Xen traces when the administrator is in the diagnostic console.
That's what the description also tries to describe, yet I still regard it as a behavioral regression in (at least) the described scenario. The hardware domain presently not having (d0) prefixed to its output is deliberate imo, not accidental.
If we only consider the classic dom0 and dom0less usage models, then what you wrote makes perfect sense. In the classic dom0 case, it is best for dom0 to have no prefix, which is the current behavior.
However, things become more complex with dom0less. As we have discussed previously, it has already become desirable on both ARM and x86 to align on the same behavior. During our last discussion, the preference was to add a '(d0)' prefix to clearly differentiate output from dom0 and other domains.
Quoted 6 lines
Up to now, we could easily detect the two different cases depending on the boot configuration. The problem arises with Denis' patches, which add the ability for dynamically created guests via
xlto access an emulated NS16550 UART that prints to the console. Because these guests are created dynamically, it is not clear how we are going to handle this case.Why would this be not clear? We already prefix their output with "(d<N>)" when going the traditional way. The same would then apply to output coming through the emulated UART.
Quoted 11 lines
If we follow the dom0less preference, then we would need a '(d0)' prefix for dom0. If we follow the classic dom0 model, then dom0 would remain without a prefix, and the new domUs would have a prefix. This would cause an inconsistency. However, this is what we have today on ARM with dom0less.
If Jan feels strongly that we should retain no prefix for the classic dom0 case, which is understandable, then I believe the best course of action would be to change our stance on dom0less on both ARM and x86 and also use no prefix for dom0 in the dom0less case (which is the current state on ARM).
Quoted 4 lines
Leaving aside that "dom0 in the dom0less" ought to really be not-a-thing, I disagree. Present behavior of not prefixing the domain's output which has input focus continues to make sense. That requires Dom0 to have a prefix whenever it doesn't have input focus.
Quoted 6 lines
If I understood correctly I like your proposal. Let me rephrase it to make sure we are aligned. You are suggesting that:
- domains without input focus will print with a (d<N>) prefix
- the domain with input focus will print without a (d<N>) prefix
- this applies to both DomUs and Dom0Except in the non-dom0less case, at least up and until there's at least one other domain. I.e. I'd like to keep Dom0 boot output as it is today, regardless of the presence of e.g. "conswitch=".
Quoted 8 lines
Quoted 5 lines
In the non-dom0less case, since dom0 has focus, it would naturally be without (d<N>) prefix. Unless the user passes "conswitch=". Honestly, I wouldn't special-case conswitch= that way and would prefer keep things simple and consistent without corner cases. I don't think conswitch= is so widely used that it is worth the complexity to special-case it.
Widely used or not - _I_ use it all the time in debug configs where serial is available.
Fair enough and your usage is really important for the project. At the same time you know exactly what's going on so you wouldn't be confused by the presence or absence of a (d0) prefix.
The main issue is when less familiar users try Xen, or less familiar developers go through the Xen source code to learn from it.
I would optimize this choice to make it simpler for users and to make the code simpler. Your use-case is really important as well, but I would trust you to understand what's going on either way, with or without the (d0) prefix.
I won't insist though.
Cheers,
Stefano
Re: [PATCH v3 2/2] xen/console: unify printout behavior for UART emulators
Hi Stefano,
Quoted 7 lines · Stefano Stabellini
Quoted 2 lines
Widely used or not - _I_ use it all the time in debug configs where serial is available.
Fair enough and your usage is really important for the project. At the same time you know exactly what's going on so you wouldn't be confused by the presence or absence of a (d0) prefix.
Quoted 7 lines
The main issue is when less familiar users try Xen, or less familiar developers go through the Xen source code to learn from it.
I would optimize this choice to make it simpler for users and to make the code simpler. Your use-case is really important as well, but I would trust you to understand what's going on either way, with or without the (d0) prefix.
Thanks for the clarification. I gave a try with and without the series to understand a bit more the difference. I think there are some imbalance in that setup because when the focus is on Xen, the logs are still prefixed with "(XEN)". So naturally the log with no prefix are the one for Dom0. So I have to agree with Jan here.
I haven't tried the behavior with dom0less. So I am not sure what would happen if the focus switch to Xen.
Also, when switching focus, I have noticed a very odd behavior with this patch. "(d0)" is printed multiple time per line:
"
(d0) [ 1.344020] v(d0) gaarb: loaded (d0) [ 1.352808] c(d0) locksource: Swit(d0) ched to clocksou(d0) rce arch_sys_cou(d0) nter (d0) [ 1.367604] V(d0) FS: Disk quotas (d0) dquot_6.6.0 (d0) [ 1.369369] V(d0) FS: Dquot-cache (d0) hash table entri(d0) es: 512 (order 0(d0) , 4096 bytes) (d0) [ 1.376766] p(d0) np: PnP ACPI: di(d0) sabled (d0) [ 1.619730] N(d0) ET: Registered P(d0) F_INET protocol (d0) family (d0) [ 1.623635] I(d0) P idents hash ta(d0) ble entries: 163(d0) 84 (order: 5, 13(d0) 1072 bytes, line(d0) ar) (d0) [ 1.636915] t(d0) cp_listen_portad(d0) dr_hash hash tab(d0) le entries: 512 (d0) (order: 3, 36864(d0) bytes, linear) (d0) [ 1.638331] T(d0) able-perturb has(d0) h table entries:(d0) 65536 (order: 6(d0) , 262144 bytes, (d0) linear) (d0) [ 1.639267] T(d0) CP established h(d0) ash table entrie(d0) s: 8192 (order: (d0) 4, 65536 bytes, (d0) linear) (d0) [ 1.643457] T(d0) CP bind hash tab(d0) le entries: 8192(d0) (order: 8, 1179(d0) 648 bytes, linea(d0) r) (d0) [ 1.652078] T(d0) CP: Hash tables (d0) configured (esta(d0) blished 8192 bin(d0) d 8192) (d0) [ 1.655824] U(d0) DP hash table en(d0) tries: 512 (orde(d0) r: 4, 81920 byte(d0) s, linear) (d0) [ 1.657807] U(d0) DP-Lite hash tab(d0) le entries: 512 (d0) (order: 4, 81920(d0) bytes, linear) (d0) [ 1.661993] N(d0) ET: Registered P(d0) F_UNIX/PF_LOCAL (d0) protocol family (d0) [ 1.674980] R(d0) PC: Registered n(d0) amed UNIX socket(d0) transport modul(d0) e. (d0) [ 1.676034] R(d0) PC: Registered u(d0) dp transport mod(d0) ule. (d0) [ 1.677241] R(d0) PC: Registered t(d0) cp transport mod(d0) ule. (d0) [ 1.677964] R(d0) PC: Registered t(d0) cp-with-tls tran(d0) sport module. (d0) [ 1.678615] R(d0) PC: Registered t(d0) cp NFSv4.1 backc(d0) hannel transport(d0) module.
"
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v3 2/2] xen/console: unify printout behavior for UART emulators
Quoted 13 lines · Julien Grall
Hi Stefano,
Quoted 10 lines · Stefano Stabellini
Quoted 2 lines
Widely used or not - _I_ use it all the time in debug configs where serial is available.
Fair enough and your usage is really important for the project. At the same time you know exactly what's going on so you wouldn't be confused by the presence or absence of a (d0) prefix.
The main issue is when less familiar users try Xen, or less familiar developers go through the Xen source code to learn from it.
Quoted 6 lines
Quoted 4 lines
I would optimize this choice to make it simpler for users and to make the code simpler. Your use-case is really important as well, but I would trust you to understand what's going on either way, with or without the (d0) prefix.
Thanks for the clarification. I gave a try with and without the series to understand a bit more the difference. I think there are some imbalance in that setup because when the focus is on Xen, the logs are still prefixed with "(XEN)". So naturally the log with no prefix are the one for Dom0. So I have to agree with Jan here.
I forgot to clarify, this is not an ask to remove (XEN) when the focus is on Xen. This is more we should keep the existing behavior.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v3 2/2] xen/console: unify printout behavior for UART emulators
In reply to Julien GrallQuoted 24 lines · Julien Grall
Hi Stefano,
Quoted 7 lines · Stefano Stabellini
Quoted 2 lines
Widely used or not - _I_ use it all the time in debug configs where serial is available.
Fair enough and your usage is really important for the project. At the same time you know exactly what's going on so you wouldn't be confused by the presence or absence of a (d0) prefix.
Quoted 7 lines
The main issue is when less familiar users try Xen, or less familiar developers go through the Xen source code to learn from it.
I would optimize this choice to make it simpler for users and to make the code simpler. Your use-case is really important as well, but I would trust you to understand what's going on either way, with or without the (d0) prefix.
Thanks for the clarification. I gave a try with and without the series to understand a bit more the difference. I think there are some imbalance in that setup because when the focus is on Xen, the logs are still prefixed with "(XEN)". So naturally the log with no prefix are the one for Dom0. So I have to agree with Jan here.
Quoted 5 lines
I haven't tried the behavior with dom0less. So I am not sure what would happen if the focus switch to Xen.
Also, when switching focus, I have noticed a very odd behavior with this patch. "(d0)" is printed multiple time per line:
Thanks for catching this, will fix.
Quoted 44 lines
"
(d0) [ 1.344020] v(d0) gaarb: loaded
(d0) [ 1.352808] c(d0) locksource: Swit(d0) ched to clocksou(d0) rcearch_sys_cou(d0)nter
(d0) [ 1.367604] V(d0) FS: Disk quotas (d0) dquot_6.6.0
(d0) [ 1.369369] V(d0) FS: Dquot-cache (d0) hash table entri(d0) es:
512 (order 0(d0) , 4096 bytes)(d0) [ 1.376766] p(d0) np: PnP ACPI: di(d0) sabled (d0) [ 1.619730] N(d0) ET: Registered P(d0) F_INET protocol (d0) family (d0) [ 1.623635] I(d0) P idents hash ta(d0) ble entries: 163(d0) 84(order: 5, 13(d0) 1072 bytes, line(d0) ar)
(d0) [ 1.636915] t(d0)cp_listen_portad(d0)dr_hashhash tab(d0) le
entries: 512 (d0) (order: 3, 36864(d0) bytes, linear)
(d0) [ 1.638331] T(d0) able-perturb has(d0) h table entries:(d0)
65536 (order: 6(d0) , 262144 bytes, (d0) linear)
(d0) [ 1.639267] T(d0) CP established h(d0) ash table entrie(d0) s:
8192 (order: (d0) 4, 65536 bytes, (d0) linear)
(d0) [ 1.643457] T(d0) CP bind hash tab(d0) le entries: 8192(d0)
(order: 8, 1179(d0) 648 bytes, linea(d0) r)
(d0) [ 1.652078] T(d0) CP: Hash tables (d0) configured (esta(d0)
blished 8192 bin(d0) d 8192)
(d0) [ 1.655824] U(d0) DP hash table en(d0) tries: 512 (orde(d0) r:
4, 81920 byte(d0) s, linear)
(d0) [ 1.657807] U(d0) DP-Lite hash tab(d0) le entries: 512 (d0)
(order: 4, 81920(d0) bytes, linear)
(d0) [ 1.661993] N(d0) ET: Registered P(d0) F_UNIX/PF_LOCAL (d0)
protocol family
(d0) [ 1.674980] R(d0) PC: Registered n(d0) amed UNIX socket(d0)
transport modul(d0) e.(d0) [ 1.676034] R(d0) PC: Registered u(d0) dp transport mod(d0) ule. (d0) [ 1.677241] R(d0) PC: Registered t(d0) cp transport mod(d0) ule. (d0) [ 1.677964] R(d0) PC: Registered t(d0) cp-with-tls tran(d0)sport module.
(d0) [ 1.678615] R(d0) PC: Registered t(d0) cp NFSv4.1 backc(d0)
hannel transport(d0) module.
"Cheers,
--
Julien Grall
Re: [PATCH v3 2/2] xen/console: unify printout behavior for UART emulators
In reply to Stefano StabelliniHi Stefano,
Quoted 20 lines · Stefano Stabellini
Quoted 11 lines · Jan Beulich
Quoted 10 lines · Stefano Stabellini
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Stefano Stabellini
Quoted 4 lines · Jan Beulich
Quoted 3 lines · On 11.06.2025 02:07, [email protected] wrote:
Quoted 2 lines · Jan Beulich
Quoted 1 line · On 06.06.2025 22:11, [email protected] wrote:
From: Denis Mukhin <[email protected]>
If I understood correctly I like your proposal. Let me rephrase it to make sure we are aligned. You are suggesting that:
Quoted 7 lines
Quoted 3 lines
- domains without input focus will print with a (d<N>) prefix
- the domain with input focus will print without a (d<N>) prefix
- this applies to both DomUs and Dom0Except in the non-dom0less case, at least up and until there's at least one other domain. I.e. I'd like to keep Dom0 boot output as it is today, regardless of the presence of e.g. "conswitch=".
Quoted 5 lines
In the non-dom0less case, since dom0 has focus, it would naturally be without (d<N>) prefix. Unless the user passes "conswitch=". Honestly, I wouldn't special-case conswitch= that way and would prefer keep things simple and consistent without corner cases. I don't think conswitch= is so widely used that it is worth the complexity to special-case it.
I am a bit confused with the wording. Before I can provide another opinion, I want to understand a bit more the concern.
From my understanding the command line option "conswitch" is to allow the admin to change with key is used to switch between Dom0 and Xen. By default this is 'a'. So are you referring to the fact a trailing "x" (to not switch to dom0 console) can be added?
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v3 2/2] xen/console: unify printout behavior for UART emulators
Quoted 29 lines · Julien Grall
Hi Stefano,
Quoted 20 lines · Stefano Stabellini
Quoted 11 lines · Jan Beulich
Quoted 10 lines · Stefano Stabellini
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Stefano Stabellini
Quoted 4 lines · Jan Beulich
Quoted 3 lines · On 11.06.2025 02:07, [email protected] wrote:
Quoted 2 lines · Jan Beulich
Quoted 1 line · On 06.06.2025 22:11, [email protected] wrote:
From: Denis Mukhin <[email protected]>
If I understood correctly I like your proposal. Let me rephrase it to make sure we are aligned. You are suggesting that:
Quoted 7 lines
Quoted 3 lines
- domains without input focus will print with a (d<N>) prefix
- the domain with input focus will print without a (d<N>) prefix
- this applies to both DomUs and Dom0Except in the non-dom0less case, at least up and until there's at least one other domain. I.e. I'd like to keep Dom0 boot output as it is today, regardless of the presence of e.g. "conswitch=".
Quoted 5 lines
In the non-dom0less case, since dom0 has focus, it would naturally be without (d<N>) prefix. Unless the user passes "conswitch=". Honestly, I wouldn't special-case conswitch= that way and would prefer keep things simple and consistent without corner cases. I don't think conswitch= is so widely used that it is worth the complexity to special-case it.
Quoted 7 lines
I am a bit confused with the wording. Before I can provide another opinion, I want to understand a bit more the concern.
From my understanding the command line option "conswitch" is to allow the admin to change with key is used to switch between Dom0 and Xen. By default this is 'a'. So are you referring to the fact a trailing "x" (to not switch to dom0 console) can be added?
Yes, conswitch can also be used to ask Xen to keep the input focus to itself, instead of giving it away to Dom0. I think this is the specific feature Jan was referring to when he said he is using conswitch and the proposal would change the way the output looks like for him, which is true.
Today, dom0 would still print without any prefix.
Tomorrow with this proposal, dom0 would print with a "(d0)" prefix because it doesn't have input focus.
The question is, with the new policy in place, whether this is worth the trouble of having a special case to remove the "(d0)" prefix in the conswitch=x case. I think it is not worth it, Jan thinks it is.
Re: [PATCH v3 2/2] xen/console: unify printout behavior for UART emulators
Quoted 44 lines · Stefano Stabellini
Quoted 29 lines · Julien Grall
Hi Stefano,
Quoted 20 lines · Stefano Stabellini
Quoted 11 lines · Jan Beulich
Quoted 10 lines · Stefano Stabellini
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Stefano Stabellini
Quoted 4 lines · Jan Beulich
Quoted 3 lines · On 11.06.2025 02:07, [email protected] wrote:
Quoted 2 lines · Jan Beulich
Quoted 1 line · On 06.06.2025 22:11, [email protected] wrote:
From: Denis Mukhin <[email protected]>
If I understood correctly I like your proposal. Let me rephrase it to make sure we are aligned. You are suggesting that:
Quoted 7 lines
Quoted 3 lines
- domains without input focus will print with a (d<N>) prefix
- the domain with input focus will print without a (d<N>) prefix
- this applies to both DomUs and Dom0Except in the non-dom0less case, at least up and until there's at least one other domain. I.e. I'd like to keep Dom0 boot output as it is today, regardless of the presence of e.g. "conswitch=".
Quoted 5 lines
In the non-dom0less case, since dom0 has focus, it would naturally be without (d<N>) prefix. Unless the user passes "conswitch=". Honestly, I wouldn't special-case conswitch= that way and would prefer keep things simple and consistent without corner cases. I don't think conswitch= is so widely used that it is worth the complexity to special-case it.
Quoted 7 lines
I am a bit confused with the wording. Before I can provide another opinion, I want to understand a bit more the concern.
From my understanding the command line option "conswitch" is to allow the admin to change with key is used to switch between Dom0 and Xen. By default this is 'a'. So are you referring to the fact a trailing "x" (to not switch to dom0 console) can be added?
Yes, conswitch can also be used to ask Xen to keep the input focus to itself, instead of giving it away to Dom0. I think this is the specific feature Jan was referring to when he said he is using conswitch and the proposal would change the way the output looks like for him, which is true.
Quoted 8 lines
Today, dom0 would still print without any prefix.
Tomorrow with this proposal, dom0 would print with a "(d0)" prefix because it doesn't have input focus.
The question is, with the new policy in place, whether this is worth the trouble of having a special case to remove the "(d0)" prefix in the conswitch=x case. I think it is not worth it, Jan thinks it is.
Just to clarify: Along with this mode being entered by conswitch=, I also expect the behavior to remain unaltered when booting (non-dom0less) without that option, and later flipping focus between Xen and Dom0 by using triple Ctrl-a. I'm saying this just to make sure that an eventual change to the patch wouldn't be keyed to the use of the command line option.
Jan
Re: [PATCH v3 2/2] xen/console: unify printout behavior for UART emulators
Quoted 54 lines · Jan Beulich
Quoted 44 lines · Stefano Stabellini
Quoted 29 lines · Julien Grall
Hi Stefano,
Quoted 20 lines · Stefano Stabellini
Quoted 11 lines · Jan Beulich
Quoted 10 lines · Stefano Stabellini
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Stefano Stabellini
Quoted 4 lines · Jan Beulich
Quoted 3 lines · On 11.06.2025 02:07, [email protected] wrote:
Quoted 2 lines · Jan Beulich
Quoted 1 line · On 06.06.2025 22:11, [email protected] wrote:
From: Denis Mukhin <[email protected]>
If I understood correctly I like your proposal. Let me rephrase it to make sure we are aligned. You are suggesting that:
Quoted 7 lines
Quoted 3 lines
- domains without input focus will print with a (d<N>) prefix
- the domain with input focus will print without a (d<N>) prefix
- this applies to both DomUs and Dom0Except in the non-dom0less case, at least up and until there's at least one other domain. I.e. I'd like to keep Dom0 boot output as it is today, regardless of the presence of e.g. "conswitch=".
Quoted 5 lines
In the non-dom0less case, since dom0 has focus, it would naturally be without (d<N>) prefix. Unless the user passes "conswitch=". Honestly, I wouldn't special-case conswitch= that way and would prefer keep things simple and consistent without corner cases. I don't think conswitch= is so widely used that it is worth the complexity to special-case it.
Quoted 7 lines
I am a bit confused with the wording. Before I can provide another opinion, I want to understand a bit more the concern.
From my understanding the command line option "conswitch" is to allow the admin to change with key is used to switch between Dom0 and Xen. By default this is 'a'. So are you referring to the fact a trailing "x" (to not switch to dom0 console) can be added?
Yes, conswitch can also be used to ask Xen to keep the input focus to itself, instead of giving it away to Dom0. I think this is the specific feature Jan was referring to when he said he is using conswitch and the proposal would change the way the output looks like for him, which is true.
Quoted 8 lines
Today, dom0 would still print without any prefix.
Tomorrow with this proposal, dom0 would print with a "(d0)" prefix because it doesn't have input focus.
The question is, with the new policy in place, whether this is worth the trouble of having a special case to remove the "(d0)" prefix in the conswitch=x case. I think it is not worth it, Jan thinks it is.
Quoted 6 lines
Just to clarify: Along with this mode being entered by conswitch=, I also expect the behavior to remain unaltered when booting (non-dom0less) without that option, and later flipping focus between Xen and Dom0 by using triple Ctrl-a. I'm saying this just to make sure that an eventual change to the patch wouldn't be keyed to the use of the command line option.
Oh, I see now where the difference of opinion lies. This is the policy as written above:
- domains without input focus will print with a (d<N>) prefix
- the domain with input focus will print without a (d<N>) prefix
- this applies to both DomUs and Dom0
Which means that when you move around with Ctrl-AAA or conswitch, no matter if it is dom0less or not, Dom0 would end up printing the prefix (d0).
Jan, and now also Julien are saying that prefer to retain the old behavior. I defer to the will of the majority. So then the policy would be:
Dom0less:
- domains without input focus will print with a (d<N>) prefix
- the domain with input focus will print without a (d<N>) prefix
- this applies to both DomUs and Dom0
Dom0:
- same as today
- the domain with input focus will print without a (d<N>) prefix
Re: [PATCH v3 2/2] xen/console: unify printout behavior for UART emulators
Quoted 77 lines · Stefano Stabellini
Quoted 54 lines · Jan Beulich
Quoted 44 lines · Stefano Stabellini
Quoted 29 lines · Julien Grall
Hi Stefano,
Quoted 20 lines · Stefano Stabellini
Quoted 11 lines · Jan Beulich
Quoted 10 lines · Stefano Stabellini
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Stefano Stabellini
Quoted 4 lines · Jan Beulich
Quoted 3 lines · On 11.06.2025 02:07, [email protected] wrote:
Quoted 2 lines · Jan Beulich
Quoted 1 line · On 06.06.2025 22:11, [email protected] wrote:
From: Denis Mukhin <[email protected]>
If I understood correctly I like your proposal. Let me rephrase it to make sure we are aligned. You are suggesting that:
Quoted 7 lines
Quoted 3 lines
- domains without input focus will print with a (d<N>) prefix
- the domain with input focus will print without a (d<N>) prefix
- this applies to both DomUs and Dom0Except in the non-dom0less case, at least up and until there's at least one other domain. I.e. I'd like to keep Dom0 boot output as it is today, regardless of the presence of e.g. "conswitch=".
Quoted 5 lines
In the non-dom0less case, since dom0 has focus, it would naturally be without (d<N>) prefix. Unless the user passes "conswitch=". Honestly, I wouldn't special-case conswitch= that way and would prefer keep things simple and consistent without corner cases. I don't think conswitch= is so widely used that it is worth the complexity to special-case it.
Quoted 7 lines
I am a bit confused with the wording. Before I can provide another opinion, I want to understand a bit more the concern.
From my understanding the command line option "conswitch" is to allow the admin to change with key is used to switch between Dom0 and Xen. By default this is 'a'. So are you referring to the fact a trailing "x" (to not switch to dom0 console) can be added?
Yes, conswitch can also be used to ask Xen to keep the input focus to itself, instead of giving it away to Dom0. I think this is the specific feature Jan was referring to when he said he is using conswitch and the proposal would change the way the output looks like for him, which is true.
Quoted 8 lines
Today, dom0 would still print without any prefix.
Tomorrow with this proposal, dom0 would print with a "(d0)" prefix because it doesn't have input focus.
The question is, with the new policy in place, whether this is worth the trouble of having a special case to remove the "(d0)" prefix in the conswitch=x case. I think it is not worth it, Jan thinks it is.
Quoted 6 lines
Just to clarify: Along with this mode being entered by conswitch=, I also expect the behavior to remain unaltered when booting (non-dom0less) without that option, and later flipping focus between Xen and Dom0 by using triple Ctrl-a. I'm saying this just to make sure that an eventual change to the patch wouldn't be keyed to the use of the command line option.
Oh, I see now where the difference of opinion lies. This is the policy as written above:
- domains without input focus will print with a (d<N>) prefix
- the domain with input focus will print without a (d<N>) prefix
- this applies to both DomUs and Dom0Which means that when you move around with Ctrl-AAA or conswitch, no matter if it is dom0less or not, Dom0 would end up printing the prefix (d0).
Jan, and now also Julien are saying that prefer to retain the old behavior. I defer to the will of the majority. So then the policy would be:
Quoted 8 lines
Dom0less:
- domains without input focus will print with a (d<N>) prefix
- the domain with input focus will print without a (d<N>) prefix
- this applies to both DomUs and Dom0Dom0:
- same as today
- the domain with input focus will print without a (d<N>) prefix
Sorry this last line was an editing error. I'll write it again for clarity.
Dom0less:
- domains without input focus will print with a (d<N>) prefix
- the domain with input focus will print without a (d<N>) prefix
- this applies to both DomUs and Dom0
Dom0:
- same as today (with or without conswitch)
Re: [PATCH v3 2/2] xen/console: unify printout behavior for UART emulators
Quoted 90 lines · Stefano Stabellini
Quoted 77 lines · Stefano Stabellini
Quoted 54 lines · Jan Beulich
Quoted 44 lines · Stefano Stabellini
Quoted 29 lines · Julien Grall
Hi Stefano,
Quoted 20 lines · Stefano Stabellini
Quoted 11 lines · Jan Beulich
Quoted 10 lines · Stefano Stabellini
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Stefano Stabellini
Quoted 4 lines · Jan Beulich
Quoted 3 lines · On 11.06.2025 02:07, [email protected] wrote:
Quoted 2 lines · Jan Beulich
On 06.06.2025 22:11, [email protected] wrote:
From: Denis Mukhin <[email protected]>If I understood correctly I like your proposal. Let me rephrase it to make sure we are aligned. You are suggesting that:
Quoted 7 lines
Quoted 3 lines
- domains without input focus will print with a (d<N>) prefix
- the domain with input focus will print without a (d<N>) prefix
- this applies to both DomUs and Dom0Except in the non-dom0less case, at least up and until there's at least one other domain. I.e. I'd like to keep Dom0 boot output as it is today, regardless of the presence of e.g. "conswitch=".
Quoted 5 lines
In the non-dom0less case, since dom0 has focus, it would naturally be without (d<N>) prefix. Unless the user passes "conswitch=". Honestly, I wouldn't special-case conswitch= that way and would prefer keep things simple and consistent without corner cases. I don't think conswitch= is so widely used that it is worth the complexity to special-case it.
Quoted 7 lines
I am a bit confused with the wording. Before I can provide another opinion, I want to understand a bit more the concern.
From my understanding the command line option "conswitch" is to allow the admin to change with key is used to switch between Dom0 and Xen. By default this is 'a'. So are you referring to the fact a trailing "x" (to not switch to dom0 console) can be added?
Yes, conswitch can also be used to ask Xen to keep the input focus to itself, instead of giving it away to Dom0. I think this is the specific feature Jan was referring to when he said he is using conswitch and the proposal would change the way the output looks like for him, which is true.
Quoted 8 lines
Today, dom0 would still print without any prefix.
Tomorrow with this proposal, dom0 would print with a "(d0)" prefix because it doesn't have input focus.
The question is, with the new policy in place, whether this is worth the trouble of having a special case to remove the "(d0)" prefix in the conswitch=x case. I think it is not worth it, Jan thinks it is.
Quoted 6 lines
Just to clarify: Along with this mode being entered by conswitch=, I also expect the behavior to remain unaltered when booting (non-dom0less) without that option, and later flipping focus between Xen and Dom0 by using triple Ctrl-a. I'm saying this just to make sure that an eventual change to the patch wouldn't be keyed to the use of the command line option.
Oh, I see now where the difference of opinion lies. This is the policy as written above:
- domains without input focus will print with a (d<N>) prefix
- the domain with input focus will print without a (d<N>) prefix
- this applies to both DomUs and Dom0Which means that when you move around with Ctrl-AAA or conswitch, no matter if it is dom0less or not, Dom0 would end up printing the prefix (d0).
Jan, and now also Julien are saying that prefer to retain the old behavior. I defer to the will of the majority. So then the policy would be:
Quoted 8 lines
Dom0less:
- domains without input focus will print with a (d<N>) prefix
- the domain with input focus will print without a (d<N>) prefix
- this applies to both DomUs and Dom0Dom0:
- same as today
- the domain with input focus will print without a (d<N>) prefixSorry this last line was an editing error. I'll write it again for clarity.
Quoted 7 lines
Dom0less:
- domains without input focus will print with a (d<N>) prefix
- the domain with input focus will print without a (d<N>) prefix
- this applies to both DomUs and Dom0Dom0:
- same as today (with or without conswitch)
Thanks!
Quoted 1 line
Re: [PATCH v3 2/2] xen/console: unify printout behavior for UART emulators
In reply to Jan BeulichQuoted 54 lines · Jan Beulich
Quoted 44 lines · Stefano Stabellini
Quoted 29 lines · Julien Grall
Hi Stefano,
Quoted 20 lines · Stefano Stabellini
Quoted 11 lines · Jan Beulich
Quoted 10 lines · Stefano Stabellini
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Stefano Stabellini
Quoted 4 lines · Jan Beulich
Quoted 3 lines · On 11.06.2025 02:07, [email protected] wrote:
Quoted 2 lines · Jan Beulich
Quoted 1 line · On 06.06.2025 22:11, [email protected] wrote:
From: Denis Mukhin <[email protected]>
If I understood correctly I like your proposal. Let me rephrase it to make sure we are aligned. You are suggesting that:
Quoted 7 lines
Quoted 3 lines
- domains without input focus will print with a (d<N>) prefix
- the domain with input focus will print without a (d<N>) prefix
- this applies to both DomUs and Dom0Except in the non-dom0less case, at least up and until there's at least one other domain. I.e. I'd like to keep Dom0 boot output as it is today, regardless of the presence of e.g. "conswitch=".
Quoted 5 lines
In the non-dom0less case, since dom0 has focus, it would naturally be without (d<N>) prefix. Unless the user passes "conswitch=". Honestly, I wouldn't special-case conswitch= that way and would prefer keep things simple and consistent without corner cases. I don't think conswitch= is so widely used that it is worth the complexity to special-case it.
Quoted 7 lines
I am a bit confused with the wording. Before I can provide another opinion, I want to understand a bit more the concern.
From my understanding the command line option "conswitch" is to allow the admin to change with key is used to switch between Dom0 and Xen. By default this is 'a'. So are you referring to the fact a trailing "x" (to not switch to dom0 console) can be added?
Yes, conswitch can also be used to ask Xen to keep the input focus to itself, instead of giving it away to Dom0. I think this is the specific feature Jan was referring to when he said he is using conswitch and the proposal would change the way the output looks like for him, which is true.
Quoted 8 lines
Today, dom0 would still print without any prefix.
Tomorrow with this proposal, dom0 would print with a "(d0)" prefix because it doesn't have input focus.
The question is, with the new policy in place, whether this is worth the trouble of having a special case to remove the "(d0)" prefix in the conswitch=x case. I think it is not worth it, Jan thinks it is.
Quoted 6 lines
Just to clarify: Along with this mode being entered by conswitch=, I also expect the behavior to remain unaltered when booting (non-dom0less) without that option, and later flipping focus between Xen and Dom0 by using triple Ctrl-a. I'm saying this just to make sure that an eventual change to the patch wouldn't be keyed to the use of the command line option.
I will preserve the existing non-dom0less dom0 behavior for printouts. Thanks for the patience and the feedback!
Quoted 2 lines
Jan
Re: [PATCH v3 2/2] xen/console: unify printout behavior for UART emulators
In reply to [email protected]Quoted 103 lines · On Fri, Jun 06, 2025 at 08:11:26PM +0000, [email protected] wrote:
From: Denis Mukhin <[email protected]>
If virtual UART from domain X prints on the physical console, the behavior is updated to (see [1]):
- console focus in domain X: do not prefix messages;
- no console focus in domain X: prefix all messages with "(dX)".Use
guest_printk()in all current in-hypervisor UART emulators. That aligns the behavior with debug I/O port0xe9handler on x86 and slightly improves the logging sinceguest_printk()already prints the domain ID.guest_printk()was modified to account for console focus ownership.Modify
guest_console_write()for hardware domain case by adding domain ID to the message when hwdom does not have console focus.Signed-off-by Denis Mukhin <[email protected]>---
Changes since v2:
- dropped rate-limiting change for vuart--- xen/arch/arm/vpl011.c | 6 +++--- xen/arch/arm/vuart.c | 2 +- xen/drivers/char/console.c | 23 +++++++++++++++++++++-- 3 files changed, 25 insertions(+), 6 deletions(-)xen/arch/arm/vpl011.c +3
-3@@ -87,7 +87,7 @@ static void vpl011_write_data_xen(struct domain *d, uint8_t data) {if ( intf->out_prod ==1 ) { -printk ("%c" , data); +guest_printk (d,"%c" , data); intf->out_prod =0 ; }else @@ -95,7 +95,7 @@ static void vpl011_write_data_xen(struct domain *d, uint8_t data)if ( data !='\n' ) intf->out[intf->out_prod++] ='\n' ; intf->out[intf->out_prod++] ='\0' ; -printk ("%s" , intf->out); +guest_printk (d,"%s" , intf->out); intf->out_prod =0 ; } }@@ -107,7 +107,7 @@ static void vpl011_write_data_xen(struct domain *d, uint8_t data)if ( data !='\n' ) intf->out[intf->out_prod++] ='\n' ; intf->out[intf->out_prod++] ='\0' ; -printk ("DOM%u: %s" , d->domain_id, intf->out); +guest_printk (d,"%s" , intf->out); intf->out_prod =0 ; } }xen/arch/arm/vuart.c +1
-1@@ -89,7 +89,7 @@ static void vuart_print_char(struct vcpu *v, char c)if ( c !='\n' ) uart->buf[uart->idx++] ='\n' ; uart->buf[uart->idx] ='\0' ; -printk (XENLOG_G_DEBUG "DOM%u: %s" , d->domain_id, uart->buf); +guest_printk (d,XENLOG_G_DEBUG "%s" , uart->buf); uart->idx =0 ; }spin_unlock (&uart->lock);xen/drivers/char/console.c +15
-0@@ -740,7 +740,17 @@ static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer,if (is_hardware_domain (cd) ) {/* Use direct console output as it could be interactive */ +char prefix[16 ] ="" ; +struct domain *consd; + + consd =console_get_domain (); +if ( consd != cd ) +snprintf (prefix,sizeof (prefix),"(d%d) " , cd->domain_id); +console_put_domain (consd); +nrspin_lock_irq (&console_lock); +if ( prefix[0 ] !='\0' ) +console_send (prefix,strlen (prefix), flags);console_send (kbuf, kcount, flags);nrspin_unlock_irq (&console_lock); }@@ -1032,12 +1042,21 @@ void printk(const char *fmt, ...)va_end (args); } +/* +* Print message from the guest on the diagnostic console. +* Prefixes all messages w/ "(dX)" if domain X does not own physical console +* focus. +*/ void guest_printk (const struct domain *d,const char *fmt, ...) {
xen/drivers/char/console.c void printk(const char *fmt, ...) · line 1059
Quoted 10 lines
xen/drivers/char/console.c +6
-2va_list args; -char prefix[16 ]; +char prefix[16 ] ="" ; +struct domain *consd; -snprintf (prefix,sizeof (prefix),"(d%d) " , d->domain_id); + consd =console_get_domain (); +if ( consd != d ) +snprintf (prefix,sizeof (prefix),"(d%d) " , d->domain_id); +console_put_domain (consd);
It might be helpful to abstract this into a separate helper, as it's used by both functions:
static void fill_console_prefix(char *prefix, unsigned int len,
const struct domain *d)
{
struct domain *consd = console_get_domain();
if ( consd ? consd != d : !is_hardware_domain(d)) )
snprintf(prefix, len, "(d%d) ", d->domain_id);
console_put_domain(consd);
}Note the above code should also handle the current discussion of not printing the (d0) prefix for the hardware domain when the console target is Xen. I think this keeps the previous behavior when console input is switched to Xen, while still providing unified (dX) prefixes otherwise.
Thanks, Roger.
Re: [PATCH v3 2/2] xen/console: unify printout behavior for UART emulators
Quoted 128 lines · Roger Pau Monné
Quoted 103 lines · On Fri, Jun 06, 2025 at 08:11:26PM +0000, [email protected] wrote:
From: Denis Mukhin <[email protected]>
If virtual UART from domain X prints on the physical console, the behavior is updated to (see [1]):
- console focus in domain X: do not prefix messages;
- no console focus in domain X: prefix all messages with "(dX)".Use
guest_printk()in all current in-hypervisor UART emulators. That aligns the behavior with debug I/O port0xe9handler on x86 and slightly improves the logging sinceguest_printk()already prints the domain ID.guest_printk()was modified to account for console focus ownership.Modify
guest_console_write()for hardware domain case by adding domain ID to the message when hwdom does not have console focus.Signed-off-by Denis Mukhin <[email protected]>---
Changes since v2:
- dropped rate-limiting change for vuart--- xen/arch/arm/vpl011.c | 6 +++--- xen/arch/arm/vuart.c | 2 +- xen/drivers/char/console.c | 23 +++++++++++++++++++++-- 3 files changed, 25 insertions(+), 6 deletions(-)xen/arch/arm/vpl011.c +3
-3@@ -87,7 +87,7 @@ static void vpl011_write_data_xen(struct domain *d, uint8_t data) {if ( intf->out_prod ==1 ) { -printk ("%c" , data); +guest_printk (d,"%c" , data); intf->out_prod =0 ; }else @@ -95,7 +95,7 @@ static void vpl011_write_data_xen(struct domain *d, uint8_t data)if ( data !='\n' ) intf->out[intf->out_prod++] ='\n' ; intf->out[intf->out_prod++] ='\0' ; -printk ("%s" , intf->out); +guest_printk (d,"%s" , intf->out); intf->out_prod =0 ; } }@@ -107,7 +107,7 @@ static void vpl011_write_data_xen(struct domain *d, uint8_t data)if ( data !='\n' ) intf->out[intf->out_prod++] ='\n' ; intf->out[intf->out_prod++] ='\0' ; -printk ("DOM%u: %s" , d->domain_id, intf->out); +guest_printk (d,"%s" , intf->out); intf->out_prod =0 ; } }xen/arch/arm/vuart.c +1
-1@@ -89,7 +89,7 @@ static void vuart_print_char(struct vcpu *v, char c)if ( c !='\n' ) uart->buf[uart->idx++] ='\n' ; uart->buf[uart->idx] ='\0' ; -printk (XENLOG_G_DEBUG "DOM%u: %s" , d->domain_id, uart->buf); +guest_printk (d,XENLOG_G_DEBUG "%s" , uart->buf); uart->idx =0 ; }spin_unlock (&uart->lock);xen/drivers/char/console.c +15
-0@@ -740,7 +740,17 @@ static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer,if (is_hardware_domain (cd) ) {/* Use direct console output as it could be interactive */ +char prefix[16 ] ="" ; +struct domain *consd; + + consd =console_get_domain (); +if ( consd != cd ) +snprintf (prefix,sizeof (prefix),"(d%d) " , cd->domain_id); +console_put_domain (consd); +nrspin_lock_irq (&console_lock); +if ( prefix[0 ] !='\0' ) +console_send (prefix,strlen (prefix), flags);console_send (kbuf, kcount, flags);nrspin_unlock_irq (&console_lock); }@@ -1032,12 +1042,21 @@ void printk(const char *fmt, ...)va_end (args); } +/* +* Print message from the guest on the diagnostic console. +* Prefixes all messages w/ "(dX)" if domain X does not own physical console +* focus. +*/ void guest_printk (const struct domain *d,const char *fmt, ...) {xen/drivers/char/console.c void printk(const char *fmt, ...) · line 1059
Quoted 10 lines
xen/drivers/char/console.c +6
-2va_list args; -char prefix[16 ]; +char prefix[16 ] ="" ; +struct domain *consd; -snprintf (prefix,sizeof (prefix),"(d%d) " , d->domain_id); + consd =console_get_domain (); +if ( consd != d ) +snprintf (prefix,sizeof (prefix),"(d%d) " , d->domain_id); +console_put_domain (consd);It might be helpful to abstract this into a separate helper, as it's used by both functions:
static void fill_console_prefix(char *prefix, unsigned int len,
const struct domain *d){ struct domain *consd = console_get_domain(); if ( consd ? consd != d : !is_hardware_domain(d)) ) snprintf(prefix, len, "(d%d) ", d->domain_id); console_put_domain(consd); }
Quoted 5 lines
Note the above code should also handle the current discussion of not printing the (d0) prefix for the hardware domain when the console target is Xen. I think this keeps the previous behavior when console input is switched to Xen, while still providing unified (dX) prefixes otherwise.
Thanks, will do.
Quoted 3 lines
Thanks, Roger.