Blob Blame History Raw
From 9d7066090ad7cde8ce74aa2566959fe7789908b9 Mon Sep 17 00:00:00 2001
From: John Snow <jsnow@redhat.com>
Date: Tue, 16 May 2017 21:00:41 +0200
Subject: [PATCH 05/27] blockdev: use drained_begin/end for qmp_block_resize

RH-Author: John Snow <jsnow@redhat.com>
Message-id: <20170516210041.12856-4-jsnow@redhat.com>
Patchwork-id: 75196
O-Subject: [RHV-7.4 qemu-kvm-rhev PATCH v2 3/3] blockdev: use drained_begin/end for qmp_block_resize
Bugzilla: 1447551
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>

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

If one tries to issue a block_resize while a guest is busy
accessing the disk, it is possible that qemu may deadlock
when invoking aio_poll from both the main loop and the iothread.

Replace another instance of bdrv_drain_all that doesn't
quite belong.

Cc: qemu-stable@nongnu.org
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 698bdfa07d66b5ec218a60229e58eae1dcde00e5)
Signed-off-by: John Snow <jsnow@redhat.com>
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 blockdev.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/blockdev.c b/blockdev.c
index 6a50742..b0894fa 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2972,10 +2972,9 @@ void qmp_block_resize(bool has_device, const char *device,
         goto out;
     }
 
-    /* complete all in-flight operations before resizing the device */
-    bdrv_drain_all();
-
+    bdrv_drained_begin(bs);
     ret = blk_truncate(blk, size, errp);
+    bdrv_drained_end(bs);
 
 out:
     blk_unref(blk);
-- 
1.8.3.1