Re: [PULL 0/3] Memory/SDHCI/ParallelFlash patches for v7.2.0-rc0

2022-11-08 Thread Philippe Mathieu-Daudé
On 8/11/22 21:57, Stefan Hajnoczi wrote: I've dropped the SDHCI CVE fix due to the CI failure. The rest of the commits are still in the staging tree and I plan to include them in v7.2.0-rc0. Thank you Stefan, sorry for not catching that failure sooner.

Re: [PATCH v3 4/4] hw/nvme: add polling support

2022-11-08 Thread Jinhao Fan
at 10:11 PM, Klaus Jensen wrote: > On Nov 8 12:39, John Levon wrote: >> On Fri, Nov 04, 2022 at 07:32:12AM +0100, Klaus Jensen wrote: >> >>> On Nov 3 21:19, Jinhao Fan wrote: On 11/3/2022 8:10 PM, Klaus Jensen wrote: > I agree that the spec is a little unclear on this point. In any

[PATCH 8/8] virtio-blk: minimize virtio_blk_reset() AioContext lock region

2022-11-08 Thread Stefan Hajnoczi
blk_drain() needs the lock because it calls AIO_WAIT_WHILE(). The s->rq loop doesn't need the lock because dataplane has been stopped when virtio_blk_reset() is called. Signed-off-by: Stefan Hajnoczi --- hw/block/virtio-blk.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git

[PATCH 7/8] virtio-blk: don't acquire AioContext in virtio_blk_handle_vq()

2022-11-08 Thread Stefan Hajnoczi
There is no need to acquire AioContext in virtio_blk_handle_vq() because no APIs used in the function require it and nothing else in the virtio-blk code requires mutual exclusion anymore. Signed-off-by: Stefan Hajnoczi --- hw/block/virtio-blk.c | 2 -- 1 file changed, 2 deletions(-) diff --git

[PATCH 1/8] virtio_queue_aio_attach_host_notifier: remove AioContext lock

2022-11-08 Thread Stefan Hajnoczi
From: Emanuele Giuseppe Esposito virtio_queue_aio_attach_host_notifier() and virtio_queue_aio_attach_host_notifier_nopoll() run always in the main loop, so there is no need to protect them with AioContext lock. On the other side, virtio_queue_aio_detach_host_notifier() runs in a bh in the

[PATCH 5/8] virtio-blk: mark IO_CODE functions

