mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-25 12:52:19 +00:00
qemu: Don't overwrite error from qemuSecurityCommandRun()
The usual pattern when starting a helper daemon is: if (qemuSecurityCommandRun(..., &exitstatus, &cmdret) < 0) goto cleanup; if (cmdret < 0 || exitstatus != 0) { virReportError(); goto cleanup; } The only problem with this pattern is that if virCommandRun() fails (i.e. cmdret < 0), then proper error was already reported. But in this pattern we overwrite it (usually with less specific) error. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
0634d640d6
commit
17ffdbab1f
@ -224,8 +224,10 @@ qemuDBusStart(virQEMUDriver *driver,
|
||||
goto cleanup;
|
||||
|
||||
if (cmdret < 0 || exitstatus != 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Could not start dbus-daemon. exitstatus: %d"), exitstatus);
|
||||
if (cmdret >= 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Could not start dbus-daemon. exitstatus: %d"), exitstatus);
|
||||
}
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -289,8 +289,10 @@ qemuPasstStart(virDomainObj *vm,
|
||||
goto error;
|
||||
|
||||
if (cmdret < 0 || exitstatus != 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Could not start 'passt': %s"), NULLSTR(errbuf));
|
||||
if (cmdret >= 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Could not start 'passt': %s"), NULLSTR(errbuf));
|
||||
}
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -626,10 +626,11 @@ qemuSecurityDomainRestorePathLabel(virQEMUDriver *driver,
|
||||
* @cmdret: pointer to int returning result of virCommandRun
|
||||
*
|
||||
* Run @cmd with seclabels set on it. If @uid and/or @gid are not
|
||||
* -1 then their value is enforced.
|
||||
* -1 then their value is enforced. If @cmdret is negative upon
|
||||
* return, then appropriate error was already reported.
|
||||
*
|
||||
* Returns: 0 on success,
|
||||
* -1 otherwise.
|
||||
* -1 otherwise (with error reported).
|
||||
*/
|
||||
int
|
||||
qemuSecurityCommandRun(virQEMUDriver *driver,
|
||||
|
@ -331,8 +331,10 @@ qemuSlirpStart(virDomainObj *vm,
|
||||
goto error;
|
||||
|
||||
if (cmdret < 0 || exitstatus != 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Could not start 'slirp'. exitstatus: %d"), exitstatus);
|
||||
if (cmdret >= 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Could not start 'slirp'. exitstatus: %d"), exitstatus);
|
||||
}
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -157,8 +157,10 @@ int qemuExtVhostUserGPUStart(virQEMUDriver *driver,
|
||||
goto error;
|
||||
|
||||
if (cmdret < 0 || exitstatus != 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Could not start 'vhost-user-gpu'. exitstatus: %d"), exitstatus);
|
||||
if (cmdret >= 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Could not start 'vhost-user-gpu'. exitstatus: %d"), exitstatus);
|
||||
}
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user