[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 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(+)

[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 --- a/block

[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 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 ebda6b0a01

[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 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 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 --- block

[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 +- tests/qemu

[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 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 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 b/block

[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 b/block

[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 00/21] parallels: Add full dirty bitmap support

2023-10-27 Thread Alexander Ivanov
leaks check. Alexander Ivanov (21): parallels: Set s->used_bmap to NULL in parallels_free_used_bitmap() parallels: Move inactivation code to a separate function parallels: Make mark_used() a global function parallels: Add parallels_mark_unused() helper parallels: Move host clusters a

[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 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 b/block

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

2023-10-27 Thread Alexander Ivanov
with GRAPH_RDLOCK_GUARD_MAINLOOP(). Signed-off-by: Alexander Ivanov --- block/parallels.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 2d82e8ff6a..4c2cb09e43 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -1465,7 +1465,7 @@ fail: return

[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 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 changed

[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 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 deletion

Re: [PATCH 09/21] parallels: fix broken parallels_check_data_off()

2023-09-18 Thread Alexander Ivanov
to_le32(data_off); +s->data_start = data_off; res->corruptions_fixed++; } Reviewed-by: Alexander Ivanov

Re: [PATCH 11/21] parallels: collect bitmap of used clusters at open

2023-09-18 Thread Alexander Ivanov
4e53e9572d..6b199443cf 100644 --- a/block/parallels.h +++ b/block/parallels.h @@ -72,6 +72,9 @@ typedef struct BDRVParallelsState { unsigned long *bat_dirty_bmap; unsigned int bat_dirty_block; +unsigned long *used_bmap; +unsigned long used_bmap_size; + uint32_t *bat_bitmap; unsigned int bat_size; Reviewed-by: Alexander Ivanov

Re: [PATCH 03/22] parallels: fix memory leak in parallels_open()

2023-09-19 Thread Alexander Ivanov
Reviewed-by: Alexander Ivanov -- Best regards, Alexander Ivanov

Re: [PATCH 19/22] parallels: naive implementation of parallels_co_pdiscard

2023-09-19 Thread Alexander Ivanov
iver bdrv_parallels = { .bdrv_co_create = parallels_co_create, .bdrv_co_create_opts= parallels_co_create_opts, .bdrv_co_check = parallels_co_check, +.bdrv_co_pdiscard = parallels_co_pdiscard, }; static void bdrv_parallels_init(void) Re

Re: [PATCH 20/22] tests: extend test 131 to cover availability of the discard operation

2023-09-19 Thread Alexander Ivanov
TEST_DIR/t.IMGFMT +0x300x10TEST_DIR/t.IMGFMT +read 1048576/1048576 bytes at offset 524288 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 524288/524288 bytes at offset 0 +512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 524288/524288 bytes at offset 1572864 +512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) == allocate with backing == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=67108864 Reviewed-by: Alexander Ivanov -- Best regards, Alexander Ivanov

Re: [PATCH 04/22] parallels: invent parallels_opts_prealloc() helper to parse prealloc opts

2023-09-19 Thread Alexander Ivanov
-fail_options: ret = -EINVAL; fail: -qemu_opts_del(opts); /* * "s" object was allocated by g_malloc0 so we can safely * try to free its fields even they were not allocated. Reviewed-by: Alexander Ivanov -- Best regards, Alexander Ivanov

Re: [PATCH 19/21] tests: extend test 131 to cover availability of the discard operation

2023-09-18 Thread Alexander Ivanov
TEST_DIR/t.IMGFMT +0x300x10TEST_DIR/t.IMGFMT +read 1048576/1048576 bytes at offset 524288 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 524288/524288 bytes at offset 0 +512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 2097152/2097152 bytes at offset 1572864 +2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) == allocate with backing == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=67108864 LGTM, but it didn't detect incorrect discarding. -- Best regards, Alexander Ivanov

Re: [PATCH 03/21] parallels: invent parallels_opts_prealloc() helper to parse prealloc opts

2023-09-18 Thread Alexander Ivanov
ags & BDRV_O_RDWR) { /* @@ -1214,7 +1226,6 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, fail_format: error_setg(errp, "Image not in Parallels format"); -fail_options: ret = -EINVAL; fail: /* Reviewed-by: Alexander Ivanov -- Best regards, Alexander Ivanov

Re: [PATCH 17/21] parallels: improve readability of allocate_clusters

2023-09-18 Thread Alexander Ivanov
map_size, new_usedsize); s->used_bmap_size = new_usedsize; Reviewed-by: Alexander Ivanov

Re: [PATCH 06/21] parallels: refactor path when we need to re-check image in parallels_open

2023-09-18 Thread Alexander Ivanov
, goto fail; } } - return 0; fail_format: Reviewed-by: Alexander Ivanov

Re: [PATCH 18/21] parallels: naive implementation of parallels_co_pdiscard

2023-09-18 Thread Alexander Ivanov
= parallels_co_create_opts, .bdrv_co_check = parallels_co_check, +.bdrv_co_pdiscard = parallels_co_pdiscard, }; static void bdrv_parallels_init(void) -- Best regards, Alexander Ivanov

Re: [PATCH 16/21] parallels: naive implementation of allocate_clusters with used bitmap

2023-09-18 Thread Alexander Ivanov
host_off / BDRV_SECTOR_SIZE / s->off_multiplier); +host_off += s->cluster_size; +} +if (host_off > s->data_end * BDRV_SECTOR_SIZE) { +s->data_end = host_off / BDRV_SECTOR_SIZE; } return bat2sect(s, idx) + sector_num % s->tracks; -- Best regards, Alexander Ivanov

Re: [PATCH 21/21] tests: extend test 131 to cover availability of the write-zeroes

2023-09-18 Thread Alexander Ivanov
X:XX.X (XXX YYY/sec and XXX ops/sec) +read 524288/524288 bytes at offset 524288 +512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) == allocate with backing == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=67108864 Reviewed-by: Alexander Ivanov -- Best regards, Alexander Ivanov

Re: [PATCH 16/21] parallels: naive implementation of allocate_clusters with used bitmap

2023-09-18 Thread Alexander Ivanov
On 9/18/23 15:14, Denis V. Lunev wrote: On 9/18/23 15:09, Alexander Ivanov wrote: On 9/15/23 20:41, Denis V. Lunev wrote: The access to the bitmap is not optimized completely. Signed-off-by: Denis V. Lunev ---   block/parallels.c | 51

Re: [PATCH 20/21] parallels: naive implementation of parallels_co_pwrite_zeroes

2023-09-18 Thread Alexander Ivanov
= parallels_co_create_opts, .bdrv_co_check = parallels_co_check, .bdrv_co_pdiscard = parallels_co_pdiscard, +.bdrv_co_pwrite_zeroes = parallels_co_pwrite_zeroes, }; static void bdrv_parallels_init(void) Reviewed-by: Alexander Ivanov -- Best regards, Alexander

Re: [PATCH 01/21] parallels: fix formatting in bdrv_parallels initialization

2023-09-18 Thread Alexander Ivanov
parallels_co_writev, +.bdrv_co_create = parallels_co_create, +.bdrv_co_create_opts= parallels_co_create_opts, +.bdrv_co_check = parallels_co_check, }; static void bdrv_parallels_init(void) Reviewed-by: Alexander Ivanov

Re: [PATCH 04/21] parallels: return earler in fail_format branch in parallels_open()

2023-09-18 Thread Alexander Ivanov
; + fail: /* * "s" object was allocated by g_malloc0 so we can safely Reviewed-by: Alexander Ivanov

Re: [PATCH 13/21] tests: test self-cure of parallels image with duplicated clusters

2023-09-18 Thread Alexander Ivanov
:XX:XX.X (XXX YYY/sec and XXX ops/sec) +== write another pattern to the first clusters == +wrote 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +== check the first cluster == +read 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +== check the second cluster (deduplicated) == +read 1048576/1048576 bytes at offset 1048576 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4194304 == TEST DATA_OFF CHECK == == write pattern to first cluster == wrote 1048576/1048576 bytes at offset 0 Reviewed-by: Alexander Ivanov

Re: [PATCH 04/21] parallels: return earler in fail_format branch in parallels_open()

2023-09-18 Thread Alexander Ivanov
: /* * "s" object was allocated by g_malloc0 so we can safely -- Best regards, Alexander Ivanov

Re: [PATCH 12/21] tests: fix broken deduplication check in parallels format test

2023-09-18 Thread Alexander Ivanov
:XX:XX.X (XXX YYY/sec and XXX ops/sec) +== check the second cluster (deduplicated) == +read 1048576/1048576 bytes at offset 1048576 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4194304 == TEST DATA_OFF CHECK == == write pattern to first cluster == Reviewed-by: Alexander Ivanov

Re: [PATCH 15/21] parallels: update used bitmap in allocate_cluster

2023-09-18 Thread Alexander Ivanov
tiplier); s->data_end += s->tracks; Otherwise the typo, LGTM. Reviewed-by: Alexander Ivanov

Re: [PATCH 02/21] parallels: mark driver as supporting CBT

2023-09-18 Thread Alexander Ivanov
s_zero_init_1, +.bdrv_supports_persistent_dirty_bitmap = parallels_is_support_dirty_bitmaps, .bdrv_probe = parallels_probe, .bdrv_open = parallels_open, Reviewed-by: Alexander Ivanov

Re: [PATCH 05/21] parallels: return earlier from parallels_open() function on error

2023-09-18 Thread Alexander Ivanov
, bdrv_opt_mem_align(bs->file->bs)); s->header = qemu_try_blockalign(bs->file->bs, s->header_size); if (s->header == NULL) { -ret = -ENOMEM; -goto fail; + return -ENOMEM; } ret = bdrv_pread(bs->file, 0, s->header_size, s->header, 0); Reviewed-by: Alexander Ivanov

Re: [PATCH 07/21] parallels: create mark_used() helper which sets bit in used bitmap

2023-09-18 Thread Alexander Ivanov
bitmap_size, host_off); +if (ret == -EBUSY) { +res->check_errors++; +goto out_repair_bat; } fixed = true; Reviewed-by: Alexander Ivanov

Re: [PATCH 08/21] tests: ensure that image validation will not cure the corruption

2023-09-18 Thread Alexander Ivanov
On 9/15/23 20:41, Denis V. Lunev wrote: Since commit cfce1091d55322789582480798a891cbaf66924e Author: Alexander Ivanov Date: Tue Jul 18 12:44:29 2023 +0200 parallels: Image repairing in parallels_open() there is a potential pit fall with calling qemu-io -c "

Re: [PATCH 14/21] parallels: accept multiple clusters in mark_used()

2023-09-18 Thread Alexander Ivanov
ally * means that -E2BIG is OK. */ -ret = mark_used(bs, bitmap, bitmap_size, host_off); +ret = mark_used(bs, bitmap, bitmap_size, host_off, 1); if (ret == -EBUSY) { res->check_errors++; goto out_repair_bat; Reviewed-by: Alexander Ivanov

Re: [PATCH 01/21] parallels: fix formatting in bdrv_parallels initialization

2023-09-18 Thread Alexander Ivanov
parallels_co_writev, +.bdrv_co_create = parallels_co_create, +.bdrv_co_create_opts= parallels_co_create_opts, +.bdrv_co_check = parallels_co_check, }; static void bdrv_parallels_init(void) Reviewed-by: Alexander Ivanov

Re: [PATCH 10/21] parallels: add test which will validate data_off fixes through repair

2023-09-18 Thread Alexander Ivanov
d and repaired: + +0 leaked clusters +1 corruptions + +Double checking the fixed image now... +No errors were found on the image. +== check first cluster == +read 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) *** done Reviewed-by: Alexander Ivanov

[PATCH 05/19] parallels: Recreate used bitmap in parallels_check_leak()

2023-10-02 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 b/block

[PATCH 02/19] parallels: Add mark_unused() helper

2023-10-02 Thread Alexander Ivanov
Add a helper to set unused areas in used bitmap. Signed-off-by: Alexander Ivanov --- block/parallels.c | 17 + 1 file changed, 17 insertions(+) diff --git a/block/parallels.c b/block/parallels.c index d5b333d5a4..b5e19ff921 100644 --- a/block/parallels.c +++ b/block/parallels.c

[PATCH 12/19] parallels: Make a loaded dirty bitmap persistent

2023-10-02 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 ebda6b0a01

[PATCH 16/19] parallels: Check unused clusters in parallels_check_leak()

2023-10-02 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 | 112 ++ 1 file changed, 63

[PATCH 10/19] parallels: Let image extensions work in RW mode

2023-10-02 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 b/block

[PATCH 04/19] parallels: Set data_end value in parallels_check_leak()

2023-10-02 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 3c69afa04b..e8d6d30fa5

[PATCH 01/19] parallels: Move inactivation code to a separate function

2023-10-02 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 18/19] tests: Turned on 256, 299, 304 and block-status-cache for parallels format

2023-10-02 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 +- tests/qemu

[PATCH 06/19] parallels: Add a note about used bitmap in parallels_check_duplicate()

2023-10-02 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 deletion

[PATCH 13/19] parallels: Reverse a conditional in parallels_check_leak() to reduce indents

2023-10-02 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 15/19] parallels: Remove unnecessary data_end field

2023-10-02 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 changed

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

2023-10-02 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 17/19] tests: Add parallels images support to test 165

2023-10-02 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 | 42

[PATCH 03/19] parallels: Move host clusters allocation to a separate function

2023-10-02 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 | 124 -- block/parallels.h | 4

[PATCH 09/19] parallels: Add dirty bitmaps saving

2023-10-02 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 14/19] parallels: Truncate images on the last used cluster

2023-10-02 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 | 16 ++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/block/parallels.c b/block

[PATCH 08/19] parallels: Make mark_used() and mark_unused() global functions

2023-10-02 Thread Alexander Ivanov
We will need these functions in parallels-ext.c too. Let them be global functions parallels_mark_used() and parallels_mark_unused(). Signed-off-by: Alexander Ivanov --- block/parallels.c | 22 -- block/parallels.h | 5 + 2 files changed, 17 insertions(+), 10 deletions

[PATCH 07/19] parallels: Create used bitmap even if checks needed

2023-10-02 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 11/19] parallels: Handle L1 entries equal to one

2023-10-02 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 --- block

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

2023-10-02 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 Alexander Ivanov (19): parallels: Move inactivation code to a separate function parallels: Add

Re: [PATCH 15/19] parallels: Remove unnecessary data_end field

2023-10-07 Thread Alexander Ivanov
On 10/6/23 21:43, Mike Maslenkin wrote: On Mon, Oct 2, 2023 at 12:01 PM Alexander Ivanov wrote: 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

Re: [PATCH 15/19] parallels: Remove unnecessary data_end field

2023-10-07 Thread Alexander Ivanov
On 10/7/23 13:21, Mike Maslenkin wrote: On Sat, Oct 7, 2023 at 1:18 PM Alexander Ivanov wrote: On 10/6/23 21:43, Mike Maslenkin wrote: On Mon, Oct 2, 2023 at 12:01 PM Alexander Ivanov wrote: Since we have used bitmap, field data_end in BDRVParallelsState is redundant and can

[PATCH v2 02/20] parallels: Move inactivation code to a separate function

2023-10-19 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 v2 04/20] parallels: Move host clusters allocation to a separate function

2023-10-19 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 | 126 -- block/parallels.h | 4

[PATCH v2 10/20] parallels: Add dirty bitmaps saving

2023-10-19 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 v2 06/20] parallels: Recreate used bitmap in parallels_check_leak()

2023-10-19 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 b/block

[PATCH v2 00/20] parallels: Add full dirty bitmap support

2023-10-19 Thread Alexander Ivanov
v2: 1: New patch to fix double free error. 4: Fixed clusters leaks. 15: Fixed (end_off != s->used_bmap_size) handling in parallels_truncate_unused_clusters(). 16,17: Changed the sequence of the patches - in this way we have correct leaks check. Alexander Ivanov (20): parallels: Se

[PATCH v2 13/20] parallels: Make a loaded dirty bitmap persistent

2023-10-19 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 ebda6b0a01

[PATCH v2 17/20] parallels: Remove unnecessary data_end field

2023-10-19 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 changed

[PATCH v2 12/20] parallels: Handle L1 entries equal to one

2023-10-19 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 --- block

[PATCH v2 16/20] parallels: Check unused clusters in parallels_check_leak()

2023-10-19 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 v2 05/20] parallels: Set data_end value in parallels_check_leak()