2022-11-08 Thread Stefan Hajnoczi
From: Emanuele Giuseppe Esposito Just as done in the block API, mark functions in virtio-blk that are called also from iothread(s). We know such functions are IO because many are blk_* callbacks, running always in the device iothread, and remaining are propagated from the leaf IO functions (if

[PATCH 6/8] virtio-blk: remove unnecessary AioContext lock from function already safe

2022-11-08 Thread Stefan Hajnoczi
From: Emanuele Giuseppe Esposito AioContext lock was introduced in b9e413dd375 and in this instance it is used to protect these 3 functions: - virtio_blk_handle_rw_error - virtio_blk_req_complete - block_acct_done Now that all three of the above functions are protected with their own locks, we

[PATCH 4/8] virtio-blk: mark GLOBAL_STATE_CODE functions

2022-11-08 Thread Stefan Hajnoczi
From: Emanuele Giuseppe Esposito Just as done in the block API, mark functions in virtio-blk that are always called in the main loop with BQL held. We know such functions are GS because they all are callbacks from virtio.c API that has already classified them as GS. Signed-off-by: Emanuele

[PATCH 2/8] block-backend: enable_write_cache should be atomic

2022-11-08 Thread Stefan Hajnoczi
From: Emanuele Giuseppe Esposito It is read from IO_CODE and written with BQL held, so setting it as atomic should be enough. Also remove the aiocontext lock that was sporadically taken around the set. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Stefan Hajnoczi Signed-off-by:

[PATCH 0/8] virtio-blk: remove AioContext lock

2022-11-08 Thread Stefan Hajnoczi
This is a continuation of Emanuele Esposito's work to remove the AioContext lock in virtio-blk. In the past it was necessary to acquire the AioContext lock in order to do I/O. Paolo Bonzini and Emanuele have removed the need for the AioContext in the core block layer code, with a few exceptions

[PATCH 3/8] virtio: categorize callbacks in GS

2022-11-08 Thread Stefan Hajnoczi
From: Emanuele Giuseppe Esposito All the callbacks below are always running in the main loop. The callbacks are the following: - start/stop_ioeventfd: these are the callbacks where blk_set_aio_context(iothread) is done, so they are called in the main loop. - save and load: called during

Re: [PULL 0/3] Memory/SDHCI/ParallelFlash patches for v7.2.0-rc0

2022-11-08 Thread Stefan Hajnoczi
I've dropped the SDHCI CVE fix due to the CI failure. The rest of the commits are still in the staging tree and I plan to include them in v7.2.0-rc0. Stefan

Re: [PULL 0/3] Memory/SDHCI/ParallelFlash patches for v7.2.0-rc0

2022-11-08 Thread Stefan Hajnoczi
available in the Git repository at: > > https://github.com/philmd/qemu.git tags/memflash-20221108 > > for you to fetch changes up to cf9b3efd816518f9f210f50a0fa3e46a00b33c27: > > Revert "hw/block/pflash_cfi: Error out if dev length isn

Re: [PATCH v3 08/17] migration/qemu-file: Add qemu_file_get_to_fd()

2022-11-08 Thread Vladimir Sementsov-Ogievskiy
On 11/3/22 19:16, Avihai Horon wrote: Add new function qemu_file_get_to_fd() that allows reading data from QEMUFile and writing it straight into a given fd. This will be used later in VFIO migration code. Signed-off-by: Avihai Horon Reviewed-by: Vladimir Sementsov-Ogievskiy -- Best

Re: [PATCH-for-7.2 1/2] hw/sd/sdhci: Do not set Buf Wr Ena before writing block (CVE-2022-3872)

2022-11-08 Thread Alexander Bulekov
On 221108 1225, Alexander Bulekov wrote: > On 221107 2312, Philippe Mathieu-Daudé wrote: > > When sdhci_write_block_to_card() is called to transfer data from > > the FIFO to the SD bus, the data is already present in the buffer > > and we have to consume it directly. > > > > See the description

Re: [PATCH v3 06/17] vfio/migration: Fix NULL pointer dereference bug

2022-11-08 Thread Vladimir Sementsov-Ogievskiy
On 11/3/22 19:16, Avihai Horon wrote: As part of its error flow, vfio_vmstate_change() accesses MigrationState->to_dst_file without any checks. This can cause a NULL pointer dereference if the error flow is taken and MigrationState->to_dst_file is not set. For example, this can happen if VM is

Re: [PATCH v3 05/17] vfio/migration: Fix wrong enum usage

2022-11-08 Thread Vladimir Sementsov-Ogievskiy
On 11/3/22 19:16, Avihai Horon wrote: vfio_migration_init() initializes VFIOMigration->device_state using enum of VFIO migration protocol v2. Current implemented protocol is v1 so v1 enum should be used. Fix it. Fixes: 429c72800654 ("vfio/migration: Fix incorrect initialization value for

Re: [PATCH v3 04/17] migration: Simplify migration_iteration_run()

2022-11-08 Thread Vladimir Sementsov-Ogievskiy
On 11/3/22 19:16, Avihai Horon wrote: From: Juan Quintela Signed-off-by: Juan Quintela Signed-off-by: Avihai Horon --- migration/migration.c | 25 + 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index

Re: [PATCH v3 03/17] migration: Block migration comment or code is wrong

2022-11-08 Thread Vladimir Sementsov-Ogievskiy
On 11/8/22 21:36, Vladimir Sementsov-Ogievskiy wrote: On 11/3/22 19:16, Avihai Horon wrote: From: Juan Quintela And it appears that what is wrong is the code. During bulk stage we need to make sure that some block is dirty, but no games with max_size at all. :) That made me interested in,

Re: [PATCH v3 03/17] migration: Block migration comment or code is wrong

2022-11-08 Thread Vladimir Sementsov-Ogievskiy
On 11/3/22 19:16, Avihai Horon wrote: From: Juan Quintela And it appears that what is wrong is the code. During bulk stage we need to make sure that some block is dirty, but no games with max_size at all. :) That made me interested in, why we need this one block, so I decided to search

