[libvirt] [PATCH for 5.10] Revert "qemu: Don't repeat virDomainObjEndAPI in qemuDomainBlockPull"

Peter Krempa posted 1 patch 4 years, 4 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/471f6605c945cf788e513cb19011487693d40ca6.1574859089.git.pkrempa@redhat.com
src/qemu/qemu_driver.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
[libvirt] [PATCH for 5.10] Revert "qemu: Don't repeat virDomainObjEndAPI in qemuDomainBlockPull"
Posted by Peter Krempa 4 years, 4 months ago
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>
---

/me hides in shame

 src/qemu/qemu_driver.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 669c12d6ca..8c2670d377 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -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);
 }


-- 
2.23.0

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

Re: [libvirt] [PATCH for 5.10] Revert "qemu: Don't repeat virDomainObjEndAPI in qemuDomainBlockPull"
Posted by Ján Tomko 4 years, 4 months ago
On Wed, Nov 27, 2019 at 01:52:23PM +0100, Peter Krempa wrote:
>This reverts commit 421c9550f5446729b513ee50f5c44e6f6969b5a2.
>

Feel free to demote this from a sentence by removing the trailing
period, to make it easier to select.

>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>
>---
>
>/me hides in shame
>
> src/qemu/qemu_driver.c | 21 ++++++++++-----------
> 1 file changed, 10 insertions(+), 11 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