]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuProcessLaunch: Return earlier if spawning qemu failed
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 23 May 2019 09:00:27 +0000 (11:00 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 20 Jun 2019 08:29:54 +0000 (10:29 +0200)
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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_process.c

index fa82adbc1e6b6f926aa0468b4c116357db5aa57b..8c5bfb23c6c045ae52ef8a2b9454bb8101eb1534 100644 (file)
@@ -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");