Re: [PATCH v5 5/8] blockdev: Add a new IF type IF_OTHER

2022-08-08 Thread Kevin Wolf
Am 08.08.2022 um 08:26 hat Markus Armbruster geschrieben: > Daniel P. Berrangé writes: > > > On Thu, Aug 04, 2022 at 05:30:40PM +0200, Markus Armbruster wrote: > >> Daniel P. Berrangé writes: > >> > >> > On Thu, Aug 04, 2022 at 04:56:15PM +0200, Markus Armbruster wrote: > >> >> Daniel P. Berran

[PATCH 0/2] virtio-blk and scsi: replace dataplane_{start/stopping/started}

2022-08-08 Thread Emanuele Giuseppe Esposito
The way the dataplane stages at startup and stop are monitored is unnecessary complicated. In virtio-scsi we have dataplane_started, dataplane_starting and dataplane_stopping in VirtIOSCSI. In virtio-blk we have dataplene_started in VirtIOBlock, and starting and stopping in VirtIOBlockDataPlane.

[PATCH 1/2] virtio-scsi: replace VirtIOBlock dataplane_{start/starting/stopped} with enum

2022-08-08 Thread Emanuele Giuseppe Esposito
Simplify the various dataplane stages in dataplane_start/stop by using a single enum instead of having multiple flags. Read/write the enum atomically, as it can be read also by iothread callbacks. Signed-off-by: Emanuele Giuseppe Esposito --- hw/scsi/virtio-scsi-dataplane.c | 21 +--

[PATCH 2/2] virtio-blk: replace dataplane_start/stopping/started with enum

2022-08-08 Thread Emanuele Giuseppe Esposito
Virtio-blk uses VirtIOBlockDataPlane and VirtIOBlock to keep track of the dataplane flags. This is completely unnecessary, as both structures are always accessed together and we can simplify the sages with an enum. Read/write the enum atomically, as it can be read also by iothread callbacks. Sign

Re: [PATCH v5 5/8] blockdev: Add a new IF type IF_OTHER

2022-08-08 Thread Markus Armbruster
Adding Paolo and Eduardo since we're wandering into QOM-land. Kevin Wolf writes: > Am 08.08.2022 um 08:26 hat Markus Armbruster geschrieben: >> Daniel P. Berrangé writes: >> >> > On Thu, Aug 04, 2022 at 05:30:40PM +0200, Markus Armbruster wrote: >> >> Daniel P. Berrangé writes: >> >> >> >> >

[PATCH 0/9] parallels: Refactor the code of images checks and fix a bug

2022-08-08 Thread Alexander Ivanov
We will add more and more checks of images so we need to reorganize the code. Put each check to a separate helper function with a separate loop. Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD for more clean code. Fix a bug when out of image offset in BAT leads to image inflation. Replace bdr

[PATCH 3/9] parallels: Move check of leaks to a separate function

2022-08-08 Thread Alexander Ivanov
Signed-off-by: Alexander Ivanov --- block/parallels.c | 96 --- 1 file changed, 58 insertions(+), 38 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 7b400ecdcc..6d4cfb738b 100644 --- a/block/parallels.c +++ b/block/parallels.c @@

[PATCH 1/9] parallels: Move check of unclean image to a separate function

2022-08-08 Thread Alexander Ivanov
Signed-off-by: Alexander Ivanov --- block/parallels.c | 29 +++-- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index a229c06f25..108aa907b8 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -413,6 +413,23 @@

[PATCH 4/9] parallels: Move check of fragmentation to a separate function

2022-08-08 Thread Alexander Ivanov
Signed-off-by: Alexander Ivanov --- block/parallels.c | 38 +- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 6d4cfb738b..0edbb812dd 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -530,12 +

[PATCH 7/9] parallels: Out of image offset in BAT leads to image inflation

2022-08-08 Thread Alexander Ivanov
When an image is opened, data_end field in BDRVParallelsState is setted as the biggest offset in the BAT plus cluster size. If there is a corrupted offset pointing outside the image, the image size increase accordingly. It potentially leads to attempts to create a file size of petabytes. Set the d

[PATCH 5/9] parallels: Move statistic collection to a separate function

2022-08-08 Thread Alexander Ivanov
Signed-off-by: Alexander Ivanov --- block/parallels.c | 25 ++--- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 0edbb812dd..b0982d60d0 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -553,13 +553,29 @@ stat

[PATCH 9/9] parallels: Merge parallels_check_fragmentation to parallels_collect_statistics

2022-08-08 Thread Alexander Ivanov
Frgamentation is a part of statistics so it is better to count the statistics in one function. Signed-off-by: Alexander Ivanov --- block/parallels.c | 31 --- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 38

[PATCH 2/9] parallels: Move check of cluster outside image to a separate function

2022-08-08 Thread Alexander Ivanov
Signed-off-by: Alexander Ivanov --- block/parallels.c | 76 +-- 1 file changed, 53 insertions(+), 23 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 108aa907b8..7b400ecdcc 100644 --- a/block/parallels.c +++ b/block/parallels.c @@

