[PATCH] msix: Assert that specified vector is in range

2022-08-29 Thread Akihiko Odaki
There were several different ways to deal with the situation where the vector specified for a msix function is out of bound: - early return a function and keep progresssing - propagate the error to the caller - mark msix unusable - assert it is in bound - just ignore An out-of-bound vector should

[PATCH v7 04/10] parallels: create parallels_set_bat_entry_helper() to assign BAT value

2022-08-29 Thread Alexander Ivanov
This helper will be reused in next patches during parallels_co_check rework to simplify its code. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff

[PATCH v7 08/10] parallels: Move check of leaks to a separate function

2022-08-29 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 84 +-- 1 f

[PATCH v7 07/10] parallels: Move check of cluster outside image to a separate function

2022-08-29 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 59 ++- 1 f

[PATCH v7 02/10] parallels: Fix high_off calculation in parallels_co_check()

2022-08-29 Thread Alexander Ivanov
Don't let high_off be more than the file size even if we don't fix the image. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 93bc2750ef..7e8cdbb

[PATCH v7 09/10] parallels: Move statistic collection to a separate function

2022-08-29 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 53 +

[PATCH v7 11/10] parallels: Incorrect condition in out-of-image check

2022-08-29 Thread Alexander Ivanov
All the offsets in the BAT must be lower than the file size. Fix the check condition for correct check. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/parallels.c b/block/parallels.c ind

[PATCH v7 03/10] parallels: Fix data_end after out-of-image check

2022-08-29 Thread Alexander Ivanov
Set data_end to the end of the last cluster inside the image. In such a way we can be sure that corrupted offsets in the BAT can't affect on the image size. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bl

[PATCH v7 05/10] parallels: Use generic infrastructure for BAT writing in parallels_co_check()

2022-08-29 Thread Alexander Ivanov
BAT is written in the context of conventional operations over the image inside bdrv_co_flush() when it calls parallels_co_flush_to_os() callback. Thus we should not modify BAT array directly, but call parallels_set_bat_entry() helper and bdrv_co_flush() further on. After that there is no need to ma

[PATCH v7 10/10] parallels: Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD

2022-08-29 Thread Alexander Ivanov
Replace the way we use mutex in parallels_co_check() for simplier and less error prone code. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 33 ++--- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/block/parallels.

[PATCH v7 06/10] parallels: Move check of unclean image to a separate function

2022-08-29 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 31 +

Re: [PATCH for 7.2] minor fixups in block code

2022-08-29 Thread Denis V. Lunev
On 17.08.2022 10:37, Denis V. Lunev wrote: These 2 patches are just minor improvements to make code a bit better. Signed-off-by: Denis V. Lunev CC: Kevin Wolf CC: Hanna Reitz CC: Stefan Hajnoczi CC: Fam Zheng CC: Ronnie Sahlberg CC: Paolo Bonzini CC: Peter Lieven CC: Vladimir Sementsov-O

[PATCH v7 02/10] parallels: Fix high_off calculation in parallels_co_check()

2022-08-29 Thread Alexander Ivanov
Don't let high_off be more than the file size even if we don't fix the image. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 93bc2750ef..7e8cdbb

[PATCH v7 01/10] parallels: Out of image offset in BAT leads to image inflation

2022-08-29 Thread Alexander Ivanov
data_end field in BDRVParallelsState is set to the biggest offset present in BAT. If this offset is outside of the image, any further write will create the cluster at this offset and/or the image will be truncated to this offset on close. This is definitely not correct. Raise an error in parallels_

[PATCH v7 00/10] parallels: Refactor the code of images checks and fix a bug

2022-08-29 Thread Alexander Ivanov
Fix image inflation when offset in BAT is out of image. Replace whole BAT syncing by flushing only dirty blocks. Move all the checks outside the main check function in separate functions Use WITH_QEMU_LOCK_GUARD for simplier code. v7: 1,2: Fix string lengths in the commit messages. 3: Fix a typ

[PATCH v7 03/10] parallels: Fix data_end after out-of-image check

2022-08-29 Thread Alexander Ivanov
Set data_end to the end of the last cluster inside the image. In such a way we can be sure that corrupted offsets in the BAT can't affect on the image size. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bl

