qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block-backend: Preserve AioContext of root across medium change
@ 2016-09-23 10:58 Fam Zheng
  2016-09-23 12:11 ` Paolo Bonzini
  2016-09-23 15:54 ` Max Reitz
  0 siblings, 2 replies; 3+ messages in thread
From: Fam Zheng @ 2016-09-23 10:58 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, Kevin Wolf, qemu-stable, qemu-block, Max Reitz

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 <famz@redhat.com>
---
 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 {
-- 
2.7.4

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

* Re: [Qemu-devel] [PATCH] block-backend: Preserve AioContext of root across medium change
  2016-09-23 10:58 [Qemu-devel] [PATCH] block-backend: Preserve AioContext of root across medium change Fam Zheng
@ 2016-09-23 12:11 ` Paolo Bonzini
  2016-09-23 15:54 ` Max Reitz
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2016-09-23 12:11 UTC (permalink / raw)
  To: Fam Zheng, qemu-devel; +Cc: Kevin Wolf, qemu-stable, qemu-block, 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 <famz@redhat.com>
> ---
>  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

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

* Re: [Qemu-devel] [PATCH] block-backend: Preserve AioContext of root across medium change
  2016-09-23 10:58 [Qemu-devel] [PATCH] block-backend: Preserve AioContext of root across medium change Fam Zheng
  2016-09-23 12:11 ` Paolo Bonzini
@ 2016-09-23 15:54 ` Max Reitz
  1 sibling, 0 replies; 3+ messages in thread
From: Max Reitz @ 2016-09-23 15:54 UTC (permalink / raw)
  To: Fam Zheng, qemu-devel; +Cc: pbonzini, Kevin Wolf, qemu-stable, qemu-block

[-- Attachment #1: Type: text/plain, Size: 2117 bytes --]

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 <famz@redhat.com>
> ---
>  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 {

The issue with using the BBRS is that it won't work with
x-blockdev-{insert,remove}-medium. Instead, I think the AioContext
should just be stored in the BB, for which Stefan sent an RFC back in April:

http://lists.nongnu.org/archive/html/qemu-devel/2016-04/msg01844.html

Max


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 480 bytes --]

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

end of thread, other threads:[~2016-09-23 15:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-23 10:58 [Qemu-devel] [PATCH] block-backend: Preserve AioContext of root across medium change Fam Zheng
2016-09-23 12:11 ` Paolo Bonzini
2016-09-23 15:54 ` Max Reitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).