[libvirt] [PATCH] qemuProcessLaunch: Return earlier if spawning qemu failed

Michal Privoznik posted 1 patch 4 years, 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/4d9d0ff04ddc29bf41123129d2682fc47d1c1947.1558602209.git.mprivozn@redhat.com
Test syntax-check passed
src/qemu/qemu_process.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
[libvirt] [PATCH] qemuProcessLaunch: Return earlier if spawning qemu failed
Posted by Michal Privoznik 4 years, 11 months ago
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 <mprivozn@redhat.com>
---
 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 90466771cd..5b5864c021 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -6624,16 +6624,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.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemuProcessLaunch: Return earlier if spawning qemu failed
Posted by Ján Tomko 4 years, 10 months ago
On Thu, May 23, 2019 at 11:03:29AM +0200, Michal Privoznik wrote:
>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 <mprivozn@redhat.com>
>---
> src/qemu/qemu_process.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list