]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Revert "qemu: Don't repeat virDomainObjEndAPI in qemuDomainBlockPull"
authorPeter Krempa <pkrempa@redhat.com>
Wed, 27 Nov 2019 12:40:14 +0000 (13:40 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 27 Nov 2019 13:19:50 +0000 (14:19 +0100)
This reverts commit 421c9550f5446729b513ee50f5c44e6f6969b5a2

qemuDomainBlockPullCommon calls virDomainObjEndAPI internally so the
original commit made us shed two references of @vm instead of one
getting us into a premature free of @vm.

This is not a straight revert as qemuDomainBlockPull was modified
meanwhile. I've also added a warning comment that @vm is consumed.

https://bugzilla.redhat.com/show_bug.cgi?id=1777230

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_driver.c

index 669c12d6ca716bcf9b1dde4b31166bc3f2a6b9af..8c2670d377e1716e16e5c16691ba066cf4273647 100644 (file)
@@ -18443,24 +18443,23 @@ qemuDomainBlockPull(virDomainPtr dom, const char *path, unsigned long bandwidth,
                     unsigned int flags)
 {
     virDomainObjPtr vm;
-    int ret = -1;
-
     virCheckFlags(VIR_DOMAIN_BLOCK_PULL_BANDWIDTH_BYTES, -1);
 
     if (!(vm = qemuDomainObjFromDomain(dom)))
         return -1;
 
-    if (virDomainBlockPullEnsureACL(dom->conn, vm->def) < 0)
-        goto cleanup;
-
-    if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0)
-        goto cleanup;
+    if (virDomainBlockPullEnsureACL(dom->conn, vm->def) < 0) {
+        virDomainObjEndAPI(&vm);
+        return -1;
+    }
 
-    ret = qemuDomainBlockPullCommon(vm, path, NULL, bandwidth, flags);
+    if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0) {
+        virDomainObjEndAPI(&vm);
+        return -1;
+    }
 
- cleanup:
-    virDomainObjEndAPI(&vm);
-    return ret;
+    /* qemuDomainBlockPullCommon consumes the reference on @vm */
+    return qemuDomainBlockPullCommon(vm, path, NULL, bandwidth, flags);
 }