Received: from eggs.gnu.org ([2001:4830:134:3::10]:47506) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnPLS-0000PW-Si for qemu-devel@nongnu.org; Fri, 23 Sep 2016 08:12:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bnPLQ-0008NK-SE for qemu-devel@nongnu.org; Fri, 23 Sep 2016 08:12:45 -0400 Sender: Paolo Bonzini References: <1474628299-27134-1-git-send-email-famz@redhat.com> From: Paolo Bonzini Message-ID: Date: Fri, 23 Sep 2016 14:11:24 +0200 MIME-Version: 1.0 In-Reply-To: <1474628299-27134-1-git-send-email-famz@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH] block-backend: Preserve AioContext of root across medium change List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: Kevin Wolf , qemu-stable@nongnu.org, qemu-block@nongnu.org, Max Reitz On 23/09/2016 12:58, Fam Zheng wrote: > This is nop for non-dataplane case, but it prevents crash > (virtio_scsi_ctx_check assertion failure) when a scsi-cd change > operation happens on a virtio-scsi dataplane device. > > Cc: qemu-stable@nongnu.org > Signed-off-by: Fam Zheng > --- > block/block-backend.c | 7 +++++++ > include/block/block_int.h | 1 + > 2 files changed, 8 insertions(+) > > diff --git a/block/block-backend.c b/block/block-backend.c > index d1349d9..c2cae9a 100644 > --- a/block/block-backend.c > +++ b/block/block-backend.c > @@ -1570,6 +1570,7 @@ void blk_update_root_state(BlockBackend *blk) > blk->root_state.open_flags = blk->root->bs->open_flags; > blk->root_state.read_only = blk->root->bs->read_only; > blk->root_state.detect_zeroes = blk->root->bs->detect_zeroes; > + blk->root_state.aio_context = blk->root->bs->aio_context; > } > > /* > @@ -1579,7 +1580,13 @@ void blk_update_root_state(BlockBackend *blk) > */ > void blk_apply_root_state(BlockBackend *blk, BlockDriverState *bs) > { > + AioContext *ctx = blk->root_state.aio_context; > bs->detect_zeroes = blk->root_state.detect_zeroes; > + if (ctx && ctx != qemu_get_aio_context()) { > + aio_context_acquire(ctx); > + bdrv_set_aio_context(bs, ctx); > + aio_context_release(ctx); > + } > } > > /* > diff --git a/include/block/block_int.h b/include/block/block_int.h > index ef3c047..23c64d2 100644 > --- a/include/block/block_int.h > +++ b/include/block/block_int.h > @@ -534,6 +534,7 @@ struct BlockBackendRootState { > int open_flags; > bool read_only; > BlockdevDetectZeroesOptions detect_zeroes; > + AioContext *aio_context; > }; > > typedef enum BlockMirrorBackingMode { > Looks good. I look forward to when we can drop bdrv_set_aio_context altogether... It's only 70 patches away! :) Paolo