[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [v0.9.12-maint 4/9] Rename virCommandTranslateStatus to virProcessTranslateStatus



From: "Daniel P. Berrange" <berrange redhat com>

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 49ecf8b41fd1c606703d01792701ce46352b7669)
Signed-off-by: Eric Blake <eblake redhat com>

Conflicts:
	src/util/command.c
---
 daemon/remote.c          |  2 +-
 src/libvirt_private.syms |  2 +-
 src/util/command.c       | 24 ++++++++++++++----------
 src/util/command.h       |  2 +-
 4 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 4ece019..24553f0 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -2600,7 +2600,7 @@ remoteDispatchAuthPolkit(virNetServerPtr server ATTRIBUTE_UNUSED,

     authdismissed = (pkout && strstr(pkout, "dismissed=true"));
     if (status != 0) {
-        char *tmp = virCommandTranslateStatus(status);
+        char *tmp = virProcessTranslateStatus(status);
         VIR_ERROR(_("Policy kit denied action %s from pid %lld, uid %d: %s"),
                   action, (long long) callerPid, callerUid, NULLSTR(tmp));
         VIR_FREE(tmp);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 5d8ff7b..13a732b 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -140,7 +140,7 @@ virCommandSetPreExecHook;
 virCommandSetWorkingDirectory;
 virCommandToString;
 virCommandTransferFD;
-virCommandTranslateStatus;
+virProcessTranslateStatus;
 virCommandWait;
 virCommandWriteArgLog;
 virFork;
diff --git a/src/util/command.c b/src/util/command.c
index 4340659..02432fa 100644
--- a/src/util/command.c
+++ b/src/util/command.c
@@ -1648,7 +1648,7 @@ virCommandToString(virCommandPtr cmd)


 /**
- * virCommandTranslateStatus:
+ * virProcessTranslateStatus:
  * @status: child exit status to translate
  *
  * 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().
  */
 char *
-virCommandTranslateStatus(int status)
+virProcessTranslateStatus(int status)
 {
     char *buf;
     if (WIFEXITED(status)) {
@@ -1986,7 +1986,7 @@ virCommandRun(virCommandPtr cmd, int *exitstatus)
     if (virCommandWait(cmd, exitstatus) < 0)
         ret = -1;

-    str = (exitstatus ? virCommandTranslateStatus(*exitstatus)
+    str = (exitstatus ? virProcessTranslateStatus(*exitstatus)
            : (char *) "status 0");
     VIR_DEBUG("Result %s, stdout: '%s' stderr: '%s'",
               NULLSTR(str),
@@ -2241,7 +2241,7 @@ virProcessWait(pid_t pid, int *exitstatus)

     if (exitstatus == NULL) {
         if (status != 0) {
-            char *st = virCommandTranslateStatus(status);
+            char *st = virProcessTranslateStatus(status);
             virCommandError(VIR_ERR_INTERNAL_ERROR,
                             _("Child process (%lld) status unexpected: %s"),
                             (long long) pid, NULLSTR(st));
@@ -2300,10 +2300,14 @@ virCommandWait(virCommandPtr cmd, int *exitstatus)
         cmd->reap = false;
         if (status) {
             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,
-                            _("Child process (%s) status unexpected: %s"),
-                            str ? str : cmd->args[0], NULLSTR(st));
+                           _("Child process (%s) unexpected %s%s%s"),
+                           str ? str : cmd->args[0], NULLSTR(st),
+                           haveErrMsg ? ": " : "",
+                           haveErrMsg ? *cmd->errbuf : "");
             VIR_FREE(str);
             VIR_FREE(st);
             return -1;
@@ -2344,7 +2348,7 @@ virProcessAbort(pid_t pid)
     while ((ret = waitpid(pid, &status, WNOHANG)) == -1 &&
            errno == EINTR);
     if (ret == pid) {
-        tmp = virCommandTranslateStatus(status);
+        tmp = virProcessTranslateStatus(status);
         VIR_DEBUG("process has ended: %s", tmp);
         goto cleanup;
     } else if (ret == 0) {
@@ -2354,7 +2358,7 @@ virProcessAbort(pid_t pid)
         while ((ret = waitpid(pid, &status, WNOHANG)) == -1 &&
                errno == EINTR);
         if (ret == pid) {
-            tmp = virCommandTranslateStatus(status);
+            tmp = virProcessTranslateStatus(status);
             VIR_DEBUG("process has ended: %s", tmp);
             goto cleanup;
         } else if (ret == 0) {
@@ -2363,7 +2367,7 @@ virProcessAbort(pid_t pid)
             while ((ret = waitpid(pid, &status, 0)) == -1 &&
                    errno == EINTR);
             if (ret == pid) {
-                tmp = virCommandTranslateStatus(status);
+                tmp = virProcessTranslateStatus(status);
                 VIR_DEBUG("process has ended: %s", tmp);
                 goto cleanup;
             }
diff --git a/src/util/command.h b/src/util/command.h
index d8a8c83..5cd85e5 100644
--- a/src/util/command.h
+++ b/src/util/command.h
@@ -138,7 +138,7 @@ void virCommandWriteArgLog(virCommandPtr cmd,
 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;

-- 
1.8.3.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]