2023-10-19 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 ce97387e3e..ba9fc46279

[PATCH v2 11/20] parallels: Let image extensions work in RW mode

2023-10-19 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 b/block

[PATCH v2 08/20] parallels: Create used bitmap even if checks needed

2023-10-19 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 v2 01/20] parallels: Set s->used_bmap to NULL in parallels_free_used_bitmap()

2023-10-19 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(+)

[PATCH v2 07/20] parallels: Add a note about used bitmap in parallels_check_duplicate()

2023-10-19 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 deletion

[PATCH v2 09/20] parallels: Make mark_used() and mark_unused() global functions

2023-10-19 Thread Alexander Ivanov
We will need these functions in parallels-ext.c too. Let them be global functions parallels_mark_used() and parallels_mark_unused(). Signed-off-by: Alexander Ivanov --- block/parallels.c | 22 -- block/parallels.h | 5 + 2 files changed, 17 insertions(+), 10 deletions

[PATCH v2 18/20] tests: Add parallels images support to test 165

2023-10-19 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 v2 19/20] tests: Turned on 256, 299, 304 and block-status-cache for parallels format

2023-10-19 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 +- tests/qemu

[PATCH v2 15/20] parallels: Truncate images on the last used cluster

2023-10-19 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 b/block

[PATCH v2 14/20] parallels: Reverse a conditional in parallels_check_leak() to reduce indents

