When starting (some) external helpers, callers of
qemuSecurityCommandRun() pass &exitstatus variable, to learn the
exit code of helper process (with qemuTPMEmulatorStart() being
the only exception). Then, if the status wasn't zero they produce
a generic error message, like:
"Starting of helper process failed. exitstatus=%d"
or, in case of qemuPasstStart():
"Could not start 'passt': %s"
This is needless as virCommandRun() (that's called under the
hood), can do both for us, if NULL was passed instead of
@exitstatus. Not only it appends exit status, it also reads
stderr of failed command producing comprehensive error message:
Child process (${args}) unexpected exit status ${exitstatus}: ${stderr}
Therefore, pass NULL everywhere. But in contrast with one of
previous commits which removed @cmdret argument, there could be a
sensible caller which might want to process exit code. So keep
the argument for now and just pass NULL.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_dbus.c | 9 +--------
src/qemu/qemu_passt.c | 11 +----------
src/qemu/qemu_security.c | 2 +-
src/qemu/qemu_slirp.c | 9 +--------
src/qemu/qemu_vhost_user_gpu.c | 9 +--------
5 files changed, 5 insertions(+), 35 deletions(-)
diff --git a/src/qemu/qemu_dbus.c b/src/qemu/qemu_dbus.c
index 74cb5457ea..a6dc802637 100644
--- a/src/qemu/qemu_dbus.c
+++ b/src/qemu/qemu_dbus.c
@@ -182,7 +182,6 @@ qemuDBusStart(virQEMUDriver *driver,
virTimeBackOffVar timebackoff;
const unsigned long long timeout = 500 * 1000; /* ms */
VIR_AUTOCLOSE errfd = -1;
- int exitstatus = 0;
pid_t cpid = -1;
int ret = -1;
@@ -218,15 +217,9 @@ qemuDBusStart(virQEMUDriver *driver,
virCommandDaemonize(cmd);
virCommandAddArgFormat(cmd, "--config-file=%s", configfile);
- if (qemuSecurityCommandRun(driver, vm, cmd, -1, -1, &exitstatus) < 0)
+ if (qemuSecurityCommandRun(driver, vm, cmd, -1, -1, NULL) < 0)
goto cleanup;
- if (exitstatus != 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Could not start dbus-daemon. exitstatus: %d"),
exitstatus);
- goto cleanup;
- }
-
if (virPidFileReadPath(pidfile, &cpid) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("dbus-daemon %s didn't show up"),
diff --git a/src/qemu/qemu_passt.c b/src/qemu/qemu_passt.c
index 81b7917026..9eb8cb9834 100644
--- a/src/qemu/qemu_passt.c
+++ b/src/qemu/qemu_passt.c
@@ -155,15 +155,12 @@ qemuPasstStart(virDomainObj *vm,
g_autofree char *passtSocketName = qemuPasstCreateSocketPath(vm, net);
g_autoptr(virCommand) cmd = NULL;
g_autofree char *pidfile = qemuPasstCreatePidFilename(vm, net);
- g_autofree char *errbuf = NULL;
char macaddr[VIR_MAC_STRING_BUFLEN];
size_t i;
- int exitstatus = 0;
cmd = virCommandNew(PASST);
virCommandClearCaps(cmd);
- virCommandSetErrorBuffer(cmd, &errbuf);
virCommandAddArgList(cmd,
"--one-off",
@@ -270,15 +267,9 @@ qemuPasstStart(virDomainObj *vm,
if (qemuExtDeviceLogCommand(driver, vm, cmd, "passt") < 0)
return -1;
- if (qemuSecurityCommandRun(driver, vm, cmd, -1, -1, &exitstatus) < 0)
+ if (qemuSecurityCommandRun(driver, vm, cmd, -1, -1, NULL) < 0)
goto error;
- if (exitstatus != 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Could not start 'passt': %s"),
NULLSTR(errbuf));
- goto error;
- }
-
return 0;
error:
diff --git a/src/qemu/qemu_security.c b/src/qemu/qemu_security.c
index 07fcffb288..ee03e2225e 100644
--- a/src/qemu/qemu_security.c
+++ b/src/qemu/qemu_security.c
@@ -622,7 +622,7 @@ qemuSecurityDomainRestorePathLabel(virQEMUDriver *driver,
* @cmd: the command to run
* @uid: the uid to force
* @gid: the gid to force
- * @existstatus: pointer to int returning exit status of process
+ * @existstatus: optional pointer to int returning exit status of process
*
* Run @cmd with seclabels set on it. If @uid and/or @gid are not
* -1 then their value is enforced.
diff --git a/src/qemu/qemu_slirp.c b/src/qemu/qemu_slirp.c
index bbe919f37a..9697542cd3 100644
--- a/src/qemu/qemu_slirp.c
+++ b/src/qemu/qemu_slirp.c
@@ -247,7 +247,6 @@ qemuSlirpStart(virDomainObj *vm,
size_t i;
pid_t pid = (pid_t) -1;
int rc;
- int exitstatus = 0;
bool killDBusDaemon = false;
g_autofree char *fdname = g_strdup_printf("slirpfd-%s",
net->info.alias);
@@ -326,15 +325,9 @@ qemuSlirpStart(virDomainObj *vm,
if (qemuExtDeviceLogCommand(driver, vm, cmd, "slirp") < 0)
goto error;
- if (qemuSecurityCommandRun(driver, vm, cmd, -1, -1, &exitstatus) < 0)
+ if (qemuSecurityCommandRun(driver, vm, cmd, -1, -1, NULL) < 0)
goto error;
- if (exitstatus != 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Could not start 'slirp'. exitstatus: %d"),
exitstatus);
- goto error;
- }
-
rc = virPidFileReadPath(pidfile, &pid);
if (rc < 0) {
virReportSystemError(-rc,
diff --git a/src/qemu/qemu_vhost_user_gpu.c b/src/qemu/qemu_vhost_user_gpu.c
index 196ebc7dff..5b49ef4e28 100644
--- a/src/qemu/qemu_vhost_user_gpu.c
+++ b/src/qemu/qemu_vhost_user_gpu.c
@@ -106,7 +106,6 @@ int qemuExtVhostUserGPUStart(virQEMUDriver *driver,
g_autoptr(virCommand) cmd = NULL;
int pair[2] = { -1, -1 };
int rc;
- int exitstatus = 0;
pid_t pid;
int ret = -1;
@@ -153,15 +152,9 @@ int qemuExtVhostUserGPUStart(virQEMUDriver *driver,
virCommandAddArgFormat(cmd, "--render-node=%s",
video->accel->rendernode);
}
- if (qemuSecurityCommandRun(driver, vm, cmd, -1, -1, &exitstatus) < 0)
+ if (qemuSecurityCommandRun(driver, vm, cmd, -1, -1, NULL) < 0)
goto error;
- if (exitstatus != 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Could not start 'vhost-user-gpu'. exitstatus:
%d"), exitstatus);
- goto cleanup;
- }
-
rc = virPidFileReadPath(pidfile, &pid);
if (rc < 0) {
virReportSystemError(-rc,
--
2.39.2