Daniel De Graaf
2013-Jan-03 20:53 UTC
[PATCH v2 RFC] xen/console: Add domain ID to output if VERBOSE
This patch adds a domain ID prefix for the PV domain serial console
output (which includes mini-os console, dom0, and Linux domUs with
earlyprintk=xen). This is similar to the output of an HVM guest''s 0xE9
I/O port, but uses "(%d) " instead of "(XEN) HVM%d: " as the
prefix.
This brings up some cosmetic issues that may need discussion:
* Do we want to allow nonprintable characters from the PV guests?
They are currently allowed, and are used by dom0 if booting with
console=hvc0 on distros whose init scripts use color terminal
escape sequences. HVM output doesn''t allow them.
* HVM guests currently use a different prefix. Should this be changed?
* Should the console-to-ring output also contain a prefix?
* Should this prefixing only be enabled #ifdef VERBOSE?
* There is currently no indication that one domain''s output line is
incomplete when another domain interrupts it (although the
interrupting text is placed on a new line). Buffering the lines as
is done for HVM will break interactive use of the console in dom0.
---------------------------->8-----------------------------------------
When compiling with VERBOSE or when permitted using XSM, any domain can
output to the serial console; add a domain ID prefix similar to the
(XEN) prefix used by the hypervisor to make it possible to distinguish
the source of each message. This is especially useful for debugging stub
domains.
Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
---
xen/drivers/char/console.c | 52 +++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 51 insertions(+), 1 deletion(-)
diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index ff360fe..8396040 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -365,8 +365,13 @@ static
DECLARE_SOFTIRQ_TASKLET(notify_dom0_con_ring_tasklet,
static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer, int count)
{
- char kbuf[128], *kptr;
+ char kbuf[128], *kptr, *kout;
int kcount;
+#ifdef VERBOSE
+ static domid_t active = DOMID_IDLE;
+ domid_t self = current->domain->domain_id;
+ char pbuf[10];
+#endif
while ( count > 0 )
{
@@ -382,8 +387,53 @@ static long
guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer, int count)
spin_lock_irq(&console_lock);
+#ifdef VERBOSE
+ kout = kbuf;
+ if (active != self)
+ {
+ snprintf(pbuf, sizeof(pbuf), "%s(%d) ",
+ (active == DOMID_IDLE) ? "" : "\n",
self);
+ sercon_puts(pbuf);
+ vga_puts(pbuf);
+ }
+ for ( ; ; )
+ {
+ char save;
+ kptr = strchr(kout, ''\n'');
+ if ( kptr )
+ {
+ save = kptr[1];
+ kptr[1] = ''\0'';
+ }
+ sercon_puts(kout);
+ vga_puts(kout);
+
+ if ( !kptr )
+ {
+ /* buffer ends before newline */
+ active = self;
+ break;
+ }
+
+ kptr[1] = save;
+ kout = kptr + 1;
+ if ( save )
+ {
+ snprintf(pbuf, sizeof(pbuf), "(%d) ", self);
+ sercon_puts(pbuf);
+ vga_puts(pbuf);
+ }
+ else
+ {
+ /* buffer ends at end of line */
+ active = DOMID_IDLE;
+ break;
+ }
+ }
+#else
sercon_puts(kbuf);
vga_puts(kbuf);
+#endif
if ( opt_console_to_ring )
{
--
1.7.11.7
Ian Campbell
2013-Jan-04 14:40 UTC
Re: [PATCH v2 RFC] xen/console: Add domain ID to output if VERBOSE
On Thu, 2013-01-03 at 20:53 +0000, Daniel De Graaf wrote:> * There is currently no indication that one domain''s output line is > incomplete when another domain interrupts it (although the > interrupting text is placed on a new line). Buffering the lines as > is done for HVM will break interactive use of the console in dom0.Buffer only for domains != 0? Ian.