Re: [PATCH 17/24] block: Protect bs->backing with graph_lock

2023-10-27 Thread Eric Blake
On Fri, Oct 27, 2023 at 05:53:26PM +0200, Kevin Wolf wrote: > Almost all functions that access bs->backing already take the graph > lock now. Add locking to the remaining users and finally annotate the > struct field itself as protected by the graph lock. > > Signed-off-by: Kevin Wolf > --- >

Re: [PATCH 16/24] block: Mark bdrv_replace_node() GRAPH_WRLOCK

2023-10-27 Thread Eric Blake
On Fri, Oct 27, 2023 at 05:53:25PM +0200, Kevin Wolf wrote: > Instead of taking the writer lock internally, require callers to already > hold it when calling bdrv_replace_node(). Its callers may already want > to hold the graph lock and so wouldn't be able to call functions that > take it

Re: [PATCH 15/24] block: Mark bdrv_replace_node_common() GRAPH_WRLOCK

2023-10-27 Thread Eric Blake
On Fri, Oct 27, 2023 at 05:53:24PM +0200, Kevin Wolf wrote: > Instead of taking the writer lock internally, require callers to already > hold it when calling bdrv_replace_node_common(). Basically everthing in > the function needs the lock and its callers may already want to hold the > graph lock

Re: [PATCH 14/24] block: Inline bdrv_set_backing_noperm()

2023-10-27 Thread Eric Blake
On Fri, Oct 27, 2023 at 05:53:23PM +0200, Kevin Wolf wrote: > It's only a single line and has a single caller. Inlining makes things > a bit easier to follow. > > Signed-off-by: Kevin Wolf > --- > block.c | 14 +- > 1 file changed, 1 insertion(+), 13 deletions(-) > Reviewed-by:

Re: [PATCH 13/24] block: Mark bdrv_set_backing_hd_drained() GRAPH_WRLOCK

2023-10-27 Thread Eric Blake
On Fri, Oct 27, 2023 at 05:53:22PM +0200, Kevin Wolf wrote: > Instead of taking the writer lock internally, require callers to already > hold it when calling bdrv_set_backing_hd_drained(). Basically everthing > in the function needs the lock and its callers may already want to hold > the graph

Re: [PATCH 12/24] block: Mark bdrv_cow_child() and callers GRAPH_RDLOCK

2023-10-27 Thread Eric Blake
On Fri, Oct 27, 2023 at 05:53:21PM +0200, Kevin Wolf wrote: > This adds GRAPH_RDLOCK annotations to declare that callers of > bdrv_cow_child() need to hold a reader lock for the graph because it > accesses bs->backing. > > Signed-off-by: Kevin Wolf > --- > include/block/block_int-io.h | 5

Re: [PATCH 11/24] block: Mark bdrv_filter_child() and callers GRAPH_RDLOCK

2023-10-27 Thread Eric Blake
On Fri, Oct 27, 2023 at 05:53:20PM +0200, Kevin Wolf wrote: > This adds GRAPH_RDLOCK annotations to declare that callers of > bdrv_filter_child() need to hold a reader lock for the graph because it > accesses bs->file/backing. > > Signed-off-by: Kevin Wolf > --- > include/block/block_int-io.h |

Re: [PATCH 10/24] block: Mark bdrv_chain_contains() and callers GRAPH_RDLOCK

2023-10-27 Thread Eric Blake
On Fri, Oct 27, 2023 at 05:53:19PM +0200, Kevin Wolf wrote: > This adds GRAPH_RDLOCK annotations to declare that callers of > bdrv_chain_contains() need to hold a reader lock for the graph because > it calls bdrv_filter_or_cow_bs(), which accesses bs->file/backing. > > Signed-off-by: Kevin Wolf

Re: [PATCH 09/24] block: Mark bdrv_(un)freeze_backing_chain() and callers GRAPH_RDLOCK

2023-10-27 Thread Eric Blake
On Fri, Oct 27, 2023 at 05:53:18PM +0200, Kevin Wolf wrote: > This adds GRAPH_RDLOCK annotations to declare that callers of > bdrv_(un)freeze_backing_chain() need to hold a reader lock for the > graph because it calls bdrv_filter_or_cow_child(), which accesses > bs->file/backing. > > Use the

Re: [PATCH 08/24] block: Mark bdrv_skip_filters() and callers GRAPH_RDLOCK

2023-10-27 Thread Eric Blake
On Fri, Oct 27, 2023 at 05:53:17PM +0200, Kevin Wolf wrote: > This adds GRAPH_RDLOCK annotations to declare that callers of > bdrv_skip_filters() need to hold a reader lock for the graph because it > calls bdrv_filter_child(), which accesses bs->file/backing. > > Signed-off-by: Kevin Wolf > ---

