[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v2 4/5] xenstore: make memory report available via XS_CONTROL
On Wed, Feb 22, 2017 at 01:43:27PM +0100, Juergen Gross wrote: > On 22/02/17 13:36, Wei Liu wrote: > > On Tue, Feb 21, 2017 at 04:07:36PM +0100, Juergen Gross wrote: > >> Add a XS_CONTROL 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@xxxxxxxx> > >> --- > >> tools/xenstore/xenstored_control.c | 36 > >> ++++++++++++++++++++++++++++++++++++ > >> tools/xenstore/xenstored_core.c | 2 +- > >> tools/xenstore/xenstored_core.h | 1 + > >> 3 files changed, 38 insertions(+), 1 deletion(-) > >> > >> diff --git a/tools/xenstore/xenstored_control.c > >> b/tools/xenstore/xenstored_control.c > >> index c3587ad..b4ec6ce 100644 > >> --- a/tools/xenstore/xenstored_control.c > >> +++ b/tools/xenstore/xenstored_control.c > >> @@ -76,6 +76,41 @@ static int do_control_logfile(void *ctx, struct > >> connection *conn, > >> return 0; > >> } > >> > >> +static int do_control_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); > > > > Why dup() the fd? Is it because you want to avoid tracefd becomes > > invalid under your feet? > > > > I want to be able to fclose() to get rid of the stream resources without > closing the log file. > Oh, right. I missed that aspect. Could you please add a comment for that please. > > Juergen _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |