All of lore.kernel.org
 help / color / mirror / Atom feed
* 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; 17+ 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] 17+ 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; 17+ 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] 17+ 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; 17+ 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] 17+ messages in thread
* Re: [Patch] Enable "sysrq c" handler for domU coredump
@ 2006-08-01  9:26 Horms
  2006-08-01 10:33 ` Akio Takebe
  0 siblings, 1 reply; 17+ messages in thread
From: Horms @ 2006-08-01  9:26 UTC (permalink / raw)
  To: Akio Takebe; +Cc: Muli Ben-Yehuda, xen-devel, Kouya Shimura

On Tue, Aug 01, 2006 at 06:06:35PM +0900, Akio Takebe wrote:
> >On Tue, Aug 01, 2006 at 01:39:23PM +0900, Akio Takebe wrote:
> >> Hi, Horms
> >> 
> >> >
> >> >That seems fine to me. Though there was some resistance to a
> >> >patch I sent which adds a panic option to xen-console, which
> >> >is the hypervisor equivalent of sysrq.
> >> >
> >> This patch focus only manually dumping domU's core.
> >> How can I use the panic option of xen-console?
> >> I thought your patch to panic xen.
> >> Can I dump domU's core with the option?
> >
> >Sorry, I was not clear.
> >
> >Yes, my patch is to panic (or more recently cause a crash dump) 
> >in the hypervisor. It does not give any special behaviour to
> >the domains.
> >
> >What I meant was, that the idea of adding a panic to domU's sysrq
> >is similar to my idea of adding panic to the xen console. And I was
> >asked to change this patch to make it trigger a kdump directly,
> >rather than a panic.
> >
> >I think that your sysrq patch and my xen-console panic patches
> >are related, and I wanted to bring that into the discussion.
> >
> Horms, what you said, that I had better call crash_kexec() 
> than panic() on dom0?

Thats not what I was thinking, but now you mention it...

> If so, I agree for dom0 directly calling crash_kexec().
> But because now vmlinux is used as both dom0 and domU,
> we cannot use ifdef for separateing dom0 and domU.
> So I call panic() on both dom0 and domU.
> I also think option like a unknown_nmi_panic is useful 
> and necessary for dump and debug.
> 
> Everyone, how about the below?
> 1. If crash_kexec() is called on dom0, dom0 do hypercall
>    then xen do kexec/kdump
> 2. If crash_kexec() is called on domU, domU do hypercall
>    then xen do panic_domain(), and domU's core is dumped.

I think that is a good idea, because it gives consistent behaviour
for dom0 and domU, even though the mechanics differ. Though if
kexec for domU is merged, things may change at that time.

> So I don't need to modify linux code. :-)

:-)

> Or How about "xm dump"?
> (Probably I use panic_domain() by hypercall.
> This way can probably dump HVM domain.)

That is also a good idea, though it could be done as well,
rather than instead of your crash_kexec() -> hypercall idea.

> I think we need to have the way manually to dump domU, or Xen.
> (Because for the time when domU or Xen don't panic 
> and spinloop and so on) 

That is a good point, which makes your xm dump idea somewhat
more attactive than the crash_kexec() -> hypercall idea.
But I still think they both make sense.

-- 
Horms
  H: http://www.vergenet.net/~horms/
  W: http://www.valinux.co.jp/en/

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

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

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
  -- strict thread matches above, loose matches on Subject: below --
2006-08-04 13:58 [Patch][RFC] Support "xm dump" (is " Graham, Simon
2006-08-03 21:52 [Patch][RFC] Support "xm dump" (is Re: Re:[Patch]Enable "sysrq " Graham, Simon
2006-08-04  9:58 ` [Patch][RFC] Support "xm dump" (is " Akio Takebe
2006-08-04 10:29   ` Harry Butterworth
2006-08-01  9:26 [Patch] Enable "sysrq c" handler for domU coredump 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

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.