daemon: Enable debug command by default.

The debug command is useful for internal testing, and so should
be enabled by default in all builds.

Note that it is still *not* part of the stable ABI.
This commit is contained in:
Richard Jones
2010-09-01 15:37:24 +01:00
parent 867319ec5f
commit 83f381f5cc
2 changed files with 8 additions and 32 deletions

View File

@@ -1,5 +1,5 @@
# libguestfs-daemon
# Copyright (C) 2009 Red Hat Inc.
# Copyright (C) 2009-2010 Red Hat Inc.
#
# 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
@@ -31,12 +31,6 @@ AC_ARG_ENABLE([32bit],
[export CC="gcc -m32"],
[enable_32bit=no])
dnl Enable 'debug' command.
AC_ARG_ENABLE([debug-command],
[AS_HELP_STRING([--enable-debug-command], [enable the 'debug' command])],
[AC_DEFINE_UNQUOTED([ENABLE_DEBUG_COMMAND],[1],[Enable the 'debug' command])],
[])
dnl Enable packet dumps when in verbose mode. This generates lots
dnl of debug info, only useful for people debugging the RPC mechanism.
AC_ARG_ENABLE([packet-dump],

View File

@@ -38,9 +38,13 @@
* to find out what you can do.
*
* Commands always output a freeform string.
*
* Since libguestfs 1.5.7, the debug command has been enabled
* by default for all builds (previously you had to enable it
* in configure). This command is not part of the stable ABI
* and may change at any time.
*/
#if ENABLE_DEBUG_COMMAND
struct cmd {
const char *cmd;
char * (*f) (const char *subcmd, int argc, char *const *const argv);
@@ -66,18 +70,10 @@ static struct cmd cmds[] = {
{ "sh", debug_sh },
{ NULL, NULL }
};
#endif
#if ! ENABLE_DEBUG_COMMAND
# define MAYBE_UNUSED ATTRIBUTE_UNUSED
#else
# define MAYBE_UNUSED /* empty */
#endif
char *
do_debug (const char *subcmd MAYBE_UNUSED, char *const *argv MAYBE_UNUSED)
do_debug (const char *subcmd, char *const *argv)
{
#if ENABLE_DEBUG_COMMAND
int argc, i;
for (i = argc = 0; argv[i] != NULL; ++i)
@@ -90,13 +86,8 @@ do_debug (const char *subcmd MAYBE_UNUSED, char *const *argv MAYBE_UNUSED)
reply_with_error ("use 'debug help' to list the supported commands");
return NULL;
#else
reply_with_error ("guestfsd was not configured with --enable-debug-command");
return NULL;
#endif
}
#if ENABLE_DEBUG_COMMAND
static char *
debug_help (const char *subcmd, int argc, char *const *const argv)
{
@@ -391,22 +382,17 @@ debug_core_pattern (const char *subcmd, int argc, char *const *const argv)
return ret;
}
#endif /* ENABLE_DEBUG_COMMAND */
#if ENABLE_DEBUG_COMMAND
static int
write_cb (void *fd_ptr, const void *buf, size_t len)
{
int fd = *(int *)fd_ptr;
return xwrite (fd, buf, len);
}
#endif
/* Has one FileIn parameter. */
int
do_debug_upload (const char *filename MAYBE_UNUSED, int mode MAYBE_UNUSED)
do_debug_upload (const char *filename, int mode)
{
#if ENABLE_DEBUG_COMMAND
/* Not chrooted - this command lets you upload a file to anywhere
* in the appliance.
*/
@@ -445,8 +431,4 @@ do_debug_upload (const char *filename MAYBE_UNUSED, int mode MAYBE_UNUSED)
}
return 0;
#else
reply_with_error ("guestfsd was not configured with --enable-debug-command");
return NULL;
#endif
}