]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: migration: Refactor cleanup in qemuMigrationSrcNBDStorageCopyDriveMirror
authorPeter Krempa <pkrempa@redhat.com>
Wed, 4 Sep 2019 10:23:16 +0000 (12:23 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 6 Sep 2019 06:12:21 +0000 (08:12 +0200)
Use VIR_AUTOFREE and remove the cleanup label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
src/qemu/qemu_migration.c

index 1a557851bb16f5b84dcca3be79a9d621fb28d80b..82625b2261b23cd6341fea329dbe07ef67c3fd0b 100644 (file)
@@ -868,36 +868,31 @@ qemuMigrationSrcNBDStorageCopyDriveMirror(virQEMUDriverPtr driver,
                                           unsigned long long mirror_speed,
                                           bool mirror_shallow)
 {
-    char *nbd_dest = NULL;
+    VIR_AUTOFREE(char *) nbd_dest = NULL;
     int mon_ret;
-    int ret = -1;
 
     if (strchr(host, ':')) {
         if (virAsprintf(&nbd_dest, "nbd:[%s]:%d:exportname=%s",
                         host, port, diskAlias) < 0)
-            goto cleanup;
+            return -1;
     } else {
         if (virAsprintf(&nbd_dest, "nbd:%s:%d:exportname=%s",
                         host, port, diskAlias) < 0)
-            goto cleanup;
+            return -1;
     }
 
     if (qemuDomainObjEnterMonitorAsync(driver, vm,
                                        QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
-        goto cleanup;
+        return -1;
 
     mon_ret = qemuMonitorDriveMirror(qemuDomainGetMonitor(vm),
                                      diskAlias, nbd_dest, "raw",
                                      mirror_speed, 0, 0, mirror_shallow, true);
 
     if (qemuDomainObjExitMonitor(driver, vm) < 0 || mon_ret < 0)
-        goto cleanup;
-
-    ret = 0;
+        return -1;
 
- cleanup:
-    VIR_FREE(nbd_dest);
-    return ret;
+    return 0;
 }