tools/xenstored: have a single do_control_memreport()

With 9pfs now available in Xenstore-stubdom, there is no reason to
have distinct do_control_memreport() variants for the daemon and the
stubdom implementations.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
This commit is contained in:
Juergen Gross authored and Jan Beulich committed 2024-02-29 17:00:19 +01:00
1 parent 8937d44628
commit d388673d1b
1 file changed
+7 -20
+7 -20
View File
@@ -216,23 +216,11 @@ static int do_control_logfile(const void *ctx, struct connection *conn,
return 0; return 0;
} }
#ifdef __MINIOS__
static int do_control_memreport(const void *ctx, struct connection *conn,
const char **vec, int num)
{
if (num)
return EINVAL;
talloc_report_full(NULL, stdout);
send_ack(conn, XS_CONTROL);
return 0;
}
#else
static int do_control_memreport(const void *ctx, struct connection *conn, static int do_control_memreport(const void *ctx, struct connection *conn,
const char **vec, int num) const char **vec, int num)
{ {
FILE *fp; FILE *fp;
const char *filename;
int fd; int fd;
if (num > 1) if (num > 1)
@@ -255,8 +243,12 @@ static int do_control_memreport(const void *ctx, struct connection *conn,
if (!fp) if (!fp)
close(fd); close(fd);
} }
} else } else {
fp = fopen(vec[0], "a"); filename = absolute_filename(ctx, vec[0]);
if (!filename)
return ENOMEM;
fp = fopen(filename, "a");
}
if (!fp) if (!fp)
return EBADF; return EBADF;
@@ -267,7 +259,6 @@ static int do_control_memreport(const void *ctx, struct connection *conn,
send_ack(conn, XS_CONTROL); send_ack(conn, XS_CONTROL);
return 0; return 0;
} }
#endif
static int do_control_print(const void *ctx, struct connection *conn, static int do_control_print(const void *ctx, struct connection *conn,
const char **vec, int num) const char **vec, int num)
@@ -310,11 +301,7 @@ static struct cmd_s cmds[] = {
" Default timeout is 60 seconds.", 5 }, " Default timeout is 60 seconds.", 5 },
#endif #endif
{ "logfile", do_control_logfile, "<file>" }, { "logfile", do_control_logfile, "<file>" },
#ifdef __MINIOS__
{ "memreport", do_control_memreport, "" },
#else
{ "memreport", do_control_memreport, "[<file>]" }, { "memreport", do_control_memreport, "[<file>]" },
#endif
{ "print", do_control_print, "<string>" }, { "print", do_control_print, "<string>" },
{ "quota", do_control_quota, { "quota", do_control_quota,
"[set <name> <val>|<domid>|max [-r]]" }, "[set <name> <val>|<domid>|max [-r]]" },
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.