]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemu: Introduce cleanup label in qemuProcessStart
authorJiri Denemark <jdenemar@redhat.com>
Tue, 20 Oct 2015 12:30:52 +0000 (14:30 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 4 Nov 2015 12:09:35 +0000 (13:09 +0100)
Remove code duplication by moving common cleanup code in a dedicated
label.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
src/qemu/qemu_process.c

index ba6d292ed5f9ec3e7aa0a7ce2389d4a1be91b55e..92eab3ca300999f0760017221e843b277f7e5290 100644 (file)
@@ -4365,6 +4365,7 @@ int qemuProcessStart(virConnectPtr conn,
                      virNetDevVPortProfileOp vmop,
                      unsigned int flags)
 {
+    int ret = -1;
     int rv;
     off_t pos = -1;
     char ebuf[1024];
@@ -5095,13 +5096,15 @@ int qemuProcessStart(virConnectPtr conn,
     if (!migrateFrom)
         qemuMonitorSetDomainLog(priv->mon, -1);
 
+    ret = 0;
+
+ cleanup:
     virCommandFree(cmd);
     VIR_FORCE_CLOSE(logfile);
     virObjectUnref(cfg);
     virObjectUnref(caps);
     VIR_FREE(nicindexes);
-
-    return 0;
+    return ret;
 
  error:
     /* We jump here if we failed to start the VM for any reason, or
@@ -5109,16 +5112,10 @@ int qemuProcessStart(virConnectPtr conn,
      * pretend we never started it */
     VIR_FREE(tmppath);
     VIR_FREE(nodeset);
-    virCommandFree(cmd);
-    VIR_FORCE_CLOSE(logfile);
     if (priv->mon)
         qemuMonitorSetDomainLog(priv->mon, -1);
     qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, stop_flags);
-    virObjectUnref(cfg);
-    virObjectUnref(caps);
-    VIR_FREE(nicindexes);
-
-    return -1;
+    goto cleanup;
 
  exit_monitor:
     ignore_value(qemuDomainObjExitMonitor(driver, vm));