ia64/xen-unstable

changeset 17049:27314cfbcefe

pv-on-hvm: Signal crash to Xen tools when HVM guest panics.

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.

Signed-off-by: Tetsu Yamamoto <yamamoto.tetsu@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Feb 13 10:42:09 2008 +0000 (2008-02-13)
parents e85399173769
children 0164d924ceba
files unmodified_drivers/linux-2.6/platform-pci/Kbuild unmodified_drivers/linux-2.6/platform-pci/panic-handler.c unmodified_drivers/linux-2.6/platform-pci/platform-pci.c
line diff
     1.1 --- a/unmodified_drivers/linux-2.6/platform-pci/Kbuild	Tue Feb 12 16:59:08 2008 +0000
     1.2 +++ b/unmodified_drivers/linux-2.6/platform-pci/Kbuild	Wed Feb 13 10:42:09 2008 +0000
     1.3 @@ -7,6 +7,7 @@ EXTRA_CFLAGS += -I$(M)/platform-pci
     1.4  xen-platform-pci-objs := evtchn.o platform-pci.o gnttab.o xen_support.o
     1.5  xen-platform-pci-objs += features.o platform-compat.o
     1.6  xen-platform-pci-objs += reboot.o machine_reboot.o
     1.7 +xen-platform-pci-objs += panic-handler.o
     1.8  
     1.9  xen-platform-pci-objs += ../xenbus/xenbus_comms.o
    1.10  xen-platform-pci-objs += ../xenbus/xenbus_xs.o
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/unmodified_drivers/linux-2.6/platform-pci/panic-handler.c	Wed Feb 13 10:42:09 2008 +0000
     2.3 @@ -0,0 +1,54 @@
     2.4 +#include <linux/module.h>
     2.5 +#include <linux/init.h>
     2.6 +#include <linux/notifier.h>
     2.7 +#include <asm/hypervisor.h>
     2.8 +
     2.9 +MODULE_LICENSE("GPL");
    2.10 +
    2.11 +#ifdef __ia64__
    2.12 +static void
    2.13 +xen_panic_hypercall(struct unw_frame_info *info, void *arg)
    2.14 +{
    2.15 +	current->thread.ksp = (__u64)info->sw - 16;
    2.16 +	HYPERVISOR_shutdown(SHUTDOWN_crash);
    2.17 +	/* we're never actually going to get here... */
    2.18 +}
    2.19 +#endif
    2.20 +
    2.21 +static int
    2.22 +xen_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
    2.23 +{
    2.24 +#ifdef __ia64__
    2.25 +	unw_init_running(xen_panic_hypercall, NULL);
    2.26 +#else /* !__ia64__ */
    2.27 +	HYPERVISOR_shutdown(SHUTDOWN_crash);
    2.28 +#endif
    2.29 +	/* we're never actually going to get here... */
    2.30 +	return NOTIFY_DONE;
    2.31 +}
    2.32 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
    2.33 +static struct notifier_block xen_panic_block = {
    2.34 +	xen_panic_event, NULL, 0 /* try to go last */
    2.35 +};
    2.36 +#else
    2.37 +static struct notifier_block xen_panic_block = {
    2.38 +	.notifier_call= xen_panic_event,
    2.39 +	.next= NULL,
    2.40 +	.priority= 0/* try to go last */
    2.41 +};
    2.42 +#endif /*LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)*/
    2.43 +
    2.44 +static int __init setup_panic_event(void)
    2.45 +{
    2.46 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
    2.47 +	notifier_chain_register(&panic_notifier_list, &xen_panic_block);
    2.48 +#else
    2.49 +	atomic_notifier_chain_register(&panic_notifier_list, &xen_panic_block);
    2.50 +#endif /*LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)*/
    2.51 +	return 0;
    2.52 +}
    2.53 +
    2.54 +int xen_panic_handler_init(void)
    2.55 +{
    2.56 +	return setup_panic_event();
    2.57 +}
     3.1 --- a/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c	Tue Feb 12 16:59:08 2008 +0000
     3.2 +++ b/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c	Wed Feb 13 10:42:09 2008 +0000
     3.3 @@ -249,6 +249,7 @@ static int set_callback_via(uint64_t via
     3.4  int xen_irq_init(struct pci_dev *pdev);
     3.5  int xenbus_init(void);
     3.6  int xen_reboot_init(void);
     3.7 +int xen_panic_handler_init(void);
     3.8  int gnttab_init(void);
     3.9  
    3.10  static int __devinit platform_pci_init(struct pci_dev *pdev,
    3.11 @@ -317,6 +318,9 @@ static int __devinit platform_pci_init(s
    3.12  	if ((ret = xen_reboot_init()))
    3.13  		goto out;
    3.14  
    3.15 +	if ((ret = xen_panic_handler_init()))
    3.16 +		goto out;
    3.17 +
    3.18   out:
    3.19  	if (ret) {
    3.20  		release_mem_region(mmio_addr, mmio_len);