Rename virCommandTranslateStatus to virProcessTranslateStatus

The virCommand prefix was inappropriate because the API
does not use any virCommandPtr object instance. This
API closely related to waitpid/exit, so use virProcess
as the prefix

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 49ecf8b41f)
Signed-off-by: Eric Blake <eblake@redhat.com>

Conflicts:
	src/util/command.c
This commit is contained in:
Daniel P. Berrange 2013-09-12 17:00:02 +01:00 committed by Eric Blake
parent 89a181053b
commit c50e029f97
4 changed files with 17 additions and 13 deletions

View File

@ -2600,7 +2600,7 @@ remoteDispatchAuthPolkit(virNetServerPtr server ATTRIBUTE_UNUSED,
authdismissed = (pkout && strstr(pkout, "dismissed=true")); authdismissed = (pkout && strstr(pkout, "dismissed=true"));
if (status != 0) { if (status != 0) {
char *tmp = virCommandTranslateStatus(status); char *tmp = virProcessTranslateStatus(status);
VIR_ERROR(_("Policy kit denied action %s from pid %lld, uid %d: %s"), VIR_ERROR(_("Policy kit denied action %s from pid %lld, uid %d: %s"),
action, (long long) callerPid, callerUid, NULLSTR(tmp)); action, (long long) callerPid, callerUid, NULLSTR(tmp));
VIR_FREE(tmp); VIR_FREE(tmp);

View File

@ -140,7 +140,7 @@ virCommandSetPreExecHook;
virCommandSetWorkingDirectory; virCommandSetWorkingDirectory;
virCommandToString; virCommandToString;
virCommandTransferFD; virCommandTransferFD;
virCommandTranslateStatus; virProcessTranslateStatus;
virCommandWait; virCommandWait;
virCommandWriteArgLog; virCommandWriteArgLog;
virFork; virFork;

View File

@ -1648,7 +1648,7 @@ virCommandToString(virCommandPtr cmd)
/** /**
* virCommandTranslateStatus: * virProcessTranslateStatus:
* @status: child exit status to translate * @status: child exit status to translate
* *
* Translate an exit status into a malloc'd string. Generic helper * Translate an exit status into a malloc'd string. Generic helper
@ -1656,7 +1656,7 @@ virCommandToString(virCommandPtr cmd)
* status argument, as well as raw waitpid(). * status argument, as well as raw waitpid().
*/ */
char * char *
virCommandTranslateStatus(int status) virProcessTranslateStatus(int status)
{ {
char *buf; char *buf;
if (WIFEXITED(status)) { if (WIFEXITED(status)) {
@ -1986,7 +1986,7 @@ virCommandRun(virCommandPtr cmd, int *exitstatus)
if (virCommandWait(cmd, exitstatus) < 0) if (virCommandWait(cmd, exitstatus) < 0)
ret = -1; ret = -1;
str = (exitstatus ? virCommandTranslateStatus(*exitstatus) str = (exitstatus ? virProcessTranslateStatus(*exitstatus)
: (char *) "status 0"); : (char *) "status 0");
VIR_DEBUG("Result %s, stdout: '%s' stderr: '%s'", VIR_DEBUG("Result %s, stdout: '%s' stderr: '%s'",
NULLSTR(str), NULLSTR(str),
@ -2241,7 +2241,7 @@ virProcessWait(pid_t pid, int *exitstatus)
if (exitstatus == NULL) { if (exitstatus == NULL) {
if (status != 0) { if (status != 0) {
char *st = virCommandTranslateStatus(status); char *st = virProcessTranslateStatus(status);
virCommandError(VIR_ERR_INTERNAL_ERROR, virCommandError(VIR_ERR_INTERNAL_ERROR,
_("Child process (%lld) status unexpected: %s"), _("Child process (%lld) status unexpected: %s"),
(long long) pid, NULLSTR(st)); (long long) pid, NULLSTR(st));
@ -2300,10 +2300,14 @@ virCommandWait(virCommandPtr cmd, int *exitstatus)
cmd->reap = false; cmd->reap = false;
if (status) { if (status) {
char *str = virCommandToString(cmd); char *str = virCommandToString(cmd);
char *st = virCommandTranslateStatus(status); char *st = virProcessTranslateStatus(status);
bool haveErrMsg = cmd->errbuf && *cmd->errbuf && (*cmd->errbuf)[0];
virCommandError(VIR_ERR_INTERNAL_ERROR, virCommandError(VIR_ERR_INTERNAL_ERROR,
_("Child process (%s) status unexpected: %s"), _("Child process (%s) unexpected %s%s%s"),
str ? str : cmd->args[0], NULLSTR(st)); str ? str : cmd->args[0], NULLSTR(st),
haveErrMsg ? ": " : "",
haveErrMsg ? *cmd->errbuf : "");
VIR_FREE(str); VIR_FREE(str);
VIR_FREE(st); VIR_FREE(st);
return -1; return -1;
@ -2344,7 +2348,7 @@ virProcessAbort(pid_t pid)
while ((ret = waitpid(pid, &status, WNOHANG)) == -1 && while ((ret = waitpid(pid, &status, WNOHANG)) == -1 &&
errno == EINTR); errno == EINTR);
if (ret == pid) { if (ret == pid) {
tmp = virCommandTranslateStatus(status); tmp = virProcessTranslateStatus(status);
VIR_DEBUG("process has ended: %s", tmp); VIR_DEBUG("process has ended: %s", tmp);
goto cleanup; goto cleanup;
} else if (ret == 0) { } else if (ret == 0) {
@ -2354,7 +2358,7 @@ virProcessAbort(pid_t pid)
while ((ret = waitpid(pid, &status, WNOHANG)) == -1 && while ((ret = waitpid(pid, &status, WNOHANG)) == -1 &&
errno == EINTR); errno == EINTR);
if (ret == pid) { if (ret == pid) {
tmp = virCommandTranslateStatus(status); tmp = virProcessTranslateStatus(status);
VIR_DEBUG("process has ended: %s", tmp); VIR_DEBUG("process has ended: %s", tmp);
goto cleanup; goto cleanup;
} else if (ret == 0) { } else if (ret == 0) {
@ -2363,7 +2367,7 @@ virProcessAbort(pid_t pid)
while ((ret = waitpid(pid, &status, 0)) == -1 && while ((ret = waitpid(pid, &status, 0)) == -1 &&
errno == EINTR); errno == EINTR);
if (ret == pid) { if (ret == pid) {
tmp = virCommandTranslateStatus(status); tmp = virProcessTranslateStatus(status);
VIR_DEBUG("process has ended: %s", tmp); VIR_DEBUG("process has ended: %s", tmp);
goto cleanup; goto cleanup;
} }

View File

@ -138,7 +138,7 @@ void virCommandWriteArgLog(virCommandPtr cmd,
char *virCommandToString(virCommandPtr cmd) ATTRIBUTE_RETURN_CHECK; char *virCommandToString(virCommandPtr cmd) ATTRIBUTE_RETURN_CHECK;
char *virCommandTranslateStatus(int exitstatus) ATTRIBUTE_RETURN_CHECK; char *virProcessTranslateStatus(int exitstatus) ATTRIBUTE_RETURN_CHECK;
int virCommandExec(virCommandPtr cmd) ATTRIBUTE_RETURN_CHECK; int virCommandExec(virCommandPtr cmd) ATTRIBUTE_RETURN_CHECK;