[PATCH v7 10/10] parallels: Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD

2022-08-29 Thread Alexander Ivanov
Replace the way we use mutex in parallels_co_check() for simplier and less error prone code. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 33 ++--- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/block/parallels.

Re: [PATCH v7 02/10] parallels: Fix high_off calculation in parallels_co_check()

2022-08-29 Thread Alexander Ivanov
Please ignore the patches in this branch.

[PATCH v7 05/10] parallels: Use generic infrastructure for BAT writing in parallels_co_check()

2022-08-29 Thread Alexander Ivanov
BAT is written in the context of conventional operations over the image inside bdrv_co_flush() when it calls parallels_co_flush_to_os() callback. Thus we should not modify BAT array directly, but call parallels_set_bat_entry() helper and bdrv_co_flush() further on. After that there is no need to ma

[PATCH v7 07/10] parallels: Move check of cluster outside image to a separate function

2022-08-29 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 59 ++- 1 f

[PATCH v7 09/10] parallels: Move statistic collection to a separate function

2022-08-29 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 53 +

[PATCH v7 04/10] parallels: create parallels_set_bat_entry_helper() to assign BAT value

2022-08-29 Thread Alexander Ivanov
This helper will be reused in next patches during parallels_co_check rework to simplify its code. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff

[PATCH v7 06/10] parallels: Move check of unclean image to a separate function

2022-08-29 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 31 +

[PATCH v7 08/10] parallels: Move check of leaks to a separate function

2022-08-29 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 84 +-- 1 f

[PATCH v7 11/10] parallels: Incorrect condition in out-of-image check

2022-08-29 Thread Alexander Ivanov
All the offsets in the BAT must be lower than the file size. Fix the check condition for correct check. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/parallels.c b/block/parallels.c ind

[PATCH v8 3/7] block: add block layer APIs resembling Linux ZonedBlockDevice ioctls

2022-08-29 Thread Sam Li
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 the device: zone_report(zrp), zone_open(zo), zone_close(zc), zone

Re: [PATCH v8 3/7] block: add block layer APIs resembling Linux ZonedBlockDevice ioctls

2022-08-29 Thread Sam Li
Sam Li 于2022年8月29日周一 20:53写道: > > 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 the device: zone_report

[PATCH] pci: Abort if pci_add_capability fails

2022-08-29 Thread 小田喜陽彦
From: Akihiko Odaki pci_add_capability appears most PCI devices. The error handling required lots of code, and led to inconsistent behaviors such as: - passing error_abort - passing error_fatal - asserting the returned value - propagating the error to the caller - skipping the rest of the functio

Re: [PATCH v8 2/7] file-posix: introduce helper funcations for sysfs attributes

2022-08-29 Thread Stefan Hajnoczi
On Sat, Aug 27, 2022 at 12:11:21AM +0800, Sam Li wrote: If you send another revision please fix the "funcations" typo in the commit message. signature.asc Description: PGP signature

Re: [PATCH v8 3/7] block: add block layer APIs resembling Linux ZonedBlockDevice ioctls

2022-08-29 Thread Stefan Hajnoczi
On Sat, Aug 27, 2022 at 12:17:04AM +0800, Sam Li wrote: > +/* > + * Send a zone_management command. > + * op is the zone operation. > + * offset is the starting zone specified as a sector offset. Does "sector offset" mean "byte offset from the start of the device" or does it mean in 512B sector un

Re: [PATCH v8 0/7] Add support for zoned device

2022-08-29 Thread Stefan Hajnoczi
On Fri, Aug 26, 2022 at 11:15:29PM +0800, Sam Li wrote: > Zoned Block Devices (ZBDs) devide the LBA space to block regions called zones > that are larger than the LBA size. It can only allow sequential writes, which > reduces write amplification in SSD, leading to higher throughput and increased >

Re: [PATCH v8 0/7] Add support for zoned device

2022-08-29 Thread Sam Li
Stefan Hajnoczi 于2022年8月30日周二 03:44写道: > > On Fri, Aug 26, 2022 at 11:15:29PM +0800, Sam Li wrote: > > Zoned Block Devices (ZBDs) devide the LBA space to block regions called > > zones > > that are larger than the LBA size. It can only allow sequential writes, > > which > > reduces write amplifi