Blame SOURCES/kvm-blockdev-fix-missed-target-unref-for-drive-backup.patch

7711c0
From 4f1adbc42c93d406d73e30243ddaa6cb11257a24 Mon Sep 17 00:00:00 2001
7711c0
From: John Snow <jsnow@redhat.com>
7711c0
Date: Tue, 4 Jun 2019 17:47:22 +0200
7711c0
Subject: [PATCH 8/9] blockdev: fix missed target unref for drive-backup
7711c0
7711c0
RH-Author: John Snow <jsnow@redhat.com>
7711c0
Message-id: <20190604174722.30906-2-jsnow@redhat.com>
7711c0
Patchwork-id: 88526
7711c0
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 1/1] blockdev: fix missed target unref for drive-backup
7711c0
Bugzilla: 1703916
7711c0
RH-Acked-by: Max Reitz <mreitz@redhat.com>
7711c0
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
7711c0
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
7711c0
7711c0
If the bitmap can't be used for whatever reason, we skip putting down
7711c0
the reference. Fix that.
7711c0
7711c0
In practice, this means that if you attempt to gracefully exit QEMU
7711c0
after a backup command being rejected, bdrv_close_all will fail and
7711c0
tell you some unpleasant things via assert().
7711c0
7711c0
Reported-by: aihua liang <aliang@redhat.com>
7711c0
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1703916
7711c0
Signed-off-by: John Snow <jsnow@redhat.com>
7711c0
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
7711c0
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7711c0
(cherry picked from commit 4da26f138db06c9c6d7199d42bd3c2be552cb956)
7711c0
Signed-off-by: John Snow <jsnow@redhat.com>
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
---
7711c0
 blockdev.c | 13 ++++++-------
7711c0
 1 file changed, 6 insertions(+), 7 deletions(-)
7711c0
7711c0
diff --git a/blockdev.c b/blockdev.c
7711c0
index 61218b4..739441d 100644
7711c0
--- a/blockdev.c
7711c0
+++ b/blockdev.c
7711c0
@@ -3673,8 +3673,7 @@ static BlockJob *do_drive_backup(DriveBackup *backup, JobTxn *txn,
7711c0
     if (set_backing_hd) {
7711c0
         bdrv_set_backing_hd(target_bs, source, &local_err);
7711c0
         if (local_err) {
7711c0
-            bdrv_unref(target_bs);
7711c0
-            goto out;
7711c0
+            goto unref;
7711c0
         }
7711c0
     }
7711c0
 
7711c0
@@ -3682,11 +3681,10 @@ static BlockJob *do_drive_backup(DriveBackup *backup, JobTxn *txn,
7711c0
         bmap = bdrv_find_dirty_bitmap(bs, backup->bitmap);
7711c0
         if (!bmap) {
7711c0
             error_setg(errp, "Bitmap '%s' could not be found", backup->bitmap);
7711c0
-            bdrv_unref(target_bs);
7711c0
-            goto out;
7711c0
+            goto unref;
7711c0
         }
7711c0
         if (bdrv_dirty_bitmap_check(bmap, BDRV_BITMAP_DEFAULT, errp)) {
7711c0
-            goto out;
7711c0
+            goto unref;
7711c0
         }
7711c0
     }
7711c0
     if (!backup->auto_finalize) {
7711c0
@@ -3700,12 +3698,13 @@ static BlockJob *do_drive_backup(DriveBackup *backup, JobTxn *txn,
7711c0
                             backup->sync, bmap, backup->compress,
7711c0
                             backup->on_source_error, backup->on_target_error,
7711c0
                             job_flags, NULL, NULL, txn, &local_err);
7711c0
-    bdrv_unref(target_bs);
7711c0
     if (local_err != NULL) {
7711c0
         error_propagate(errp, local_err);
7711c0
-        goto out;
7711c0
+        goto unref;
7711c0
     }
7711c0
 
7711c0
+unref:
7711c0
+    bdrv_unref(target_bs);
7711c0
 out:
7711c0
     aio_context_release(aio_context);
7711c0
     return job;
7711c0
-- 
7711c0
1.8.3.1
7711c0