[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH 4/4] block/block-backend.c: assertions for block-backend
From: |
Stefan Hajnoczi |
Subject: |
Re: [RFC PATCH 4/4] block/block-backend.c: assertions for block-backend |
Date: |
Mon, 13 Sep 2021 14:38:03 +0100 |
On Wed, Sep 08, 2021 at 09:10:21AM -0400, Emanuele Giuseppe Esposito wrote:
> @@ -1767,12 +1817,14 @@ void blk_drain_all(void)
> void blk_set_on_error(BlockBackend *blk, BlockdevOnError on_read_error,
> BlockdevOnError on_write_error)
> {
> + g_assert(qemu_in_main_thread());
> blk->on_read_error = on_read_error;
> blk->on_write_error = on_write_error;
> }
>
> BlockdevOnError blk_get_on_error(BlockBackend *blk, bool is_read)
> {
> + g_assert(qemu_in_main_thread());
> return is_read ? blk->on_read_error : blk->on_write_error;
> }
>
> @@ -1780,6 +1832,7 @@ BlockErrorAction blk_get_error_action(BlockBackend
> *blk, bool is_read,
> int error)
> {
> BlockdevOnError on_err = blk_get_on_error(blk, is_read);
> + g_assert(qemu_in_main_thread());
>
> switch (on_err) {
> case BLOCKDEV_ON_ERROR_ENOSPC:
> @@ -1819,6 +1872,7 @@ void blk_error_action(BlockBackend *blk,
> BlockErrorAction action,
> bool is_read, int error)
> {
> assert(error >= 0);
> + g_assert(qemu_in_main_thread());
>
> if (action == BLOCK_ERROR_ACTION_STOP) {
> /* First set the iostatus, so that "info block" returns an iostatus
The error action APIs are called from the I/O code path. For example,
hw/block/virtio-blk.c:virtio_blk_handle_rw_error() is called from an
IOThread with -device virtio-blk-pci,iothread=... with the AioContext
held.
> @@ -1983,11 +2045,13 @@ uint32_t blk_get_max_transfer(BlockBackend *blk)
>
> int blk_get_max_iov(BlockBackend *blk)
> {
> + g_assert(qemu_in_main_thread());
> return blk->root->bs->bl.max_iov;
> }
This is called by hw/block/virtio-blk.c:virtio_blk_submit_multireq()
from an IOThread with the AioContext held.
signature.asc
Description: PGP signature
- [RFC PATCH 0/4] block layer: split block APIs in graph and I/O, Emanuele Giuseppe Esposito, 2021/09/08
- [RFC PATCH 2/4] migration: block-dirty-bitmap: add missing qemu_mutex_lock_iothread, Emanuele Giuseppe Esposito, 2021/09/08
- [RFC PATCH 1/4] main-loop.h: introduce qemu_in_main_thread(), Emanuele Giuseppe Esposito, 2021/09/08
- [RFC PATCH 4/4] block/block-backend.c: assertions for block-backend, Emanuele Giuseppe Esposito, 2021/09/08
- Re: [RFC PATCH 4/4] block/block-backend.c: assertions for block-backend,
Stefan Hajnoczi <=
- [RFC PATCH 3/4] include/sysemu/block-backend: split header into I/O and graph API, Emanuele Giuseppe Esposito, 2021/09/08
- Re: [RFC PATCH 3/4] include/sysemu/block-backend: split header into I/O and graph API, Stefan Hajnoczi, 2021/09/13
- Re: [RFC PATCH 0/4] block layer: split block APIs in graph and I/O, Stefan Hajnoczi, 2021/09/13