From 53fb7844f03241a0e6de2c342c9e1b89df12da4d Mon Sep 17 00:00:00 2001 From: Alberto Faria Date: Thu, 9 Jun 2022 16:27:35 +0100 Subject: block: Add a 'flags' param to bdrv_{pread,pwrite,pwrite_sync}() For consistency with other I/O functions, and in preparation to implement them using generated_co_wrapper. Callers were updated using this Coccinelle script: @@ expression child, offset, buf, bytes; @@ - bdrv_pread(child, offset, buf, bytes) + bdrv_pread(child, offset, buf, bytes, 0) @@ expression child, offset, buf, bytes; @@ - bdrv_pwrite(child, offset, buf, bytes) + bdrv_pwrite(child, offset, buf, bytes, 0) @@ expression child, offset, buf, bytes; @@ - bdrv_pwrite_sync(child, offset, buf, bytes) + bdrv_pwrite_sync(child, offset, buf, bytes, 0) Resulting overly-long lines were then fixed by hand. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Stefan Hajnoczi Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <20220609152744.3891847-2-afaria@redhat.com> Reviewed-by: Hanna Reitz Signed-off-by: Hanna Reitz --- tests/unit/test-block-iothread.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c index 94718c9..4db1ad5 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -88,11 +88,11 @@ static void test_sync_op_pread(BdrvChild *c) int ret; /* Success */ - ret = bdrv_pread(c, 0, buf, sizeof(buf)); + ret = bdrv_pread(c, 0, buf, sizeof(buf), 0); g_assert_cmpint(ret, ==, 512); /* Early error: Negative offset */ - ret = bdrv_pread(c, -2, buf, sizeof(buf)); + ret = bdrv_pread(c, -2, buf, sizeof(buf), 0); g_assert_cmpint(ret, ==, -EIO); } @@ -102,11 +102,11 @@ static void test_sync_op_pwrite(BdrvChild *c) int ret; /* Success */ - ret = bdrv_pwrite(c, 0, buf, sizeof(buf)); + ret = bdrv_pwrite(c, 0, buf, sizeof(buf), 0); g_assert_cmpint(ret, ==, 512); /* Early error: Negative offset */ - ret = bdrv_pwrite(c, -2, buf, sizeof(buf)); + ret = bdrv_pwrite(c, -2, buf, sizeof(buf), 0); g_assert_cmpint(ret, ==, -EIO); } -- cgit v1.1 From 32cc71def9e3885f9527af713e6d8dc7521ddc08 Mon Sep 17 00:00:00 2001 From: Alberto Faria Date: Thu, 9 Jun 2022 16:27:36 +0100 Subject: block: Change bdrv_{pread,pwrite,pwrite_sync}() param order Swap 'buf' and 'bytes' around for consistency with bdrv_co_{pread,pwrite}(), and in preparation to implement these functions using generated_co_wrapper. Callers were updated using this Coccinelle script: @@ expression child, offset, buf, bytes, flags; @@ - bdrv_pread(child, offset, buf, bytes, flags) + bdrv_pread(child, offset, bytes, buf, flags) @@ expression child, offset, buf, bytes, flags; @@ - bdrv_pwrite(child, offset, buf, bytes, flags) + bdrv_pwrite(child, offset, bytes, buf, flags) @@ expression child, offset, buf, bytes, flags; @@ - bdrv_pwrite_sync(child, offset, buf, bytes, flags) + bdrv_pwrite_sync(child, offset, bytes, buf, flags) Resulting overly-long lines were then fixed by hand. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Stefan Hajnoczi Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <20220609152744.3891847-3-afaria@redhat.com> Reviewed-by: Hanna Reitz Signed-off-by: Hanna Reitz --- tests/unit/test-block-iothread.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c index 4db1ad5..49fb1ef 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -88,11 +88,11 @@ static void test_sync_op_pread(BdrvChild *c) int ret; /* Success */ - ret = bdrv_pread(c, 0, buf, sizeof(buf), 0); + ret = bdrv_pread(c, 0, sizeof(buf), buf, 0); g_assert_cmpint(ret, ==, 512); /* Early error: Negative offset */ - ret = bdrv_pread(c, -2, buf, sizeof(buf), 0); + ret = bdrv_pread(c, -2, sizeof(buf), buf, 0); g_assert_cmpint(ret, ==, -EIO); } @@ -102,11 +102,11 @@ static void test_sync_op_pwrite(BdrvChild *c) int ret; /* Success */ - ret = bdrv_pwrite(c, 0, buf, sizeof(buf), 0); + ret = bdrv_pwrite(c, 0, sizeof(buf), buf, 0); g_assert_cmpint(ret, ==, 512); /* Early error: Negative offset */ - ret = bdrv_pwrite(c, -2, buf, sizeof(buf), 0); + ret = bdrv_pwrite(c, -2, sizeof(buf), buf, 0); g_assert_cmpint(ret, ==, -EIO); } -- cgit v1.1 From 353a5d84b25c335b259f37c4f43dad96e6d60ba8 Mon Sep 17 00:00:00 2001 From: Alberto Faria Date: Thu, 9 Jun 2022 16:27:37 +0100 Subject: block: Make bdrv_{pread,pwrite}() return 0 on success They currently return the value of their 'bytes' parameter on success. Make them return 0 instead, for consistency with other I/O functions and in preparation to implement them using generated_co_wrapper. This also makes it clear that short reads/writes are not possible. The few callers that rely on the previous behavior are adjusted accordingly by hand. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Stefan Hajnoczi Message-Id: <20220609152744.3891847-4-afaria@redhat.com> Reviewed-by: Hanna Reitz Signed-off-by: Hanna Reitz --- tests/unit/test-block-iothread.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c index 49fb1ef..a5c163a 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -89,7 +89,7 @@ static void test_sync_op_pread(BdrvChild *c) /* Success */ ret = bdrv_pread(c, 0, sizeof(buf), buf, 0); - g_assert_cmpint(ret, ==, 512); + g_assert_cmpint(ret, ==, 0); /* Early error: Negative offset */ ret = bdrv_pread(c, -2, sizeof(buf), buf, 0); @@ -103,7 +103,7 @@ static void test_sync_op_pwrite(BdrvChild *c) /* Success */ ret = bdrv_pwrite(c, 0, sizeof(buf), buf, 0); - g_assert_cmpint(ret, ==, 512); + g_assert_cmpint(ret, ==, 0); /* Early error: Negative offset */ ret = bdrv_pwrite(c, -2, sizeof(buf), buf, 0); -- cgit v1.1 From 757dda54b43867936012970a1b457f3d16e7398d Mon Sep 17 00:00:00 2001 From: Alberto Faria Date: Thu, 9 Jun 2022 16:27:38 +0100 Subject: crypto: Make block callbacks return 0 on success They currently return the value of their headerlen/buflen parameter on success. Returning 0 instead makes it clear that short reads/writes are not possible. Signed-off-by: Alberto Faria Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-Id: <20220609152744.3891847-5-afaria@redhat.com> Reviewed-by: Hanna Reitz Signed-off-by: Hanna Reitz --- tests/unit/test-crypto-block.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'tests') diff --git a/tests/unit/test-crypto-block.c b/tests/unit/test-crypto-block.c index 3b1f0d5..3417b67 100644 --- a/tests/unit/test-crypto-block.c +++ b/tests/unit/test-crypto-block.c @@ -188,12 +188,12 @@ static struct QCryptoBlockTestData { }; -static ssize_t test_block_read_func(QCryptoBlock *block, - size_t offset, - uint8_t *buf, - size_t buflen, - void *opaque, - Error **errp) +static int test_block_read_func(QCryptoBlock *block, + size_t offset, + uint8_t *buf, + size_t buflen, + void *opaque, + Error **errp) { Buffer *header = opaque; @@ -201,14 +201,14 @@ static ssize_t test_block_read_func(QCryptoBlock *block, memcpy(buf, header->buffer + offset, buflen); - return buflen; + return 0; } -static ssize_t test_block_init_func(QCryptoBlock *block, - size_t headerlen, - void *opaque, - Error **errp) +static int test_block_init_func(QCryptoBlock *block, + size_t headerlen, + void *opaque, + Error **errp) { Buffer *header = opaque; @@ -216,16 +216,16 @@ static ssize_t test_block_init_func(QCryptoBlock *block, buffer_reserve(header, headerlen); - return headerlen; + return 0; } -static ssize_t test_block_write_func(QCryptoBlock *block, - size_t offset, - const uint8_t *buf, - size_t buflen, - void *opaque, - Error **errp) +static int test_block_write_func(QCryptoBlock *block, + size_t offset, + const uint8_t *buf, + size_t buflen, + void *opaque, + Error **errp) { Buffer *header = opaque; @@ -234,7 +234,7 @@ static ssize_t test_block_write_func(QCryptoBlock *block, memcpy(header->buffer + offset, buf, buflen); header->offset = offset + buflen; - return buflen; + return 0; } -- cgit v1.1 From 3698f162323ef6908a658514fbca5cfd8c97f73c Mon Sep 17 00:00:00 2001 From: John Snow Date: Thu, 16 Jun 2022 10:26:50 -0400 Subject: tests/qemu-iotests: hotfix for 307, 223 output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: 58a6fdcc Signed-off-by: John Snow Tested-by: Daniel P. Berrangé Reviewed-by: Daniel P. Berrangé Message-Id: <20220616142659.3184115-2-jsnow@redhat.com> Reviewed-by: Hanna Reitz Signed-off-by: Hanna Reitz --- tests/qemu-iotests/223.out | 4 ++-- tests/qemu-iotests/307.out | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/qemu-iotests/223.out b/tests/qemu-iotests/223.out index 0647941..26fb347 100644 --- a/tests/qemu-iotests/223.out +++ b/tests/qemu-iotests/223.out @@ -93,7 +93,7 @@ exports available: 3 export: 'n2' description: some text size: 4194304 - flags: 0xced ( flush fua trim zeroes df cache fast-zero ) + flags: 0xded ( flush fua trim zeroes df multi cache fast-zero ) min block: 1 opt block: 4096 max block: 33554432 @@ -212,7 +212,7 @@ exports available: 3 export: 'n2' description: some text size: 4194304 - flags: 0xced ( flush fua trim zeroes df cache fast-zero ) + flags: 0xded ( flush fua trim zeroes df multi cache fast-zero ) min block: 1 opt block: 4096 max block: 33554432 diff --git a/tests/qemu-iotests/307.out b/tests/qemu-iotests/307.out index ec8d2be..390f05d 100644 --- a/tests/qemu-iotests/307.out +++ b/tests/qemu-iotests/307.out @@ -83,7 +83,7 @@ exports available: 2 export: 'export1' description: This is the writable second export size: 67108864 - flags: 0xced ( flush fua trim zeroes df cache fast-zero ) + flags: 0xded ( flush fua trim zeroes df multi cache fast-zero ) min block: XXX opt block: XXX max block: XXX @@ -109,7 +109,7 @@ exports available: 1 export: 'export1' description: This is the writable second export size: 67108864 - flags: 0xced ( flush fua trim zeroes df cache fast-zero ) + flags: 0xded ( flush fua trim zeroes df multi cache fast-zero ) min block: XXX opt block: XXX max block: XXX -- cgit v1.1 From 92529251d2333ea07176cdbd7273483064ba5a7b Mon Sep 17 00:00:00 2001 From: John Snow Date: Thu, 16 Jun 2022 10:26:51 -0400 Subject: tests/qemu-iotests: skip 108 when FUSE is not loaded In certain container environments we may not have FUSE at all, so skip the test in this circumstance too. Signed-off-by: John Snow Message-Id: <20220616142659.3184115-3-jsnow@redhat.com> Reviewed-by: Thomas Huth Reviewed-by: Hanna Reitz Signed-off-by: Hanna Reitz --- tests/qemu-iotests/108 | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests') diff --git a/tests/qemu-iotests/108 b/tests/qemu-iotests/108 index 9e923d6..54e935a 100755 --- a/tests/qemu-iotests/108 +++ b/tests/qemu-iotests/108 @@ -60,6 +60,11 @@ if sudo -n losetup &>/dev/null; then else loopdev=false + # Check for usable FUSE in the host environment: + if test ! -c "/dev/fuse"; then + _notrun 'No passwordless sudo nor usable /dev/fuse' + fi + # QSD --export fuse will either yield "Parameter 'id' is missing" # or "Invalid parameter 'fuse'", depending on whether there is # FUSE support or not. -- cgit v1.1 From bf5b16fa401633475d21d69c66532f5b29e8433d Mon Sep 17 00:00:00 2001 From: Alberto Faria Date: Tue, 5 Jul 2022 17:15:09 +0100 Subject: block: Make blk_{pread,pwrite}() return 0 on success They currently return the value of their 'bytes' parameter on success. Make them return 0 instead, for consistency with other I/O functions and in preparation to implement them using generated_co_wrapper. This also makes it clear that short reads/writes are not possible. Signed-off-by: Alberto Faria Message-Id: <20220705161527.1054072-2-afaria@redhat.com> Reviewed-by: Hanna Reitz Signed-off-by: Hanna Reitz --- tests/unit/test-block-iothread.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c index a5c163a..3c1a3f6 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -117,7 +117,7 @@ static void test_sync_op_blk_pread(BlockBackend *blk) /* Success */ ret = blk_pread(blk, 0, buf, sizeof(buf)); - g_assert_cmpint(ret, ==, 512); + g_assert_cmpint(ret, ==, 0); /* Early error: Negative offset */ ret = blk_pread(blk, -2, buf, sizeof(buf)); @@ -131,7 +131,7 @@ static void test_sync_op_blk_pwrite(BlockBackend *blk) /* Success */ ret = blk_pwrite(blk, 0, buf, sizeof(buf), 0); - g_assert_cmpint(ret, ==, 512); + g_assert_cmpint(ret, ==, 0); /* Early error: Negative offset */ ret = blk_pwrite(blk, -2, buf, sizeof(buf), 0); -- cgit v1.1 From 3b35d4542c8537a9269f6372df531ced6c960084 Mon Sep 17 00:00:00 2001 From: Alberto Faria Date: Tue, 5 Jul 2022 17:15:10 +0100 Subject: block: Add a 'flags' param to blk_pread() For consistency with other I/O functions, and in preparation to implement it using generated_co_wrapper. Callers were updated using this Coccinelle script: @@ expression blk, offset, buf, bytes; @@ - blk_pread(blk, offset, buf, bytes) + blk_pread(blk, offset, buf, bytes, 0) It had no effect on hw/block/nand.c, presumably due to the #if, so that file was updated manually. Overly-long lines were then fixed by hand. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Greg Kurz Reviewed-by: Hanna Reitz Message-Id: <20220705161527.1054072-3-afaria@redhat.com> Signed-off-by: Hanna Reitz --- tests/unit/test-block-iothread.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c index 3c1a3f6..bfd12c9c 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -116,11 +116,11 @@ static void test_sync_op_blk_pread(BlockBackend *blk) int ret; /* Success */ - ret = blk_pread(blk, 0, buf, sizeof(buf)); + ret = blk_pread(blk, 0, buf, sizeof(buf), 0); g_assert_cmpint(ret, ==, 0); /* Early error: Negative offset */ - ret = blk_pread(blk, -2, buf, sizeof(buf)); + ret = blk_pread(blk, -2, buf, sizeof(buf), 0); g_assert_cmpint(ret, ==, -EIO); } -- cgit v1.1 From a9262f551eba44d4d0f9e396d7124c059a93e204 Mon Sep 17 00:00:00 2001 From: Alberto Faria Date: Tue, 5 Jul 2022 17:15:11 +0100 Subject: block: Change blk_{pread,pwrite}() param order Swap 'buf' and 'bytes' around for consistency with blk_co_{pread,pwrite}(), and in preparation to implement these functions using generated_co_wrapper. Callers were updated using this Coccinelle script: @@ expression blk, offset, buf, bytes, flags; @@ - blk_pread(blk, offset, buf, bytes, flags) + blk_pread(blk, offset, bytes, buf, flags) @@ expression blk, offset, buf, bytes, flags; @@ - blk_pwrite(blk, offset, buf, bytes, flags) + blk_pwrite(blk, offset, bytes, buf, flags) It had no effect on hw/block/nand.c, presumably due to the #if, so that file was updated manually. Overly-long lines were then fixed by hand. Signed-off-by: Alberto Faria Reviewed-by: Eric Blake Reviewed-by: Hanna Reitz Message-Id: <20220705161527.1054072-4-afaria@redhat.com> Signed-off-by: Hanna Reitz --- tests/unit/test-block-iothread.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c index bfd12c9c..0ced533 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -116,11 +116,11 @@ static void test_sync_op_blk_pread(BlockBackend *blk) int ret; /* Success */ - ret = blk_pread(blk, 0, buf, sizeof(buf), 0); + ret = blk_pread(blk, 0, sizeof(buf), buf, 0); g_assert_cmpint(ret, ==, 0); /* Early error: Negative offset */ - ret = blk_pread(blk, -2, buf, sizeof(buf), 0); + ret = blk_pread(blk, -2, sizeof(buf), buf, 0); g_assert_cmpint(ret, ==, -EIO); } @@ -130,11 +130,11 @@ static void test_sync_op_blk_pwrite(BlockBackend *blk) int ret; /* Success */ - ret = blk_pwrite(blk, 0, buf, sizeof(buf), 0); + ret = blk_pwrite(blk, 0, sizeof(buf), buf, 0); g_assert_cmpint(ret, ==, 0); /* Early error: Negative offset */ - ret = blk_pwrite(blk, -2, buf, sizeof(buf), 0); + ret = blk_pwrite(blk, -2, sizeof(buf), buf, 0); g_assert_cmpint(ret, ==, -EIO); } -- cgit v1.1 From 7c8cd723c7e3c108a62938bd7741c2db95fcfb8a Mon Sep 17 00:00:00 2001 From: Alberto Faria Date: Tue, 5 Jul 2022 17:15:15 +0100 Subject: block: Add blk_{preadv,pwritev}() Implement them using generated_co_wrapper. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Hanna Reitz Message-Id: <20220705161527.1054072-8-afaria@redhat.com> Signed-off-by: Hanna Reitz --- tests/unit/test-block-iothread.c | 42 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c index 0ced533..b9c5da3 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -138,6 +138,36 @@ static void test_sync_op_blk_pwrite(BlockBackend *blk) g_assert_cmpint(ret, ==, -EIO); } +static void test_sync_op_blk_preadv(BlockBackend *blk) +{ + uint8_t buf[512]; + QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, sizeof(buf)); + int ret; + + /* Success */ + ret = blk_preadv(blk, 0, sizeof(buf), &qiov, 0); + g_assert_cmpint(ret, ==, 0); + + /* Early error: Negative offset */ + ret = blk_preadv(blk, -2, sizeof(buf), &qiov, 0); + g_assert_cmpint(ret, ==, -EIO); +} + +static void test_sync_op_blk_pwritev(BlockBackend *blk) +{ + uint8_t buf[512] = { 0 }; + QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, sizeof(buf)); + int ret; + + /* Success */ + ret = blk_pwritev(blk, 0, sizeof(buf), &qiov, 0); + g_assert_cmpint(ret, ==, 0); + + /* Early error: Negative offset */ + ret = blk_pwritev(blk, -2, sizeof(buf), &qiov, 0); + g_assert_cmpint(ret, ==, -EIO); +} + static void test_sync_op_load_vmstate(BdrvChild *c) { uint8_t buf[512]; @@ -302,6 +332,14 @@ const SyncOpTest sync_op_tests[] = { .fn = test_sync_op_pwrite, .blkfn = test_sync_op_blk_pwrite, }, { + .name = "/sync-op/preadv", + .fn = NULL, + .blkfn = test_sync_op_blk_preadv, + }, { + .name = "/sync-op/pwritev", + .fn = NULL, + .blkfn = test_sync_op_blk_pwritev, + }, { .name = "/sync-op/load_vmstate", .fn = test_sync_op_load_vmstate, }, { @@ -349,7 +387,9 @@ static void test_sync_op(const void *opaque) blk_set_aio_context(blk, ctx, &error_abort); aio_context_acquire(ctx); - t->fn(c); + if (t->fn) { + t->fn(c); + } if (t->blkfn) { t->blkfn(blk); } -- cgit v1.1 From d1d3fc3d1d3bf4749400df18462f8fef4c4ca1fb Mon Sep 17 00:00:00 2001 From: Alberto Faria Date: Tue, 5 Jul 2022 17:15:16 +0100 Subject: block: Add blk_[co_]preadv_part() Implement blk_preadv_part() using generated_co_wrapper. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Hanna Reitz Message-Id: <20220705161527.1054072-9-afaria@redhat.com> Signed-off-by: Hanna Reitz --- tests/unit/test-block-iothread.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests') diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c index b9c5da3..2fa1248 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -168,6 +168,21 @@ static void test_sync_op_blk_pwritev(BlockBackend *blk) g_assert_cmpint(ret, ==, -EIO); } +static void test_sync_op_blk_preadv_part(BlockBackend *blk) +{ + uint8_t buf[512]; + QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, sizeof(buf)); + int ret; + + /* Success */ + ret = blk_preadv_part(blk, 0, sizeof(buf), &qiov, 0, 0); + g_assert_cmpint(ret, ==, 0); + + /* Early error: Negative offset */ + ret = blk_preadv_part(blk, -2, sizeof(buf), &qiov, 0, 0); + g_assert_cmpint(ret, ==, -EIO); +} + static void test_sync_op_load_vmstate(BdrvChild *c) { uint8_t buf[512]; @@ -340,6 +355,10 @@ const SyncOpTest sync_op_tests[] = { .fn = NULL, .blkfn = test_sync_op_blk_pwritev, }, { + .name = "/sync-op/preadv_part", + .fn = NULL, + .blkfn = test_sync_op_blk_preadv_part, + }, { .name = "/sync-op/load_vmstate", .fn = test_sync_op_load_vmstate, }, { -- cgit v1.1 From 09cca043bf68719f93f0ce1f1efafbec4ca72229 Mon Sep 17 00:00:00 2001 From: Alberto Faria Date: Tue, 5 Jul 2022 17:15:17 +0100 Subject: block: Export blk_pwritev_part() in block-backend-io.h Also convert it into a generated_co_wrapper. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Hanna Reitz Message-Id: <20220705161527.1054072-10-afaria@redhat.com> Signed-off-by: Hanna Reitz --- tests/unit/test-block-iothread.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests') diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c index 2fa1248..274e9e3 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -183,6 +183,21 @@ static void test_sync_op_blk_preadv_part(BlockBackend *blk) g_assert_cmpint(ret, ==, -EIO); } +static void test_sync_op_blk_pwritev_part(BlockBackend *blk) +{ + uint8_t buf[512] = { 0 }; + QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, sizeof(buf)); + int ret; + + /* Success */ + ret = blk_pwritev_part(blk, 0, sizeof(buf), &qiov, 0, 0); + g_assert_cmpint(ret, ==, 0); + + /* Early error: Negative offset */ + ret = blk_pwritev_part(blk, -2, sizeof(buf), &qiov, 0, 0); + g_assert_cmpint(ret, ==, -EIO); +} + static void test_sync_op_load_vmstate(BdrvChild *c) { uint8_t buf[512]; @@ -359,6 +374,10 @@ const SyncOpTest sync_op_tests[] = { .fn = NULL, .blkfn = test_sync_op_blk_preadv_part, }, { + .name = "/sync-op/pwritev_part", + .fn = NULL, + .blkfn = test_sync_op_blk_pwritev_part, + }, { .name = "/sync-op/load_vmstate", .fn = test_sync_op_load_vmstate, }, { -- cgit v1.1 From 2c9715fa28042ce84215dfd6b3bf35af90624e14 Mon Sep 17 00:00:00 2001 From: Alberto Faria Date: Tue, 5 Jul 2022 17:15:19 +0100 Subject: block: Add blk_co_pwrite_compressed() Also convert blk_pwrite_compressed() into a generated_co_wrapper. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Hanna Reitz Message-Id: <20220705161527.1054072-12-afaria@redhat.com> Signed-off-by: Hanna Reitz --- tests/unit/test-block-iothread.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests') diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c index 274e9e3..3a46886 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -198,6 +198,20 @@ static void test_sync_op_blk_pwritev_part(BlockBackend *blk) g_assert_cmpint(ret, ==, -EIO); } +static void test_sync_op_blk_pwrite_compressed(BlockBackend *blk) +{ + uint8_t buf[512] = { 0 }; + int ret; + + /* Late error: Not supported */ + ret = blk_pwrite_compressed(blk, 0, sizeof(buf), buf); + g_assert_cmpint(ret, ==, -ENOTSUP); + + /* Early error: Negative offset */ + ret = blk_pwrite_compressed(blk, -2, sizeof(buf), buf); + g_assert_cmpint(ret, ==, -EIO); +} + static void test_sync_op_load_vmstate(BdrvChild *c) { uint8_t buf[512]; @@ -378,6 +392,10 @@ const SyncOpTest sync_op_tests[] = { .fn = NULL, .blkfn = test_sync_op_blk_pwritev_part, }, { + .name = "/sync-op/pwrite_compressed", + .fn = NULL, + .blkfn = test_sync_op_blk_pwrite_compressed, + }, { .name = "/sync-op/load_vmstate", .fn = test_sync_op_load_vmstate, }, { -- cgit v1.1 From 1c95dc914a0218e58dc8d857b736b966a721d96d Mon Sep 17 00:00:00 2001 From: Alberto Faria Date: Tue, 5 Jul 2022 17:15:20 +0100 Subject: block: Implement blk_pwrite_zeroes() using generated_co_wrapper Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Hanna Reitz Message-Id: <20220705161527.1054072-13-afaria@redhat.com> Signed-off-by: Hanna Reitz --- tests/unit/test-block-iothread.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests') diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c index 3a46886..bb9230a 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -212,6 +212,19 @@ static void test_sync_op_blk_pwrite_compressed(BlockBackend *blk) g_assert_cmpint(ret, ==, -EIO); } +static void test_sync_op_blk_pwrite_zeroes(BlockBackend *blk) +{ + int ret; + + /* Success */ + ret = blk_pwrite_zeroes(blk, 0, 512, 0); + g_assert_cmpint(ret, ==, 0); + + /* Early error: Negative offset */ + ret = blk_pwrite_zeroes(blk, -2, 512, 0); + g_assert_cmpint(ret, ==, -EIO); +} + static void test_sync_op_load_vmstate(BdrvChild *c) { uint8_t buf[512]; @@ -396,6 +409,10 @@ const SyncOpTest sync_op_tests[] = { .fn = NULL, .blkfn = test_sync_op_blk_pwrite_compressed, }, { + .name = "/sync-op/pwrite_zeroes", + .fn = NULL, + .blkfn = test_sync_op_blk_pwrite_zeroes, + }, { .name = "/sync-op/load_vmstate", .fn = test_sync_op_load_vmstate, }, { -- cgit v1.1 From 015ed2529a1a1876f2a78de90b768361c6e79345 Mon Sep 17 00:00:00 2001 From: Alberto Faria Date: Tue, 5 Jul 2022 17:15:24 +0100 Subject: block: Add blk_co_truncate() Also convert blk_truncate() into a generated_co_wrapper. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Hanna Reitz Message-Id: <20220705161527.1054072-17-afaria@redhat.com> Signed-off-by: Hanna Reitz --- tests/unit/test-block-iothread.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests') diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c index bb9230a..8b55ecc 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -298,6 +298,19 @@ static void test_sync_op_truncate(BdrvChild *c) c->bs->open_flags |= BDRV_O_RDWR; } +static void test_sync_op_blk_truncate(BlockBackend *blk) +{ + int ret; + + /* Normal success path */ + ret = blk_truncate(blk, 65536, false, PREALLOC_MODE_OFF, 0, NULL); + g_assert_cmpint(ret, ==, 0); + + /* Early error: Negative offset */ + ret = blk_truncate(blk, -2, false, PREALLOC_MODE_OFF, 0, NULL); + g_assert_cmpint(ret, ==, -EINVAL); +} + static void test_sync_op_block_status(BdrvChild *c) { int ret; @@ -425,6 +438,7 @@ const SyncOpTest sync_op_tests[] = { }, { .name = "/sync-op/truncate", .fn = test_sync_op_truncate, + .blkfn = test_sync_op_blk_truncate, }, { .name = "/sync-op/block_status", .fn = test_sync_op_block_status, -- cgit v1.1 From 9907dba91dbcde20a8f966c8f22ae1635c5f7e78 Mon Sep 17 00:00:00 2001 From: Hanna Reitz Date: Tue, 21 Jun 2022 11:25:36 +0200 Subject: iotests/297: Have mypy ignore unused ignores e7874a50ff3f5b20fb46f36958ad ("python: update for mypy 0.950") has added `warn_unused_ignores = False` to python/setup.cfg, to be able to keep compatibility with both pre- and post-0.950 mypy versions. The iotests' mypy.ini needs the same, or 297 will fail (on both pre- and post-0.950 mypy, as far as I can tell; just for different `ignore` lines). Signed-off-by: Hanna Reitz Message-Id: <20220621092536.19837-1-hreitz@redhat.com> Acked-by: John Snow --- tests/qemu-iotests/mypy.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/qemu-iotests/mypy.ini b/tests/qemu-iotests/mypy.ini index 4c0339f..d66ffc2 100644 --- a/tests/qemu-iotests/mypy.ini +++ b/tests/qemu-iotests/mypy.ini @@ -9,4 +9,4 @@ no_implicit_optional = True scripts_are_modules = True warn_redundant_casts = True warn_unused_configs = True -warn_unused_ignores = True +warn_unused_ignores = False -- cgit v1.1