]> git.proxmox.com Git - pve-qemu.git/blame - debian/patches/pve/0038-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch
fix patch for accepting NULL qiov when padding
[pve-qemu.git] / debian / patches / pve / 0038-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch
CommitLineData
677d0d16
SR
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Stefan Reiter <s.reiter@proxmox.com>
3Date: Tue, 2 Mar 2021 16:11:54 +0100
4Subject: [PATCH] block/io: accept NULL qiov in bdrv_pad_request
5
6Some operations, e.g. block-stream, perform reads while discarding the
7results (only copy-on-read matters). In this case they will pass NULL as
8the target QEMUIOVector, which will however trip bdrv_pad_request, since
9it wants to extend its passed vector.
10
061e9ceb
FE
11If there is no qiov, no operation can be done with it, but the bytes
12and offset still need to be updated, so the subsequent aligned read
13will actually be aligned and not run into an assertion failure.
ddbf7a87
TL
14
15Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
061e9ceb
FE
16[FE: do update bytes and offset in any case]
17Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
677d0d16 18---
061e9ceb
FE
19 block/io.c | 29 ++++++++++++++++-------------
20 1 file changed, 16 insertions(+), 13 deletions(-)
677d0d16
SR
21
22diff --git a/block/io.c b/block/io.c
061e9ceb 23index 83d1b1dfdc..e927881e40 100644
677d0d16
SR
24--- a/block/io.c
25+++ b/block/io.c
061e9ceb
FE
26@@ -1723,22 +1723,25 @@ static int bdrv_pad_request(BlockDriverState *bs,
27 return 0;
28 }
677d0d16 29
061e9ceb
FE
30- sliced_iov = qemu_iovec_slice(*qiov, *qiov_offset, *bytes,
31- &sliced_head, &sliced_tail,
32- &sliced_niov);
33-
34- /* Guaranteed by bdrv_check_request32() */
35- assert(*bytes <= SIZE_MAX);
36- ret = bdrv_create_padded_qiov(bs, pad, sliced_iov, sliced_niov,
37- sliced_head, *bytes);
38- if (ret < 0) {
39- bdrv_padding_finalize(pad);
40- return ret;
41+ if (qiov && *qiov) {
42+ sliced_iov = qemu_iovec_slice(*qiov, *qiov_offset, *bytes,
43+ &sliced_head, &sliced_tail,
44+ &sliced_niov);
677d0d16 45+
061e9ceb
FE
46+ /* Guaranteed by bdrv_check_request32() */
47+ assert(*bytes <= SIZE_MAX);
48+ ret = bdrv_create_padded_qiov(bs, pad, sliced_iov, sliced_niov,
49+ sliced_head, *bytes);
50+ if (ret < 0) {
51+ bdrv_padding_finalize(pad);
52+ return ret;
53+ }
54+ *qiov = &pad->local_qiov;
55+ *qiov_offset = 0;
56 }
57+
58 *bytes += pad->head + pad->tail;
59 *offset -= pad->head;
60- *qiov = &pad->local_qiov;
61- *qiov_offset = 0;
62 if (padded) {
63 *padded = true;
64 }