]> xenbits.xensource.com Git - libvirt.git/commit
util: include stderr in log message when an external command fails
authorLaine Stump <laine@laine.org>
Mon, 6 Aug 2012 15:40:06 +0000 (11:40 -0400)
committerLaine Stump <laine@laine.org>
Tue, 7 Aug 2012 19:25:40 +0000 (15:25 -0400)
commitb8c298d3019ffed3f93989314c90821ddbe47f83
tree0dcd9c4098c2b69a407939cfc4ae17755dbf8ed6
parent7c1119e3bbd483c52ae4cdfebe23dd179ad28124
util: include stderr in log message when an external command fails

This patch is in response to:

  https://bugzilla.redhat.com/show_bug.cgi?id=818467

If a caller to virCommandRun doesn't ask for the exitstatus of the
program it's running, the virCommand functions assume that they should
log an error message and return failure if the exit code isn't
0. However, only the commandline and exit status are logged, while
potentially useful information sent by the program to stderr is
discarded.

Fortunately, virCommandRun is already checking if the caller had asked
for stderr to be saved and, if not, sets things up to save it in
*cmd->errbuf. This makes it fairly simple for virCommandWait to
include *cmd->errbuf in the error log (there are still other callers
that don't setup errbuf, and even virCommandRun won't set it up if the
command is being daemonized, so we have to check that it's non-zero).
src/util/command.c