[PATCH 8/9] parallels: Replace bdrv_co_pwrite_sync by bdrv_co_flush for BAT flushing

2022-08-08 Thread Alexander Ivanov
It's too costly to write all the BAT to the disk. Let the flush function write only dirty blocks. Signed-off-by: Alexander Ivanov --- block/parallels.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/parallels.c b/block/parallels.c index 72cf7499c1..38b1482e81 100644 --

Re: [PATCH 2/9] parallels: Move check of cluster outside image to a separate function

2022-08-08 Thread Denis V. Lunev
On 08.08.2022 14:07, Alexander Ivanov wrote: Signed-off-by: Alexander Ivanov --- block/parallels.c | 76 +-- 1 file changed, 53 insertions(+), 23 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 108aa907b8..7b400ecdcc 100644 --

[PATCH 6/9] parallels: Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD

2022-08-08 Thread Alexander Ivanov
Replace the way that we use mutex in parallels_co_check() for more clean code. Signed-off-by: Alexander Ivanov --- block/parallels.c | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index b0982d60d0..3cb5452613 100644 --- a/blo

Re: [PATCH 9/9] parallels: Merge parallels_check_fragmentation to parallels_collect_statistics

2022-08-08 Thread Denis V. Lunev
On 08.08.2022 14:07, Alexander Ivanov wrote: Frgamentation is a part of statistics so it is better to count the statistics in one function. Signed-off-by: Alexander Ivanov --- block/parallels.c | 31 --- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git

Re: [PATCH 5/9] parallels: Move statistic collection to a separate function

2022-08-08 Thread Denis V. Lunev
On 08.08.2022 14:07, Alexander Ivanov wrote: Signed-off-by: Alexander Ivanov --- block/parallels.c | 25 ++--- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 0edbb812dd..b0982d60d0 100644 --- a/block/parallels.c +

Re: [PATCH 8/9] parallels: Replace bdrv_co_pwrite_sync by bdrv_co_flush for BAT flushing

2022-08-08 Thread Denis V. Lunev
On 08.08.2022 14:07, Alexander Ivanov wrote: It's too costly to write all the BAT to the disk. Let the flush function write only dirty blocks. Signed-off-by: Alexander Ivanov --- block/parallels.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/parallels.c b/block/p

Re: [PATCH 7/9] parallels: Out of image offset in BAT leads to image inflation

2022-08-08 Thread Denis V. Lunev
On 08.08.2022 14:07, Alexander Ivanov wrote: When an image is opened, data_end field in BDRVParallelsState is setted as the biggest offset in the BAT plus cluster size. If there is a corrupted offset pointing outside the image, the image size increase accordingly. It potentially leads to attempts

Re: [PATCH 2/9] parallels: Move check of cluster outside image to a separate function

2022-08-08 Thread Denis V. Lunev
On 08.08.2022 14:19, Denis V. Lunev wrote: On 08.08.2022 14:07, Alexander Ivanov wrote: Signed-off-by: Alexander Ivanov ---   block/parallels.c | 76 +--   1 file changed, 53 insertions(+), 23 deletions(-) diff --git a/block/parallels.c b/block/parall

Re: [PATCH 1/9] parallels: Move check of unclean image to a separate function

2022-08-08 Thread Denis V. Lunev
On 08.08.2022 14:07, Alexander Ivanov wrote: Signed-off-by: Alexander Ivanov --- block/parallels.c | 29 +++-- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index a229c06f25..108aa907b8 100644 --- a/block/parallel

Re: [PATCH v6 8/8] docs/zoned-storage: add zoned device documentation

2022-08-08 Thread Stefan Hajnoczi
On Fri, Aug 05, 2022 at 03:57:51PM +0800, Sam Li wrote: > Add the documentation about the zoned device support to virtio-blk > emulation. > > Signed-off-by: Sam Li > --- > docs/devel/zoned-storage.rst | 41 ++ > docs/system/qemu-block-drivers.rst.inc | 6 >

Re: [PATCH v6 3/8] file-posix: introduce get_sysfs_str_val for device zoned model

2022-08-08 Thread Stefan Hajnoczi
On Fri, Aug 05, 2022 at 03:57:46PM +0800, Sam Li wrote: > Use sysfs attribute files to get the string value of device > zoned model. Then get_sysfs_zoned_model can convert it to > BlockZoneModel type in QEMU. > > Signed-off-by: Sam Li > Reviewed-by: Hannes Reinecke > --- > block/file-posix.c

Re: [PATCH v6 2/8] file-posix: introduce get_sysfs_long_val for the long sysfs attribute

2022-08-08 Thread Stefan Hajnoczi
On Fri, Aug 05, 2022 at 03:57:45PM +0800, Sam Li wrote: > Use sysfs attribute files to get the long value of zoned device > information. > > Signed-off-by: Sam Li > Reviewed-by: Hannes Reinecke > --- > block/file-posix.c | 37 +++-- > 1 file changed, 23 insertion

Re: [PATCH v6 6/8] config: add check to block layer

