mbox series

[0/3] block: fix blk_aio_*() segfault when blk->root == NULL

Message ID 20180208171807.24267-1-stefanha@redhat.com
Headers show
Series block: fix blk_aio_*() segfault when blk->root == NULL | expand

Message

Stefan Hajnoczi Feb. 8, 2018, 5:18 p.m. UTC
Using bdrv_inc_in_flight(blk_bs(blk)) doesn't work since BlockBackend->root may
be NULL.

This patch series solves the issue by adding an BlockBackend->in_flight counter
so requests can be tracked even when there is no BlockDriverState.

This should fix the IDE and virtio-blk segfaults that have been encountered
when there is no BlockDriverState.

The patch is based on work by Kevin Wolf.

Kevin Wolf (1):
  block: test blk_aio_flush() with blk->root == NULL

Stefan Hajnoczi (2):
  block: add BlockBackend->in_flight counter
  Revert "IDE: Do not flush empty CDROM drives"

 tests/Makefile.include     |  2 ++
 block.c                    |  2 +-
 block/block-backend.c      | 59 +++++++++++++++++++++++++++++----
 hw/ide/core.c              | 10 +-----
 tests/test-block-backend.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 138 insertions(+), 17 deletions(-)
 create mode 100644 tests/test-block-backend.c

Comments

Eric Blake Feb. 9, 2018, 3:34 p.m. UTC | #1
On 02/08/2018 11:18 AM, Stefan Hajnoczi wrote:
> Using bdrv_inc_in_flight(blk_bs(blk)) doesn't work since BlockBackend->root may
> be NULL.
> 
> This patch series solves the issue by adding an BlockBackend->in_flight counter
> so requests can be tracked even when there is no BlockDriverState.
> 
> This should fix the IDE and virtio-blk segfaults that have been encountered
> when there is no BlockDriverState.
> 
> The patch is based on work by Kevin Wolf.
> 
> Kevin Wolf (1):
>    block: test blk_aio_flush() with blk->root == NULL
> 
> Stefan Hajnoczi (2):
>    block: add BlockBackend->in_flight counter
>    Revert "IDE: Do not flush empty CDROM drives"

Tested by applying the series out of order (2, 3, 1) - the new test 
fails after 2 (so even our workaround was not robust), fails after 3 
(expected there, because we revert the workaround), then finally passes 
after 1 (the correct fix with no workaround needed).  So for the series, 
you can add:
Tested-by: Eric Blake <eblake@redhat.com>