The attached patch logs the the argv's passed to the virExec and virRun functions. There's a bit of trickery here: since virRun is just a wrapper for virExec, we don't want the argv string to be logged twice. I addressed this by renaming virExec to __virExec, and keeping the original function name to simply debug the argv and then hand off control. This means anytime virExec is explictly called, the argv will be logged, but if functions wish to by pass that they can just call __virExec (which is what virRun does.) Please let me know if there are any problems with that approach. Thanks, Cole
commit 8330537d24ed7d924e3caecff92402e9dc57dd4f Author: Cole Robinson <crobinso@xxxxxxxxxx> Date: Tue Oct 28 11:59:56 2008 -0400 Log argv string passed to virExec and virRun diff --git a/src/util.c b/src/util.c index 4476323..e59e25c 100644 --- a/src/util.c +++ b/src/util.c @@ -136,14 +136,14 @@ static int virSetNonBlock(int fd) { return 0; } -int -virExec(virConnectPtr conn, - const char *const*argv, - const char *const*envp, - const fd_set *keepfd, - int *retpid, - int infd, int *outfd, int *errfd, - int flags) { +static int +__virExec(virConnectPtr conn, + const char *const*argv, + const char *const*envp, + const fd_set *keepfd, + int *retpid, + int infd, int *outfd, int *errfd, + int flags) { int pid, null, i, openmax; int pipeout[2] = {-1,-1}; int pipeerr[2] = {-1,-1}; @@ -393,6 +393,27 @@ virExec(virConnectPtr conn, return -1; } +int +virExec(virConnectPtr conn, + const char *const*argv, + const char *const*envp, + const fd_set *keepfd, + int *retpid, + int infd, int *outfd, int *errfd, + int flags) { + char *argv_str; + + if ((argv_str = virArgvToString(argv)) == NULL) { + ReportError(conn, VIR_ERR_NO_MEMORY, _("command debug string")); + return -1; + } + DEBUG0(argv_str); + VIR_FREE(argv_str); + + return __virExec(conn, argv, envp, keepfd, retpid, infd, outfd, errfd, + flags); +} + /** * @conn connection to report errors against * @argv NULL terminated argv to run @@ -413,9 +434,17 @@ virRun(virConnectPtr conn, const char *const*argv, int *status) { int childpid, exitstatus, ret; + char *argv_str; + + if ((argv_str = virArgvToString(argv)) == NULL) { + ReportError(conn, VIR_ERR_NO_MEMORY, _("command debug string")); + return -1; + } + DEBUG0(argv_str); + VIR_FREE(argv_str); - if ((ret = virExec(conn, argv, NULL, NULL, - &childpid, -1, NULL, NULL, VIR_EXEC_NONE)) < 0) + if ((ret = __virExec(conn, argv, NULL, NULL, + &childpid, -1, NULL, NULL, VIR_EXEC_NONE)) < 0) return ret; while ((ret = waitpid(childpid, &exitstatus, 0) == -1) && errno == EINTR);
-- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list