thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-dirty-bitmap-fix-double-lock-on-bitmap-enabling.patch

26ba25
From c2d0ba193251782ce258dff254b00848bfc3de5a Mon Sep 17 00:00:00 2001
26ba25
From: John Snow <jsnow@redhat.com>
26ba25
Date: Wed, 18 Jul 2018 22:54:43 +0200
26ba25
Subject: [PATCH 225/268] dirty-bitmap: fix double lock on bitmap enabling
26ba25
26ba25
RH-Author: John Snow <jsnow@redhat.com>
26ba25
Message-id: <20180718225511.14878-8-jsnow@redhat.com>
26ba25
Patchwork-id: 81403
26ba25
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 07/35] dirty-bitmap: fix double lock on bitmap enabling
26ba25
Bugzilla: 1207657
26ba25
RH-Acked-by: Eric Blake <eblake@redhat.com>
26ba25
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
26ba25
RH-Acked-by: Fam Zheng <famz@redhat.com>
26ba25
26ba25
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
26ba25
26ba25
Bitmap lock/unlock were added to bdrv_enable_dirty_bitmap in
26ba25
8b1402ce80d, but some places were not updated correspondingly, which
26ba25
leads to trying to take this lock twice, which is dead-lock. Fix this.
26ba25
26ba25
Actually, iotest 199 (about dirty bitmap postcopy migration) is broken
26ba25
now, and this fixes it.
26ba25
26ba25
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
26ba25
Message-id: 20180625165745.25259-3-vsementsov@virtuozzo.com
26ba25
Signed-off-by: John Snow <jsnow@redhat.com>
26ba25
(cherry picked from commit 58f72b965e9e1820d246329461216c4d13140122)
26ba25
Signed-off-by: John Snow <jsnow@redhat.com>
26ba25
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
26ba25
---
26ba25
 block/dirty-bitmap.c           | 3 ++-
26ba25
 migration/block-dirty-bitmap.c | 4 ++--
26ba25
 2 files changed, 4 insertions(+), 3 deletions(-)
26ba25
26ba25
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
26ba25
index 4d6ae8b..f580c1a 100644
26ba25
--- a/block/dirty-bitmap.c
26ba25
+++ b/block/dirty-bitmap.c
26ba25
@@ -259,8 +259,9 @@ void bdrv_enable_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap)
26ba25
 /* Called with BQL taken. */
26ba25
 void bdrv_dirty_bitmap_enable_successor(BdrvDirtyBitmap *bitmap)
26ba25
 {
26ba25
+    assert(bitmap->mutex == bitmap->successor->mutex);
26ba25
     qemu_mutex_lock(bitmap->mutex);
26ba25
-    bdrv_enable_dirty_bitmap(bitmap->successor);
26ba25
+    bdrv_enable_dirty_bitmap_locked(bitmap->successor);
26ba25
     qemu_mutex_unlock(bitmap->mutex);
26ba25
 }
26ba25
 
26ba25
diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c
26ba25
index dd04f10..abba0b6 100644
26ba25
--- a/migration/block-dirty-bitmap.c
26ba25
+++ b/migration/block-dirty-bitmap.c
26ba25
@@ -511,7 +511,7 @@ void dirty_bitmap_mig_before_vm_start(void)
26ba25
         DirtyBitmapLoadBitmapState *b = item->data;
26ba25
 
26ba25
         if (b->migrated) {
26ba25
-            bdrv_enable_dirty_bitmap(b->bitmap);
26ba25
+            bdrv_enable_dirty_bitmap_locked(b->bitmap);
26ba25
         } else {
26ba25
             bdrv_dirty_bitmap_enable_successor(b->bitmap);
26ba25
         }
26ba25
@@ -547,7 +547,7 @@ static void dirty_bitmap_load_complete(QEMUFile *f, DirtyBitmapLoadState *s)
26ba25
         if (enabled_bitmaps == NULL) {
26ba25
             /* in postcopy */
26ba25
             bdrv_reclaim_dirty_bitmap_locked(s->bs, s->bitmap, &error_abort);
26ba25
-            bdrv_enable_dirty_bitmap(s->bitmap);
26ba25
+            bdrv_enable_dirty_bitmap_locked(s->bitmap);
26ba25
         } else {
26ba25
             /* target not started, successor must be empty */
26ba25
             int64_t count = bdrv_get_dirty_count(s->bitmap);
26ba25
-- 
26ba25
1.8.3.1
26ba25