[PULL 3/3] Revert "hw/block/pflash_cfi: Error out if dev length isn't power of 2"

2022-11-08 Thread Philippe Mathieu-Daudé
From: Daniel Henrique Barboza Commit 334c388f25 ("pflash_cfi: Error out if device length isn't a power of two") aimed to finish the effort started by commit 06f1521795 ("pflash: Require backend size to match device, improve errors"), but unfortunately we are not quite there since various

[PULL 2/3] hw/sd/sdhci: Do not set Buf Wr Ena before writing block (CVE-2022-3872)

2022-11-08 Thread Philippe Mathieu-Daudé
When sdhci_write_block_to_card() is called to transfer data from the FIFO to the SD bus, the data is already present in the buffer and we have to consume it directly. See the description of the 'Buffer Write Enable' bit from the 'Present State' register (prnsts::SDHC_SPACE_AVAILABLE) in Table

[PULL 0/3] Memory/SDHCI/ParallelFlash patches for v7.2.0-rc0

2022-11-08 Thread Philippe Mathieu-Daudé
The following changes since commit ade760a2f63804b7ab1839fbc3e5ddbf30538718: Merge tag 'pull-request-2022-11-08' of https://gitlab.com/thuth/qemu into staging (2022-11-08 11:34:06 -0500) are available in the Git repository at: https://github.com/philmd/qemu.git tags/memflash-20221108

[PULL 1/3] memory: Fix wrong end address dump

2022-11-08 Thread Philippe Mathieu-Daudé
From: Zhenzhong Duan The end address of memory region section isn't correctly calculated which leads to overflowed mtree dump: Dispatch Physical sections .. #70 @2000..00011fff io [ROOT] #71 @5000..5fff (noname) #72

Re: [PATCH-for-7.2 0/2] hw/sd/sdhci: Do not set Buf Wr Ena before writing block (CVE-2022-3872)

2022-11-08 Thread Stefan Hajnoczi
Applied to the staging tree. Thanks! Stefan

Re: [PATCH-for-7.2] Revert "hw/block/pflash_cfi: Error out if dev length isn't power of 2"

2022-11-08 Thread Stefan Hajnoczi
Applied to staging. Thanks! Stefan

Re: [PATCH v3 02/17] migration: No save_live_pending() method uses the QEMUFile parameter

2022-11-08 Thread Vladimir Sementsov-Ogievskiy
On 11/3/22 19:16, Avihai Horon wrote: From: Juan Quintela So remove it everywhere. Signed-off-by: Juan Quintela Reviewed-by: Vladimir Sementsov-Ogievskiy -- Best regards, Vladimir

[PATCH-for-7.2] Revert "hw/block/pflash_cfi: Error out if dev length isn't power of 2"

2022-11-08 Thread Philippe Mathieu-Daudé
Commit 334c388f25 ("pflash_cfi: Error out if device length isn't a power of two") aimed to finish the effort started by commit 06f1521795 ("pflash: Require backend size to match device, improve errors"), but unfortunately we are not quite there since various machines are still ready to accept

Re: [PATCH v3 01/17] migration: Remove res_compatible parameter

2022-11-08 Thread Vladimir Sementsov-Ogievskiy
On 11/3/22 19:16, Avihai Horon wrote: From: Juan Quintela It was only used for RAM, and in that case, it means that this amount of data was sent for memory. Not clear for me, what means "this amount of data was sent for memory"... That amount of data was not yet sent, actually. Just