2023-10-19 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 v2 20/20] tests: Add parallels format support to image-fleecing

2023-10-19 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 v2 03/20] parallels: Add mark_unused() helper

2023-10-19 Thread Alexander Ivanov
Add a helper to set unused areas in used bitmap. Signed-off-by: Alexander Ivanov --- block/parallels.c | 17 + 1 file changed, 17 insertions(+) diff --git a/block/parallels.c b/block/parallels.c index 7eb92f87ab..6a4e3945c6 100644 --- a/block/parallels.c +++ b/block/parallels.c

Re: [PATCH v2 10/20] parallels: Add dirty bitmaps saving

2023-10-23 Thread Alexander Ivanov
On 10/21/23 12:40, Mike Maslenkin wrote: On Thu, Oct 19, 2023 at 4:05 PM Alexander Ivanov wrote: 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

Re: [PATCH 15/19] parallels: Remove unnecessary data_end field

2023-10-08 Thread Alexander Ivanov
On 10/7/23 19:54, Mike Maslenkin wrote: On Sat, Oct 7, 2023 at 5:30 PM Alexander Ivanov wrote: On 10/7/23 13:21, Mike Maslenkin wrote: On Sat, Oct 7, 2023 at 1:18 PM Alexander Ivanov wrote: On 10/6/23 21:43, Mike Maslenkin wrote: On Mon, Oct 2, 2023 at 12:01 PM Alexander Ivanov