Re: [PATCH 03/24] block: Mark bdrv_filter_bs() and callers GRAPH_RDLOCK

2023-10-27 Thread Eric Blake
On Fri, Oct 27, 2023 at 03:02:38PM -0500, Eric Blake wrote: > On Fri, Oct 27, 2023 at 05:53:12PM +0200, Kevin Wolf wrote: > > This adds GRAPH_RDLOCK annotations to declare that callers of > > bdrv_filter_bs() need to hold a reader lock for the graph because > > it calls bdrv_filter_child(), which

Re: [PATCH 07/24] block: Mark bdrv_skip_implicit_filters() and callers GRAPH_RDLOCK

2023-10-27 Thread Eric Blake
On Fri, Oct 27, 2023 at 05:53:16PM +0200, Kevin Wolf wrote: > This adds GRAPH_RDLOCK annotations to declare that callers of > bdrv_skip_implicit_filters() need to hold a reader lock for the graph > because it calls bdrv_filter_child(), which accesses bs->file/backing. > > Signed-off-by: Kevin

Re: [PATCH 06/24] block: Mark bdrv_filter_or_cow_bs() and callers GRAPH_RDLOCK

2023-10-27 Thread Eric Blake
On Fri, Oct 27, 2023 at 05:53:15PM +0200, Kevin Wolf wrote: > This adds GRAPH_RDLOCK annotations to declare that callers of > bdrv_filter_or_cow_bs() need to hold a reader lock for the graph because > it calls bdrv_filter_or_cow_child(), which accesses bs->file/backing. > > Signed-off-by: Kevin

Re: [PATCH 05/24] block: Mark block_job_add_bdrv() GRAPH_WRLOCK

2023-10-27 Thread Eric Blake
On Fri, Oct 27, 2023 at 05:53:14PM +0200, Kevin Wolf wrote: > Instead of taking the writer lock internally, require callers to already > hold it when calling block_job_add_bdrv(). These callers will typically > already hold the graph lock once the locking work is completed, which > means that they

Re: [PATCH 04/24] block: Mark bdrv_root_attach_child() GRAPH_WRLOCK

2023-10-27 Thread Eric Blake
On Fri, Oct 27, 2023 at 05:53:13PM +0200, Kevin Wolf wrote: > Instead of taking the writer lock internally, require callers to already > hold it when calling bdrv_root_attach_child(). These callers will > typically already hold the graph lock once the locking work is > completed, which means that

Re: [PATCH 03/24] block: Mark bdrv_filter_bs() and callers GRAPH_RDLOCK

2023-10-27 Thread Eric Blake
On Fri, Oct 27, 2023 at 05:53:12PM +0200, Kevin Wolf wrote: > This adds GRAPH_RDLOCK annotations to declare that callers of > bdrv_filter_bs() need to hold a reader lock for the graph because > it calls bdrv_filter_child(), which accesses bs->file/backing. > > Signed-off-by: Kevin Wolf > --- >

Re: [PATCH 02/24] block: Mark bdrv_has_zero_init() and callers GRAPH_RDLOCK

2023-10-27 Thread Eric Blake
On Fri, Oct 27, 2023 at 05:53:11PM +0200, Kevin Wolf wrote: > This adds GRAPH_RDLOCK annotations to declare that callers of > bdrv_has_zero_init() need to hold a reader lock for the graph because > it calls bdrv_filter_bs(), which accesses bs->file/backing. > > Signed-off-by: Kevin Wolf > --- >

Re: [PATCH 01/24] block: Mark bdrv_probe_blocksizes() and callers GRAPH_RDLOCK

2023-10-27 Thread Eric Blake
On Fri, Oct 27, 2023 at 05:53:10PM +0200, Kevin Wolf wrote: > This adds GRAPH_RDLOCK annotations to declare that callers of > bdrv_probe_blocksizes() need to hold a reader lock for the graph because > it calls bdrv_filter_bs(), which accesses bs->file/backing. > > Signed-off-by: Kevin Wolf > ---

[PATCH 24/24] block: Protect bs->file with graph_lock

2023-10-27 Thread Kevin Wolf
Almost all functions that access bs->file already take the graph lock now. Add locking to the remaining users and finally annotate the struct field itself as protected by the graph lock. Signed-off-by: Kevin Wolf --- block/parallels.h| 5 +++-- block/qed.h

[PATCH 16/24] block: Mark bdrv_replace_node() GRAPH_WRLOCK

2023-10-27 Thread Kevin Wolf
Instead of taking the writer lock internally, require callers to already hold it when calling bdrv_replace_node(). Its callers may already want to hold the graph lock and so wouldn't be able to call functions that take it internally. Signed-off-by: Kevin Wolf ---

