2021-03-15 18:41:24 +03:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Stefan Reiter <s.reiter@proxmox.com>
|
|
|
|
Date: Tue, 2 Mar 2021 16:11:54 +0100
|
|
|
|
Subject: [PATCH] block/io: accept NULL qiov in bdrv_pad_request
|
|
|
|
|
|
|
|
Some operations, e.g. block-stream, perform reads while discarding the
|
|
|
|
results (only copy-on-read matters). In this case they will pass NULL as
|
|
|
|
the target QEMUIOVector, which will however trip bdrv_pad_request, since
|
|
|
|
it wants to extend its passed vector.
|
|
|
|
|
2024-03-12 11:47:50 +03:00
|
|
|
If there is no qiov, no operation can be done with it, but the bytes
|
|
|
|
and offset still need to be updated, so the subsequent aligned read
|
|
|
|
will actually be aligned and not run into an assertion failure.
|
2022-01-13 12:34:33 +03:00
|
|
|
|
|
|
|
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
2024-03-12 11:47:50 +03:00
|
|
|
[FE: do update bytes and offset in any case]
|
|
|
|
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
2021-03-15 18:41:24 +03:00
|
|
|
---
|
2024-03-12 11:47:50 +03:00
|
|
|
block/io.c | 29 ++++++++++++++++-------------
|
|
|
|
1 file changed, 16 insertions(+), 13 deletions(-)
|
2021-03-15 18:41:24 +03:00
|
|
|
|
|
|
|
diff --git a/block/io.c b/block/io.c
|
2024-03-12 11:47:50 +03:00
|
|
|
index 83d1b1dfdc..e927881e40 100644
|
2021-03-15 18:41:24 +03:00
|
|
|
--- a/block/io.c
|
|
|
|
+++ b/block/io.c
|
2024-03-12 11:47:50 +03:00
|
|
|
@@ -1723,22 +1723,25 @@ static int bdrv_pad_request(BlockDriverState *bs,
|
|
|
|
return 0;
|
|
|
|
}
|
2021-03-15 18:41:24 +03:00
|
|
|
|
2024-03-12 11:47:50 +03:00
|
|
|
- sliced_iov = qemu_iovec_slice(*qiov, *qiov_offset, *bytes,
|
|
|
|
- &sliced_head, &sliced_tail,
|
|
|
|
- &sliced_niov);
|
|
|
|
-
|
|
|
|
- /* Guaranteed by bdrv_check_request32() */
|
|
|
|
- assert(*bytes <= SIZE_MAX);
|
|
|
|
- ret = bdrv_create_padded_qiov(bs, pad, sliced_iov, sliced_niov,
|
|
|
|
- sliced_head, *bytes);
|
|
|
|
- if (ret < 0) {
|
|
|
|
- bdrv_padding_finalize(pad);
|
|
|
|
- return ret;
|
|
|
|
+ if (qiov && *qiov) {
|
|
|
|
+ sliced_iov = qemu_iovec_slice(*qiov, *qiov_offset, *bytes,
|
|
|
|
+ &sliced_head, &sliced_tail,
|
|
|
|
+ &sliced_niov);
|
2021-03-15 18:41:24 +03:00
|
|
|
+
|
2024-03-12 11:47:50 +03:00
|
|
|
+ /* Guaranteed by bdrv_check_request32() */
|
|
|
|
+ assert(*bytes <= SIZE_MAX);
|
|
|
|
+ ret = bdrv_create_padded_qiov(bs, pad, sliced_iov, sliced_niov,
|
|
|
|
+ sliced_head, *bytes);
|
|
|
|
+ if (ret < 0) {
|
|
|
|
+ bdrv_padding_finalize(pad);
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+ *qiov = &pad->local_qiov;
|
|
|
|
+ *qiov_offset = 0;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
*bytes += pad->head + pad->tail;
|
|
|
|
*offset -= pad->head;
|
|
|
|
- *qiov = &pad->local_qiov;
|
|
|
|
- *qiov_offset = 0;
|
|
|
|
if (padded) {
|
|
|
|
*padded = true;
|
|
|
|
}
|