]> git.proxmox.com Git - pve-qemu.git/blame - debian/patches/pve/0046-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch
bump version to 5.2.0-11
[pve-qemu.git] / debian / patches / pve / 0046-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
11Simply check for NULL and do nothing, there's no reason to pad the
12target if it will be discarded anyway.
13---
14 block/io.c | 13 ++++++++-----
15 1 file changed, 8 insertions(+), 5 deletions(-)
16
17diff --git a/block/io.c b/block/io.c
18index ec5e152bb7..08dee005ec 100644
19--- a/block/io.c
20+++ b/block/io.c
21@@ -1613,13 +1613,16 @@ static bool bdrv_pad_request(BlockDriverState *bs,
22 return false;
23 }
24
25- qemu_iovec_init_extended(&pad->local_qiov, pad->buf, pad->head,
26- *qiov, *qiov_offset, *bytes,
27- pad->buf + pad->buf_len - pad->tail, pad->tail);
28+ if (*qiov) {
29+ qemu_iovec_init_extended(&pad->local_qiov, pad->buf, pad->head,
30+ *qiov, *qiov_offset, *bytes,
31+ pad->buf + pad->buf_len - pad->tail, pad->tail);
32+ *qiov = &pad->local_qiov;
33+ *qiov_offset = 0;
34+ }
35+
36 *bytes += pad->head + pad->tail;
37 *offset -= pad->head;
38- *qiov = &pad->local_qiov;
39- *qiov_offset = 0;
40
41 return true;
42 }