[PATCH] block: m25p80: fix dummy byte count read from spansion cfg register

2022-11-08 Thread Ramon Aerne
Spansion nor-flash stores the dummy read count in bits in a config register. This is currently read and used as the byte count which is wrong. This patch fixes this bit to byte conversion without warning about unsupported configurations (such as bits % 8 != 0) Signed-off-by: Ramon Aerne ---

Re: [PATCH-for-7.2 1/2] hw/sd/sdhci: Do not set Buf Wr Ena before writing block (CVE-2022-3872)

2022-11-08 Thread Alexander Bulekov
On 221107 2312, Philippe Mathieu-Daudé wrote: > When sdhci_write_block_to_card() is called to transfer data from > the FIFO to the SD bus, the data is already present in the buffer > and we have to consume it directly. > > See the description of the 'Buffer Write Enable' bit from the > 'Present

Re: [PATCH v1 5/9] hw/virtio: introduce virtio_device_should_start

2022-11-08 Thread Alex Bennée
"Michael S. Tsirkin" writes: > On Tue, Nov 08, 2022 at 11:21:26AM +, Alex Bennée wrote: >> >> "Michael S. Tsirkin" writes: >> >> > On Tue, Nov 08, 2022 at 10:23:15AM +, Alex Bennée wrote: >> >> >> >> "Michael S. Tsirkin" writes: >> >> >> >> > On Tue, Nov 08, 2022 at 09:23:04AM

Re: [PATCH v2 2/9] block-copy: add missing coroutine_fn annotations

