All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch] Enable "sysrq c" handler for domU coredump
@ 2006-08-01  3:11 Akio Takebe
  2006-08-01  3:48 ` Horms
  2006-08-01  8:03 ` [Patch] Enable "sysrq c" handler for domU coredump Keir Fraser
  0 siblings, 2 replies; 27+ messages in thread
From: Akio Takebe @ 2006-08-01  3:11 UTC (permalink / raw)
  To: xen-devel, Horms, Kouya Shimura

[-- Attachment #1: Mail message body --]
[-- Type: text/plain, Size: 754 bytes --]

Hi,

In the case of linux, crash_kexec() is occured by "sysrq c".
In the case of DomainU on xen, Help is occured by "sysrq c" now.
So The way of dumping DomainU's memory manualy is nothing.

I fix this issue by the following way.
1. Panic is occured by "sysrq c" on both Domain0 and DomainU.
2. On DomainU, coredump is generated in /var/xen/dump (on Domain0).
   On Domain0, crash_kexec() is called by panic() if implemented.

I tested the below.
1. vi /etc/xen/xend-config.sxp
   (enabel-dump yes)
2. xm create -c domU
   echo 1 >/proc/sys/kernel/sysrq (on domU)
3. xm sysrq domU c (on dom0)
4. ls -lh /var/xen/dump

Signed-off-by: Akio Takebe <takebe_akio@jp.fujitsu.com>
Signed-off-by: Kouya Shimura <kouya@jp.fujitsu.com>

Best Regards,

Akio Takebe

[-- Attachment #2: xen_sysrq_domUcore.patch --]
[-- Type: application/octet-stream, Size: 1606 bytes --]

diff -r d2bf1a7cc131 patches/linux-2.6.16.13/xen_sysrq_for_domUcore.patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/linux-2.6.16.13/xen_sysrq_for_domUcore.patch	Tue Aug 01 01:55:10 2006 +0900
@@ -0,0 +1,46 @@
+--- ../pristine-linux-2.6.16.13/drivers/char/sysrq.c	2006-05-03 06:38:44.000000000 +0900
++++ ./drivers/char/sysrq.c	2006-08-01 01:54:25.413617336 +0900
+@@ -95,6 +95,19 @@ static struct sysrq_key_op sysrq_unraw_o
+ };
+ #endif /* CONFIG_VT */
+ 
++#ifdef CONFIG_XEN
++static void sysrq_handle_crash(int key, struct pt_regs *pt_regs,
++			      struct tty_struct *tty) 
++{
++	panic("Panic domain by request\n");
++}
++static struct sysrq_key_op sysrq_crash_op = {
++	.handler	= sysrq_handle_crash,
++	.help_msg	= "CrashDomain",
++	.action_msg	= "Panic domain by request",
++	.enable_mask	= SYSRQ_ENABLE_DUMP,
++};
++#else
+ #ifdef CONFIG_KEXEC
+ /* crashdump sysrq handler */
+ static void sysrq_handle_crashdump(int key, struct pt_regs *pt_regs,
+@@ -109,6 +122,7 @@ static struct sysrq_key_op sysrq_crashdu
+ 	.enable_mask	= SYSRQ_ENABLE_DUMP,
+ };
+ #endif
++#endif
+ 
+ /* reboot sysrq handler */
+ static void sysrq_handle_reboot(int key, struct pt_regs *pt_regs,
+@@ -304,11 +318,15 @@ static struct sysrq_key_op *sysrq_key_ta
+ 		 it is handled specially on the sparc
+ 		 and will never arrive */
+ /* b */	&sysrq_reboot_op,
++#ifdef CONFIG_XEN /* for domU crash dump */
++/* c */	&sysrq_crash_op,
++#else
+ #ifdef CONFIG_KEXEC
+ /* c */ &sysrq_crashdump_op,
+ #else
+ /* c */	NULL,
+ #endif
++#endif
+ #ifdef CONFIG_DEBUG_MUTEXES
+ /* d */ &sysrq_showlocks_op,
+ #else

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 27+ messages in thread
* RE: [Patch][RFC] Support "xm dump" (is Re: Re: [Patch]Enable "sysrq c" handler for domU coredump)
@ 2006-08-03 14:45 Graham, Simon
  2006-08-03 15:24 ` [Patch][RFC] Support "xm dump" (is Re: " Akio Takebe
  0 siblings, 1 reply; 27+ messages in thread
From: Graham, Simon @ 2006-08-03 14:45 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 2404 bytes --]

Two things:

1. I'm not convinced 'xm crash' is needed - 'xm destroy' will do this
(and if you want
   a dump, do 'xm dump' followed by 'xm destroy')

2. I don't see the point of the --noreboot option on 'xm dump' -- I
think this command
   should simply live-dump the specified domain - as above you can use
other commands
   to cause the domain to restart afterwards.

3. There's no need to pause the domain to dump it - I actually wrote a
little utility
   to live dump a guest (based on xenconsoled and attached) and it seems
to work
   quite nicely! This could easily be morphed into the 'xm dump' command
- it just
   didn't occur to me at the time!

Simon


> -----Original Message-----
> From: xen-devel-bounces@lists.xensource.com [mailto:xen-devel-
> bounces@lists.xensource.com] On Behalf Of Akio Takebe
> Sent: Thursday, August 03, 2006 8:57 AM
> To: Tristan Gingold; John Levon; Keir Fraser
> Cc: Muli Ben-Yehuda; Horms; Akio Takebe; xen-devel; Kouya Shimura
> Subject: Re: [Patch][RFC] Support "xm dump" (is Re: [Xen-devel] Re:
> [Patch]Enable "sysrq c" handler for domU coredump)
> 
> Hi, all
> 
> >>   For example panic dump option is used when domU kernel is hungup,
> >>   and we want to reboot and make coredump atomatically.
> >I'd prefer 'xm crash' (or 'xm panic') and 'xm dump' .
> >I'd prefer 'xm dump' *not* to panic by default.  It is too dangerous.
> >
> OK. I also think both are necessary.
> How about the following specification?
> 
> 1. xm crash
>    This is only for crashing a domain.
>    If enable-dump is yes, we can get the domain's core after crash.
>    And If we want to atomatically reboot, we should set
> on_crash='restart'
>    in domain configuration.
> 
> 2. xm dump
>    This is for live dumping a domain.
>    This implementation is:
>      1. pause the domain
>      2. dumping the domain
>      3. unpause the domain
>      4. reboot (if --noreboot option, don't reboot)
> 
>      I think we want to reboot when we want to dump.
>      So I want to be default reboot.
> 
>    BTW, I think the feature to online-dump domain and
>    hypervisor is also necessary.(meaning online is "don't pause")
> 
> Best Regards,
> 
> Akio Takebe
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel

[-- Attachment #2: xendump.c --]
[-- Type: application/octet-stream, Size: 3409 bytes --]

/*
 *  Copyright (c) 2006 Stratus Technologies, Inc
 *  Copyright (C) International Business Machines  Corp., 2005
 *  Author(s): Simon Graham <simon.graham@stratus.com>
 *  	       Anthony Liguori <aliguori@us.ibm.com>
 *
 *  Xen Dump Utility
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; under version 2 of the License.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <getopt.h>
#include <err.h>
#include <ctype.h>
#include <string.h>

#include "xenctrl.h"
#include "xs.h"

static int find_domain_id_by_name(struct xs_handle *xs_handle, const char *name)
{
	int domain_id=-1, id, i, num;
	char path[80];
	char *domain_name;
    
	char **list = xs_directory(xs_handle, XBT_NULL, "/local/domain", &num);
	if (list == NULL)
		return 0;
    
	for (i=0; i<num; i++) {
		id = strtol(list[i], NULL, 10);
		if (id == 0)
			continue;

		snprintf(path, sizeof(path), "/local/domain/%i/name", id);
		domain_name = xs_read(xs_handle, XBT_NULL, path, NULL);

		if (strcmp(domain_name, name) == 0) 
			domain_id = id;
	}

	return domain_id;
}

static int get_domain_id(const char *value)
{
	int domid;
	struct xs_handle *xs;
	xs = xs_daemon_open_readonly();
	domid = find_domain_id_by_name(xs, value);
	xs_daemon_close(xs);

	return domid;
}

static void dumpDomU(int domid, const char *dumpname)
{
	int xc_handle;
	int rc;

	xc_handle = xc_interface_open();
	if (xc_handle == -1) {
		err(errno, "xc_interface_open()");
	}

	printf("Dumping domain id %d to %s\n",domid,dumpname);

	rc = xc_domain_dumpcore(xc_handle, domid, dumpname);
	if (rc < 0) {
		err(-rc,"failed to dump core");
	}
}

static void usage(const char *program) {
	printf("Usage: %s [options] domain-name dump-path\n"
	       "Dumps specified domain to named file\n"
	       "\n"
	       "  -h, --help       display this help and exit\n"
	       , program);
}

int main(int argc, char **argv)
{
	int domid;
	char *end;
	char *sopt = "h";
	int ch;
	int opt_ind=0;
	struct option lopt[] = {
		{ "help",    0, 0, 'h' },
		{ 0 },

	};
	while((ch = getopt_long(argc, argv, sopt, lopt, &opt_ind)) != -1) {
		switch(ch) {
		case 'h':
			usage(argv[0]);
			exit(0);
			break;
		}
	}
	
	if ((argc - optind) != 2) {
		fprintf(stderr, "Invalid number of arguments\n");
		fprintf(stderr, "Try `%s --help' for more information.\n", 
			argv[0]);
		exit(EINVAL);
	}

	// Did use specify a numeric domid?
	domid = strtol(argv[optind], &end, 10);
	if (end && *end) {
		// no - treat as name instead
		domid = get_domain_id(argv[optind]);

		if (domid < 0) {
			err(EINVAL,"domain not found");
		}
	}

	dumpDomU(domid, argv[optind+1]);

	return 0;
}