[PATCH 23/24] block: Take graph lock for most of .bdrv_open

2023-10-27 Thread Kevin Wolf
Most implementations of .bdrv_open first open their file child (which is an operation that internally takes the write lock and therefore we shouldn't hold the graph lock while calling it), and afterwards many operations that require holding the graph lock, e.g. for accessing bs->file. This

[PATCH 04/24] block: Mark bdrv_root_attach_child() GRAPH_WRLOCK

2023-10-27 Thread Kevin Wolf
Instead of taking the writer lock internally, require callers to already hold it when calling bdrv_root_attach_child(). These callers will typically already hold the graph lock once the locking work is completed, which means that they can't call functions that take it internally. Signed-off-by:

[PATCH 12/24] block: Mark bdrv_cow_child() and callers GRAPH_RDLOCK

2023-10-27 Thread Kevin Wolf
This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_cow_child() need to hold a reader lock for the graph because it accesses bs->backing. Signed-off-by: Kevin Wolf --- include/block/block_int-io.h | 5 +++-- block/stream.c | 2 +- qemu-img.c | 11

[PATCH 10/24] block: Mark bdrv_chain_contains() and callers GRAPH_RDLOCK

2023-10-27 Thread Kevin Wolf
This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_chain_contains() need to hold a reader lock for the graph because it calls bdrv_filter_or_cow_bs(), which accesses bs->file/backing. Signed-off-by: Kevin Wolf --- include/block/block-global-state.h | 4 ++- block.c

[PATCH 14/24] block: Inline bdrv_set_backing_noperm()

2023-10-27 Thread Kevin Wolf
It's only a single line and has a single caller. Inlining makes things a bit easier to follow. Signed-off-by: Kevin Wolf --- block.c | 14 +- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/block.c b/block.c index d79a6f41f9..dc43e36f69 100644 --- a/block.c +++

[PATCH 15/24] block: Mark bdrv_replace_node_common() GRAPH_WRLOCK

2023-10-27 Thread Kevin Wolf
Instead of taking the writer lock internally, require callers to already hold it when calling bdrv_replace_node_common(). Basically everthing in the function needs the lock and its callers may already want to hold the graph lock and so wouldn't be able to call functions that take it internally.

[PATCH 11/24] block: Mark bdrv_filter_child() and callers GRAPH_RDLOCK

2023-10-27 Thread Kevin Wolf
This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_filter_child() need to hold a reader lock for the graph because it accesses bs->file/backing. Signed-off-by: Kevin Wolf --- include/block/block_int-io.h | 4 ++-- block.c | 4 ++-- 2 files changed, 4

[PATCH 05/24] block: Mark block_job_add_bdrv() GRAPH_WRLOCK

2023-10-27 Thread Kevin Wolf
Instead of taking the writer lock internally, require callers to already hold it when calling block_job_add_bdrv(). These callers will typically already hold the graph lock once the locking work is completed, which means that they can't call functions that take it internally. Signed-off-by: Kevin

[PATCH 13/24] block: Mark bdrv_set_backing_hd_drained() GRAPH_WRLOCK

2023-10-27 Thread Kevin Wolf
Instead of taking the writer lock internally, require callers to already hold it when calling bdrv_set_backing_hd_drained(). Basically everthing in the function needs the lock and its callers may already want to hold the graph lock and so wouldn't be able to call functions that take it internally.

[PATCH 20/24] block: Add missing GRAPH_RDLOCK annotations

2023-10-27 Thread Kevin Wolf
This adds GRAPH_RDLOCK to some driver callbacks that are already called with the graph lock held, and which will need the annotation because they access bs->file, but don't have it yet. This also covers a few callbacks that were not marked GRAPH_RDLOCK before, but where updating BlockDriver is

[PATCH 18/24] blkverify: Add locking for request_fn

2023-10-27 Thread Kevin Wolf
This is either bdrv_co_preadv() or bdrv_co_pwritev() which both need to have the graph locked. Annotate the function pointer accordingly and add locking to its callers. This shouldn't actually have resulted in a bug because the graph lock is already held by blkverify_co_prwv(), which waits for

[PATCH 07/24] block: Mark bdrv_skip_implicit_filters() and callers GRAPH_RDLOCK

2023-10-27 Thread Kevin Wolf
This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_skip_implicit_filters() need to hold a reader lock for the graph because it calls bdrv_filter_child(), which accesses bs->file/backing. Signed-off-by: Kevin Wolf --- include/block/block_int-global-state.h | 3 ++- block.c

[PATCH 08/24] block: Mark bdrv_skip_filters() and callers GRAPH_RDLOCK

2023-10-27 Thread Kevin Wolf
This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_skip_filters() need to hold a reader lock for the graph because it calls bdrv_filter_child(), which accesses bs->file/backing. Signed-off-by: Kevin Wolf --- include/block/block-global-state.h | 8 ---

[PATCH 19/24] block: Introduce bdrv_co_change_backing_file()

2023-10-27 Thread Kevin Wolf
bdrv_change_backing_file() is called both inside and outside coroutine context. This makes it difficult for it to take the graph lock internally. It also means that driver implementations need to be able to run outside of coroutines, too. Switch it to the usual model with a coroutine based

[PATCH 09/24] block: Mark bdrv_(un)freeze_backing_chain() and callers GRAPH_RDLOCK

2023-10-27 Thread Kevin Wolf
This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_(un)freeze_backing_chain() need to hold a reader lock for the graph because it calls bdrv_filter_or_cow_child(), which accesses bs->file/backing. Use the opportunity to make bdrv_is_backing_chain_frozen() static, it has no

[PATCH 06/24] block: Mark bdrv_filter_or_cow_bs() and callers GRAPH_RDLOCK

2023-10-27 Thread Kevin Wolf
This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_filter_or_cow_bs() need to hold a reader lock for the graph because it calls bdrv_filter_or_cow_child(), which accesses bs->file/backing. Signed-off-by: Kevin Wolf --- include/block/block_int-io.h | 3 ++- block.c

[PATCH 21/24] qcow2: Take locks for accessing bs->file

2023-10-27 Thread Kevin Wolf
This updates the qcow2 code to add GRAPH_RDLOCK annotations for all places that read bs->file. Signed-off-by: Kevin Wolf --- block/qcow2.h | 48 ++- block/qcow2-bitmap.c | 14 +++-- block/qcow2-cluster.c | 25 +++---

[PATCH 03/24] block: Mark bdrv_filter_bs() and callers GRAPH_RDLOCK

2023-10-27 Thread Kevin Wolf
This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_filter_bs() need to hold a reader lock for the graph because it calls bdrv_filter_child(), which accesses bs->file/backing. Signed-off-by: Kevin Wolf --- include/block/block-io.h | 2 +- include/block/block_int-io.h | 3

[PATCH 01/24] block: Mark bdrv_probe_blocksizes() and callers GRAPH_RDLOCK

2023-10-27 Thread Kevin Wolf
This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_probe_blocksizes() need to hold a reader lock for the graph because it calls bdrv_filter_bs(), which accesses bs->file/backing. Signed-off-by: Kevin Wolf --- include/block/block-global-state.h | 2 +-

[PATCH 22/24] vhdx: Take locks for accessing bs->file

2023-10-27 Thread Kevin Wolf
This updates the vhdx code to add GRAPH_RDLOCK annotations for all places that read bs->file. Signed-off-by: Kevin Wolf --- block/vhdx.h | 9 ++--- block/vhdx-log.c | 40 ++-- block/vhdx.c | 18 +++--- 3 files changed, 39

[PATCH 17/24] block: Protect bs->backing with graph_lock

2023-10-27 Thread Kevin Wolf
Almost all functions that access bs->backing already take the graph lock now. Add locking to the remaining users and finally annotate the struct field itself as protected by the graph lock. Signed-off-by: Kevin Wolf --- include/block/block_int-common.h | 2 +- block.c

[PATCH 02/24] block: Mark bdrv_has_zero_init() and callers GRAPH_RDLOCK

2023-10-27 Thread Kevin Wolf
This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_has_zero_init() need to hold a reader lock for the graph because it calls bdrv_filter_bs(), which accesses bs->file/backing. Signed-off-by: Kevin Wolf --- include/block/block-global-state.h | 2 +-

[PATCH 00/24] block: Graph locking part 6 (bs->file/backing)

2023-10-27 Thread Kevin Wolf
This series is pleasantly boring for the most part and results in a GRAPH_RDLOCK_PTR annotation for bs->file and bs->backing. Kevin Wolf (24): block: Mark bdrv_probe_blocksizes() and callers GRAPH_RDLOCK block: Mark bdrv_has_zero_init() and callers GRAPH_RDLOCK block: Mark bdrv_filter_bs()

Re: [PATCH 4/7] qcow2: make subclusters discardable

2023-10-27 Thread Jean-Louis Dupond
On 20/10/2023 23:56, Andrey Drobyshev wrote: This commit makes the discard operation work on the subcluster level rather than cluster level. It introduces discard_l2_subclusters() function and makes use of it in qcow2 discard implementation, much like it's done with zero_in_l2_slice() /

Re: [PATCH v3 13/28] hw/xen: automatically assign device index to block devices

2023-10-27 Thread David Woodhouse
On Fri, 2023-10-27 at 11:32 +0100, Durrant, Paul wrote: > On 27/10/2023 11:25, David Woodhouse wrote: > > On Fri, 2023-10-27 at 10:01 +0100, Durrant, Paul wrote: > > > > > > This code is allocating a name automatically so I think the onus is on > > > it not create a needless clash which is likely

Re: [PATCH v3 13/28] hw/xen: automatically assign device index to block devices

2023-10-27 Thread Durrant, Paul
On 27/10/2023 11:25, David Woodhouse wrote: On Fri, 2023-10-27 at 10:01 +0100, Durrant, Paul wrote: This code is allocating a name automatically so I think the onus is on it not create a needless clash which is likely to have unpredictable results depending on what the guest is. Just avoid any

Re: [PATCH v3 13/28] hw/xen: automatically assign device index to block devices

2023-10-27 Thread David Woodhouse
On Fri, 2023-10-27 at 10:01 +0100, Durrant, Paul wrote: > > This code is allocating a name automatically so I think the onus is on > it not create a needless clash which is likely to have unpredictable > results depending on what the guest is. Just avoid any aliasing in the > first place and

Re: [PATCH v3 27/28] hw/xen: use qemu_create_nic_bus_devices() to instantiate Xen NICs

2023-10-27 Thread Durrant, Paul
On 25/10/2023 15:50, David Woodhouse wrote: From: David Woodhouse When instantiating XenBus itself, for each NIC which is configured with either the model unspecified, or set to to "xen" or "xen-net-device", create a corresponding xen-net-device for it. Now we can launch emulated Xen guests

Re: [PATCH v3 26/28] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_devices()

2023-10-27 Thread Durrant, Paul
On 25/10/2023 15:50, David Woodhouse wrote: From: David Woodhouse Eliminate direct access to nd_table[] and nb_nics by processing the the ISA NICs first and then calling pci_init_nic_devices() for the test. It's important to do this *before* the subsequent patch which registers the Xen PV

Re: [PATCH v3 25/28] hw/pci: add pci_init_nic_devices(), pci_init_nic_in_slot()

2023-10-27 Thread Durrant, Paul
On 25/10/2023 15:50, David Woodhouse wrote: From: David Woodhouse The loop over nd_table[] to add PCI NICs is repeated in quite a few places. Add a helper function to do it. Some platforms also try to instantiate a specific model in a specific slot, to match the real hardware. Add

Re: [PATCH v3 24/28] net: add qemu_create_nic_bus_devices()

2023-10-27 Thread Durrant, Paul
On 25/10/2023 15:50, David Woodhouse wrote: From: David Woodhouse This will instantiate any NICs which live on a given bus type. Each bus is allowed *one* substitution (for PCI it's virtio → virtio-net-pci, for Xen it's xen → xen-net-device; no point in overengineering it unless we actually

Re: [PATCH v3 23/28] net: report list of available models according to platform

2023-10-27 Thread Durrant, Paul
On 25/10/2023 15:50, David Woodhouse wrote: From: David Woodhouse By noting the models for which a configuration was requested, we can give the user an accurate list of which NIC models were actually available on the platform/configuration that was otherwise chosen. Signed-off-by: David

Re: [PATCH v3 22/28] net: add qemu_{configure,create}_nic_device(), qemu_find_nic_info()

2023-10-27 Thread Durrant, Paul
On 25/10/2023 15:50, David Woodhouse wrote: From: David Woodhouse Most code which directly accesses nd_table[] and nb_nics uses them for one of two things. Either "I have created a NIC device and I'd like a configuration for it", or "I will create a NIC device *if* there is a configuration for

Re: [PATCH v3 21/28] xen-platform: unplug AHCI disks

2023-10-27 Thread Durrant, Paul
On 25/10/2023 15:50, David Woodhouse wrote: From: David Woodhouse To support Xen guests using the Q35 chipset, the unplug protocol needs to also remove AHCI disks. Make pci_xen_ide_unplug() more generic, iterating over the children of the PCI device and destroying the "ide-hd" devices. That

Re: [PATCH v3 13/28] hw/xen: automatically assign device index to block devices

2023-10-27 Thread Durrant, Paul
On 27/10/2023 09:45, David Woodhouse wrote: On Fri, 2023-10-27 at 08:30 +0100, Durrant, Paul wrote: +    if (blockdev->props.vdev.type == XEN_BLOCK_VDEV_TYPE_INVALID) { +    XenBus *xenbus = XEN_BUS(qdev_get_parent_bus(DEVICE(xendev))); +    char fe_path[XENSTORE_ABS_PATH_MAX + 1]; +  

Re: [PATCH v3 13/28] hw/xen: automatically assign device index to block devices

2023-10-27 Thread David Woodhouse
On Fri, 2023-10-27 at 08:30 +0100, Durrant, Paul wrote: > > > +    if (blockdev->props.vdev.type == XEN_BLOCK_VDEV_TYPE_INVALID) { > > +    XenBus *xenbus = XEN_BUS(qdev_get_parent_bus(DEVICE(xendev))); > > +    char fe_path[XENSTORE_ABS_PATH_MAX + 1]; > > +    char *value; > > +  

Re: [PATCH v3 20/28] net: do not delete nics in net_cleanup()

2023-10-27 Thread Durrant, Paul
On 25/10/2023 15:50, David Woodhouse wrote: From: David Woodhouse In net_cleanup() we only need to delete the netdevs, as those may have state which outlives Qemu when it exits, and thus may actually need to be cleaned up on exit. The nics, on the other hand, are owned by the device which

Re: [PATCH v3 19/28] hw/xen: update Xen PV NIC to XenDevice model

2023-10-27 Thread Durrant, Paul
On 25/10/2023 15:50, David Woodhouse wrote: From: David Woodhouse This allows us to use Xen PV networking with emulated Xen guests, and to add them on the command line or hotplug. Signed-off-by: David Woodhouse --- hw/net/meson.build| 2 +- hw/net/trace-events | 11 +

Re: [PATCH v3 18/28] hw/xen: only remove peers of PCI NICs on unplug

2023-10-27 Thread Durrant, Paul
On 25/10/2023 15:50, David Woodhouse wrote: From: David Woodhouse When the Xen guest asks to unplug *emulated* NICs, it's kind of unhelpful also to unplug the peer of the *Xen* PV NIC. Signed-off-by: David Woodhouse --- hw/i386/xen/xen_platform.c | 9 +++-- 1 file changed, 7

[PATCH v3 18/21] parallels: Remove unnecessary data_end field

2023-10-27 Thread Alexander Ivanov
Since we have used bitmap, field data_end in BDRVParallelsState is redundant and can be removed. Add parallels_data_end() helper and remove data_end handling. Signed-off-by: Alexander Ivanov --- block/parallels.c | 33 + block/parallels.h | 1 - 2 files

[PATCH v3 06/21] parallels: Set data_end value in parallels_check_leak()

2023-10-27 Thread Alexander Ivanov
In parallels_check_leak() we change file size but don't correct data_end field of BDRVParallelsState structure. Fix it. Signed-off-by: Alexander Ivanov --- block/parallels.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/parallels.c b/block/parallels.c index 33bb8f1084..d6dbb6757f

[PATCH v3 08/21] parallels: Add a note about used bitmap in parallels_check_duplicate()

2023-10-27 Thread Alexander Ivanov
In parallels_check_duplicate() We use a bitmap for duplication detection. This bitmap is not related to used_bmap field in BDRVParallelsState. Add a comment about it to avoid confusion. Signed-off-by: Alexander Ivanov --- block/parallels.c | 5 - 1 file changed, 4 insertions(+), 1

[PATCH v3 03/21] parallels: Make mark_used() a global function

2023-10-27 Thread Alexander Ivanov
We will need this function and a function for marking unused clusters (will be added in the next patch) in parallels-ext.c too. Let it be a global function parallels_mark_used(). Signed-off-by: Alexander Ivanov --- block/parallels.c | 14 -- block/parallels.h | 3 +++ 2 files

[PATCH v3 11/21] parallels: Mark parallels_inactivate GRAPH_RDLOCK, guard parallels_close

2023-10-27 Thread Alexander Ivanov
Add GRAPH_RDLOCK annotation to declare parallels_inactivate() have to hold a reader lock for the graph because it calls bdrv_get_device_or_node_name(), which accesses the parents list of a node. Assert we are in the main thread in parallels_close() and guard the code with

[PATCH v3 12/21] parallels: Let image extensions work in RW mode

2023-10-27 Thread Alexander Ivanov
Now we support extensions saving and can let to work with them in read-write mode. Signed-off-by: Alexander Ivanov --- block/parallels-ext.c | 4 block/parallels.c | 17 - 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/block/parallels-ext.c

[PATCH v3 21/21] tests: Add parallels format support to image-fleecing

2023-10-27 Thread Alexander Ivanov
Use a different bitmap name for parallels images because their has own ID format, and can't contain an arbitrary string. Replace hardcoded 'qcow2' format to iotests.imgfmt. Add 'parallels' to supported formats. Signed-off-by: Alexander Ivanov --- tests/qemu-iotests/tests/image-fleecing | 13

[PATCH v3 16/21] parallels: Truncate images on the last used cluster

2023-10-27 Thread Alexander Ivanov
On an image closing there can be unused clusters in the end of the image. Truncate these clusters and update data_end field. Signed-off-by: Alexander Ivanov --- block/parallels.c | 20 ++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/block/parallels.c

[PATCH v3 07/21] parallels: Recreate used bitmap in parallels_check_leak()

2023-10-27 Thread Alexander Ivanov
In parallels_check_leak() file can be truncated. In this case the used bitmap would not comply to the file. Recreate the bitmap after file truncation. Signed-off-by: Alexander Ivanov --- block/parallels.c | 8 1 file changed, 8 insertions(+) diff --git a/block/parallels.c

[PATCH v3 17/21] parallels: Check unused clusters in parallels_check_leak()

2023-10-27 Thread Alexander Ivanov
Since we have used bitmap, leak check is useless. Transform parallels_truncate_unused_clusters() to parallels_check_unused_clusters() helper and use it in leak check. Signed-off-by: Alexander Ivanov --- block/parallels.c | 121 +- 1 file changed, 67

[PATCH v3 20/21] tests: Turned on 256, 299, 304 and block-status-cache for parallels format

2023-10-27 Thread Alexander Ivanov
These tests pass with parallels format. Add parallels to supporting formats for these tests. Signed-off-by: Alexander Ivanov --- tests/qemu-iotests/256 | 2 +- tests/qemu-iotests/299 | 2 +- tests/qemu-iotests/304 | 2 +-

[PATCH v3 19/21] tests: Add parallels images support to test 165

2023-10-27 Thread Alexander Ivanov
Use a different bitmap name for parallels images because their has own ID format, and can't contain an arbitrary string. Replace image reopen by shutdown/launch VM because parallels images doesn't support reopen. Signed-off-by: Alexander Ivanov --- tests/qemu-iotests/165 | 40

[PATCH v3 15/21] parallels: Reverse a conditional in parallels_check_leak() to reduce indents

2023-10-27 Thread Alexander Ivanov
Let the function return a success code if a file size is not bigger than image_end_offset. Thus we can decrease indents in the next code block. Signed-off-by: Alexander Ivanov --- block/parallels.c | 72 +++ 1 file changed, 36 insertions(+), 36

[PATCH v3 10/21] parallels: Add dirty bitmaps saving

2023-10-27 Thread Alexander Ivanov
Now dirty bitmaps can be loaded but there is no their saving. Add code for dirty bitmap storage. Signed-off-by: Alexander Ivanov --- block/parallels-ext.c | 167 ++ block/parallels.c | 16 +++- block/parallels.h | 5 ++ 3 files changed, 186

[PATCH v3 14/21] parallels: Make a loaded dirty bitmap persistent

2023-10-27 Thread Alexander Ivanov
After bitmap loading the bitmap is not persistent and is removed on image saving. Set bitmap persistence to true. Signed-off-by: Alexander Ivanov --- block/parallels-ext.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/parallels-ext.c b/block/parallels-ext.c index

[PATCH v3 09/21] parallels: Create used bitmap even if checks needed

2023-10-27 Thread Alexander Ivanov
All the checks were fixed to work with used bitmap. Create used bitmap in parallels_open() even if need_check is true. Signed-off-by: Alexander Ivanov --- block/parallels.c | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index

[PATCH v3 13/21] parallels: Handle L1 entries equal to one

2023-10-27 Thread Alexander Ivanov
If all the bits in a dirty bitmap cluster are ones, the cluster shouldn't be written. Instead the corresponding L1 entry should be set to 1. Check if all bits in a memory region are ones and set 1 to L1 entries corresponding clusters filled with ones. Signed-off-by: Alexander Ivanov ---

[PATCH v3 05/21] parallels: Move host clusters allocation to a separate function

2023-10-27 Thread Alexander Ivanov
For parallels images extensions we need to allocate host clusters without any connection to BAT. Move host clusters allocation code to allocate_host_clusters(). Signed-off-by: Alexander Ivanov --- block/parallels.c | 128 -- block/parallels.h | 4 ++

[PATCH v3 04/21] parallels: Add parallels_mark_unused() helper

2023-10-27 Thread Alexander Ivanov
Add a helper to set unused areas in the used bitmap. Signed-off-by: Alexander Ivanov --- block/parallels.c | 17 + block/parallels.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/block/parallels.c b/block/parallels.c index e9a8cbe430..a30bb5fe0d 100644 ---

[PATCH v3 01/21] parallels: Set s->used_bmap to NULL in parallels_free_used_bitmap()

2023-10-27 Thread Alexander Ivanov
After used bitmap freeng s->used_bmap points to the freed memory. If we try to free used bitmap one more time it leads to double free error. Set s->used_bmap to NULL to exclude double free error. Signed-off-by: Alexander Ivanov --- block/parallels.c | 1 + 1 file changed, 1 insertion(+) diff

[PATCH v3 02/21] parallels: Move inactivation code to a separate function

2023-10-27 Thread Alexander Ivanov
We are going to add parallels image extensions storage and need a separate function for inactivation code. Signed-off-by: Alexander Ivanov --- block/parallels.c | 22 -- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/block/parallels.c b/block/parallels.c

[PATCH v3 00/21] parallels: Add full dirty bitmap support

2023-10-27 Thread Alexander Ivanov
Parallels format driver: * make some preparation * add dirty bitmap saving * make dirty bitmap RW * fix broken checks * refactor leak check * add parallels format support to several tests You could find these patches in my repo: https://github.com/AlexanderIvanov-Virtuozzo/qemu/tree/parallels-v3

Re: [PATCH v3 17/28] hw/xen: add support for Xen primary console in emulated mode

2023-10-27 Thread Durrant, Paul
On 25/10/2023 15:50, David Woodhouse wrote: From: David Woodhouse The primary console is special because the toolstack maps a page into the guest for its ring, and also allocates the guest-side event channel. The guest's grant table is even primed to export that page using a known grant ref#.

Re: [PATCH 00/10] tests: Clean up global variables shadowing

2023-10-27 Thread Thomas Huth
On 09/10/2023 12.02, Philippe Mathieu-Daudé wrote: Clean up global variables shadowing in tests/ in order to be able to use -Wshadow with Clang. Philippe Mathieu-Daudé (10): system/qtest: Clean up global variable shadowing in qtest_server_init() tests/throttle: Clean up global

Re: [PATCH v3 14/28] hw/xen: add get_frontend_path() method to XenDeviceClass

2023-10-27 Thread Durrant, Paul
On 25/10/2023 15:50, David Woodhouse wrote: From: David Woodhouse The primary Xen console is special. The guest's side is set up for it by the toolstack automatically and not by the standard PV init sequence. Accordingly, its *frontend* doesn't appear in …/device/console/0 either; instead it

Re: [PATCH v3 13/28] hw/xen: automatically assign device index to block devices

2023-10-27 Thread Durrant, Paul
On 25/10/2023 15:50, David Woodhouse wrote: From: David Woodhouse There's no need to force the user to assign a vdev. We can automatically assign one, starting at xvda and searching until we find the first disk name that's unused. This means we can now allow '-drive if=xen,file=xxx' to work

Re: [PATCH v3 08/28] i386/xen: Ignore VCPU_SSHOTTMR_future flag in set_singleshot_timer()

2023-10-27 Thread Durrant, Paul
On 25/10/2023 15:50, David Woodhouse wrote: From: David Woodhouse Upstream Xen now ignores this flag¹, since the only guest kernel ever to use it was buggy. ¹ https://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=19c6cbd909 Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant ---

Re: [PATCH v3 07/28] hw/xen: use correct default protocol for xen-block on x86

2023-10-27 Thread Durrant, Paul
On 25/10/2023 15:50, David Woodhouse wrote: From: David Woodhouse Even on x86_64 the default protocol is the x86-32 one if the guest doesn't specifically ask for x86-64. Fixes: b6af8926fb85 ("xen: add implementations of xen-block connect and disconnect functions...") Signed-off-by: David

Re: [PATCH v2 1/2] hw/ide: reset: cancel async DMA operation before resetting state

2023-10-27 Thread Fiona Ebner
Am 26.10.23 um 08:17 schrieb Michael Tokarev: > 06.09.2023 16:09, Fiona Ebner wrote: >> If there is a pending DMA operation during ide_bus_reset(), the fact >> that the IDEState is already reset before the operation is canceled >> can be problematic. In particular, ide_dma_cb() might be called and

Re: [PATCH v3 06/28] hw/xen: take iothread mutex in xen_evtchn_reset_op()

2023-10-27 Thread Durrant, Paul
On 25/10/2023 15:50, David Woodhouse wrote: From: David Woodhouse The xen_evtchn_soft_reset() function requires the iothread mutex, but is also called for the EVTCHNOP_reset hypercall. Ensure the mutex is taken in that case. Fixes: a15b10978fe6 ("hw/xen: Implement EVTCHNOP_reset")

Re: [PATCH v3 05/28] hw/xen: fix XenStore watch delivery to guest

2023-10-27 Thread Durrant, Paul
On 25/10/2023 15:50, David Woodhouse wrote: From: David Woodhouse When fire_watch_cb() found the response buffer empty, it would call deliver_watch() to generate the XS_WATCH_EVENT message in the response buffer and send an event channel notification to the guest… without actually *copying*