2022-11-08 Thread Vladimir Sementsov-Ogievskiy
On 11/8/22 19:19, Vladimir Sementsov-Ogievskiy wrote: This is a lot better than our "coroutine_fn" sign, which actually do no check (and can't do). Don't you plan to swap a "coroutine_fn" noop marker with more meaningful IN_COROUTINE(); (or something like this, which just do

Re: [PATCH v2 2/9] block-copy: add missing coroutine_fn annotations

2022-11-08 Thread Vladimir Sementsov-Ogievskiy
[add Stefan] On 11/8/22 18:09, Emanuele Giuseppe Esposito wrote: Am 08/11/2022 um 15:48 schrieb Vladimir Sementsov-Ogievskiy: On 11/4/22 12:56, Emanuele Giuseppe Esposito wrote: These functions end up calling bdrv_common_block_status_above(), a generated_co_wrapper function.

Re: [PATCH v2 1/9] block: call bdrv_co_drain_begin in a coroutine

2022-11-08 Thread Emanuele Giuseppe Esposito
Am 08/11/2022 um 16:52 schrieb Vladimir Sementsov-Ogievskiy: > On 11/8/22 18:13, Emanuele Giuseppe Esposito wrote: >> >> >> Am 08/11/2022 um 15:33 schrieb Vladimir Sementsov-Ogievskiy: >>> On 11/4/22 12:56, Emanuele Giuseppe Esposito wrote: It seems that bdrv_open_driver() forgot to create

Re: [PATCH v2 1/9] block: call bdrv_co_drain_begin in a coroutine

2022-11-08 Thread Vladimir Sementsov-Ogievskiy
On 11/8/22 18:13, Emanuele Giuseppe Esposito wrote: Am 08/11/2022 um 15:33 schrieb Vladimir Sementsov-Ogievskiy: On 11/4/22 12:56, Emanuele Giuseppe Esposito wrote: It seems that bdrv_open_driver() forgot to create a coroutine where to call bs->drv->bdrv_co_drain_begin(), a callback marked

Re: [PATCH v1 5/9] hw/virtio: introduce virtio_device_should_start

2022-11-08 Thread Michael S. Tsirkin
On Tue, Nov 08, 2022 at 11:21:26AM +, Alex Bennée wrote: > > "Michael S. Tsirkin" writes: > > > On Tue, Nov 08, 2022 at 10:23:15AM +, Alex Bennée wrote: > >> > >> "Michael S. Tsirkin" writes: > >> > >> > On Tue, Nov 08, 2022 at 09:23:04AM +, Alex Bennée wrote: > >> >> The

Re: [PATCH v2 8/9] block: bdrv_create is never called in non-coroutine context

2022-11-08 Thread Kevin Wolf
Am 04.11.2022 um 10:56 hat Emanuele Giuseppe Esposito geschrieben: > Delete the if case and make sure it won't be called again > in coroutines. > > Signed-off-by: Emanuele Giuseppe Esposito > Reviewed-by: Paolo Bonzini In the subject line, it should be "never called in coroutine context"

Re: [PATCH v2 1/9] block: call bdrv_co_drain_begin in a coroutine

2022-11-08 Thread Kevin Wolf
Am 08.11.2022 um 15:33 hat Vladimir Sementsov-Ogievskiy geschrieben: > On 11/4/22 12:56, Emanuele Giuseppe Esposito wrote: > > It seems that bdrv_open_driver() forgot to create a coroutine > > where to call bs->drv->bdrv_co_drain_begin(), a callback > > marked as coroutine_fn. > > > > Because

Re: [PATCH v2 1/9] block: call bdrv_co_drain_begin in a coroutine

2022-11-08 Thread Emanuele Giuseppe Esposito
Am 08/11/2022 um 15:33 schrieb Vladimir Sementsov-Ogievskiy: > On 11/4/22 12:56, Emanuele Giuseppe Esposito wrote: >> It seems that bdrv_open_driver() forgot to create a coroutine >> where to call bs->drv->bdrv_co_drain_begin(), a callback >> marked as coroutine_fn. >> >> Because there is no

Re: [PATCH v2 2/9] block-copy: add missing coroutine_fn annotations

2022-11-08 Thread Emanuele Giuseppe Esposito
Am 08/11/2022 um 15:48 schrieb Vladimir Sementsov-Ogievskiy: > On 11/4/22 12:56, Emanuele Giuseppe Esposito wrote: >> These functions end up calling bdrv_common_block_status_above(), a >> generated_co_wrapper function. > > generated_co_wrapper is not a coroutine_fn. Сonversely it's a function

Re: [PATCH v2 5/9] block: distinguish between bdrv_create running in coroutine and not

2022-11-08 Thread Vladimir Sementsov-Ogievskiy
On 11/4/22 12:56, Emanuele Giuseppe Esposito wrote: Call two different functions depending on whether bdrv_create is in coroutine or not, following the same pattern as generated_co_wrapper functions. This allows to also call the coroutine function directly, without using CreateCo or relying in

Re: [PATCH v3 4/4] hw/nvme: add polling support

2022-11-08 Thread John Levon
On Fri, Nov 04, 2022 at 07:32:12AM +0100, Klaus Jensen wrote: > On Nov 3 21:19, Jinhao Fan wrote: > > On 11/3/2022 8:10 PM, Klaus Jensen wrote: > > > I agree that the spec is a little unclear on this point. In any case, in > > > Linux, when the driver has decided that the sq tail must be

Re: [PATCH v2 3/9] nbd/server.c: add missing coroutine_fn annotations

2022-11-08 Thread Vladimir Sementsov-Ogievskiy
On 11/4/22 12:56, Emanuele Giuseppe Esposito wrote: These functions end up calling bdrv_*() implemented as generated_co_wrapper functions. Same here. Sorry that I joined only on v3. In past we had a lot of "coroutine wrappers", each IO function in block/io.c and many in block.c had two

Re: [PATCH v2 2/9] block-copy: add missing coroutine_fn annotations

2022-11-08 Thread Vladimir Sementsov-Ogievskiy
On 11/4/22 12:56, Emanuele Giuseppe Esposito wrote: These functions end up calling bdrv_common_block_status_above(), a generated_co_wrapper function. generated_co_wrapper is not a coroutine_fn. Сonversely it's a function that do a class coroutine wrapping - start a coroutine and do POLL to

[PATCH for-7.2] block/blkio: Set BlockDriver::has_variable_length to false

2022-11-08 Thread Alberto Faria
Setting it to true can cause the device size to be queried from libblkio in otherwise fast paths, degrading performance. Set it to false and require users to refresh the device size explicitly instead. Fixes: 4c8f4fda0504 ("block/blkio: Tolerate device size changes") Suggested-by: Kevin Wolf

Re: [PATCH v2 1/9] block: call bdrv_co_drain_begin in a coroutine

2022-11-08 Thread Vladimir Sementsov-Ogievskiy
On 11/4/22 12:56, Emanuele Giuseppe Esposito wrote: It seems that bdrv_open_driver() forgot to create a coroutine where to call bs->drv->bdrv_co_drain_begin(), a callback marked as coroutine_fn. Because there is no active I/O at this point, the coroutine should end right after entering, so the

[PATCH] qapi/block-core: Fix BlockdevOptionsNvmeIoUring @path description

2022-11-08 Thread Alberto Faria
The nvme-io_uring BlockDriver's path option must point at the character device of an NVMe namespace, not at an image file. Fixes: fd66dbd424f5 ("blkio: add libblkio block driver") Suggested-by: Stefano Garzarella Signed-off-by: Alberto Faria --- qapi/block-core.json | 2 +- 1 file changed, 1

Re: [PATCH v2 0/3] block: Start/end drain on correct AioContext

2022-11-08 Thread Kevin Wolf
Am 08.11.2022 um 15:13 hat Kevin Wolf geschrieben: > Am 07.11.2022 um 16:13 hat Hanna Reitz geschrieben: > > Hi, > > > > v1 cover letter: > > https://lists.nongnu.org/archive/html/qemu-block/2022-09/msg00389.html > > > > bdrv_replace_child_noperm() drains the child via > >

Re: [PATCH v3 09/30] nbd/server: Clean up abuse of BlockExportOptionsNbd member @arg

2022-11-08 Thread Vladimir Sementsov-Ogievskiy
On 11/4/22 19:06, Markus Armbruster wrote: block-export-add argument @name defaults to the value of argument @node-name. nbd_export_create() implements this by copying @node_name to @name. It leaves @has_node_name false, violating the "has_node_name == !!node_name" invariant. Unclean. Falls

Re: [PATCH v2 0/3] block: Start/end drain on correct AioContext

2022-11-08 Thread Kevin Wolf
Am 07.11.2022 um 16:13 hat Hanna Reitz geschrieben: > Hi, > > v1 cover letter: > https://lists.nongnu.org/archive/html/qemu-block/2022-09/msg00389.html > > bdrv_replace_child_noperm() drains the child via > bdrv_parent_drained_{begin,end}_single(). When it removes a child, the >

Re: [PATCH v3 4/4] hw/nvme: add polling support

2022-11-08 Thread Klaus Jensen
On Nov 8 12:39, John Levon wrote: > On Fri, Nov 04, 2022 at 07:32:12AM +0100, Klaus Jensen wrote: > > > On Nov 3 21:19, Jinhao Fan wrote: > > > On 11/3/2022 8:10 PM, Klaus Jensen wrote: > > > > I agree that the spec is a little unclear on this point. In any case, in > > > > Linux, when the

[PATCH 05/13] block: Inline bdrv_drain_invoke()

2022-11-08 Thread Kevin Wolf
bdrv_drain_invoke() has now two entirely separate cases that share no code any more and are selected depending on a bool parameter. Each case has only one caller. Just inline the function. Signed-off-by: Kevin Wolf --- block/io.c | 23 ++- 1 file changed, 6 insertions(+), 17

[PATCH 12/13] block: Don't poll in bdrv_replace_child_noperm()

2022-11-08 Thread Kevin Wolf
In order to make sure that bdrv_replace_child_noperm() doesn't have to poll any more, get rid of the bdrv_parent_drained_begin_single() call. This is possible now because we can require that the child is already drained when the function is called (it better be, having in-flight requests while

[PATCH 09/13] block: Remove subtree drains

2022-11-08 Thread Kevin Wolf
Subtree drains are not used any more. Remove them. After this, BdrvChildClass.attach/detach() don't poll any more. Signed-off-by: Kevin Wolf --- include/block/block-io.h | 18 +-- include/block/block_int-common.h | 1 - include/block/block_int-io.h | 12 -- block.c

[PATCH 07/13] block: Don't use subtree drains in bdrv_drop_intermediate()

2022-11-08 Thread Kevin Wolf
Instead of using a subtree drain from the top node (which also drains child nodes of base that we're not even interested in), use a normal drain for base, which automatically drains all of the parents, too. Signed-off-by: Kevin Wolf --- block.c | 4 ++-- 1 file changed, 2 insertions(+), 2

[PATCH 10/13] block: Call drain callbacks only once

2022-11-08 Thread Kevin Wolf
We only need to call both the BlockDriver's callback and the parent callbacks when going from undrained to drained or vice versa. A second drain section doesn't make a difference for the driver or the parent, they weren't supposed to send new requests before and after the second drain. One thing

[PATCH 11/13] block: Remove ignore_bds_parents parameter from drain functions

2022-11-08 Thread Kevin Wolf
ignore_bds_parents is now ignored, so we can just remove it. Signed-off-by: Kevin Wolf --- include/block/block-io.h | 10 ++ block.c | 4 +-- block/io.c | 78 +++- 3 files changed, 32 insertions(+), 60 deletions(-) diff

[PATCH 02/13] test-bdrv-drain: Don't yield in .bdrv_co_drained_begin/end()

2022-11-08 Thread Kevin Wolf
We want to change .bdrv_co_drained_begin/end() back to be non-coroutine callbacks, so in preparation, avoid yielding in their implementation. This does almost the same as the existing logic in bdrv_drain_invoke(), by creating and entering coroutines internally. However, since the test case is by

[PATCH 13/13] block: Remove poll parameter from bdrv_parent_drained_begin_single()

2022-11-08 Thread Kevin Wolf
All callers of bdrv_parent_drained_begin_single() pass poll=false now, so we don't need the parameter any more. Signed-off-by: Kevin Wolf --- include/block/block-io.h | 5 ++--- block.c | 4 ++-- block/io.c | 7 ++- 3 files changed, 6 insertions(+), 10

[PATCH 08/13] stream: Replace subtree drain with a single node drain

2022-11-08 Thread Kevin Wolf
The subtree drain was introduced in commit b1e1af394d9 as a way to avoid graph changes between finding the base node and changing the block graph as necessary on completion of the image streaming job. The block graph could change between these two points because bdrv_set_backing_hd() first drains

[PATCH 00/13] block: Simplify drain

2022-11-08 Thread Kevin Wolf
I'm aware that exactly nobody has been looking forward to a series with this title, but it has to be. The way drain works means that we need to poll in bdrv_replace_child_noperm() and that makes things rather messy with Emanuele's multiqueue work because you must not poll while you hold the graph

[PATCH 04/13] block: Remove drained_end_counter

2022-11-08 Thread Kevin Wolf
drained_end_counter is unused now, nobody changes its value any more. It can be removed. In cases where we had two almost identical functions that only differed in whether the caller passes drained_end_counter, or whether they would poll for a local drained_end_counter to reach 0, these become a

[PATCH 06/13] block: Drain invidual nodes during reopen

2022-11-08 Thread Kevin Wolf
bdrv_reopen() and friends use subtree drains as a lazy way of covering all the nodes they touch. Turns out that this lazy way is a lot more complicated than just draining the nodes individually, even not accounting for the additional complexity in the drain mechanism itself. Simplify the code by

[PATCH 01/13] qed: Don't yield in bdrv_qed_co_drain_begin()

2022-11-08 Thread Kevin Wolf
We want to change .bdrv_co_drained_begin() back to be a non-coroutine callback, so in preparation, avoid yielding in its implementation. Because we increase bs->in_flight and bdrv_drained_begin() polls, the behaviour is unchanged. Signed-off-by: Kevin Wolf --- block/qed.c | 20

[PATCH 03/13] block: Revert .bdrv_drained_begin/end to non-coroutine_fn

2022-11-08 Thread Kevin Wolf
Polling during bdrv_drained_end() can be problematic (and in the future, we may get cases for bdrv_drained_begin() where polling is forbidden, and we don't care about already in-flight requests, but just want to prevent new requests from arriving). The .bdrv_drained_begin/end callbacks running in

Re: [PATCH v1 5/9] hw/virtio: introduce virtio_device_should_start

2022-11-08 Thread Alex Bennée
"Michael S. Tsirkin" writes: > On Tue, Nov 08, 2022 at 10:23:15AM +, Alex Bennée wrote: >> >> "Michael S. Tsirkin" writes: >> >> > On Tue, Nov 08, 2022 at 09:23:04AM +, Alex Bennée wrote: >> >> The previous fix to virtio_device_started revealed a problem in its >> >> use by both the

Re: [PATCH v1 5/9] hw/virtio: introduce virtio_device_should_start

2022-11-08 Thread Michael S. Tsirkin
On Tue, Nov 08, 2022 at 10:23:15AM +, Alex Bennée wrote: > > "Michael S. Tsirkin" writes: > > > On Tue, Nov 08, 2022 at 09:23:04AM +, Alex Bennée wrote: > >> The previous fix to virtio_device_started revealed a problem in its > >> use by both the core and the device code. The core code

Re: [PATCH v1 5/9] hw/virtio: introduce virtio_device_should_start

2022-11-08 Thread Alex Bennée
"Michael S. Tsirkin" writes: > On Tue, Nov 08, 2022 at 09:23:04AM +, Alex Bennée wrote: >> The previous fix to virtio_device_started revealed a problem in its >> use by both the core and the device code. The core code should be able >> to handle the device "starting" while the VM isn't

Re: [PATCH v1 5/9] hw/virtio: introduce virtio_device_should_start

2022-11-08 Thread Michael S. Tsirkin
On Tue, Nov 08, 2022 at 09:23:04AM +, Alex Bennée wrote: > The previous fix to virtio_device_started revealed a problem in its > use by both the core and the device code. The core code should be able > to handle the device "starting" while the VM isn't running to handle > the restoration of

Re: [PATCH v1 5/9] hw/virtio: introduce virtio_device_should_start

2022-11-08 Thread Michael S. Tsirkin
On Tue, Nov 08, 2022 at 09:23:04AM +, Alex Bennée wrote: > The previous fix to virtio_device_started revealed a problem in its > use by both the core and the device code. The core code should be able > to handle the device "starting" while the VM isn't running to handle > the restoration of

[PATCH v1 5/9] hw/virtio: introduce virtio_device_should_start

2022-11-08 Thread Alex Bennée
The previous fix to virtio_device_started revealed a problem in its use by both the core and the device code. The core code should be able to handle the device "starting" while the VM isn't running to handle the restoration of migration state. To solve this dual use introduce a new helper for use

Re: [PATCH-for-7.2 1/2] hw/sd/sdhci: Do not set Buf Wr Ena before writing block (CVE-2022-3872)

2022-11-08 Thread Mauro Matteo Cascella
On Mon, Nov 7, 2022 at 11:12 PM Philippe Mathieu-Daudé wrote: > > When sdhci_write_block_to_card() is called to transfer data from > the FIFO to the SD bus, the data is already present in the buffer > and we have to consume it directly. > > See the description of the 'Buffer Write Enable' bit