Commit Graph

34 Commits

Author SHA1 Message Date
Richard W.M. Jones
8dbc5f201f debug: 'progress' (unsupported debug command) now checks argument is reasonable (RHBZ#816839).
Thanks Yuyu Zhou.
(cherry picked from commit cc79854037)
2012-05-01 14:48:52 +01:00
Richard W.M. Jones
138e2dcff0 daemon: debug: Close fd along error path (found by Coverity).
Error: RESOURCE_LEAK:
/builddir/build/BUILD/libguestfs-1.16.5/daemon/debug.c:469: open_fn: Calling opening function "open".
/builddir/build/BUILD/libguestfs-1.16.5/daemon/debug.c:469: var_assign: Assigning: "fd" =  handle returned from "open("/proc/sys/kernel/core_pattern", 1)".
/builddir/build/BUILD/libguestfs-1.16.5/daemon/debug.c:474: noescape: Variable "fd" is not closed or saved in function "write".
/builddir/build/BUILD/libguestfs-1.16.5/daemon/debug.c:476: leaked_handle: Handle variable "fd" going out of scope leaks the handle.
(cherry picked from commit 3b3d9ca4e1)
2012-03-08 18:14:35 +00:00
Richard W.M. Jones
01e717b3c1 daemon: debug segv correct use of dereferencing NULL. 2012-01-09 16:55:49 +00:00
Richard W.M. Jones
498758faee tests: Split regressions -> various subdirectories of tests/ 2011-12-22 13:04:41 +00:00
Matthew Booth
04ea1375c5 Update FSF address. 2011-11-08 14:43:07 +00:00
Matthew Booth
4e3a1205eb Fix debug help error message.
When given an invalid debug command, libguestfs responds with the
error message:

  libguestfs: error: debug: use 'debug help' to list the supported commands

However this command does not work, as debug requires two
arguments. This change updates the message to prompt the user to use
'debug help 0'.
2011-10-31 16:47:50 +00:00
Richard W.M. Jones
d7356a2801 Add regression test to catch missing libraries in the appliance.
Related to RHBZ#727178.
2011-08-02 11:04:13 +01:00
Richard W.M. Jones
9160eec4fb Coverity: Remove unreachable code. 2011-06-09 10:53:12 +01:00
Richard W.M. Jones
f4d996fd26 proto: Fix both-ends-cancel case.
In the case where both ends cancel at the same time (eg. both ends
realize there are errors before or during the transfer), previously we
skipped sending back an error from the daemon, on the spurious basis
that the library would not need it (the library is cancelling because
of its own error).

However this is wrong: we should always send back an error message
from the daemon in order to preserve synchronization of the protocol.

A simple test case is:

  $ guestfish -N fs -m /dev/sda1 upload nosuchfile /
  libguestfs: error: open: nosuchfile: No such file or directory
  libguestfs: error: unexpected procedure number (66/282)

(Notice two things: there are errors at both ends, and the
loss of synchronization).

After applying this commit, the loss of synchronization does not occur
and we just see the library error:

  $ guestfish -N fs -m /dev/sda1 upload nosuchfile /
  libguestfs: error: open: nosuchfile: No such file or directory

The choice of displaying the library or the daemon error is fairly
arbitrary in this case -- it would be valid to display either or even
to combine them into one error.  Displaying the library error only
makes the code considerably simpler.

This commit also (re-)enables a test for this case.
2011-03-18 18:27:24 +00:00
Richard W.M. Jones
9ff9941836 daemon: Don't use ../src path to include generator_protocol.h
This file is already hard-linked into the current directory, so
the relative path is not required.
2010-11-03 13:15:19 +00:00
Richard W.M. Jones
13276f7534 debug: Add qtrace <device> on|off to allow selective traces. 2010-10-06 11:26:25 +01:00
Richard Jones
8c37961b45 debug: Add 'debug progress' command.
This debugging command generates progress notification messages,
used for testing purposes.
2010-09-01 17:03:19 +01:00
Richard Jones
99679fe5a2 debug: Arrange prototypes in alphabetical order. 2010-09-01 15:38:15 +01:00
Richard Jones
83f381f5cc 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.
2010-09-01 15:37:24 +01:00
Matthew Booth
a45302cb8a Add a core_pattern debug command
This adds a new debug command, core_pattern, which writes a new pattern for
coredump files to the appliance kernel, and sets the daemon's hard and soft core
limits to infinity.
2010-08-26 14:00:57 +01:00
Richard Jones
87e49e7e87 New API: debug-upload (not a formal part of the API/ABI).
Allow arbitrary files to be uploaded into the appliance, but
only when --enable-debug-command is enabled.  This lets you
run shell scripts, like this:

  ><fs> debug-upload -<<EOF /tmp/script.sh 0700
  #!/bin/sh -
  # ...
  EOF
  ><fs> debug sh "/tmp/script.sh"
2010-04-19 16:31:24 +01:00
Richard Jones
e9c3711310 daemon: Don't need to prefix error messages with the command name.
The RPC stubs already prefix the command name to error messages.
The daemon doesn't have to do this.  As a (small) benefit this also
makes the daemon slightly smaller.

Code in the daemon such as:

  if (argv[0] == NULL) {
    reply_with_error ("passed an empty list");
    return NULL;
  }

now results in error messages like this:

  ><fs> command ""
  libguestfs: error: command: passed an empty list

(whereas previously you would have seen ..command: command:..)
2010-02-12 16:49:00 +00:00
Jim Meyering
9a8889e4d0 use STREQ, not strcmp: part 1
git grep -l 'strcmp *([^=]*== *0'|xargs \
  perl -pi -e 's/\bstrcmp( *\(.*?\)) *== *0/STREQ$1/g'
2009-11-09 22:34:16 +01:00
Jim Meyering
9353c6253d convert uses of strcasecmp to STRCASEEQ
git grep -l 'strcasecmp *([^=]*== *0'| xargs \
  perl -pi -e 's/\bstrcasecmp( *\(.*?\)) *== *0/STRCASEEQ$1/'
2009-11-09 22:34:16 +01:00
Richard Jones
24a6cf4533 Implement 'debug ls' and 'debug ll' commands.
These commands can be used to list files in the appliance.
2009-08-18 08:56:18 +01:00
Jim Meyering
adf20c0c4d adjust const "**" pointers to avoid warnings
Also, ...
* src/generator.ml: Add DeviceList type, and propagate that change
out to all calling/interface code.
2009-08-17 11:40:24 +02:00
Jim Meyering
84fc760439 generator.ml: use new "Pathname" designation
Nearly every file-related function in daemons/*.c is affected:
Remove this pair of statements from each affected do_* function:
-  NEED_ROOT (return -1);
-  ABS_PATH (dir, return -1);
and change the type of the corresponding parameter to "const char *".
* src/generator.ml: Emit NEED_ROOT just once, even when there are two or
more Pathname args.
2009-08-13 14:45:34 +02:00
Jim Meyering
92ac2400a3 build: daemon/do_debug: parameters aren't always unused
* daemon/debug.c (MAYBE_UNUSED): Define.
(do_debug): Mark parameters as unused only when they really
are unused.  Spotted by Richard Jones.

SCALAR(0xdd8370)
prefer sizeof *VAR sizeof TYPE (no semantic change)
2009-08-10 12:49:22 +02:00
Jim Meyering
5b3452e999 build: avoid warnings in daemon/debug.c
* daemon/debug.c (do_debug): Mark parameters as unused.
2009-08-10 11:53:33 +02:00
Jim Meyering
2f1a50d816 Convert all TABs-as-indentation to spaces.
Do it by running this command:
[exempted files are matched via .x-sc_TAB_in_indentation]

  git ls-files \
    | pcregrep -vf .x-sc_TAB_in_indentation \
    | xargs pcregrep -l '^ *\t' \
    | xargs perl -MText::Tabs -ni -le \
      '$m=/^( *\t[ \t]*)(.*)/; print $m ? expand($1) . $2 : $_'
2009-08-03 17:17:57 +02:00
Jim Meyering
a7b73d4a1e remove trailing blanks 2009-07-03 17:04:21 +02:00
Richard Jones
baa5a40994 The 'debug sh' command now uses a real shell. 2009-06-22 12:23:56 +01:00
Richard Jones
56bef498f4 In the daemon, change all const char * parameters to char *. 2009-06-10 14:16:47 +01:00
Richard Jones
5f76f421d0 Add 'debug env' command to print environment. 2009-05-22 10:52:28 +01:00
Richard Jones
15e0fd573a Generated code to support last 3 commits. 2009-05-08 15:20:36 +01:00
Richard W.M. Jones
8be6c7056d catsprintf leaks, use open_memstream instead. 2009-04-23 19:33:00 +01:00
Richard W.M. Jones
012a2ec1ac Remove the 'debug mem' command, it's never going to work. 2009-04-23 19:23:52 +01:00
Richard W.M. Jones
21dbad6b95 Implement 'debug sh' and 'debug fds' commands. 2009-04-23 18:52:34 +01:00
Richard W.M. Jones
713283f4a6 Add outline of 'debug' command. 2009-04-23 14:39:18 +01:00