WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] automatic dump when guest linux on HVM domain panics

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] automatic dump when guest linux on HVM domain panics
From: Tetsu Yamamoto <yamamoto.tetsu@xxxxxxxxxxxxxx>
Date: Tue, 12 Feb 2008 14:40:32 -0500
Delivery-date: Tue, 12 Feb 2008 11:40:58 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.9 (Windows/20071031)
Hi,

Attached patch adds a function to automatically dump core file when
guest linux on HVM domain panics, in the same way as PV domain.

I tested this patch with kernel 2.6.9 and 2.6.18 on both of x86 and ia64
(to buid for ia64, some patches in the ia64 tree are needed) by the
following steps, and confirmed it works well:

1. Build xen-platform-pci.ko.
2. In /etc/xen/xend-config.sxp, set (enable-dump yes).
3. On guest linux, execute insmod:
   # insmod xen-platform-pci.ko
4. When guest linux panics, a core file is dumped.

Regards,

Tetsu Yamamoto

Signed-off-by: Tetsu Yamamoto <yamamoto.tetsu@xxxxxxxxxxxxxx>
diff -r 2a3111016f88 unmodified_drivers/linux-2.6/platform-pci/Kbuild
--- a/unmodified_drivers/linux-2.6/platform-pci/Kbuild  Mon Feb 11 15:59:49 
2008 +0000
+++ b/unmodified_drivers/linux-2.6/platform-pci/Kbuild  Tue Feb 12 16:26:08 
2008 +0900
@@ -7,6 +7,7 @@ xen-platform-pci-objs := evtchn.o platfo
 xen-platform-pci-objs := evtchn.o platform-pci.o gnttab.o xen_support.o
 xen-platform-pci-objs += features.o platform-compat.o
 xen-platform-pci-objs += reboot.o machine_reboot.o
+xen-platform-pci-objs += panic-handler.o
 
 xen-platform-pci-objs += ../xenbus/xenbus_comms.o
 xen-platform-pci-objs += ../xenbus/xenbus_xs.o
diff -r 2a3111016f88 unmodified_drivers/linux-2.6/platform-pci/panic-handler.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/platform-pci/panic-handler.c Tue Feb 12 
16:26:08 2008 +0900
@@ -0,0 +1,54 @@
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/notifier.h>
+#include <asm/hypervisor.h>
+
+MODULE_LICENSE("GPL");
+
+#ifdef __ia64__
+static void
+xen_panic_hypercall(struct unw_frame_info *info, void *arg)
+{
+       current->thread.ksp = (__u64)info->sw - 16;
+       HYPERVISOR_shutdown(SHUTDOWN_crash);
+       /* we're never actually going to get here... */
+}
+#endif
+
+static int
+xen_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
+{
+#ifdef __ia64__
+       unw_init_running(xen_panic_hypercall, NULL);
+#else /* !__ia64__ */
+       HYPERVISOR_shutdown(SHUTDOWN_crash);
+#endif
+       /* we're never actually going to get here... */
+       return NOTIFY_DONE;
+}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
+static struct notifier_block xen_panic_block = {
+       xen_panic_event, NULL, 0 /* try to go last */
+};
+#else
+static struct notifier_block xen_panic_block = {
+       .notifier_call= xen_panic_event,
+       .next= NULL,
+       .priority= 0/* try to go last */
+};
+#endif /*LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)*/
+
+static int __init setup_panic_event(void)
+{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
+       notifier_chain_register(&panic_notifier_list, &xen_panic_block);
+#else
+       atomic_notifier_chain_register(&panic_notifier_list, &xen_panic_block);
+#endif /*LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)*/
+       return 0;
+}
+
+int xen_panic_handler_init(void)
+{
+       return setup_panic_event();
+}
diff -r 2a3111016f88 unmodified_drivers/linux-2.6/platform-pci/platform-pci.c
--- a/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c  Mon Feb 11 
15:59:49 2008 +0000
+++ b/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c  Tue Feb 12 
16:26:08 2008 +0900
@@ -249,6 +249,7 @@ int xen_irq_init(struct pci_dev *pdev);
 int xen_irq_init(struct pci_dev *pdev);
 int xenbus_init(void);
 int xen_reboot_init(void);
+int xen_panic_handler_init(void);
 int gnttab_init(void);
 
 static int __devinit platform_pci_init(struct pci_dev *pdev,
@@ -317,6 +318,9 @@ static int __devinit platform_pci_init(s
        if ((ret = xen_reboot_init()))
                goto out;
 
+       if ((ret = xen_panic_handler_init()))
+               goto out;
+
  out:
        if (ret) {
                release_mem_region(mmio_addr, mmio_len);
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] automatic dump when guest linux on HVM domain panics, Tetsu Yamamoto <=