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

[Xen-changelog] [xen-unstable] xen/console: introduce a 'w' debug-key that dumps the console ring


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-unstable <patchbot@xxxxxxx>
  • Date: Tue, 02 Oct 2012 01:44:11 +0000
  • Delivery-date: Tue, 02 Oct 2012 01:44:21 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# HG changeset patch
# User Matt Wilson <msw@xxxxxxxxxx>
# Date 1349118165 -3600
# Node ID ffac3db27e2ea6b8f393bcca3d6eb40d5d05b9d1
# Parent  ef898f37a560d56e1559e2acb12b49baeb3f25b8
xen/console: introduce a 'w' debug-key that dumps the console ring

This patch adds a new 'w' debug-key, chosen from the limited remaining
keys only due to its proximity to 'q', that dumps the console ring to
configured console devices. It's useful to for tracking down how an
unresponsive system got into a broken state via serial console.

Signed-off-by: Matt Wilson <msw@xxxxxxxxxx>
Committed-by: Keir Fraser <keir@xxxxxxx>
---


diff -r ef898f37a560 -r ffac3db27e2e xen/drivers/char/console.c
--- a/xen/drivers/char/console.c        Mon Oct 01 20:01:55 2012 +0100
+++ b/xen/drivers/char/console.c        Mon Oct 01 20:02:45 2012 +0100
@@ -264,6 +264,49 @@ static void sercon_puts(const char *s)
         serial_puts(sercon_handle, s);
 }
 
+static void dump_console_ring_key(unsigned char key)
+{
+    uint32_t idx, len, sofar, c;
+    unsigned int order;
+    char *buf;
+
+    printk("'%c' pressed -> dumping console ring buffer (dmesg)\n", key);
+
+    /* create a buffer in which we'll copy the ring in the correct
+       order and NUL terminate */
+    order = get_order_from_bytes(conring_size + 1);
+    buf = alloc_xenheap_pages(order, 0);
+    if ( buf == NULL )
+    {
+        printk("unable to allocate memory!\n");
+        return;
+    }
+
+    c = conringc;
+    sofar = 0;
+    while ( (c != conringp) )
+    {
+        idx = CONRING_IDX_MASK(c);
+        len = conringp - c;
+        if ( (idx + len) > conring_size )
+            len = conring_size - idx;
+        memcpy(buf + sofar, &conring[idx], len);
+        sofar += len;
+        c += len;
+    }
+    buf[sofar] = '\0';
+
+    sercon_puts(buf);
+    vga_puts(buf);
+
+    free_xenheap_pages(buf, order);
+}
+
+static struct keyhandler dump_console_ring_keyhandler = {
+    .u.fn = dump_console_ring_key,
+    .desc = "synchronously dump console ring buffer (dmesg)"
+};
+
 /* CTRL-<switch_char> switches input direction between Xen and DOM0. */
 #define switch_code (opt_conswitch[0]-'a'+1)
 static int __read_mostly xen_rx = 1; /* FALSE => serial input passed to domain 
0. */
@@ -661,6 +704,8 @@ void __init console_endboot(void)
     if ( opt_conswitch[1] == 'x' )
         xen_rx = !xen_rx;
 
+    register_keyhandler('w', &dump_console_ring_keyhandler);
+
     /* Serial input is directed to DOM0 by default. */
     switch_serial_input();
 }

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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