/*
 * Local variables:
 *  c-file-style: "linux"
 *  indent-tabs-mode: t
 *  c-indent-level: 8
 *  c-basic-offset: 8
 *  tab-width: 8
 * End:
 */

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 27+ messages in thread
* RE: [Patch][RFC] Support "xm dump" (is Re: Re:[Patch]Enable "sysrq c" handler for domU coredump)
@ 2006-08-03 21:52 Graham, Simon
  2006-08-04  9:58 ` [Patch][RFC] Support "xm dump" (is " Akio Takebe
  0 siblings, 1 reply; 27+ messages in thread
From: Graham, Simon @ 2006-08-03 21:52 UTC (permalink / raw)
  To: Akio Takebe, xen-devel

> Hi, Simon
> 
> >Two things:
> >
> >1. I'm not convinced 'xm crash' is needed - 'xm destroy' will do this
> >(and if you want
> >   a dump, do 'xm dump' followed by 'xm destroy')
> >
> What do you mean?
> I think we cannot dump with "xm destroy" now.
> "xm destory" only call the following domain_kill().

I mean that if you want to crash a domain and collect a dump, you can do
'xm dump' followed by 'xm destroy' or 'xm reboot' -- there's no need to 
add another command to do the combination.

> >2. I don't see the point of the --noreboot option on 'xm dump' -- I
> >think this command
> >   should simply live-dump the specified domain - as above you can
use
> >other commands
> >   to cause the domain to restart afterwards.
> >
> Ordinary dump features have atomatically rebooting features.
> (e.g. diskdump, kdump, and so on)
> So I think this is necessary.

xm dump foo
xm reboot foo

does the job nicely -- why complicate things by adding extra
options/commands

> 
> >3. There's no need to pause the domain to dump it - I actually wrote
a
> >little utility
> >   to live dump a guest (based on xenconsoled and attached) and it
> seems
> >to work
> >   quite nicely! This could easily be morphed into the 'xm dump'
> command
> >- it just
> >   didn't occur to me at the time!
> >
> Your xendump command is dump feature without pause.
> In the case without pause, domain's memory is modified while dumping.
> I think both w/o and w pause are needed.

Hmm... perhaps although I'm not convinced -- I understand that memory
can change during the dump and therefore there can be some
inconsistencies in the dump, HOWEVER, pausing the domain doesn't ensure
all the data structures are consistent either - it pretty much just
stops the VM wherever is happens to be so the memory can still be
inconsistent. 

I also think there is an issue with pausing -- unless I am mistaken,
pause requires code to run in the domain - if the domain is glued up
this cant run and the pause will hang (and lets face it, the usual
reason for dumping a domain is because something is wrong; definitely a
good idea to minimize the amount of work you expect from the domain in
this case).

FWIW, my opinion is that it isn't necessary to pause.

/simgr

^ permalink raw reply	[flat|nested] 27+ messages in thread
* RE: [Patch][RFC] Support "xm dump" (is Re:Re:[Patch]Enable"sysrq c" handler for domU coredump)
@ 2006-08-04 13:58 Graham, Simon
  0 siblings, 0 replies; 27+ messages in thread
From: Graham, Simon @ 2006-08-04 13:58 UTC (permalink / raw)
  To: Akio Takebe, xen-devel

> BTW, I try to make your xendump.c, but cannot compile it.
> Could you post the Makefile?
> I'd like to use your xendump.

I actually build this out of tree along with some other utilities so the
Makefile wont be a lot of use to you. However, the
relevant sections (mostly taken from tools/console/Makefile btw) are
attached.

Having said that, if you are going to add an 'xm dump' command, I think
it should be done by modifying the xend Python code
rather than building an external C program (I wish I'd thought of this!)

Simon

------Makefile extract------

XEN_ROOT=<path to top of xen tree>

include $(XEN_ROOT)/tools/Rules.mk

CFLAGS  += -Werror -g
CFLAGS  += -I $(XEN_XC)
CFLAGS  += -I $(XEN_LIBXC)
CFLAGS  += -I $(XEN_XENSTORE)
LDFLAGS += -L $(XEN_LIBXC)
LDFLAGS += -L $(XEN_XENSTORE)

BIN = xendump

.PHONY: build

build: $(BIN)

%: %.c
	$(CC) $(CFLAGS) $(LDFLAGS) -lxenctrl -l xenstore -o $@ $<

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2006-08-08 15:00 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-01  3:11 [Patch] Enable "sysrq c" handler for domU coredump Akio Takebe
2006-08-01  3:48 ` Horms
2006-08-01  4:39   ` Akio Takebe
2006-08-01  6:48     ` Horms
2006-08-01  9:06       ` Akio Takebe
2006-08-01  9:26         ` Horms
2006-08-01 10:33           ` Akio Takebe
2006-08-03  0:18             ` [Patch][RFC] Support "xm dump" (is Re: Re: [Patch] Enable "sysrq c" handler for domU coredump) Akio Takebe
2006-08-03  0:26               ` John Levon
2006-08-03  6:09                 ` Tristan Gingold
2006-08-03 11:10                   ` Akio Takebe
2006-08-03 11:58                     ` Tristan Gingold
2006-08-03 12:57                       ` Akio Takebe
2006-08-07 18:04                     ` John Levon
2006-08-03  1:50               ` Horms
2006-08-03 11:10                 ` Akio Takebe
2006-08-01  8:03 ` [Patch] Enable "sysrq c" handler for domU coredump Keir Fraser
2006-08-01  8:15   ` Muli Ben-Yehuda
2006-08-01  8:12     ` Keir Fraser
  -- strict thread matches above, loose matches on Subject: below --
2006-08-03 14:45 [Patch][RFC] Support "xm dump" (is Re: Re: [Patch]Enable "sysrq c" handler for domU coredump) Graham, Simon
2006-08-03 15:24 ` [Patch][RFC] Support "xm dump" (is Re: " Akio Takebe
2006-08-08 12:31   ` John Levon
2006-08-08 15:00     ` Akio Takebe
2006-08-03 21:52 Graham, Simon
2006-08-04  9:58 ` [Patch][RFC] Support "xm dump" (is " Akio Takebe
2006-08-04 10:29   ` Harry Butterworth
2006-08-04 13:58 [Patch][RFC] Support "xm dump" (is " Graham, Simon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.