Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP3:GA
xen.8425
xs-27-memory-report.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File xs-27-memory-report.patch of Package xen.8425
commit 27816a2eda7a2c6041003abe6c5af37d8b88bc69 Author: Juergen Gross <jgross@suse.com> Date: Fri Feb 24 07:21:44 2017 +0100 xenstore: make memory report available via XS_CONTROL 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@suse.com> Reviewed-by: Wei Liu <wei.liu2@citrix.com> Index: xen-4.4.4-testing/tools/xenstore/xenstored_control.c =================================================================== --- xen-4.4.4-testing.orig/tools/xenstore/xenstored_control.c +++ xen-4.4.4-testing/tools/xenstore/xenstored_control.c @@ -20,6 +20,7 @@ #include <stdarg.h> #include <stdio.h> #include <string.h> +#include <unistd.h> #include "utils.h" #include "talloc.h" @@ -76,6 +77,45 @@ static int do_control_logfile(void *ctx, 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 { + /* + * Use dup() in order to avoid closing the file later + * with fclose() which will release stream resources. + */ + 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_CONTROL); + return 0; +} + static int do_control_print(void *ctx, struct connection *conn, char **vec, int num) { @@ -94,6 +134,7 @@ static struct cmd_s cmds[] = { { "check", do_control_check, "" }, { "log", do_control_log, "on|off" }, { "logfile", do_control_logfile, "<file>" }, + { "memreport", do_control_memreport, "[<file>]" }, { "print", do_control_print, "<string>" }, { "help", do_control_help, "" }, }; Index: xen-4.4.4-testing/tools/xenstore/xenstored_core.c =================================================================== --- xen-4.4.4-testing.orig/tools/xenstore/xenstored_core.c +++ xen-4.4.4-testing/tools/xenstore/xenstored_core.c @@ -66,7 +66,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 bool remove_local = true; static int reopen_log_pipe[2]; Index: xen-4.4.4-testing/tools/xenstore/xenstored_core.h =================================================================== --- xen-4.4.4-testing.orig/tools/xenstore/xenstored_core.h +++ xen-4.4.4-testing/tools/xenstore/xenstored_core.h @@ -176,6 +176,7 @@ void reopen_log(void); void close_log(void); extern char *tracefile; +extern int tracefd; extern int dom0_event; extern int priv_domid;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor