Message ID | 20170221120059.15627-4-jgross@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Tue, Feb 21, 2017 at 01:00:58PM +0100, Juergen Gross wrote: > Add a XS_DEBUG command to xenstored for doing a talloc report to a > file. Right now this is supported by specifying a command line option > when starting xenstored and sending a signal to the daemon to trigger > the report. > > To dump the report to the standard log file call: > > xenstore-control memreport > > To dump the report to a new file call: > > xenstore-control memreport <file> > I think this should be named xenstore-debug to match the wire command name. (Will review this series in detail later)
On 21/02/17 13:16, Wei Liu wrote: > On Tue, Feb 21, 2017 at 01:00:58PM +0100, Juergen Gross wrote: >> Add a XS_DEBUG command to xenstored for doing a talloc report to a >> file. Right now this is supported by specifying a command line option >> when starting xenstored and sending a signal to the daemon to trigger >> the report. >> >> To dump the report to the standard log file call: >> >> xenstore-control memreport >> >> To dump the report to a new file call: >> >> xenstore-control memreport <file> >> > > I think this should be named xenstore-debug to match the wire command name. So you think I should rename the already existing program? BTW: I'd rather rename XS_DEBUG to XS_CONTROL (or make that an alias to XS_DEBUG), as I think there are more useful ways to control xenstore behavior, e.g. by modifying quota (per domain or globally). Juergen
On Tue, Feb 21, 2017 at 01:36:58PM +0100, Juergen Gross wrote: > On 21/02/17 13:16, Wei Liu wrote: > > On Tue, Feb 21, 2017 at 01:00:58PM +0100, Juergen Gross wrote: > >> Add a XS_DEBUG command to xenstored for doing a talloc report to a > >> file. Right now this is supported by specifying a command line option > >> when starting xenstored and sending a signal to the daemon to trigger > >> the report. > >> > >> To dump the report to the standard log file call: > >> > >> xenstore-control memreport > >> > >> To dump the report to a new file call: > >> > >> xenstore-control memreport <file> > >> > > > > I think this should be named xenstore-debug to match the wire command name. > > So you think I should rename the already existing program? > Oops. No. > BTW: I'd rather rename XS_DEBUG to XS_CONTROL (or make that an > alias to XS_DEBUG), as I think there are more useful ways to > control xenstore behavior, e.g. by modifying quota (per domain > or globally). > Yes, this is better. We should rename XS_DEBUG to XS_CONTROL and then #define XS_DEBUG XS_CONTROL in header file. > > Juergen
diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c index 1b0c1c3..ae7681f 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -76,7 +76,7 @@ static unsigned int nr_fds; static bool verbose = false; LIST_HEAD(connections); -static int tracefd = -1; +int tracefd = -1; static bool recovery = true; static int reopen_log_pipe[2]; static int reopen_log_pipe0_pollfd_idx = -1; diff --git a/tools/xenstore/xenstored_core.h b/tools/xenstore/xenstored_core.h index d315568..92cccb6 100644 --- a/tools/xenstore/xenstored_core.h +++ b/tools/xenstore/xenstored_core.h @@ -172,6 +172,7 @@ void reopen_log(void); void close_log(void); extern char *tracefile; +extern int tracefd; extern int dom0_domid; extern int dom0_event; extern int priv_domid; diff --git a/tools/xenstore/xenstored_debug.c b/tools/xenstore/xenstored_debug.c index 0161b3b..59349c1 100644 --- a/tools/xenstore/xenstored_debug.c +++ b/tools/xenstore/xenstored_debug.c @@ -76,6 +76,41 @@ static int do_debug_logfile(void *ctx, struct connection *conn, return 0; } +static int do_debug_memreport(void *ctx, struct connection *conn, + char **vec, int num) +{ + FILE *fp; + int fd; + + if (num > 1) + return EINVAL; + + if (num == 0) { + if (tracefd < 0) { + if (!tracefile) + return EBADF; + fp = fopen(tracefile, "a"); + } else { + fd = dup(tracefd); + if (fd < 0) + return EBADF; + fp = fdopen(fd, "a"); + if (!fp) + close(fd); + } + } else + fp = fopen(vec[0], "a"); + + if (!fp) + return EBADF; + + talloc_report_full(NULL, fp); + fclose(fp); + + send_ack(conn, XS_DEBUG); + return 0; +} + static int do_debug_print(void *ctx, struct connection *conn, char **vec, int num) { @@ -94,6 +129,7 @@ static struct cmd_s cmds[] = { { "check", do_debug_check, "" }, { "log", do_debug_log, "on|off" }, { "logfile", do_debug_logfile, "<file>" }, + { "memreport", do_debug_memreport, "[<file>]" }, { "print", do_debug_print, "<string>" }, { "help", do_debug_help, "" }, };
Add a XS_DEBUG command to xenstored for doing a talloc report to a file. Right now this is supported by specifying a command line option when starting xenstored and sending a signal to the daemon to trigger the report. To dump the report to the standard log file call: xenstore-control memreport To dump the report to a new file call: xenstore-control memreport <file> Signed-off-by: Juergen Gross <jgross@suse.com> --- tools/xenstore/xenstored_core.c | 2 +- tools/xenstore/xenstored_core.h | 1 + tools/xenstore/xenstored_debug.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-)