1
The following changes since commit dd25f97c66a75d1508f1d4c6478ed2c95bec428f:
1
The following changes since commit 6c769690ac845fa62642a5f93b4e4bd906adab95:
2
2
3
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20190913' into staging (2019-09-16 10:15:15 +0100)
3
Merge remote-tracking branch 'remotes/vsementsov/tags/pull-simplebench-2021-05-04' into staging (2021-05-21 12:02:34 +0100)
4
4
5
are available in the Git repository at:
5
are available in the Git repository at:
6
6
7
https://github.com/XanClic/qemu.git tags/pull-block-2019-09-16
7
https://gitlab.com/stefanha/qemu.git tags/block-pull-request
8
8
9
for you to fetch changes up to 1825cc0783ccf0ec5d9f0b225a99b340bdd4c68f:
9
for you to fetch changes up to 0a6f0c76a030710780ce10d6347a70f098024d21:
10
10
11
qemu-iotests: Add test for bz #1745922 (2019-09-16 15:37:12 +0200)
11
coroutine-sleep: introduce qemu_co_sleep (2021-05-21 18:22:33 +0100)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Block patches:
14
Pull request
15
- Fix for block jobs when used with I/O threads
15
16
- Fix for a corruption when using qcow2's LUKS encryption mode
16
(Resent due to an email preparation mistake.)
17
- cURL fix
18
- check-block.sh cleanups (for make check)
19
- Refactoring
20
17
21
----------------------------------------------------------------
18
----------------------------------------------------------------
22
Max Reitz (7):
23
curl: Keep pointer to the CURLState in CURLSocket
24
curl: Keep *socket until the end of curl_sock_cb()
25
curl: Check completion in curl_multi_do()
26
curl: Pass CURLSocket to curl_multi_do()
27
curl: Report only ready sockets
28
curl: Handle success in multi_check_completion
29
curl: Check curl_multi_add_handle()'s return code
30
19
31
Maxim Levitsky (3):
20
Paolo Bonzini (6):
32
block/qcow2: Fix corruption introduced by commit 8ac0f15f335
21
coroutine-sleep: use a stack-allocated timer
33
block/qcow2: refactor encryption code
22
coroutine-sleep: disallow NULL QemuCoSleepState** argument
34
qemu-iotests: Add test for bz #1745922
23
coroutine-sleep: allow qemu_co_sleep_wake that wakes nothing
24
coroutine-sleep: move timer out of QemuCoSleepState
25
coroutine-sleep: replace QemuCoSleepState pointer with struct in the
26
API
27
coroutine-sleep: introduce qemu_co_sleep
35
28
36
Nir Soffer (2):
29
Philippe Mathieu-Daudé (1):
37
block: Use QEMU_IS_ALIGNED
30
bitops.h: Improve find_xxx_bit() documentation
38
block: Remove unused masks
39
31
40
Sergio Lopez (1):
32
Zenghui Yu (1):
41
blockjob: update nodes head while removing all bdrv
33
multi-process: Initialize variables declared with g_auto*
42
34
43
Thomas Huth (2):
35
include/qemu/bitops.h | 15 ++++++--
44
tests/qemu-iotests/check: Replace "tests" with "iotests" in final
36
include/qemu/coroutine.h | 27 ++++++++-----
45
status text
37
block/block-copy.c | 10 ++---
46
tests/Makefile: Do not print the name of the check-block.sh shell
38
block/nbd.c | 14 +++----
47
script
39
hw/remote/memory.c | 5 +--
48
40
hw/remote/proxy.c | 3 +-
49
Vladimir Sementsov-Ogievskiy (1):
41
util/qemu-coroutine-sleep.c | 75 +++++++++++++++++++------------------
50
tests/qemu-iotests: Fix qemu-io related output in 026.out.nocache
42
7 files changed, 79 insertions(+), 70 deletions(-)
51
52
tests/Makefile.include | 2 +-
53
block/qcow2.h | 8 +-
54
include/block/block.h | 2 -
55
block/bochs.c | 4 +-
56
block/cloop.c | 4 +-
57
block/curl.c | 133 ++++++++++-------------
58
block/dmg.c | 4 +-
59
block/io.c | 8 +-
60
block/qcow2-cluster.c | 40 +++----
61
block/qcow2-threads.c | 63 ++++++++---
62
block/qcow2.c | 9 +-
63
block/vvfat.c | 8 +-
64
blockjob.c | 17 ++-
65
migration/block.c | 2 +-
66
qemu-img.c | 2 +-
67
tests/qemu-iotests/026.out.nocache | 168 ++++++++++++++---------------
68
tests/qemu-iotests/263 | 91 ++++++++++++++++
69
tests/qemu-iotests/263.out | 40 +++++++
70
tests/qemu-iotests/check | 8 +-
71
tests/qemu-iotests/group | 1 +
72
20 files changed, 380 insertions(+), 234 deletions(-)
73
create mode 100755 tests/qemu-iotests/263
74
create mode 100644 tests/qemu-iotests/263.out
75
43
76
--
44
--
77
2.21.0
45
2.31.1
78
46
79
diff view generated by jsdifflib
Deleted patch
1
From: Nir Soffer <nirsof@gmail.com>
2
1
3
Replace instances of:
4
5
(n & (BDRV_SECTOR_SIZE - 1)) == 0
6
7
And:
8
9
(n & ~BDRV_SECTOR_MASK) == 0
10
11
With:
12
13
QEMU_IS_ALIGNED(n, BDRV_SECTOR_SIZE)
14
15
Which reveals the intent of the code better, and makes it easier to
16
locate the code checking alignment.
17
18
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
19
Message-id: 20190827185913.27427-2-nsoffer@redhat.com
20
Reviewed-by: John Snow <jsnow@redhat.com>
21
Signed-off-by: Max Reitz <mreitz@redhat.com>
22
---
23
block/bochs.c | 4 ++--
24
block/cloop.c | 4 ++--
25
block/dmg.c | 4 ++--
26
block/io.c | 8 ++++----
27
block/qcow2-cluster.c | 4 ++--
28
block/qcow2.c | 4 ++--
29
block/vvfat.c | 8 ++++----
30
qemu-img.c | 2 +-
31
8 files changed, 19 insertions(+), 19 deletions(-)
32
33
diff --git a/block/bochs.c b/block/bochs.c
34
index XXXXXXX..XXXXXXX 100644
35
--- a/block/bochs.c
36
+++ b/block/bochs.c
37
@@ -XXX,XX +XXX,XX @@ bochs_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
38
QEMUIOVector local_qiov;
39
int ret;
40
41
- assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0);
42
- assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0);
43
+ assert(QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE));
44
+ assert(QEMU_IS_ALIGNED(bytes, BDRV_SECTOR_SIZE));
45
46
qemu_iovec_init(&local_qiov, qiov->niov);
47
qemu_co_mutex_lock(&s->lock);
48
diff --git a/block/cloop.c b/block/cloop.c
49
index XXXXXXX..XXXXXXX 100644
50
--- a/block/cloop.c
51
+++ b/block/cloop.c
52
@@ -XXX,XX +XXX,XX @@ cloop_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
53
int nb_sectors = bytes >> BDRV_SECTOR_BITS;
54
int ret, i;
55
56
- assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0);
57
- assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0);
58
+ assert(QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE));
59
+ assert(QEMU_IS_ALIGNED(bytes, BDRV_SECTOR_SIZE));
60
61
qemu_co_mutex_lock(&s->lock);
62
63
diff --git a/block/dmg.c b/block/dmg.c
64
index XXXXXXX..XXXXXXX 100644
65
--- a/block/dmg.c
66
+++ b/block/dmg.c
67
@@ -XXX,XX +XXX,XX @@ dmg_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
68
int nb_sectors = bytes >> BDRV_SECTOR_BITS;
69
int ret, i;
70
71
- assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0);
72
- assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0);
73
+ assert(QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE));
74
+ assert(QEMU_IS_ALIGNED(bytes, BDRV_SECTOR_SIZE));
75
76
qemu_co_mutex_lock(&s->lock);
77
78
diff --git a/block/io.c b/block/io.c
79
index XXXXXXX..XXXXXXX 100644
80
--- a/block/io.c
81
+++ b/block/io.c
82
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_driver_preadv(BlockDriverState *bs,
83
sector_num = offset >> BDRV_SECTOR_BITS;
84
nb_sectors = bytes >> BDRV_SECTOR_BITS;
85
86
- assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0);
87
- assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0);
88
+ assert(QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE));
89
+ assert(QEMU_IS_ALIGNED(bytes, BDRV_SECTOR_SIZE));
90
assert(bytes <= BDRV_REQUEST_MAX_BYTES);
91
assert(drv->bdrv_co_readv);
92
93
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_driver_pwritev(BlockDriverState *bs,
94
sector_num = offset >> BDRV_SECTOR_BITS;
95
nb_sectors = bytes >> BDRV_SECTOR_BITS;
96
97
- assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0);
98
- assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0);
99
+ assert(QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE));
100
+ assert(QEMU_IS_ALIGNED(bytes, BDRV_SECTOR_SIZE));
101
assert(bytes <= BDRV_REQUEST_MAX_BYTES);
102
103
assert(drv->bdrv_co_writev);
104
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
105
index XXXXXXX..XXXXXXX 100644
106
--- a/block/qcow2-cluster.c
107
+++ b/block/qcow2-cluster.c
108
@@ -XXX,XX +XXX,XX @@ static bool coroutine_fn do_perform_cow_encrypt(BlockDriverState *bs,
109
{
110
if (bytes && bs->encrypted) {
111
BDRVQcow2State *s = bs->opaque;
112
- assert((offset_in_cluster & ~BDRV_SECTOR_MASK) == 0);
113
- assert((bytes & ~BDRV_SECTOR_MASK) == 0);
114
+ assert(QEMU_IS_ALIGNED(offset_in_cluster, BDRV_SECTOR_SIZE));
115
+ assert(QEMU_IS_ALIGNED(bytes, BDRV_SECTOR_SIZE));
116
assert(s->crypto);
117
if (qcow2_co_encrypt(bs, cluster_offset,
118
src_cluster_offset + offset_in_cluster,
119
diff --git a/block/qcow2.c b/block/qcow2.c
120
index XXXXXXX..XXXXXXX 100644
121
--- a/block/qcow2.c
122
+++ b/block/qcow2.c
123
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int qcow2_co_preadv_part(BlockDriverState *bs,
124
goto fail;
125
}
126
127
- assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0);
128
- assert((cur_bytes & (BDRV_SECTOR_SIZE - 1)) == 0);
129
+ assert(QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE));
130
+ assert(QEMU_IS_ALIGNED(cur_bytes, BDRV_SECTOR_SIZE));
131
if (qcow2_co_decrypt(bs, cluster_offset, offset,
132
cluster_data, cur_bytes) < 0) {
133
ret = -EIO;
134
diff --git a/block/vvfat.c b/block/vvfat.c
135
index XXXXXXX..XXXXXXX 100644
136
--- a/block/vvfat.c
137
+++ b/block/vvfat.c
138
@@ -XXX,XX +XXX,XX @@ vvfat_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
139
int nb_sectors = bytes >> BDRV_SECTOR_BITS;
140
void *buf;
141
142
- assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0);
143
- assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0);
144
+ assert(QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE));
145
+ assert(QEMU_IS_ALIGNED(bytes, BDRV_SECTOR_SIZE));
146
147
buf = g_try_malloc(bytes);
148
if (bytes && buf == NULL) {
149
@@ -XXX,XX +XXX,XX @@ vvfat_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
150
int nb_sectors = bytes >> BDRV_SECTOR_BITS;
151
void *buf;
152
153
- assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0);
154
- assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0);
155
+ assert(QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE));
156
+ assert(QEMU_IS_ALIGNED(bytes, BDRV_SECTOR_SIZE));
157
158
buf = g_try_malloc(bytes);
159
if (bytes && buf == NULL) {
160
diff --git a/qemu-img.c b/qemu-img.c
161
index XXXXXXX..XXXXXXX 100644
162
--- a/qemu-img.c
163
+++ b/qemu-img.c
164
@@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv)
165
int64_t sval;
166
167
sval = cvtnum(optarg);
168
- if (sval < 0 || sval & (BDRV_SECTOR_SIZE - 1) ||
169
+ if (sval < 0 || !QEMU_IS_ALIGNED(sval, BDRV_SECTOR_SIZE) ||
170
sval / BDRV_SECTOR_SIZE > MAX_BUF_SECTORS) {
171
error_report("Invalid buffer size for sparse output specified. "
172
"Valid sizes are multiples of %llu up to %llu. Select "
173
--
174
2.21.0
175
176
diff view generated by jsdifflib
Deleted patch
1
From: Nir Soffer <nirsof@gmail.com>
2
1
3
Replace confusing usage:
4
5
~BDRV_SECTOR_MASK
6
7
With more clear:
8
9
(BDRV_SECTOR_SIZE - 1)
10
11
Remove BDRV_SECTOR_MASK and the unused BDRV_BLOCK_OFFSET_MASK which was
12
it's last user.
13
14
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
15
Message-id: 20190827185913.27427-3-nsoffer@redhat.com
16
Reviewed-by: Juan Quintela <quintela@redhat.com>
17
Reviewed-by: John Snow <jsnow@redhat.com>
18
Signed-off-by: Max Reitz <mreitz@redhat.com>
19
---
20
include/block/block.h | 2 --
21
migration/block.c | 2 +-
22
2 files changed, 1 insertion(+), 3 deletions(-)
23
24
diff --git a/include/block/block.h b/include/block/block.h
25
index XXXXXXX..XXXXXXX 100644
26
--- a/include/block/block.h
27
+++ b/include/block/block.h
28
@@ -XXX,XX +XXX,XX @@ typedef struct HDGeometry {
29
30
#define BDRV_SECTOR_BITS 9
31
#define BDRV_SECTOR_SIZE (1ULL << BDRV_SECTOR_BITS)
32
-#define BDRV_SECTOR_MASK ~(BDRV_SECTOR_SIZE - 1)
33
34
#define BDRV_REQUEST_MAX_SECTORS MIN(SIZE_MAX >> BDRV_SECTOR_BITS, \
35
INT_MAX >> BDRV_SECTOR_BITS)
36
@@ -XXX,XX +XXX,XX @@ typedef struct HDGeometry {
37
#define BDRV_BLOCK_ALLOCATED 0x10
38
#define BDRV_BLOCK_EOF 0x20
39
#define BDRV_BLOCK_RECURSE 0x40
40
-#define BDRV_BLOCK_OFFSET_MASK BDRV_SECTOR_MASK
41
42
typedef QSIMPLEQ_HEAD(BlockReopenQueue, BlockReopenQueueEntry) BlockReopenQueue;
43
44
diff --git a/migration/block.c b/migration/block.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/migration/block.c
47
+++ b/migration/block.c
48
@@ -XXX,XX +XXX,XX @@ static int block_load(QEMUFile *f, void *opaque, int version_id)
49
do {
50
addr = qemu_get_be64(f);
51
52
- flags = addr & ~BDRV_SECTOR_MASK;
53
+ flags = addr & (BDRV_SECTOR_SIZE - 1);
54
addr >>= BDRV_SECTOR_BITS;
55
56
if (flags & BLK_MIG_FLAG_DEVICE_BLOCK) {
57
--
58
2.21.0
59
60
diff view generated by jsdifflib
1
From: Maxim Levitsky <mlevitsk@redhat.com>
1
From: Zenghui Yu <yuzenghui@huawei.com>
2
2
3
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
3
Quote docs/devel/style.rst (section "Automatic memory deallocation"):
4
Tested-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
4
5
Message-id: 20190915203655.21638-4-mlevitsk@redhat.com
5
* Variables declared with g_auto* MUST always be initialized,
6
Reviewed-by: Max Reitz <mreitz@redhat.com>
6
otherwise the cleanup function will use uninitialized stack memory
7
Signed-off-by: Max Reitz <mreitz@redhat.com>
7
8
Initialize @name properly to get rid of the compilation error (using
9
gcc-7.3.0 on CentOS):
10
11
../hw/remote/proxy.c: In function 'pci_proxy_dev_realize':
12
/usr/include/glib-2.0/glib/glib-autocleanups.h:28:3: error: 'name' may be used uninitialized in this function [-Werror=maybe-uninitialized]
13
g_free (*pp);
14
^~~~~~~~~~~~
15
../hw/remote/proxy.c:350:30: note: 'name' was declared here
16
g_autofree char *name;
17
^~~~
18
19
Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
20
Reviewed-by: Jagannathan Raman <jag.raman@oracle.com>
21
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
22
Reviewed-by: Miroslav Rezanina <mrezanin@redhat.com>
23
Message-id: 20210312112143.1369-1-yuzenghui@huawei.com
24
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8
---
25
---
9
tests/qemu-iotests/263 | 91 ++++++++++++++++++++++++++++++++++++++
26
hw/remote/memory.c | 5 ++---
10
tests/qemu-iotests/263.out | 40 +++++++++++++++++
27
hw/remote/proxy.c | 3 +--
11
tests/qemu-iotests/group | 1 +
28
2 files changed, 3 insertions(+), 5 deletions(-)
12
3 files changed, 132 insertions(+)
13
create mode 100755 tests/qemu-iotests/263
14
create mode 100644 tests/qemu-iotests/263.out
15
29
16
diff --git a/tests/qemu-iotests/263 b/tests/qemu-iotests/263
30
diff --git a/hw/remote/memory.c b/hw/remote/memory.c
17
new file mode 100755
18
index XXXXXXX..XXXXXXX
19
--- /dev/null
20
+++ b/tests/qemu-iotests/263
21
@@ -XXX,XX +XXX,XX @@
22
+#!/usr/bin/env bash
23
+#
24
+# Test encrypted write that crosses cluster boundary of two unallocated clusters
25
+# Based on 188
26
+#
27
+# Copyright (C) 2019 Red Hat, Inc.
28
+#
29
+# This program is free software; you can redistribute it and/or modify
30
+# it under the terms of the GNU General Public License as published by
31
+# the Free Software Foundation; either version 2 of the License, or
32
+# (at your option) any later version.
33
+#
34
+# This program is distributed in the hope that it will be useful,
35
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
36
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37
+# GNU General Public License for more details.
38
+#
39
+# You should have received a copy of the GNU General Public License
40
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
41
+#
42
+
43
+# creator
44
+owner=mlevitsk@redhat.com
45
+
46
+seq=`basename $0`
47
+echo "QA output created by $seq"
48
+
49
+status=1    # failure is the default!
50
+
51
+_cleanup()
52
+{
53
+    _cleanup_test_img
54
+}
55
+trap "_cleanup; exit \$status" 0 1 2 3 15
56
+
57
+# get standard environment, filters and checks
58
+. ./common.rc
59
+. ./common.filter
60
+
61
+_supported_fmt qcow2
62
+_supported_proto generic
63
+_supported_os Linux
64
+
65
+
66
+size=1M
67
+
68
+SECRET="secret,id=sec0,data=astrochicken"
69
+QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT
70
+
71
+
72
+_run_test()
73
+{
74
+    echo "== reading the whole image =="
75
+    $QEMU_IO --object $SECRET -c "read -P 0 0 $size" --image-opts "$1" | _filter_qemu_io | _filter_testdir
76
+
77
+    echo
78
+    echo "== write two 512 byte sectors on a cluster boundary =="
79
+    $QEMU_IO --object $SECRET -c "write -P 0xAA 0xFE00 0x400" --image-opts "$1" | _filter_qemu_io | _filter_testdir
80
+
81
+    echo
82
+    echo "== verify that the rest of the image is not changed =="
83
+    $QEMU_IO --object $SECRET -c "read -P 0x00 0x00000 0xFE00" --image-opts "$1" | _filter_qemu_io | _filter_testdir
84
+    $QEMU_IO --object $SECRET -c "read -P 0xAA 0x0FE00 0x400" --image-opts "$1" | _filter_qemu_io | _filter_testdir
85
+    $QEMU_IO --object $SECRET -c "read -P 0x00 0x10200 0xEFE00" --image-opts "$1" | _filter_qemu_io | _filter_testdir
86
+
87
+}
88
+
89
+
90
+echo
91
+echo "testing LUKS qcow2 encryption"
92
+echo
93
+
94
+_make_test_img --object $SECRET -o "encrypt.format=luks,encrypt.key-secret=sec0,encrypt.iter-time=10,cluster_size=64K" $size
95
+_run_test "driver=$IMGFMT,encrypt.key-secret=sec0,file.filename=$TEST_IMG"
96
+_cleanup_test_img
97
+
98
+echo
99
+echo "testing legacy AES qcow2 encryption"
100
+echo
101
+
102
+
103
+_make_test_img --object $SECRET -o "encrypt.format=aes,encrypt.key-secret=sec0,cluster_size=64K" $size
104
+_run_test "driver=$IMGFMT,encrypt.key-secret=sec0,file.filename=$TEST_IMG"
105
+_cleanup_test_img
106
+
107
+
108
+
109
+# success, all done
110
+echo "*** done"
111
+rm -f $seq.full
112
+status=0
113
diff --git a/tests/qemu-iotests/263.out b/tests/qemu-iotests/263.out
114
new file mode 100644
115
index XXXXXXX..XXXXXXX
116
--- /dev/null
117
+++ b/tests/qemu-iotests/263.out
118
@@ -XXX,XX +XXX,XX @@
119
+QA output created by 263
120
+
121
+testing LUKS qcow2 encryption
122
+
123
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 encrypt.format=luks encrypt.key-secret=sec0 encrypt.iter-time=10
124
+== reading the whole image ==
125
+read 1048576/1048576 bytes at offset 0
126
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
127
+
128
+== write two 512 byte sectors on a cluster boundary ==
129
+wrote 1024/1024 bytes at offset 65024
130
+1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
131
+
132
+== verify that the rest of the image is not changed ==
133
+read 65024/65024 bytes at offset 0
134
+63.500 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
135
+read 1024/1024 bytes at offset 65024
136
+1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
137
+read 982528/982528 bytes at offset 66048
138
+959.500 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
139
+
140
+testing legacy AES qcow2 encryption
141
+
142
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 encrypt.format=aes encrypt.key-secret=sec0
143
+== reading the whole image ==
144
+read 1048576/1048576 bytes at offset 0
145
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
146
+
147
+== write two 512 byte sectors on a cluster boundary ==
148
+wrote 1024/1024 bytes at offset 65024
149
+1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
150
+
151
+== verify that the rest of the image is not changed ==
152
+read 65024/65024 bytes at offset 0
153
+63.500 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
154
+read 1024/1024 bytes at offset 65024
155
+1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
156
+read 982528/982528 bytes at offset 66048
157
+959.500 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
158
+*** done
159
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
160
index XXXXXXX..XXXXXXX 100644
31
index XXXXXXX..XXXXXXX 100644
161
--- a/tests/qemu-iotests/group
32
--- a/hw/remote/memory.c
162
+++ b/tests/qemu-iotests/group
33
+++ b/hw/remote/memory.c
163
@@ -XXX,XX +XXX,XX @@
34
@@ -XXX,XX +XXX,XX @@ void remote_sysmem_reconfig(MPQemuMsg *msg, Error **errp)
164
257 rw
35
165
258 rw quick
36
remote_sysmem_reset();
166
262 rw quick migration
37
167
+263 rw quick
38
- for (region = 0; region < msg->num_fds; region++) {
168
265 rw auto quick
39
- g_autofree char *name;
169
266 rw quick
40
+ for (region = 0; region < msg->num_fds; region++, suffix++) {
41
+ g_autofree char *name = g_strdup_printf("remote-mem-%u", suffix);
42
subregion = g_new(MemoryRegion, 1);
43
- name = g_strdup_printf("remote-mem-%u", suffix++);
44
memory_region_init_ram_from_fd(subregion, NULL,
45
name, sysmem_info->sizes[region],
46
true, msg->fds[region],
47
diff --git a/hw/remote/proxy.c b/hw/remote/proxy.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/hw/remote/proxy.c
50
+++ b/hw/remote/proxy.c
51
@@ -XXX,XX +XXX,XX @@ static void probe_pci_info(PCIDevice *dev, Error **errp)
52
PCI_BASE_ADDRESS_SPACE_IO : PCI_BASE_ADDRESS_SPACE_MEMORY;
53
54
if (size) {
55
- g_autofree char *name;
56
+ g_autofree char *name = g_strdup_printf("bar-region-%d", i);
57
pdev->region[i].dev = pdev;
58
pdev->region[i].present = true;
59
if (type == PCI_BASE_ADDRESS_SPACE_MEMORY) {
60
pdev->region[i].memory = true;
61
}
62
- name = g_strdup_printf("bar-region-%d", i);
63
memory_region_init_io(&pdev->region[i].mr, OBJECT(pdev),
64
&proxy_mr_ops, &pdev->region[i],
65
name, size);
170
--
66
--
171
2.21.0
67
2.31.1
172
68
173
diff view generated by jsdifflib
1
From: Maxim Levitsky <mlevitsk@redhat.com>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
* Change the qcow2_co_{encrypt|decrypt} to just receive full host and
3
Document the following functions return the bitmap size
4
guest offsets and use this function directly instead of calling
4
if no matching bit is found:
5
do_perform_cow_encrypt (which is removed by that patch).
6
5
7
* Adjust qcow2_co_encdec to take full host and guest offsets as well.
6
- find_first_bit
7
- find_next_bit
8
- find_last_bit
9
- find_first_zero_bit
10
- find_next_zero_bit
8
11
9
* Document the qcow2_co_{encrypt|decrypt} arguments
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
to prevent the bug fixed in former commit from hopefully
13
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
happening again.
14
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
15
Message-id: 20210510200758.2623154-2-philmd@redhat.com
16
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
17
---
18
include/qemu/bitops.h | 15 ++++++++++++---
19
1 file changed, 12 insertions(+), 3 deletions(-)
12
20
13
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
21
diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h
14
Message-id: 20190915203655.21638-3-mlevitsk@redhat.com
22
index XXXXXXX..XXXXXXX 100644
15
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
23
--- a/include/qemu/bitops.h
16
[mreitz: Let perform_cow() return the error value returned by
24
+++ b/include/qemu/bitops.h
17
qcow2_co_encrypt(), as proposed by Vladimir]
25
@@ -XXX,XX +XXX,XX @@ static inline int test_bit(long nr, const unsigned long *addr)
18
Signed-off-by: Max Reitz <mreitz@redhat.com>
26
* @addr: The address to start the search at
19
---
27
* @size: The maximum size to search
20
block/qcow2.h | 8 +++---
28
*
21
block/qcow2-cluster.c | 41 +++++++++-------------------
29
- * Returns the bit number of the first set bit, or size.
22
block/qcow2-threads.c | 63 +++++++++++++++++++++++++++++++++----------
30
+ * Returns the bit number of the last set bit,
23
block/qcow2.c | 5 ++--
31
+ * or @size if there is no set bit in the bitmap.
24
4 files changed, 69 insertions(+), 48 deletions(-)
32
*/
33
unsigned long find_last_bit(const unsigned long *addr,
34
unsigned long size);
35
@@ -XXX,XX +XXX,XX @@ unsigned long find_last_bit(const unsigned long *addr,
36
* @addr: The address to base the search on
37
* @offset: The bitnumber to start searching at
38
* @size: The bitmap size in bits
39
+ *
40
+ * Returns the bit number of the next set bit,
41
+ * or @size if there are no further set bits in the bitmap.
42
*/
43
unsigned long find_next_bit(const unsigned long *addr,
44
unsigned long size,
45
@@ -XXX,XX +XXX,XX @@ unsigned long find_next_bit(const unsigned long *addr,
46
* @addr: The address to base the search on
47
* @offset: The bitnumber to start searching at
48
* @size: The bitmap size in bits
49
+ *
50
+ * Returns the bit number of the next cleared bit,
51
+ * or @size if there are no further clear bits in the bitmap.
52
*/
53
54
unsigned long find_next_zero_bit(const unsigned long *addr,
55
@@ -XXX,XX +XXX,XX @@ unsigned long find_next_zero_bit(const unsigned long *addr,
56
* @addr: The address to start the search at
57
* @size: The maximum size to search
58
*
59
- * Returns the bit number of the first set bit.
60
+ * Returns the bit number of the first set bit,
61
+ * or @size if there is no set bit in the bitmap.
62
*/
63
static inline unsigned long find_first_bit(const unsigned long *addr,
64
unsigned long size)
65
@@ -XXX,XX +XXX,XX @@ static inline unsigned long find_first_bit(const unsigned long *addr,
66
* @addr: The address to start the search at
67
* @size: The maximum size to search
68
*
69
- * Returns the bit number of the first cleared bit.
70
+ * Returns the bit number of the first cleared bit,
71
+ * or @size if there is no clear bit in the bitmap.
72
*/
73
static inline unsigned long find_first_zero_bit(const unsigned long *addr,
74
unsigned long size)
75
--
76
2.31.1
25
77
26
diff --git a/block/qcow2.h b/block/qcow2.h
27
index XXXXXXX..XXXXXXX 100644
28
--- a/block/qcow2.h
29
+++ b/block/qcow2.h
30
@@ -XXX,XX +XXX,XX @@ ssize_t coroutine_fn
31
qcow2_co_decompress(BlockDriverState *bs, void *dest, size_t dest_size,
32
const void *src, size_t src_size);
33
int coroutine_fn
34
-qcow2_co_encrypt(BlockDriverState *bs, uint64_t file_cluster_offset,
35
- uint64_t offset, void *buf, size_t len);
36
+qcow2_co_encrypt(BlockDriverState *bs, uint64_t host_offset,
37
+ uint64_t guest_offset, void *buf, size_t len);
38
int coroutine_fn
39
-qcow2_co_decrypt(BlockDriverState *bs, uint64_t file_cluster_offset,
40
- uint64_t offset, void *buf, size_t len);
41
+qcow2_co_decrypt(BlockDriverState *bs, uint64_t host_offset,
42
+ uint64_t guest_offset, void *buf, size_t len);
43
44
#endif
45
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
46
index XXXXXXX..XXXXXXX 100644
47
--- a/block/qcow2-cluster.c
48
+++ b/block/qcow2-cluster.c
49
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn do_perform_cow_read(BlockDriverState *bs,
50
return 0;
51
}
52
53
-static bool coroutine_fn do_perform_cow_encrypt(BlockDriverState *bs,
54
- uint64_t src_cluster_offset,
55
- uint64_t cluster_offset,
56
- unsigned offset_in_cluster,
57
- uint8_t *buffer,
58
- unsigned bytes)
59
-{
60
- if (bytes && bs->encrypted) {
61
- BDRVQcow2State *s = bs->opaque;
62
- assert(QEMU_IS_ALIGNED(offset_in_cluster, BDRV_SECTOR_SIZE));
63
- assert(QEMU_IS_ALIGNED(bytes, BDRV_SECTOR_SIZE));
64
- assert(s->crypto);
65
- if (qcow2_co_encrypt(bs,
66
- start_of_cluster(s, cluster_offset + offset_in_cluster),
67
- src_cluster_offset + offset_in_cluster,
68
- buffer, bytes) < 0) {
69
- return false;
70
- }
71
- }
72
- return true;
73
-}
74
-
75
static int coroutine_fn do_perform_cow_write(BlockDriverState *bs,
76
uint64_t cluster_offset,
77
unsigned offset_in_cluster,
78
@@ -XXX,XX +XXX,XX @@ static int perform_cow(BlockDriverState *bs, QCowL2Meta *m)
79
80
/* Encrypt the data if necessary before writing it */
81
if (bs->encrypted) {
82
- if (!do_perform_cow_encrypt(bs, m->offset, m->alloc_offset,
83
- start->offset, start_buffer,
84
- start->nb_bytes) ||
85
- !do_perform_cow_encrypt(bs, m->offset, m->alloc_offset,
86
- end->offset, end_buffer, end->nb_bytes)) {
87
- ret = -EIO;
88
+ ret = qcow2_co_encrypt(bs,
89
+ m->alloc_offset + start->offset,
90
+ m->offset + start->offset,
91
+ start_buffer, start->nb_bytes);
92
+ if (ret < 0) {
93
+ goto fail;
94
+ }
95
+
96
+ ret = qcow2_co_encrypt(bs,
97
+ m->alloc_offset + end->offset,
98
+ m->offset + end->offset,
99
+ end_buffer, end->nb_bytes);
100
+ if (ret < 0) {
101
goto fail;
102
}
103
}
104
diff --git a/block/qcow2-threads.c b/block/qcow2-threads.c
105
index XXXXXXX..XXXXXXX 100644
106
--- a/block/qcow2-threads.c
107
+++ b/block/qcow2-threads.c
108
@@ -XXX,XX +XXX,XX @@ static int qcow2_encdec_pool_func(void *opaque)
109
}
110
111
static int coroutine_fn
112
-qcow2_co_encdec(BlockDriverState *bs, uint64_t file_cluster_offset,
113
- uint64_t offset, void *buf, size_t len, Qcow2EncDecFunc func)
114
+qcow2_co_encdec(BlockDriverState *bs, uint64_t host_offset,
115
+ uint64_t guest_offset, void *buf, size_t len,
116
+ Qcow2EncDecFunc func)
117
{
118
BDRVQcow2State *s = bs->opaque;
119
Qcow2EncDecData arg = {
120
.block = s->crypto,
121
- .offset = s->crypt_physical_offset ?
122
- file_cluster_offset + offset_into_cluster(s, offset) :
123
- offset,
124
+ .offset = s->crypt_physical_offset ? host_offset : guest_offset,
125
.buf = buf,
126
.len = len,
127
.func = func,
128
};
129
130
- return qcow2_co_process(bs, qcow2_encdec_pool_func, &arg);
131
+ assert(QEMU_IS_ALIGNED(guest_offset, BDRV_SECTOR_SIZE));
132
+ assert(QEMU_IS_ALIGNED(host_offset, BDRV_SECTOR_SIZE));
133
+ assert(QEMU_IS_ALIGNED(len, BDRV_SECTOR_SIZE));
134
+ assert(s->crypto);
135
+
136
+ return len == 0 ? 0 : qcow2_co_process(bs, qcow2_encdec_pool_func, &arg);
137
}
138
139
+/*
140
+ * qcow2_co_encrypt()
141
+ *
142
+ * Encrypts one or more contiguous aligned sectors
143
+ *
144
+ * @host_offset - underlying storage offset of the first sector of the
145
+ * data to be encrypted
146
+ *
147
+ * @guest_offset - guest (virtual) offset of the first sector of the
148
+ * data to be encrypted
149
+ *
150
+ * @buf - buffer with the data to encrypt, that after encryption
151
+ * will be written to the underlying storage device at
152
+ * @host_offset
153
+ *
154
+ * @len - length of the buffer (must be a BDRV_SECTOR_SIZE multiple)
155
+ *
156
+ * Depending on the encryption method, @host_offset and/or @guest_offset
157
+ * may be used for generating the initialization vector for
158
+ * encryption.
159
+ *
160
+ * Note that while the whole range must be aligned on sectors, it
161
+ * does not have to be aligned on clusters and can also cross cluster
162
+ * boundaries
163
+ */
164
int coroutine_fn
165
-qcow2_co_encrypt(BlockDriverState *bs, uint64_t file_cluster_offset,
166
- uint64_t offset, void *buf, size_t len)
167
+qcow2_co_encrypt(BlockDriverState *bs, uint64_t host_offset,
168
+ uint64_t guest_offset, void *buf, size_t len)
169
{
170
- return qcow2_co_encdec(bs, file_cluster_offset, offset, buf, len,
171
- qcrypto_block_encrypt);
172
+ return qcow2_co_encdec(bs, host_offset, guest_offset, buf, len,
173
+ qcrypto_block_encrypt);
174
}
175
176
+/*
177
+ * qcow2_co_decrypt()
178
+ *
179
+ * Decrypts one or more contiguous aligned sectors
180
+ * Similar to qcow2_co_encrypt
181
+ */
182
int coroutine_fn
183
-qcow2_co_decrypt(BlockDriverState *bs, uint64_t file_cluster_offset,
184
- uint64_t offset, void *buf, size_t len)
185
+qcow2_co_decrypt(BlockDriverState *bs, uint64_t host_offset,
186
+ uint64_t guest_offset, void *buf, size_t len)
187
{
188
- return qcow2_co_encdec(bs, file_cluster_offset, offset, buf, len,
189
- qcrypto_block_decrypt);
190
+ return qcow2_co_encdec(bs, host_offset, guest_offset, buf, len,
191
+ qcrypto_block_decrypt);
192
}
193
diff --git a/block/qcow2.c b/block/qcow2.c
194
index XXXXXXX..XXXXXXX 100644
195
--- a/block/qcow2.c
196
+++ b/block/qcow2.c
197
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int qcow2_co_preadv_part(BlockDriverState *bs,
198
199
assert(QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE));
200
assert(QEMU_IS_ALIGNED(cur_bytes, BDRV_SECTOR_SIZE));
201
- if (qcow2_co_decrypt(bs, cluster_offset, offset,
202
+ if (qcow2_co_decrypt(bs, cluster_offset + offset_in_cluster,
203
+ offset,
204
cluster_data, cur_bytes) < 0) {
205
ret = -EIO;
206
goto fail;
207
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int qcow2_co_pwritev_part(
208
qemu_iovec_to_buf(qiov, qiov_offset + bytes_done,
209
cluster_data, cur_bytes);
210
211
- if (qcow2_co_encrypt(bs, cluster_offset, offset,
212
+ if (qcow2_co_encrypt(bs, cluster_offset + offset_in_cluster, offset,
213
cluster_data, cur_bytes) < 0) {
214
ret = -EIO;
215
goto out_unlocked;
216
--
217
2.21.0
218
219
diff view generated by jsdifflib
1
From: Maxim Levitsky <mlevitsk@redhat.com>
1
From: Paolo Bonzini <pbonzini@redhat.com>
2
2
3
This fixes subtle corruption introduced by luks threaded encryption
3
The lifetime of the timer is well-known (it cannot outlive
4
in commit 8ac0f15f335
4
qemu_co_sleep_ns_wakeable, because it's deleted by the time the
5
coroutine resumes), so it is not necessary to place it on the heap.
5
6
6
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1745922
7
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
8
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
9
Message-id: 20210517100548.28806-2-pbonzini@redhat.com
10
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11
---
12
util/qemu-coroutine-sleep.c | 9 ++++-----
13
1 file changed, 4 insertions(+), 5 deletions(-)
7
14
8
The corruption happens when we do a write that
15
diff --git a/util/qemu-coroutine-sleep.c b/util/qemu-coroutine-sleep.c
9
* writes to two or more unallocated clusters at once
16
index XXXXXXX..XXXXXXX 100644
10
* doesn't fully cover the first sector
17
--- a/util/qemu-coroutine-sleep.c
11
* doesn't fully cover the last sector
18
+++ b/util/qemu-coroutine-sleep.c
12
* uses luks encryption
19
@@ -XXX,XX +XXX,XX @@ static const char *qemu_co_sleep_ns__scheduled = "qemu_co_sleep_ns";
20
21
struct QemuCoSleepState {
22
Coroutine *co;
23
- QEMUTimer *ts;
24
+ QEMUTimer ts;
25
QemuCoSleepState **user_state_pointer;
26
};
27
28
@@ -XXX,XX +XXX,XX @@ void qemu_co_sleep_wake(QemuCoSleepState *sleep_state)
29
if (sleep_state->user_state_pointer) {
30
*sleep_state->user_state_pointer = NULL;
31
}
32
- timer_del(sleep_state->ts);
33
+ timer_del(&sleep_state->ts);
34
aio_co_wake(sleep_state->co);
35
}
36
37
@@ -XXX,XX +XXX,XX @@ void coroutine_fn qemu_co_sleep_ns_wakeable(QEMUClockType type, int64_t ns,
38
AioContext *ctx = qemu_get_current_aio_context();
39
QemuCoSleepState state = {
40
.co = qemu_coroutine_self(),
41
- .ts = aio_timer_new(ctx, type, SCALE_NS, co_sleep_cb, &state),
42
.user_state_pointer = sleep_state,
43
};
44
45
@@ -XXX,XX +XXX,XX @@ void coroutine_fn qemu_co_sleep_ns_wakeable(QEMUClockType type, int64_t ns,
46
abort();
47
}
48
49
+ aio_timer_init(ctx, &state.ts, type, SCALE_NS, co_sleep_cb, &state);
50
if (sleep_state) {
51
*sleep_state = &state;
52
}
53
- timer_mod(state.ts, qemu_clock_get_ns(type) + ns);
54
+ timer_mod(&state.ts, qemu_clock_get_ns(type) + ns);
55
qemu_coroutine_yield();
56
if (sleep_state) {
57
/*
58
@@ -XXX,XX +XXX,XX @@ void coroutine_fn qemu_co_sleep_ns_wakeable(QEMUClockType type, int64_t ns,
59
*/
60
assert(*sleep_state == NULL);
61
}
62
- timer_free(state.ts);
63
}
64
--
65
2.31.1
13
66
14
In this case, when allocating the new clusters we COW both areas
15
prior to the write and after the write, and we encrypt them.
16
17
The above mentioned commit accidentally made it so we encrypt the
18
second COW area using the physical cluster offset of the first area.
19
20
The problem is that offset_in_cluster in do_perform_cow_encrypt
21
can be larger that the cluster size, thus cluster_offset
22
will no longer point to the start of the cluster at which encrypted
23
area starts.
24
25
Next patch in this series will refactor the code to avoid all these
26
assumptions.
27
28
In the bugreport that was triggered by rebasing a luks image to new,
29
zero filled base, which lot of such writes, and causes some files
30
with zero areas to contain garbage there instead.
31
But as described above it can happen elsewhere as well
32
33
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
34
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
35
Message-id: 20190915203655.21638-2-mlevitsk@redhat.com
36
Reviewed-by: Max Reitz <mreitz@redhat.com>
37
Signed-off-by: Max Reitz <mreitz@redhat.com>
38
---
39
block/qcow2-cluster.c | 7 ++++---
40
1 file changed, 4 insertions(+), 3 deletions(-)
41
42
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
43
index XXXXXXX..XXXXXXX 100644
44
--- a/block/qcow2-cluster.c
45
+++ b/block/qcow2-cluster.c
46
@@ -XXX,XX +XXX,XX @@ static bool coroutine_fn do_perform_cow_encrypt(BlockDriverState *bs,
47
assert(QEMU_IS_ALIGNED(offset_in_cluster, BDRV_SECTOR_SIZE));
48
assert(QEMU_IS_ALIGNED(bytes, BDRV_SECTOR_SIZE));
49
assert(s->crypto);
50
- if (qcow2_co_encrypt(bs, cluster_offset,
51
- src_cluster_offset + offset_in_cluster,
52
- buffer, bytes) < 0) {
53
+ if (qcow2_co_encrypt(bs,
54
+ start_of_cluster(s, cluster_offset + offset_in_cluster),
55
+ src_cluster_offset + offset_in_cluster,
56
+ buffer, bytes) < 0) {
57
return false;
58
}
59
}
60
--
61
2.21.0
62
63
diff view generated by jsdifflib
1
From: Sergio Lopez <slp@redhat.com>
1
From: Paolo Bonzini <pbonzini@redhat.com>
2
2
3
block_job_remove_all_bdrv() iterates through job->nodes, calling
3
Simplify the code by removing conditionals. qemu_co_sleep_ns
4
bdrv_root_unref_child() for each entry. The call to the latter may
4
can simply point the argument to an on-stack temporary.
5
reach child_job_[can_]set_aio_ctx(), which will also attempt to
6
traverse job->nodes, potentially finding entries that where freed
7
on previous iterations.
8
5
9
To avoid this situation, update job->nodes head on each iteration to
6
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
10
ensure that already freed entries are no longer linked to the list.
7
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8
Message-id: 20210517100548.28806-3-pbonzini@redhat.com
9
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10
---
11
include/qemu/coroutine.h | 5 +++--
12
util/qemu-coroutine-sleep.c | 18 +++++-------------
13
2 files changed, 8 insertions(+), 15 deletions(-)
11
14
12
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1746631
15
diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h
13
Signed-off-by: Sergio Lopez <slp@redhat.com>
16
index XXXXXXX..XXXXXXX 100644
14
Cc: qemu-stable@nongnu.org
17
--- a/include/qemu/coroutine.h
15
Signed-off-by: Max Reitz <mreitz@redhat.com>
18
+++ b/include/qemu/coroutine.h
16
Message-id: 20190911100316.32282-1-mreitz@redhat.com
19
@@ -XXX,XX +XXX,XX @@ typedef struct QemuCoSleepState QemuCoSleepState;
17
Reviewed-by: Sergio Lopez <slp@redhat.com>
20
18
Signed-off-by: Max Reitz <mreitz@redhat.com>
21
/**
19
---
22
* Yield the coroutine for a given duration. During this yield, @sleep_state
20
blockjob.c | 17 +++++++++++++----
23
- * (if not NULL) is set to an opaque pointer, which may be used for
21
1 file changed, 13 insertions(+), 4 deletions(-)
24
+ * is set to an opaque pointer, which may be used for
25
* qemu_co_sleep_wake(). Be careful, the pointer is set back to zero when the
26
* timer fires. Don't save the obtained value to other variables and don't call
27
* qemu_co_sleep_wake from another aio context.
28
@@ -XXX,XX +XXX,XX @@ void coroutine_fn qemu_co_sleep_ns_wakeable(QEMUClockType type, int64_t ns,
29
QemuCoSleepState **sleep_state);
30
static inline void coroutine_fn qemu_co_sleep_ns(QEMUClockType type, int64_t ns)
31
{
32
- qemu_co_sleep_ns_wakeable(type, ns, NULL);
33
+ QemuCoSleepState *unused = NULL;
34
+ qemu_co_sleep_ns_wakeable(type, ns, &unused);
35
}
36
37
/**
38
diff --git a/util/qemu-coroutine-sleep.c b/util/qemu-coroutine-sleep.c
39
index XXXXXXX..XXXXXXX 100644
40
--- a/util/qemu-coroutine-sleep.c
41
+++ b/util/qemu-coroutine-sleep.c
42
@@ -XXX,XX +XXX,XX @@ void qemu_co_sleep_wake(QemuCoSleepState *sleep_state)
43
qemu_co_sleep_ns__scheduled, NULL);
44
45
assert(scheduled == qemu_co_sleep_ns__scheduled);
46
- if (sleep_state->user_state_pointer) {
47
- *sleep_state->user_state_pointer = NULL;
48
- }
49
+ *sleep_state->user_state_pointer = NULL;
50
timer_del(&sleep_state->ts);
51
aio_co_wake(sleep_state->co);
52
}
53
@@ -XXX,XX +XXX,XX @@ void coroutine_fn qemu_co_sleep_ns_wakeable(QEMUClockType type, int64_t ns,
54
}
55
56
aio_timer_init(ctx, &state.ts, type, SCALE_NS, co_sleep_cb, &state);
57
- if (sleep_state) {
58
- *sleep_state = &state;
59
- }
60
+ *sleep_state = &state;
61
timer_mod(&state.ts, qemu_clock_get_ns(type) + ns);
62
qemu_coroutine_yield();
63
- if (sleep_state) {
64
- /*
65
- * Note that *sleep_state is cleared during qemu_co_sleep_wake
66
- * before resuming this coroutine.
67
- */
68
- assert(*sleep_state == NULL);
69
- }
70
+
71
+ /* qemu_co_sleep_wake clears *sleep_state before resuming this coroutine. */
72
+ assert(*sleep_state == NULL);
73
}
74
--
75
2.31.1
22
76
23
diff --git a/blockjob.c b/blockjob.c
24
index XXXXXXX..XXXXXXX 100644
25
--- a/blockjob.c
26
+++ b/blockjob.c
27
@@ -XXX,XX +XXX,XX @@ static const BdrvChildRole child_job = {
28
29
void block_job_remove_all_bdrv(BlockJob *job)
30
{
31
- GSList *l;
32
- for (l = job->nodes; l; l = l->next) {
33
+ /*
34
+ * bdrv_root_unref_child() may reach child_job_[can_]set_aio_ctx(),
35
+ * which will also traverse job->nodes, so consume the list one by
36
+ * one to make sure that such a concurrent access does not attempt
37
+ * to process an already freed BdrvChild.
38
+ */
39
+ while (job->nodes) {
40
+ GSList *l = job->nodes;
41
BdrvChild *c = l->data;
42
+
43
+ job->nodes = l->next;
44
+
45
bdrv_op_unblock_all(c->bs, job->blocker);
46
bdrv_root_unref_child(c);
47
+
48
+ g_slist_free_1(l);
49
}
50
- g_slist_free(job->nodes);
51
- job->nodes = NULL;
52
}
53
54
bool block_job_has_bdrv(BlockJob *job, BlockDriverState *bs)
55
--
56
2.21.0
57
58
diff view generated by jsdifflib
1
curl_multi_do_locked() currently marks all sockets as ready. That is
1
From: Paolo Bonzini <pbonzini@redhat.com>
2
not only inefficient, but in fact unsafe (the loop is). A follow-up
3
patch will change that, but to do so, curl_multi_do_locked() needs to
4
know exactly which socket is ready; and that is accomplished by this
5
patch here.
6
2
7
Cc: qemu-stable@nongnu.org
3
All callers of qemu_co_sleep_wake are checking whether they are passing
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
4
a NULL argument inside the pointer-to-pointer: do the check in
9
Message-id: 20190910124136.10565-5-mreitz@redhat.com
5
qemu_co_sleep_wake itself.
10
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
6
11
Reviewed-by: John Snow <jsnow@redhat.com>
7
As a side effect, qemu_co_sleep_wake can be called more than once and
12
Signed-off-by: Max Reitz <mreitz@redhat.com>
8
it will only wake the coroutine once; after the first time, the argument
9
will be set to NULL via *sleep_state->user_state_pointer. However, this
10
would not be safe unless co_sleep_cb keeps using the QemuCoSleepState*
11
directly, so make it go through the pointer-to-pointer instead.
12
13
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
14
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
15
Message-id: 20210517100548.28806-4-pbonzini@redhat.com
16
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
---
17
---
14
block/curl.c | 20 +++++++++++---------
18
block/block-copy.c | 4 +---
15
1 file changed, 11 insertions(+), 9 deletions(-)
19
block/nbd.c | 8 ++------
20
util/qemu-coroutine-sleep.c | 21 ++++++++++++---------
21
3 files changed, 15 insertions(+), 18 deletions(-)
16
22
17
diff --git a/block/curl.c b/block/curl.c
23
diff --git a/block/block-copy.c b/block/block-copy.c
18
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
19
--- a/block/curl.c
25
--- a/block/block-copy.c
20
+++ b/block/curl.c
26
+++ b/block/block-copy.c
21
@@ -XXX,XX +XXX,XX @@ static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action,
27
@@ -XXX,XX +XXX,XX @@ out:
22
switch (action) {
28
23
case CURL_POLL_IN:
29
void block_copy_kick(BlockCopyCallState *call_state)
24
aio_set_fd_handler(s->aio_context, fd, false,
30
{
25
- curl_multi_do, NULL, NULL, state);
31
- if (call_state->sleep_state) {
26
+ curl_multi_do, NULL, NULL, socket);
32
- qemu_co_sleep_wake(call_state->sleep_state);
27
break;
33
- }
28
case CURL_POLL_OUT:
34
+ qemu_co_sleep_wake(call_state->sleep_state);
29
aio_set_fd_handler(s->aio_context, fd, false,
30
- NULL, curl_multi_do, NULL, state);
31
+ NULL, curl_multi_do, NULL, socket);
32
break;
33
case CURL_POLL_INOUT:
34
aio_set_fd_handler(s->aio_context, fd, false,
35
- curl_multi_do, curl_multi_do, NULL, state);
36
+ curl_multi_do, curl_multi_do, NULL, socket);
37
break;
38
case CURL_POLL_REMOVE:
39
aio_set_fd_handler(s->aio_context, fd, false,
40
@@ -XXX,XX +XXX,XX @@ static void curl_multi_check_completion(BDRVCURLState *s)
41
}
35
}
42
36
43
/* Called with s->mutex held. */
37
/*
44
-static void curl_multi_do_locked(CURLState *s)
38
diff --git a/block/nbd.c b/block/nbd.c
45
+static void curl_multi_do_locked(CURLSocket *ready_socket)
39
index XXXXXXX..XXXXXXX 100644
40
--- a/block/nbd.c
41
+++ b/block/nbd.c
42
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn nbd_client_co_drain_begin(BlockDriverState *bs)
43
BDRVNBDState *s = (BDRVNBDState *)bs->opaque;
44
45
s->drained = true;
46
- if (s->connection_co_sleep_ns_state) {
47
- qemu_co_sleep_wake(s->connection_co_sleep_ns_state);
48
- }
49
+ qemu_co_sleep_wake(s->connection_co_sleep_ns_state);
50
51
nbd_co_establish_connection_cancel(bs, false);
52
53
@@ -XXX,XX +XXX,XX @@ static void nbd_teardown_connection(BlockDriverState *bs)
54
55
s->state = NBD_CLIENT_QUIT;
56
if (s->connection_co) {
57
- if (s->connection_co_sleep_ns_state) {
58
- qemu_co_sleep_wake(s->connection_co_sleep_ns_state);
59
- }
60
+ qemu_co_sleep_wake(s->connection_co_sleep_ns_state);
61
nbd_co_establish_connection_cancel(bs, true);
62
}
63
if (qemu_in_coroutine()) {
64
diff --git a/util/qemu-coroutine-sleep.c b/util/qemu-coroutine-sleep.c
65
index XXXXXXX..XXXXXXX 100644
66
--- a/util/qemu-coroutine-sleep.c
67
+++ b/util/qemu-coroutine-sleep.c
68
@@ -XXX,XX +XXX,XX @@ struct QemuCoSleepState {
69
70
void qemu_co_sleep_wake(QemuCoSleepState *sleep_state)
46
{
71
{
47
CURLSocket *socket, *next_socket;
72
- /* Write of schedule protected by barrier write in aio_co_schedule */
48
+ CURLState *s = ready_socket->state;
73
- const char *scheduled = qatomic_cmpxchg(&sleep_state->co->scheduled,
49
int running;
74
- qemu_co_sleep_ns__scheduled, NULL);
50
int r;
75
+ if (sleep_state) {
51
76
+ /* Write of schedule protected by barrier write in aio_co_schedule */
52
@@ -XXX,XX +XXX,XX @@ static void curl_multi_do_locked(CURLState *s)
77
+ const char *scheduled = qatomic_cmpxchg(&sleep_state->co->scheduled,
53
78
+ qemu_co_sleep_ns__scheduled, NULL);
54
static void curl_multi_do(void *arg)
79
80
- assert(scheduled == qemu_co_sleep_ns__scheduled);
81
- *sleep_state->user_state_pointer = NULL;
82
- timer_del(&sleep_state->ts);
83
- aio_co_wake(sleep_state->co);
84
+ assert(scheduled == qemu_co_sleep_ns__scheduled);
85
+ *sleep_state->user_state_pointer = NULL;
86
+ timer_del(&sleep_state->ts);
87
+ aio_co_wake(sleep_state->co);
88
+ }
89
}
90
91
static void co_sleep_cb(void *opaque)
55
{
92
{
56
- CURLState *s = (CURLState *)arg;
93
- qemu_co_sleep_wake(opaque);
57
+ CURLSocket *socket = arg;
94
+ QemuCoSleepState **sleep_state = opaque;
58
+ BDRVCURLState *s = socket->state->s;
95
+ qemu_co_sleep_wake(*sleep_state);
59
60
- qemu_mutex_lock(&s->s->mutex);
61
- curl_multi_do_locked(s);
62
- curl_multi_check_completion(s->s);
63
- qemu_mutex_unlock(&s->s->mutex);
64
+ qemu_mutex_lock(&s->mutex);
65
+ curl_multi_do_locked(socket);
66
+ curl_multi_check_completion(s);
67
+ qemu_mutex_unlock(&s->mutex);
68
}
96
}
69
97
70
static void curl_multi_timeout_do(void *arg)
98
void coroutine_fn qemu_co_sleep_ns_wakeable(QEMUClockType type, int64_t ns,
99
@@ -XXX,XX +XXX,XX @@ void coroutine_fn qemu_co_sleep_ns_wakeable(QEMUClockType type, int64_t ns,
100
abort();
101
}
102
103
- aio_timer_init(ctx, &state.ts, type, SCALE_NS, co_sleep_cb, &state);
104
+ aio_timer_init(ctx, &state.ts, type, SCALE_NS, co_sleep_cb, sleep_state);
105
*sleep_state = &state;
106
timer_mod(&state.ts, qemu_clock_get_ns(type) + ns);
107
qemu_coroutine_yield();
71
--
108
--
72
2.21.0
109
2.31.1
73
110
74
diff view generated by jsdifflib
1
From: Thomas Huth <thuth@redhat.com>
1
From: Paolo Bonzini <pbonzini@redhat.com>
2
2
3
When running "make check -j8" or something similar, the iotests are
3
This simplification is enabled by the previous patch. Now aio_co_wake
4
running in parallel with the other tests. So when they are printing
4
will only be called once, therefore we do not care about a spurious
5
out "Passed all xx tests" or a similar status message at the end,
5
firing of the timer after a qemu_co_sleep_wake.
6
it might not be quite clear that this message belongs to the iotests,
7
since the output might be mixed with the other tests. Thus change the
8
word "tests" here to "iotests" instead to avoid confusion.
9
6
10
Signed-off-by: Thomas Huth <thuth@redhat.com>
7
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
11
Message-id: 20190906113920.11271-1-thuth@redhat.com
8
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12
Reviewed-by: John Snow <jsnow@redhat.com>
9
Message-id: 20210517100548.28806-5-pbonzini@redhat.com
13
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
14
---
11
---
15
tests/qemu-iotests/check | 8 ++++----
12
util/qemu-coroutine-sleep.c | 8 ++++----
16
1 file changed, 4 insertions(+), 4 deletions(-)
13
1 file changed, 4 insertions(+), 4 deletions(-)
17
14
18
diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
15
diff --git a/util/qemu-coroutine-sleep.c b/util/qemu-coroutine-sleep.c
19
index XXXXXXX..XXXXXXX 100755
16
index XXXXXXX..XXXXXXX 100644
20
--- a/tests/qemu-iotests/check
17
--- a/util/qemu-coroutine-sleep.c
21
+++ b/tests/qemu-iotests/check
18
+++ b/util/qemu-coroutine-sleep.c
22
@@ -XXX,XX +XXX,XX @@ END { if (NR > 0) {
19
@@ -XXX,XX +XXX,XX @@ static const char *qemu_co_sleep_ns__scheduled = "qemu_co_sleep_ns";
23
if [ ! -z "$n_bad" -a $n_bad != 0 ]
20
24
then
21
struct QemuCoSleepState {
25
echo "Failures:$bad"
22
Coroutine *co;
26
- echo "Failed $n_bad of $try tests"
23
- QEMUTimer ts;
27
+ echo "Failed $n_bad of $try iotests"
24
QemuCoSleepState **user_state_pointer;
28
echo "Failures:$bad" | fmt >>check.log
25
};
29
- echo "Failed $n_bad of $try tests" >>check.log
26
30
+ echo "Failed $n_bad of $try iotests" >>check.log
27
@@ -XXX,XX +XXX,XX @@ void qemu_co_sleep_wake(QemuCoSleepState *sleep_state)
31
else
28
32
- echo "Passed all $try tests"
29
assert(scheduled == qemu_co_sleep_ns__scheduled);
33
- echo "Passed all $try tests" >>check.log
30
*sleep_state->user_state_pointer = NULL;
34
+ echo "Passed all $try iotests"
31
- timer_del(&sleep_state->ts);
35
+ echo "Passed all $try iotests" >>check.log
32
aio_co_wake(sleep_state->co);
36
fi
33
}
37
needwrap=false
34
}
38
fi
35
@@ -XXX,XX +XXX,XX @@ void coroutine_fn qemu_co_sleep_ns_wakeable(QEMUClockType type, int64_t ns,
36
QemuCoSleepState **sleep_state)
37
{
38
AioContext *ctx = qemu_get_current_aio_context();
39
+ QEMUTimer ts;
40
QemuCoSleepState state = {
41
.co = qemu_coroutine_self(),
42
.user_state_pointer = sleep_state,
43
@@ -XXX,XX +XXX,XX @@ void coroutine_fn qemu_co_sleep_ns_wakeable(QEMUClockType type, int64_t ns,
44
abort();
45
}
46
47
- aio_timer_init(ctx, &state.ts, type, SCALE_NS, co_sleep_cb, sleep_state);
48
+ aio_timer_init(ctx, &ts, type, SCALE_NS, co_sleep_cb, sleep_state);
49
*sleep_state = &state;
50
- timer_mod(&state.ts, qemu_clock_get_ns(type) + ns);
51
+ timer_mod(&ts, qemu_clock_get_ns(type) + ns);
52
qemu_coroutine_yield();
53
+ timer_del(&ts);
54
55
/* qemu_co_sleep_wake clears *sleep_state before resuming this coroutine. */
56
assert(*sleep_state == NULL);
39
--
57
--
40
2.21.0
58
2.31.1
41
59
42
diff view generated by jsdifflib
Deleted patch
1
From: Thomas Huth <thuth@redhat.com>
2
1
3
The check script is already printing out which iotest is currently
4
running, so printing out the name of the check-block.sh shell script
5
looks superfluous here.
6
7
Signed-off-by: Thomas Huth <thuth@redhat.com>
8
Message-id: 20190906113534.10907-1-thuth@redhat.com
9
Acked-by: John Snow <jsnow@redhat.com>
10
Reviewed-by: Max Reitz <mreitz@redhat.com>
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
12
---
13
tests/Makefile.include | 2 +-
14
1 file changed, 1 insertion(+), 1 deletion(-)
15
16
diff --git a/tests/Makefile.include b/tests/Makefile.include
17
index XXXXXXX..XXXXXXX 100644
18
--- a/tests/Makefile.include
19
+++ b/tests/Makefile.include
20
@@ -XXX,XX +XXX,XX @@ QEMU_IOTESTS_HELPERS-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_LINUX)) = tests/qemu
21
check-tests/check-block.sh: tests/check-block.sh qemu-img$(EXESUF) \
22
        qemu-io$(EXESUF) qemu-nbd$(EXESUF) $(QEMU_IOTESTS_HELPERS-y) \
23
        $(patsubst %,%/all,$(filter %-softmmu,$(TARGET_DIRS)))
24
-    $<
25
+    @$<
26
27
.PHONY: $(patsubst %, check-%, $(check-qapi-schema-y))
28
$(patsubst %, check-%, $(check-qapi-schema-y)): check-%.json: $(SRC_PATH)/%.json
29
--
30
2.21.0
31
32
diff view generated by jsdifflib
Deleted patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
1
3
qemu-io now prefixes its error and warnings with "qemu-io:".
4
36b9986b08787019e fixed a lot of iotests output but forget about
5
026.out.nocache. Fix it too.
6
7
Fixes: 99e98d7c9fc1a1639fad ("qemu-io: Use error_[gs]et_progname()")
8
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
9
Message-id: 20190816153015.447957-2-vsementsov@virtuozzo.com
10
Reviewed-by: John Snow <jsnow@redhat.com>
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
12
---
13
tests/qemu-iotests/026.out.nocache | 168 ++++++++++++++---------------
14
1 file changed, 84 insertions(+), 84 deletions(-)
15
16
diff --git a/tests/qemu-iotests/026.out.nocache b/tests/qemu-iotests/026.out.nocache
17
index XXXXXXX..XXXXXXX 100644
18
--- a/tests/qemu-iotests/026.out.nocache
19
+++ b/tests/qemu-iotests/026.out.nocache
20
@@ -XXX,XX +XXX,XX @@ No errors were found on the image.
21
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
22
23
Event: l1_update; errno: 5; imm: off; once: off; write
24
-Failed to flush the L2 table cache: Input/output error
25
-Failed to flush the refcount block cache: Input/output error
26
+qemu-io: Failed to flush the L2 table cache: Input/output error
27
+qemu-io: Failed to flush the refcount block cache: Input/output error
28
write failed: Input/output error
29
30
1 leaked clusters were found on the image.
31
@@ -XXX,XX +XXX,XX @@ This means waste of disk space, but no harm to data.
32
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
33
34
Event: l1_update; errno: 5; imm: off; once: off; write -b
35
-Failed to flush the L2 table cache: Input/output error
36
-Failed to flush the refcount block cache: Input/output error
37
+qemu-io: Failed to flush the L2 table cache: Input/output error
38
+qemu-io: Failed to flush the refcount block cache: Input/output error
39
write failed: Input/output error
40
41
1 leaked clusters were found on the image.
42
@@ -XXX,XX +XXX,XX @@ No errors were found on the image.
43
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
44
45
Event: l1_update; errno: 28; imm: off; once: off; write
46
-Failed to flush the L2 table cache: No space left on device
47
-Failed to flush the refcount block cache: No space left on device
48
+qemu-io: Failed to flush the L2 table cache: No space left on device
49
+qemu-io: Failed to flush the refcount block cache: No space left on device
50
write failed: No space left on device
51
52
1 leaked clusters were found on the image.
53
@@ -XXX,XX +XXX,XX @@ This means waste of disk space, but no harm to data.
54
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
55
56
Event: l1_update; errno: 28; imm: off; once: off; write -b
57
-Failed to flush the L2 table cache: No space left on device
58
-Failed to flush the refcount block cache: No space left on device
59
+qemu-io: Failed to flush the L2 table cache: No space left on device
60
+qemu-io: Failed to flush the refcount block cache: No space left on device
61
write failed: No space left on device
62
63
1 leaked clusters were found on the image.
64
@@ -XXX,XX +XXX,XX @@ No errors were found on the image.
65
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
66
67
Event: l2_update; errno: 5; imm: off; once: off; write
68
-Failed to flush the L2 table cache: Input/output error
69
-Failed to flush the refcount block cache: Input/output error
70
+qemu-io: Failed to flush the L2 table cache: Input/output error
71
+qemu-io: Failed to flush the refcount block cache: Input/output error
72
wrote 131072/131072 bytes at offset 0
73
128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
74
75
@@ -XXX,XX +XXX,XX @@ This means waste of disk space, but no harm to data.
76
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
77
78
Event: l2_update; errno: 5; imm: off; once: off; write -b
79
-Failed to flush the L2 table cache: Input/output error
80
-Failed to flush the refcount block cache: Input/output error
81
+qemu-io: Failed to flush the L2 table cache: Input/output error
82
+qemu-io: Failed to flush the refcount block cache: Input/output error
83
wrote 131072/131072 bytes at offset 0
84
128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
85
86
@@ -XXX,XX +XXX,XX @@ No errors were found on the image.
87
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
88
89
Event: l2_update; errno: 28; imm: off; once: off; write
90
-Failed to flush the L2 table cache: No space left on device
91
-Failed to flush the refcount block cache: No space left on device
92
+qemu-io: Failed to flush the L2 table cache: No space left on device
93
+qemu-io: Failed to flush the refcount block cache: No space left on device
94
wrote 131072/131072 bytes at offset 0
95
128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
96
97
@@ -XXX,XX +XXX,XX @@ This means waste of disk space, but no harm to data.
98
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
99
100
Event: l2_update; errno: 28; imm: off; once: off; write -b
101
-Failed to flush the L2 table cache: No space left on device
102
-Failed to flush the refcount block cache: No space left on device
103
+qemu-io: Failed to flush the L2 table cache: No space left on device
104
+qemu-io: Failed to flush the refcount block cache: No space left on device
105
wrote 131072/131072 bytes at offset 0
106
128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
107
108
@@ -XXX,XX +XXX,XX @@ No errors were found on the image.
109
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
110
111
Event: l2_alloc_write; errno: 5; imm: off; once: off; write
112
-Failed to flush the L2 table cache: Input/output error
113
-Failed to flush the refcount block cache: Input/output error
114
+qemu-io: Failed to flush the L2 table cache: Input/output error
115
+qemu-io: Failed to flush the refcount block cache: Input/output error
116
write failed: Input/output error
117
No errors were found on the image.
118
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
119
120
Event: l2_alloc_write; errno: 5; imm: off; once: off; write -b
121
-Failed to flush the L2 table cache: Input/output error
122
-Failed to flush the refcount block cache: Input/output error
123
+qemu-io: Failed to flush the L2 table cache: Input/output error
124
+qemu-io: Failed to flush the refcount block cache: Input/output error
125
write failed: Input/output error
126
127
1 leaked clusters were found on the image.
128
@@ -XXX,XX +XXX,XX @@ No errors were found on the image.
129
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
130
131
Event: l2_alloc_write; errno: 28; imm: off; once: off; write
132
-Failed to flush the L2 table cache: No space left on device
133
-Failed to flush the refcount block cache: No space left on device
134
+qemu-io: Failed to flush the L2 table cache: No space left on device
135
+qemu-io: Failed to flush the refcount block cache: No space left on device
136
write failed: No space left on device
137
No errors were found on the image.
138
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
139
140
Event: l2_alloc_write; errno: 28; imm: off; once: off; write -b
141
-Failed to flush the L2 table cache: No space left on device
142
-Failed to flush the refcount block cache: No space left on device
143
+qemu-io: Failed to flush the L2 table cache: No space left on device
144
+qemu-io: Failed to flush the refcount block cache: No space left on device
145
write failed: No space left on device
146
147
1 leaked clusters were found on the image.
148
@@ -XXX,XX +XXX,XX @@ No errors were found on the image.
149
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
150
151
Event: write_aio; errno: 5; imm: off; once: off; write
152
-Failed to flush the L2 table cache: Input/output error
153
-Failed to flush the refcount block cache: Input/output error
154
+qemu-io: Failed to flush the L2 table cache: Input/output error
155
+qemu-io: Failed to flush the refcount block cache: Input/output error
156
write failed: Input/output error
157
No errors were found on the image.
158
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
159
160
Event: write_aio; errno: 5; imm: off; once: off; write -b
161
-Failed to flush the L2 table cache: Input/output error
162
-Failed to flush the refcount block cache: Input/output error
163
+qemu-io: Failed to flush the L2 table cache: Input/output error
164
+qemu-io: Failed to flush the refcount block cache: Input/output error
165
write failed: Input/output error
166
No errors were found on the image.
167
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
168
@@ -XXX,XX +XXX,XX @@ No errors were found on the image.
169
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
170
171
Event: write_aio; errno: 28; imm: off; once: off; write
172
-Failed to flush the L2 table cache: No space left on device
173
-Failed to flush the refcount block cache: No space left on device
174
+qemu-io: Failed to flush the L2 table cache: No space left on device
175
+qemu-io: Failed to flush the refcount block cache: No space left on device
176
write failed: No space left on device
177
No errors were found on the image.
178
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
179
180
Event: write_aio; errno: 28; imm: off; once: off; write -b
181
-Failed to flush the L2 table cache: No space left on device
182
-Failed to flush the refcount block cache: No space left on device
183
+qemu-io: Failed to flush the L2 table cache: No space left on device
184
+qemu-io: Failed to flush the refcount block cache: No space left on device
185
write failed: No space left on device
186
No errors were found on the image.
187
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
188
@@ -XXX,XX +XXX,XX @@ No errors were found on the image.
189
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
190
191
Event: refblock_load; errno: 5; imm: off; once: off; write
192
-Failed to flush the L2 table cache: Input/output error
193
-Failed to flush the refcount block cache: Input/output error
194
+qemu-io: Failed to flush the L2 table cache: Input/output error
195
+qemu-io: Failed to flush the refcount block cache: Input/output error
196
write failed: Input/output error
197
No errors were found on the image.
198
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
199
200
Event: refblock_load; errno: 5; imm: off; once: off; write -b
201
-Failed to flush the L2 table cache: Input/output error
202
-Failed to flush the refcount block cache: Input/output error
203
+qemu-io: Failed to flush the L2 table cache: Input/output error
204
+qemu-io: Failed to flush the refcount block cache: Input/output error
205
write failed: Input/output error
206
No errors were found on the image.
207
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
208
@@ -XXX,XX +XXX,XX @@ No errors were found on the image.
209
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
210
211
Event: refblock_load; errno: 28; imm: off; once: off; write
212
-Failed to flush the L2 table cache: No space left on device
213
-Failed to flush the refcount block cache: No space left on device
214
+qemu-io: Failed to flush the L2 table cache: No space left on device
215
+qemu-io: Failed to flush the refcount block cache: No space left on device
216
write failed: No space left on device
217
No errors were found on the image.
218
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
219
220
Event: refblock_load; errno: 28; imm: off; once: off; write -b
221
-Failed to flush the L2 table cache: No space left on device
222
-Failed to flush the refcount block cache: No space left on device
223
+qemu-io: Failed to flush the L2 table cache: No space left on device
224
+qemu-io: Failed to flush the refcount block cache: No space left on device
225
write failed: No space left on device
226
No errors were found on the image.
227
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
228
@@ -XXX,XX +XXX,XX @@ No errors were found on the image.
229
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
230
231
Event: refblock_update_part; errno: 5; imm: off; once: off; write
232
-Failed to flush the L2 table cache: Input/output error
233
-Failed to flush the refcount block cache: Input/output error
234
+qemu-io: Failed to flush the L2 table cache: Input/output error
235
+qemu-io: Failed to flush the refcount block cache: Input/output error
236
write failed: Input/output error
237
No errors were found on the image.
238
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
239
240
Event: refblock_update_part; errno: 5; imm: off; once: off; write -b
241
-Failed to flush the L2 table cache: Input/output error
242
-Failed to flush the refcount block cache: Input/output error
243
+qemu-io: Failed to flush the L2 table cache: Input/output error
244
+qemu-io: Failed to flush the refcount block cache: Input/output error
245
write failed: Input/output error
246
No errors were found on the image.
247
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
248
@@ -XXX,XX +XXX,XX @@ No errors were found on the image.
249
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
250
251
Event: refblock_update_part; errno: 28; imm: off; once: off; write
252
-Failed to flush the L2 table cache: No space left on device
253
-Failed to flush the refcount block cache: No space left on device
254
+qemu-io: Failed to flush the L2 table cache: No space left on device
255
+qemu-io: Failed to flush the refcount block cache: No space left on device
256
write failed: No space left on device
257
No errors were found on the image.
258
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
259
260
Event: refblock_update_part; errno: 28; imm: off; once: off; write -b
261
-Failed to flush the L2 table cache: No space left on device
262
-Failed to flush the refcount block cache: No space left on device
263
+qemu-io: Failed to flush the L2 table cache: No space left on device
264
+qemu-io: Failed to flush the refcount block cache: No space left on device
265
write failed: No space left on device
266
No errors were found on the image.
267
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
268
@@ -XXX,XX +XXX,XX @@ No errors were found on the image.
269
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
270
271
Event: refblock_alloc; errno: 5; imm: off; once: off; write
272
-Failed to flush the L2 table cache: Input/output error
273
-Failed to flush the refcount block cache: Input/output error
274
+qemu-io: Failed to flush the L2 table cache: Input/output error
275
+qemu-io: Failed to flush the refcount block cache: Input/output error
276
write failed: Input/output error
277
No errors were found on the image.
278
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
279
280
Event: refblock_alloc; errno: 5; imm: off; once: off; write -b
281
-Failed to flush the L2 table cache: Input/output error
282
-Failed to flush the refcount block cache: Input/output error
283
+qemu-io: Failed to flush the L2 table cache: Input/output error
284
+qemu-io: Failed to flush the refcount block cache: Input/output error
285
write failed: Input/output error
286
No errors were found on the image.
287
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
288
@@ -XXX,XX +XXX,XX @@ No errors were found on the image.
289
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
290
291
Event: refblock_alloc; errno: 28; imm: off; once: off; write
292
-Failed to flush the L2 table cache: No space left on device
293
-Failed to flush the refcount block cache: No space left on device
294
+qemu-io: Failed to flush the L2 table cache: No space left on device
295
+qemu-io: Failed to flush the refcount block cache: No space left on device
296
write failed: No space left on device
297
No errors were found on the image.
298
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
299
300
Event: refblock_alloc; errno: 28; imm: off; once: off; write -b
301
-Failed to flush the L2 table cache: No space left on device
302
-Failed to flush the refcount block cache: No space left on device
303
+qemu-io: Failed to flush the L2 table cache: No space left on device
304
+qemu-io: Failed to flush the refcount block cache: No space left on device
305
write failed: No space left on device
306
No errors were found on the image.
307
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
308
@@ -XXX,XX +XXX,XX @@ No errors were found on the image.
309
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
310
311
Event: refblock_alloc_hookup; errno: 28; imm: off; once: off; write
312
-Failed to flush the L2 table cache: No space left on device
313
-Failed to flush the refcount block cache: No space left on device
314
+qemu-io: Failed to flush the L2 table cache: No space left on device
315
+qemu-io: Failed to flush the refcount block cache: No space left on device
316
write failed: No space left on device
317
318
55 leaked clusters were found on the image.
319
@@ -XXX,XX +XXX,XX @@ This means waste of disk space, but no harm to data.
320
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
321
322
Event: refblock_alloc_hookup; errno: 28; imm: off; once: off; write -b
323
-Failed to flush the L2 table cache: No space left on device
324
-Failed to flush the refcount block cache: No space left on device
325
+qemu-io: Failed to flush the L2 table cache: No space left on device
326
+qemu-io: Failed to flush the refcount block cache: No space left on device
327
write failed: No space left on device
328
329
251 leaked clusters were found on the image.
330
@@ -XXX,XX +XXX,XX @@ No errors were found on the image.
331
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
332
333
Event: refblock_alloc_write; errno: 28; imm: off; once: off; write
334
-Failed to flush the L2 table cache: No space left on device
335
-Failed to flush the refcount block cache: No space left on device
336
+qemu-io: Failed to flush the L2 table cache: No space left on device
337
+qemu-io: Failed to flush the refcount block cache: No space left on device
338
write failed: No space left on device
339
No errors were found on the image.
340
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
341
342
Event: refblock_alloc_write; errno: 28; imm: off; once: off; write -b
343
-Failed to flush the L2 table cache: No space left on device
344
-Failed to flush the refcount block cache: No space left on device
345
+qemu-io: Failed to flush the L2 table cache: No space left on device
346
+qemu-io: Failed to flush the refcount block cache: No space left on device
347
write failed: No space left on device
348
No errors were found on the image.
349
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
350
@@ -XXX,XX +XXX,XX @@ No errors were found on the image.
351
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
352
353
Event: refblock_alloc_write_blocks; errno: 28; imm: off; once: off; write
354
-Failed to flush the L2 table cache: No space left on device
355
-Failed to flush the refcount block cache: No space left on device
356
+qemu-io: Failed to flush the L2 table cache: No space left on device
357
+qemu-io: Failed to flush the refcount block cache: No space left on device
358
write failed: No space left on device
359
360
10 leaked clusters were found on the image.
361
@@ -XXX,XX +XXX,XX @@ This means waste of disk space, but no harm to data.
362
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
363
364
Event: refblock_alloc_write_blocks; errno: 28; imm: off; once: off; write -b
365
-Failed to flush the L2 table cache: No space left on device
366
-Failed to flush the refcount block cache: No space left on device
367
+qemu-io: Failed to flush the L2 table cache: No space left on device
368
+qemu-io: Failed to flush the refcount block cache: No space left on device
369
write failed: No space left on device
370
371
23 leaked clusters were found on the image.
372
@@ -XXX,XX +XXX,XX @@ No errors were found on the image.
373
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
374
375
Event: refblock_alloc_write_table; errno: 28; imm: off; once: off; write
376
-Failed to flush the L2 table cache: No space left on device
377
-Failed to flush the refcount block cache: No space left on device
378
+qemu-io: Failed to flush the L2 table cache: No space left on device
379
+qemu-io: Failed to flush the refcount block cache: No space left on device
380
write failed: No space left on device
381
382
10 leaked clusters were found on the image.
383
@@ -XXX,XX +XXX,XX @@ This means waste of disk space, but no harm to data.
384
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
385
386
Event: refblock_alloc_write_table; errno: 28; imm: off; once: off; write -b
387
-Failed to flush the L2 table cache: No space left on device
388
-Failed to flush the refcount block cache: No space left on device
389
+qemu-io: Failed to flush the L2 table cache: No space left on device
390
+qemu-io: Failed to flush the refcount block cache: No space left on device
391
write failed: No space left on device
392
393
23 leaked clusters were found on the image.
394
@@ -XXX,XX +XXX,XX @@ No errors were found on the image.
395
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
396
397
Event: refblock_alloc_switch_table; errno: 28; imm: off; once: off; write
398
-Failed to flush the L2 table cache: No space left on device
399
-Failed to flush the refcount block cache: No space left on device
400
+qemu-io: Failed to flush the L2 table cache: No space left on device
401
+qemu-io: Failed to flush the refcount block cache: No space left on device
402
write failed: No space left on device
403
404
10 leaked clusters were found on the image.
405
@@ -XXX,XX +XXX,XX @@ This means waste of disk space, but no harm to data.
406
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
407
408
Event: refblock_alloc_switch_table; errno: 28; imm: off; once: off; write -b
409
-Failed to flush the L2 table cache: No space left on device
410
-Failed to flush the refcount block cache: No space left on device
411
+qemu-io: Failed to flush the L2 table cache: No space left on device
412
+qemu-io: Failed to flush the refcount block cache: No space left on device
413
write failed: No space left on device
414
415
23 leaked clusters were found on the image.
416
@@ -XXX,XX +XXX,XX @@ No errors were found on the image.
417
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
418
419
Event: l1_grow_write_table; errno: 5; imm: off; once: off
420
-Failed to flush the L2 table cache: Input/output error
421
-Failed to flush the refcount block cache: Input/output error
422
+qemu-io: Failed to flush the L2 table cache: Input/output error
423
+qemu-io: Failed to flush the refcount block cache: Input/output error
424
write failed: Input/output error
425
No errors were found on the image.
426
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
427
@@ -XXX,XX +XXX,XX @@ No errors were found on the image.
428
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
429
430
Event: l1_grow_write_table; errno: 28; imm: off; once: off
431
-Failed to flush the L2 table cache: No space left on device
432
-Failed to flush the refcount block cache: No space left on device
433
+qemu-io: Failed to flush the L2 table cache: No space left on device
434
+qemu-io: Failed to flush the refcount block cache: No space left on device
435
write failed: No space left on device
436
No errors were found on the image.
437
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
438
@@ -XXX,XX +XXX,XX @@ No errors were found on the image.
439
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
440
441
Event: l1_grow_activate_table; errno: 5; imm: off; once: off
442
-Failed to flush the L2 table cache: Input/output error
443
-Failed to flush the refcount block cache: Input/output error
444
+qemu-io: Failed to flush the L2 table cache: Input/output error
445
+qemu-io: Failed to flush the refcount block cache: Input/output error
446
write failed: Input/output error
447
448
96 leaked clusters were found on the image.
449
@@ -XXX,XX +XXX,XX @@ No errors were found on the image.
450
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
451
452
Event: l1_grow_activate_table; errno: 28; imm: off; once: off
453
-Failed to flush the L2 table cache: No space left on device
454
-Failed to flush the refcount block cache: No space left on device
455
+qemu-io: Failed to flush the L2 table cache: No space left on device
456
+qemu-io: Failed to flush the refcount block cache: No space left on device
457
write failed: No space left on device
458
459
96 leaked clusters were found on the image.
460
--
461
2.21.0
462
463
diff view generated by jsdifflib
Deleted patch
1
A follow-up patch will make curl_multi_do() and curl_multi_read() take a
2
CURLSocket instead of the CURLState. They still need the latter,
3
though, so add a pointer to it to the former.
4
1
5
Cc: qemu-stable@nongnu.org
6
Signed-off-by: Max Reitz <mreitz@redhat.com>
7
Reviewed-by: John Snow <jsnow@redhat.com>
8
Message-id: 20190910124136.10565-2-mreitz@redhat.com
9
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
---
12
block/curl.c | 3 +++
13
1 file changed, 3 insertions(+)
14
15
diff --git a/block/curl.c b/block/curl.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/block/curl.c
18
+++ b/block/curl.c
19
@@ -XXX,XX +XXX,XX @@ static CURLMcode __curl_multi_socket_action(CURLM *multi_handle,
20
#define CURL_BLOCK_OPT_TIMEOUT_DEFAULT 5
21
22
struct BDRVCURLState;
23
+struct CURLState;
24
25
static bool libcurl_initialized;
26
27
@@ -XXX,XX +XXX,XX @@ typedef struct CURLAIOCB {
28
29
typedef struct CURLSocket {
30
int fd;
31
+ struct CURLState *state;
32
QLIST_ENTRY(CURLSocket) next;
33
} CURLSocket;
34
35
@@ -XXX,XX +XXX,XX @@ static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action,
36
if (!socket) {
37
socket = g_new0(CURLSocket, 1);
38
socket->fd = fd;
39
+ socket->state = state;
40
QLIST_INSERT_HEAD(&state->sockets, socket, next);
41
}
42
socket = NULL;
43
--
44
2.21.0
45
46
diff view generated by jsdifflib
1
This does not really change anything, but it makes the code a bit easier
1
From: Paolo Bonzini <pbonzini@redhat.com>
2
to follow once we use @socket as the opaque pointer for
2
3
aio_set_fd_handler().
3
Right now, users of qemu_co_sleep_ns_wakeable are simply passing
4
4
a pointer to QemuCoSleepState by reference to the function. But
5
Cc: qemu-stable@nongnu.org
5
QemuCoSleepState really is just a Coroutine*; making the
6
Signed-off-by: Max Reitz <mreitz@redhat.com>
6
content of the struct public is just as efficient and lets us
7
Message-id: 20190910124136.10565-3-mreitz@redhat.com
7
skip the user_state_pointer indirection.
8
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
8
9
Reviewed-by: John Snow <jsnow@redhat.com>
9
Since the usage is changed, take the occasion to rename the
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
struct to QemuCoSleep.
11
12
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
13
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
14
Message-id: 20210517100548.28806-6-pbonzini@redhat.com
15
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11
---
16
---
12
block/curl.c | 10 +++++-----
17
include/qemu/coroutine.h | 23 +++++++++++----------
13
1 file changed, 5 insertions(+), 5 deletions(-)
18
block/block-copy.c | 8 ++++----
14
19
block/nbd.c | 10 ++++-----
15
diff --git a/block/curl.c b/block/curl.c
20
util/qemu-coroutine-sleep.c | 41 ++++++++++++++++---------------------
16
index XXXXXXX..XXXXXXX 100644
21
4 files changed, 39 insertions(+), 43 deletions(-)
17
--- a/block/curl.c
22
18
+++ b/block/curl.c
23
diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h
19
@@ -XXX,XX +XXX,XX @@ static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action,
24
index XXXXXXX..XXXXXXX 100644
20
25
--- a/include/qemu/coroutine.h
21
QLIST_FOREACH(socket, &state->sockets, next) {
26
+++ b/include/qemu/coroutine.h
22
if (socket->fd == fd) {
27
@@ -XXX,XX +XXX,XX @@ void qemu_co_rwlock_wrlock(CoRwlock *lock);
23
- if (action == CURL_POLL_REMOVE) {
28
*/
24
- QLIST_REMOVE(socket, next);
29
void qemu_co_rwlock_unlock(CoRwlock *lock);
25
- g_free(socket);
30
26
- }
31
-typedef struct QemuCoSleepState QemuCoSleepState;
27
break;
32
+typedef struct QemuCoSleep {
28
}
33
+ Coroutine *to_wake;
34
+} QemuCoSleep;
35
36
/**
37
- * Yield the coroutine for a given duration. During this yield, @sleep_state
38
- * is set to an opaque pointer, which may be used for
39
- * qemu_co_sleep_wake(). Be careful, the pointer is set back to zero when the
40
- * timer fires. Don't save the obtained value to other variables and don't call
41
- * qemu_co_sleep_wake from another aio context.
42
+ * Yield the coroutine for a given duration. Initializes @w so that,
43
+ * during this yield, it can be passed to qemu_co_sleep_wake() to
44
+ * terminate the sleep.
45
*/
46
-void coroutine_fn qemu_co_sleep_ns_wakeable(QEMUClockType type, int64_t ns,
47
- QemuCoSleepState **sleep_state);
48
+void coroutine_fn qemu_co_sleep_ns_wakeable(QemuCoSleep *w,
49
+ QEMUClockType type, int64_t ns);
50
+
51
static inline void coroutine_fn qemu_co_sleep_ns(QEMUClockType type, int64_t ns)
52
{
53
- QemuCoSleepState *unused = NULL;
54
- qemu_co_sleep_ns_wakeable(type, ns, &unused);
55
+ QemuCoSleep w = { 0 };
56
+ qemu_co_sleep_ns_wakeable(&w, type, ns);
57
}
58
59
/**
60
@@ -XXX,XX +XXX,XX @@ static inline void coroutine_fn qemu_co_sleep_ns(QEMUClockType type, int64_t ns)
61
* qemu_co_sleep_ns() and should be checked to be non-NULL before calling
62
* qemu_co_sleep_wake().
63
*/
64
-void qemu_co_sleep_wake(QemuCoSleepState *sleep_state);
65
+void qemu_co_sleep_wake(QemuCoSleep *w);
66
67
/**
68
* Yield until a file descriptor becomes readable
69
diff --git a/block/block-copy.c b/block/block-copy.c
70
index XXXXXXX..XXXXXXX 100644
71
--- a/block/block-copy.c
72
+++ b/block/block-copy.c
73
@@ -XXX,XX +XXX,XX @@ typedef struct BlockCopyCallState {
74
/* State */
75
int ret;
76
bool finished;
77
- QemuCoSleepState *sleep_state;
78
+ QemuCoSleep sleep;
79
bool cancelled;
80
81
/* OUT parameters */
82
@@ -XXX,XX +XXX,XX @@ block_copy_dirty_clusters(BlockCopyCallState *call_state)
83
if (ns > 0) {
84
block_copy_task_end(task, -EAGAIN);
85
g_free(task);
86
- qemu_co_sleep_ns_wakeable(QEMU_CLOCK_REALTIME, ns,
87
- &call_state->sleep_state);
88
+ qemu_co_sleep_ns_wakeable(&call_state->sleep,
89
+ QEMU_CLOCK_REALTIME, ns);
90
continue;
91
}
92
}
93
@@ -XXX,XX +XXX,XX @@ out:
94
95
void block_copy_kick(BlockCopyCallState *call_state)
96
{
97
- qemu_co_sleep_wake(call_state->sleep_state);
98
+ qemu_co_sleep_wake(&call_state->sleep);
99
}
100
101
/*
102
diff --git a/block/nbd.c b/block/nbd.c
103
index XXXXXXX..XXXXXXX 100644
104
--- a/block/nbd.c
105
+++ b/block/nbd.c
106
@@ -XXX,XX +XXX,XX @@ typedef struct BDRVNBDState {
107
CoQueue free_sema;
108
Coroutine *connection_co;
109
Coroutine *teardown_co;
110
- QemuCoSleepState *connection_co_sleep_ns_state;
111
+ QemuCoSleep reconnect_sleep;
112
bool drained;
113
bool wait_drained_end;
114
int in_flight;
115
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn nbd_client_co_drain_begin(BlockDriverState *bs)
116
BDRVNBDState *s = (BDRVNBDState *)bs->opaque;
117
118
s->drained = true;
119
- qemu_co_sleep_wake(s->connection_co_sleep_ns_state);
120
+ qemu_co_sleep_wake(&s->reconnect_sleep);
121
122
nbd_co_establish_connection_cancel(bs, false);
123
124
@@ -XXX,XX +XXX,XX @@ static void nbd_teardown_connection(BlockDriverState *bs)
125
126
s->state = NBD_CLIENT_QUIT;
127
if (s->connection_co) {
128
- qemu_co_sleep_wake(s->connection_co_sleep_ns_state);
129
+ qemu_co_sleep_wake(&s->reconnect_sleep);
130
nbd_co_establish_connection_cancel(bs, true);
29
}
131
}
30
@@ -XXX,XX +XXX,XX @@ static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action,
132
if (qemu_in_coroutine()) {
31
socket->state = state;
133
@@ -XXX,XX +XXX,XX @@ static coroutine_fn void nbd_co_reconnect_loop(BDRVNBDState *s)
32
QLIST_INSERT_HEAD(&state->sockets, socket, next);
134
}
135
bdrv_inc_in_flight(s->bs);
136
} else {
137
- qemu_co_sleep_ns_wakeable(QEMU_CLOCK_REALTIME, timeout,
138
- &s->connection_co_sleep_ns_state);
139
+ qemu_co_sleep_ns_wakeable(&s->reconnect_sleep,
140
+ QEMU_CLOCK_REALTIME, timeout);
141
if (s->drained) {
142
continue;
143
}
144
diff --git a/util/qemu-coroutine-sleep.c b/util/qemu-coroutine-sleep.c
145
index XXXXXXX..XXXXXXX 100644
146
--- a/util/qemu-coroutine-sleep.c
147
+++ b/util/qemu-coroutine-sleep.c
148
@@ -XXX,XX +XXX,XX @@
149
150
static const char *qemu_co_sleep_ns__scheduled = "qemu_co_sleep_ns";
151
152
-struct QemuCoSleepState {
153
+void qemu_co_sleep_wake(QemuCoSleep *w)
154
+{
155
Coroutine *co;
156
- QemuCoSleepState **user_state_pointer;
157
-};
158
159
-void qemu_co_sleep_wake(QemuCoSleepState *sleep_state)
160
-{
161
- if (sleep_state) {
162
+ co = w->to_wake;
163
+ w->to_wake = NULL;
164
+ if (co) {
165
/* Write of schedule protected by barrier write in aio_co_schedule */
166
- const char *scheduled = qatomic_cmpxchg(&sleep_state->co->scheduled,
167
+ const char *scheduled = qatomic_cmpxchg(&co->scheduled,
168
qemu_co_sleep_ns__scheduled, NULL);
169
170
assert(scheduled == qemu_co_sleep_ns__scheduled);
171
- *sleep_state->user_state_pointer = NULL;
172
- aio_co_wake(sleep_state->co);
173
+ aio_co_wake(co);
33
}
174
}
34
- socket = NULL;
175
}
35
176
36
trace_curl_sock_cb(action, (int)fd);
177
static void co_sleep_cb(void *opaque)
37
switch (action) {
178
{
38
@@ -XXX,XX +XXX,XX @@ static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action,
179
- QemuCoSleepState **sleep_state = opaque;
39
break;
180
- qemu_co_sleep_wake(*sleep_state);
181
+ QemuCoSleep *w = opaque;
182
+ qemu_co_sleep_wake(w);
183
}
184
185
-void coroutine_fn qemu_co_sleep_ns_wakeable(QEMUClockType type, int64_t ns,
186
- QemuCoSleepState **sleep_state)
187
+void coroutine_fn qemu_co_sleep_ns_wakeable(QemuCoSleep *w,
188
+ QEMUClockType type, int64_t ns)
189
{
190
+ Coroutine *co = qemu_coroutine_self();
191
AioContext *ctx = qemu_get_current_aio_context();
192
QEMUTimer ts;
193
- QemuCoSleepState state = {
194
- .co = qemu_coroutine_self(),
195
- .user_state_pointer = sleep_state,
196
- };
197
198
- const char *scheduled = qatomic_cmpxchg(&state.co->scheduled, NULL,
199
- qemu_co_sleep_ns__scheduled);
200
+ const char *scheduled = qatomic_cmpxchg(&co->scheduled, NULL,
201
+ qemu_co_sleep_ns__scheduled);
202
if (scheduled) {
203
fprintf(stderr,
204
"%s: Co-routine was already scheduled in '%s'\n",
205
@@ -XXX,XX +XXX,XX @@ void coroutine_fn qemu_co_sleep_ns_wakeable(QEMUClockType type, int64_t ns,
206
abort();
40
}
207
}
41
208
42
+ if (action == CURL_POLL_REMOVE) {
209
- aio_timer_init(ctx, &ts, type, SCALE_NS, co_sleep_cb, sleep_state);
43
+ QLIST_REMOVE(socket, next);
210
- *sleep_state = &state;
44
+ g_free(socket);
211
+ w->to_wake = co;
45
+ }
212
+ aio_timer_init(ctx, &ts, type, SCALE_NS, co_sleep_cb, w),
46
+
213
timer_mod(&ts, qemu_clock_get_ns(type) + ns);
47
return 0;
214
qemu_coroutine_yield();
48
}
215
timer_del(&ts);
49
216
217
- /* qemu_co_sleep_wake clears *sleep_state before resuming this coroutine. */
218
- assert(*sleep_state == NULL);
219
+ /* w->to_wake is cleared before resuming this coroutine. */
220
+ assert(w->to_wake == NULL);
221
}
50
--
222
--
51
2.21.0
223
2.31.1
52
224
53
diff view generated by jsdifflib
Deleted patch
1
While it is more likely that transfers complete after some file
2
descriptor has data ready to read, we probably should not rely on it.
3
Better be safe than sorry and call curl_multi_check_completion() in
4
curl_multi_do(), too, just like it is done in curl_multi_read().
5
1
6
With this change, curl_multi_do() and curl_multi_read() are actually the
7
same, so drop curl_multi_read() and use curl_multi_do() as the sole FD
8
handler.
9
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
Message-id: 20190910124136.10565-4-mreitz@redhat.com
12
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
13
Reviewed-by: John Snow <jsnow@redhat.com>
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
---
16
block/curl.c | 14 ++------------
17
1 file changed, 2 insertions(+), 12 deletions(-)
18
19
diff --git a/block/curl.c b/block/curl.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/block/curl.c
22
+++ b/block/curl.c
23
@@ -XXX,XX +XXX,XX @@ typedef struct BDRVCURLState {
24
25
static void curl_clean_state(CURLState *s);
26
static void curl_multi_do(void *arg);
27
-static void curl_multi_read(void *arg);
28
29
#ifdef NEED_CURL_TIMER_CALLBACK
30
/* Called from curl_multi_do_locked, with s->mutex held. */
31
@@ -XXX,XX +XXX,XX @@ static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action,
32
switch (action) {
33
case CURL_POLL_IN:
34
aio_set_fd_handler(s->aio_context, fd, false,
35
- curl_multi_read, NULL, NULL, state);
36
+ curl_multi_do, NULL, NULL, state);
37
break;
38
case CURL_POLL_OUT:
39
aio_set_fd_handler(s->aio_context, fd, false,
40
@@ -XXX,XX +XXX,XX @@ static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action,
41
break;
42
case CURL_POLL_INOUT:
43
aio_set_fd_handler(s->aio_context, fd, false,
44
- curl_multi_read, curl_multi_do, NULL, state);
45
+ curl_multi_do, curl_multi_do, NULL, state);
46
break;
47
case CURL_POLL_REMOVE:
48
aio_set_fd_handler(s->aio_context, fd, false,
49
@@ -XXX,XX +XXX,XX @@ static void curl_multi_do(void *arg)
50
{
51
CURLState *s = (CURLState *)arg;
52
53
- qemu_mutex_lock(&s->s->mutex);
54
- curl_multi_do_locked(s);
55
- qemu_mutex_unlock(&s->s->mutex);
56
-}
57
-
58
-static void curl_multi_read(void *arg)
59
-{
60
- CURLState *s = (CURLState *)arg;
61
-
62
qemu_mutex_lock(&s->s->mutex);
63
curl_multi_do_locked(s);
64
curl_multi_check_completion(s->s);
65
--
66
2.21.0
67
68
diff view generated by jsdifflib
1
Instead of reporting all sockets to cURL, only report the one that has
1
From: Paolo Bonzini <pbonzini@redhat.com>
2
caused curl_multi_do_locked() to be called. This lets us get rid of the
3
QLIST_FOREACH_SAFE() list, which was actually wrong: SAFE foreaches are
4
only safe when the current element is removed in each iteration. If it
5
possible for the list to be concurrently modified, we cannot guarantee
6
that only the current element will be removed. Therefore, we must not
7
use QLIST_FOREACH_SAFE() here.
8
2
9
Fixes: ff5ca1664af85b24a4180d595ea6873fd3deac57
3
Allow using QemuCoSleep to sleep forever until woken by qemu_co_sleep_wake.
10
Cc: qemu-stable@nongnu.org
4
This makes the logic of qemu_co_sleep_ns_wakeable easy to understand.
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
5
12
Message-id: 20190910124136.10565-6-mreitz@redhat.com
6
In the future we will introduce an API that can work even if the
13
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
7
sleep and wake happen from different threads. For now, initializing
14
Reviewed-by: John Snow <jsnow@redhat.com>
8
w->to_wake after timer_mod is fine because the timer can only fire in
15
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
the same AioContext.
10
11
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
12
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
13
Message-id: 20210517100548.28806-7-pbonzini@redhat.com
14
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
16
---
15
---
17
block/curl.c | 17 ++++++-----------
16
include/qemu/coroutine.h | 5 +++++
18
1 file changed, 6 insertions(+), 11 deletions(-)
17
util/qemu-coroutine-sleep.c | 26 +++++++++++++++++++-------
18
2 files changed, 24 insertions(+), 7 deletions(-)
19
19
20
diff --git a/block/curl.c b/block/curl.c
20
diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h
21
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
22
--- a/block/curl.c
22
--- a/include/qemu/coroutine.h
23
+++ b/block/curl.c
23
+++ b/include/qemu/coroutine.h
24
@@ -XXX,XX +XXX,XX @@ static void curl_multi_check_completion(BDRVCURLState *s)
24
@@ -XXX,XX +XXX,XX @@ typedef struct QemuCoSleep {
25
void coroutine_fn qemu_co_sleep_ns_wakeable(QemuCoSleep *w,
26
QEMUClockType type, int64_t ns);
27
28
+/**
29
+ * Yield the coroutine until the next call to qemu_co_sleep_wake.
30
+ */
31
+void coroutine_fn qemu_co_sleep(QemuCoSleep *w);
32
+
33
static inline void coroutine_fn qemu_co_sleep_ns(QEMUClockType type, int64_t ns)
34
{
35
QemuCoSleep w = { 0 };
36
diff --git a/util/qemu-coroutine-sleep.c b/util/qemu-coroutine-sleep.c
37
index XXXXXXX..XXXXXXX 100644
38
--- a/util/qemu-coroutine-sleep.c
39
+++ b/util/qemu-coroutine-sleep.c
40
@@ -XXX,XX +XXX,XX @@ static void co_sleep_cb(void *opaque)
41
qemu_co_sleep_wake(w);
25
}
42
}
26
43
27
/* Called with s->mutex held. */
44
-void coroutine_fn qemu_co_sleep_ns_wakeable(QemuCoSleep *w,
28
-static void curl_multi_do_locked(CURLSocket *ready_socket)
45
- QEMUClockType type, int64_t ns)
29
+static void curl_multi_do_locked(CURLSocket *socket)
46
+void coroutine_fn qemu_co_sleep(QemuCoSleep *w)
30
{
47
{
31
- CURLSocket *socket, *next_socket;
48
Coroutine *co = qemu_coroutine_self();
32
- CURLState *s = ready_socket->state;
49
- AioContext *ctx = qemu_get_current_aio_context();
33
+ BDRVCURLState *s = socket->state->s;
50
- QEMUTimer ts;
34
int running;
51
35
int r;
52
const char *scheduled = qatomic_cmpxchg(&co->scheduled, NULL,
36
53
qemu_co_sleep_ns__scheduled);
37
- if (!s->s->multi) {
54
@@ -XXX,XX +XXX,XX @@ void coroutine_fn qemu_co_sleep_ns_wakeable(QemuCoSleep *w,
38
+ if (!s->multi) {
39
return;
40
}
55
}
41
56
42
- /* Need to use _SAFE because curl_multi_socket_action() may trigger
57
w->to_wake = co;
43
- * curl_sock_cb() which might modify this list */
58
- aio_timer_init(ctx, &ts, type, SCALE_NS, co_sleep_cb, w),
44
- QLIST_FOREACH_SAFE(socket, &s->sockets, next, next_socket) {
59
- timer_mod(&ts, qemu_clock_get_ns(type) + ns);
45
- do {
60
qemu_coroutine_yield();
46
- r = curl_multi_socket_action(s->s->multi, socket->fd, 0, &running);
61
- timer_del(&ts);
47
- } while (r == CURLM_CALL_MULTI_PERFORM);
62
48
- }
63
/* w->to_wake is cleared before resuming this coroutine. */
49
+ do {
64
assert(w->to_wake == NULL);
50
+ r = curl_multi_socket_action(s->multi, socket->fd, 0, &running);
51
+ } while (r == CURLM_CALL_MULTI_PERFORM);
52
}
65
}
53
66
+
54
static void curl_multi_do(void *arg)
67
+void coroutine_fn qemu_co_sleep_ns_wakeable(QemuCoSleep *w,
68
+ QEMUClockType type, int64_t ns)
69
+{
70
+ AioContext *ctx = qemu_get_current_aio_context();
71
+ QEMUTimer ts;
72
+
73
+ aio_timer_init(ctx, &ts, type, SCALE_NS, co_sleep_cb, w);
74
+ timer_mod(&ts, qemu_clock_get_ns(type) + ns);
75
+
76
+ /*
77
+ * The timer will fire in the current AiOContext, so the callback
78
+ * must happen after qemu_co_sleep yields and there is no race
79
+ * between timer_mod and qemu_co_sleep.
80
+ */
81
+ qemu_co_sleep(w);
82
+ timer_del(&ts);
83
+}
55
--
84
--
56
2.21.0
85
2.31.1
57
86
58
diff view generated by jsdifflib
Deleted patch
1
Background: As of cURL 7.59.0, it verifies that several functions are
2
not called from within a callback. Among these functions is
3
curl_multi_add_handle().
4
1
5
curl_read_cb() is a callback from cURL and not a coroutine. Waking up
6
acb->co will lead to entering it then and there, which means the current
7
request will settle and the caller (if it runs in the same coroutine)
8
may then issue the next request. In such a case, we will enter
9
curl_setup_preadv() effectively from within curl_read_cb().
10
11
Calling curl_multi_add_handle() will then fail and the new request will
12
not be processed.
13
14
Fix this by not letting curl_read_cb() wake up acb->co. Instead, leave
15
the whole business of settling the AIOCB objects to
16
curl_multi_check_completion() (which is called from our timer callback
17
and our FD handler, so not from any cURL callbacks).
18
19
Reported-by: Natalie Gavrielov <ngavrilo@redhat.com>
20
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1740193
21
Cc: qemu-stable@nongnu.org
22
Signed-off-by: Max Reitz <mreitz@redhat.com>
23
Message-id: 20190910124136.10565-7-mreitz@redhat.com
24
Reviewed-by: John Snow <jsnow@redhat.com>
25
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
26
Signed-off-by: Max Reitz <mreitz@redhat.com>
27
---
28
block/curl.c | 69 ++++++++++++++++++++++------------------------------
29
1 file changed, 29 insertions(+), 40 deletions(-)
30
31
diff --git a/block/curl.c b/block/curl.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/block/curl.c
34
+++ b/block/curl.c
35
@@ -XXX,XX +XXX,XX @@ static size_t curl_read_cb(void *ptr, size_t size, size_t nmemb, void *opaque)
36
{
37
CURLState *s = ((CURLState*)opaque);
38
size_t realsize = size * nmemb;
39
- int i;
40
41
trace_curl_read_cb(realsize);
42
43
@@ -XXX,XX +XXX,XX @@ static size_t curl_read_cb(void *ptr, size_t size, size_t nmemb, void *opaque)
44
memcpy(s->orig_buf + s->buf_off, ptr, realsize);
45
s->buf_off += realsize;
46
47
- for(i=0; i<CURL_NUM_ACB; i++) {
48
- CURLAIOCB *acb = s->acb[i];
49
-
50
- if (!acb)
51
- continue;
52
-
53
- if ((s->buf_off >= acb->end)) {
54
- size_t request_length = acb->bytes;
55
-
56
- qemu_iovec_from_buf(acb->qiov, 0, s->orig_buf + acb->start,
57
- acb->end - acb->start);
58
-
59
- if (acb->end - acb->start < request_length) {
60
- size_t offset = acb->end - acb->start;
61
- qemu_iovec_memset(acb->qiov, offset, 0,
62
- request_length - offset);
63
- }
64
-
65
- acb->ret = 0;
66
- s->acb[i] = NULL;
67
- qemu_mutex_unlock(&s->s->mutex);
68
- aio_co_wake(acb->co);
69
- qemu_mutex_lock(&s->s->mutex);
70
- }
71
- }
72
-
73
read_end:
74
/* curl will error out if we do not return this value */
75
return size * nmemb;
76
@@ -XXX,XX +XXX,XX @@ static void curl_multi_check_completion(BDRVCURLState *s)
77
break;
78
79
if (msg->msg == CURLMSG_DONE) {
80
+ int i;
81
CURLState *state = NULL;
82
+ bool error = msg->data.result != CURLE_OK;
83
+
84
curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE,
85
(char **)&state);
86
87
- /* ACBs for successful messages get completed in curl_read_cb */
88
- if (msg->data.result != CURLE_OK) {
89
- int i;
90
+ if (error) {
91
static int errcount = 100;
92
93
/* Don't lose the original error message from curl, since
94
@@ -XXX,XX +XXX,XX @@ static void curl_multi_check_completion(BDRVCURLState *s)
95
error_report("curl: further errors suppressed");
96
}
97
}
98
+ }
99
100
- for (i = 0; i < CURL_NUM_ACB; i++) {
101
- CURLAIOCB *acb = state->acb[i];
102
+ for (i = 0; i < CURL_NUM_ACB; i++) {
103
+ CURLAIOCB *acb = state->acb[i];
104
105
- if (acb == NULL) {
106
- continue;
107
- }
108
+ if (acb == NULL) {
109
+ continue;
110
+ }
111
+
112
+ if (!error) {
113
+ /* Assert that we have read all data */
114
+ assert(state->buf_off >= acb->end);
115
+
116
+ qemu_iovec_from_buf(acb->qiov, 0,
117
+ state->orig_buf + acb->start,
118
+ acb->end - acb->start);
119
120
- acb->ret = -EIO;
121
- state->acb[i] = NULL;
122
- qemu_mutex_unlock(&s->mutex);
123
- aio_co_wake(acb->co);
124
- qemu_mutex_lock(&s->mutex);
125
+ if (acb->end - acb->start < acb->bytes) {
126
+ size_t offset = acb->end - acb->start;
127
+ qemu_iovec_memset(acb->qiov, offset, 0,
128
+ acb->bytes - offset);
129
+ }
130
}
131
+
132
+ acb->ret = error ? -EIO : 0;
133
+ state->acb[i] = NULL;
134
+ qemu_mutex_unlock(&s->mutex);
135
+ aio_co_wake(acb->co);
136
+ qemu_mutex_lock(&s->mutex);
137
}
138
139
curl_clean_state(state);
140
--
141
2.21.0
142
143
diff view generated by jsdifflib
Deleted patch
1
If we had done that all along, debugging would have been much simpler.
2
(Also, I/O errors are better than hangs.)
3
1
4
Signed-off-by: Max Reitz <mreitz@redhat.com>
5
Message-id: 20190910124136.10565-8-mreitz@redhat.com
6
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
7
Reviewed-by: John Snow <jsnow@redhat.com>
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
---
10
block/curl.c | 8 +++++++-
11
1 file changed, 7 insertions(+), 1 deletion(-)
12
13
diff --git a/block/curl.c b/block/curl.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/block/curl.c
16
+++ b/block/curl.c
17
@@ -XXX,XX +XXX,XX @@ static void curl_setup_preadv(BlockDriverState *bs, CURLAIOCB *acb)
18
trace_curl_setup_preadv(acb->bytes, start, state->range);
19
curl_easy_setopt(state->curl, CURLOPT_RANGE, state->range);
20
21
- curl_multi_add_handle(s->multi, state->curl);
22
+ if (curl_multi_add_handle(s->multi, state->curl) != CURLM_OK) {
23
+ state->acb[0] = NULL;
24
+ acb->ret = -EIO;
25
+
26
+ curl_clean_state(state);
27
+ goto out;
28
+ }
29
30
/* Tell curl it needs to kick things off */
31
curl_multi_socket_action(s->multi, CURL_SOCKET_TIMEOUT, 0, &running);
32
--
33
2.21.0
34
35
diff view generated by jsdifflib