All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] blk: fix aio context loss on media change
@ 2017-03-14 17:11 Vladimir Sementsov-Ogievskiy
  2017-03-15 11:03 ` Kevin Wolf
  0 siblings, 1 reply; 13+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2017-03-14 17:11 UTC (permalink / raw)
  To: qemu-block, qemu-devel
  Cc: kwolf, mreitz, jsnow, famz, den, vsementsov, stefanha

If we have separate iothread for cdrom, we lose connection to it on
qmp_blockdev_change_medium, as aio_context is on bds which is dropped
and switched with new one.

As an example result, after such media change we have crash on
virtio_scsi_ctx_check: Assertion `blk_get_aio_context(d->conf.blk) == s->ctx' failed.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---

Hi all!

We've faced into this assert, and there some kind of fix. I don't sure that
such fix doesn't break some conceptions, in this case, I hope, someone will
propose a true-way solution.

======
Also, on master branch I can't reproduce it as vm crashed earlier, without any
eject/change, on assert(s->ctx && s->dataplane_started) in
virtio_scsi_data_plane_handle_ctrl(). It looks like race with
virtio_scsi_dataplane_start(), and for test (to reproduce assert described above),
I've "fixed" it with just:

@@ -63,6 +63,7 @@ static bool virtio_scsi_data_plane_handle_ctrl(VirtIODevice *vdev,
 {
     VirtIOSCSI *s = VIRTIO_SCSI(vdev);
 
+    sleep(10);
     assert(s->ctx && s->dataplane_started);
     return virtio_scsi_handle_ctrl_vq(s, vq);
 }

This race is not reproduced for me in our 2.6 based branch.

 block/block-backend.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/block/block-backend.c b/block/block-backend.c
index 5742c09c2c..6d5044228e 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -65,6 +65,8 @@ struct BlockBackend {
     bool allow_write_beyond_eof;
 
     NotifierList remove_bs_notifiers, insert_bs_notifiers;
+
+    AioContext *aio_context;
 };
 
 typedef struct BlockBackendAIOCB {
@@ -559,6 +561,10 @@ int blk_insert_bs(BlockBackend *blk, BlockDriverState *bs, Error **errp)
     }
     bdrv_ref(bs);
 
+    if (blk->aio_context != NULL) {
+        bdrv_set_aio_context(bs, blk->aio_context);
+    }
+
     notifier_list_notify(&blk->insert_bs_notifiers, blk);
     if (blk->public.throttle_state) {
         throttle_timers_attach_aio_context(
@@ -1607,6 +1613,7 @@ void blk_set_aio_context(BlockBackend *blk, AioContext *new_context)
 {
     BlockDriverState *bs = blk_bs(blk);
 
+    blk->aio_context = new_context;
     if (bs) {
         if (blk->public.throttle_state) {
             throttle_timers_detach_aio_context(&blk->public.throttle_timers);
-- 
2.11.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-03-15 15:30 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-14 17:11 [Qemu-devel] [PATCH] blk: fix aio context loss on media change Vladimir Sementsov-Ogievskiy
2017-03-15 11:03 ` Kevin Wolf
2017-03-15 11:14   ` Fam Zheng
2017-03-15 12:06     ` Kevin Wolf
2017-03-15 13:13       ` Fam Zheng
2017-03-15 14:04         ` Vladimir Sementsov-Ogievskiy
2017-03-15 14:42           ` Fam Zheng
2017-03-15 13:39   ` Paolo Bonzini
2017-03-15 14:30     ` Kevin Wolf
2017-03-15 14:43       ` Paolo Bonzini
2017-03-15 15:02         ` Kevin Wolf
2017-03-15 15:09           ` Paolo Bonzini
2017-03-15 15:30             ` Kevin Wolf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.