2022-08-08 Thread Stefan Hajnoczi
On Fri, Aug 05, 2022 at 03:57:49PM +0800, Sam Li wrote: > Putting zoned/non-zoned BlockDrivers on top of each other is not > allowed. > > Signed-off-by: Sam Li > Reviewed-by: Stefan Hajnoczi > --- > block.c | 13 + > block/file-posix.c | 1 + >

Re: [PATCH v6 4/8] block: add block layer APIs resembling Linux ZonedBlockDevice ioctls

2022-08-08 Thread Stefan Hajnoczi
On Fri, Aug 05, 2022 at 03:57:47PM +0800, Sam Li wrote: > By adding zone management operations in BlockDriver, storage controller > emulation can use the new block layer APIs including Report Zone and > four zone management operations (open, close, finish, reset). > > Add zoned storage commands of

Re: [PATCH v6 3/8] file-posix: introduce get_sysfs_str_val for device zoned model

2022-08-08 Thread Sam Li
Stefan Hajnoczi 于2022年8月8日周一 21:52写道: > > On Fri, Aug 05, 2022 at 03:57:46PM +0800, Sam Li wrote: > > Use sysfs attribute files to get the string value of device > > zoned model. Then get_sysfs_zoned_model can convert it to > > BlockZoneModel type in QEMU. > > > > Signed-off-by: Sam Li > > Review

Re: [PATCH v6 2/8] file-posix: introduce get_sysfs_long_val for the long sysfs attribute

2022-08-08 Thread Sam Li
Stefan Hajnoczi 于2022年8月8日周一 21:52写道: > > On Fri, Aug 05, 2022 at 03:57:45PM +0800, Sam Li wrote: > > Use sysfs attribute files to get the long value of zoned device > > information. > > > > Signed-off-by: Sam Li > > Reviewed-by: Hannes Reinecke > > --- > > block/file-posix.c | 37 +

Re: [PATCH 1/2] virtio-scsi: replace VirtIOBlock dataplane_{start/starting/stopped} with enum

2022-08-08 Thread Stefan Hajnoczi
On Mon, Aug 08, 2022 at 05:41:46AM -0400, Emanuele Giuseppe Esposito wrote: > Simplify the various dataplane stages in dataplane_start/stop by using > a single enum instead of having multiple flags. > > Read/write the enum atomically, as it can be read also by iothread > callbacks. What guarantee

Re: [PATCH 2/2] virtio-blk: replace dataplane_start/stopping/started with enum

2022-08-08 Thread Stefan Hajnoczi
On Mon, Aug 08, 2022 at 05:41:47AM -0400, Emanuele Giuseppe Esposito wrote: > Virtio-blk uses VirtIOBlockDataPlane and VirtIOBlock to keep track of > the dataplane flags. This is completely unnecessary, as both structures > are always accessed together and we can simplify the sages with an enum. s

Re: [PATCH 0/2] virtio-blk and scsi: replace dataplane_{start/stopping/started}

2022-08-08 Thread Stefan Hajnoczi
On Mon, Aug 08, 2022 at 05:41:45AM -0400, Emanuele Giuseppe Esposito wrote: > The way the dataplane stages at startup and stop are monitored is unnecessary > complicated. In virtio-scsi we have dataplane_started, dataplane_starting and > dataplane_stopping in VirtIOSCSI. > In virtio-blk we have dat

[PATCH v2] virtio-scsi: fix race in virtio_scsi_dataplane_start()

2022-08-08 Thread Stefan Hajnoczi
As soon as virtio_scsi_data_plane_start() attaches host notifiers the IOThread may start virtqueue processing. There is a race between IOThread virtqueue processing and virtio_scsi_data_plane_start() because it only assigns s->dataplane_started after attaching host notifiers. When a virtqueue hand

Re: [PATCH 0/2] virtio-blk and scsi: replace dataplane_{start/stopping/started}

2022-08-08 Thread Stefan Hajnoczi
On Mon, Aug 08, 2022 at 05:41:45AM -0400, Emanuele Giuseppe Esposito wrote: > The way the dataplane stages at startup and stop are monitored is unnecessary > complicated. In virtio-scsi we have dataplane_started, dataplane_starting and > dataplane_stopping in VirtIOSCSI. > In virtio-blk we have dat

Re: [PATCH v2] virtio-scsi: fix race in virtio_scsi_dataplane_start()

2022-08-08 Thread Michael S. Tsirkin
On Mon, Aug 08, 2022 at 12:21:34PM -0400, Stefan Hajnoczi wrote: > As soon as virtio_scsi_data_plane_start() attaches host notifiers the > IOThread may start virtqueue processing. There is a race between > IOThread virtqueue processing and virtio_scsi_data_plane_start() because > it only assigns s-

Re: Deadlock between bdrv_drain_all_begin and prepare_mmio_access

2022-08-08 Thread Liang Yan
On 8/2/22 08:35, Kevin Wolf wrote: Am 24.07.2022 um 23:41 hat Liang Yan geschrieben: Hello All, I am facing a lock situation between main-loop thread 1 and vcpu thread 4 when doing a qmp snapshot. QEMU is running on 6.0.x, checked the upstream code and did not see any big change since between.