Re: [PATCH v2 09/20] parallels: Make mark_used() and mark_unused() global functions

2023-10-24 Thread Alexander Ivanov
On 10/21/23 15:29, Mike Maslenkin wrote: On Thu, Oct 19, 2023 at 5:23 PM Alexander Ivanov wrote: We will need these functions in parallels-ext.c too. Let them be global functions parallels_mark_used() and parallels_mark_unused(). Signed-off-by: Alexander Ivanov --- block/parallels.c

Re: [PATCH v2 01/20] parallels: Set s->used_bmap to NULL in parallels_free_used_bitmap()

2023-10-24 Thread Alexander Ivanov
On 10/21/23 12:40, Mike Maslenkin wrote: On Thu, Oct 19, 2023 at 4:06 PM Alexander Ivanov wrote: 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 doubl

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

2022-08-23 Thread Alexander Ivanov
On 23.08.2022 11:20, Denis V. Lunev wrote: On 23.08.2022 09:23, Alexander Ivanov wrote: On 23.08.2022 08:58, Vladimir Sementsov-Ogievskiy wrote: On 8/22/22 12:05, Alexander Ivanov wrote: data_end field in BDRVParallelsState is set to the biggest offset present in BAT. If this offset

Re: [PATCH v5 7/9] parallels: Move check of leaks to a separate function

2022-08-23 Thread Alexander Ivanov
On 23.08.2022 11:40, Denis V. Lunev wrote: On 22.08.2022 11:05, Alexander Ivanov wrote: 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 ---   block

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

2022-08-23 Thread Alexander Ivanov
On 23.08.2022 11:58, Vladimir Sementsov-Ogievskiy wrote: On 8/23/22 12:20, Denis V. Lunev wrote: On 23.08.2022 09:23, Alexander Ivanov wrote: On 23.08.2022 08:58, Vladimir Sementsov-Ogievskiy wrote: On 8/22/22 12:05, Alexander Ivanov wrote: data_end field in BDRVParallelsState is set

  1   2   3   4   5   >