From 7979066b699d405576d4e499483ed4ef76a9b872 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Thu, 23 May 2019 11:00:27 +0200 Subject: [PATCH] qemuProcessLaunch: Return earlier if spawning qemu failed MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit If spawning qemu fails then we report an error and proceed to writing status XML onto the disk. This is unnecessary as we are sure that the domain is not running. At the same time, if virPidFileReadPath() fails it returns -errno. Use it in the error message. It may explain what went wrong. Signed-off-by: Michal Privoznik Reviewed-by: Ján Tomko --- src/qemu/qemu_process.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index fa82adbc1e..8c5bfb23c6 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6695,16 +6695,18 @@ qemuProcessLaunch(virConnectPtr conn, /* wait for qemu process to show up */ if (rv == 0) { - if (virPidFileReadPath(priv->pidfile, &vm->pid) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Domain %s didn't show up"), vm->def->name); - rv = -1; + if ((rv = virPidFileReadPath(priv->pidfile, &vm->pid)) < 0) { + virReportSystemError(-rv, + _("Domain %s didn't show up"), + vm->def->name); + goto cleanup; } VIR_DEBUG("QEMU vm=%p name=%s running with pid=%lld", vm, vm->def->name, (long long)vm->pid); } else { VIR_DEBUG("QEMU vm=%p name=%s failed to spawn", vm, vm->def->name); + goto cleanup; } VIR_DEBUG("Writing early domain status to disk"); -- 2.47.2