1
The following changes since commit 0a301624c2f4ced3331ffd5bce85b4274fe132af:
1
The following changes since commit 4f59102571fce49af180cfc6d4cdd2b5df7bdb14:
2
2
3
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20220208' into staging (2022-02-08 11:40:08 +0000)
3
Merge remote-tracking branch 'remotes/amarkovic/tags/mips-queue-oct-01-2019' into staging (2019-10-01 16:21:42 +0100)
4
4
5
are available in the Git repository at:
5
are available in the Git repository at:
6
6
7
https://gitlab.com/kmwolf/qemu.git tags/for-upstream
7
git://repo.or.cz/qemu/kevin.git tags/for-upstream
8
8
9
for you to fetch changes up to fdb8541b2e4f6ff60f435fbb5a5e1df20c275a86:
9
for you to fetch changes up to 7e693a0500455edab21754573c32b7146138cffd:
10
10
11
hw/block/fdc-isa: Respect QOM properties when building AML (2022-02-11 17:37:26 +0100)
11
iotests: Remove Python 2 compatibility code (2019-10-04 11:59:16 +0200)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Block layer patches
14
Block layer patches:
15
15
16
- Fix crash in blockdev-reopen with iothreads
16
- Fix internal snapshots with typical -blockdev setups
17
- fdc-isa: Respect QOM properties when building AML
17
- iotests: Require Python 3.6 or later
18
18
19
----------------------------------------------------------------
19
----------------------------------------------------------------
20
Bernhard Beschow (1):
20
Kevin Wolf (4):
21
hw/block/fdc-isa: Respect QOM properties when building AML
21
block/snapshot: Restrict set of snapshot nodes
22
iotests: Test internal snapshots with -blockdev
23
iotests: Require Python 3.6 or later
24
iotests: Remove Python 2 compatibility code
22
25
23
Kevin Wolf (2):
26
block/snapshot.c | 26 ++++--
24
block: Lock AioContext for drain_end in blockdev-reopen
27
tests/qemu-iotests/044 | 3 -
25
iotests: Test blockdev-reopen with iothreads and throttling
28
tests/qemu-iotests/163 | 3 -
29
tests/qemu-iotests/267 | 168 ++++++++++++++++++++++++++++++++++++
30
tests/qemu-iotests/267.out | 182 +++++++++++++++++++++++++++++++++++++++
31
tests/qemu-iotests/check | 13 ++-
32
tests/qemu-iotests/common.filter | 11 ++-
33
tests/qemu-iotests/group | 1 +
34
tests/qemu-iotests/iotests.py | 13 +--
35
9 files changed, 392 insertions(+), 28 deletions(-)
36
create mode 100755 tests/qemu-iotests/267
37
create mode 100644 tests/qemu-iotests/267.out
26
38
27
blockdev.c | 11 ++++++++++-
28
hw/block/fdc-isa.c | 11 +++++++----
29
tests/qemu-iotests/245 | 36 +++++++++++++++++++++++++++++++++---
30
tests/qemu-iotests/245.out | 4 ++--
31
4 files changed, 52 insertions(+), 10 deletions(-)
32
33
diff view generated by jsdifflib
New patch
1
Nodes involved in internal snapshots were those that were returned by
2
bdrv_next(), inserted and not read-only. bdrv_next() in turn returns all
3
nodes that are either the root node of a BlockBackend or monitor-owned
4
nodes.
1
5
6
With the typical -drive use, this worked well enough. However, in the
7
typical -blockdev case, the user defines one node per option, making all
8
nodes monitor-owned nodes. This includes protocol nodes etc. which often
9
are not snapshottable, so "savevm" only returns an error.
10
11
Change the conditions so that internal snapshot still include all nodes
12
that have a BlockBackend attached (we definitely want to snapshot
13
anything attached to a guest device and probably also the built-in NBD
14
server; snapshotting block job BlockBackends is more of an accident, but
15
a preexisting one), but other monitor-owned nodes are only included if
16
they have no parents.
17
18
This makes internal snapshots usable again with typical -blockdev
19
configurations.
20
21
Cc: qemu-stable@nongnu.org
22
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
23
Reviewed-by: Eric Blake <eblake@redhat.com>
24
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
25
Tested-by: Peter Krempa <pkrempa@redhat.com>
26
---
27
block/snapshot.c | 26 +++++++++++++++++++-------
28
1 file changed, 19 insertions(+), 7 deletions(-)
29
30
diff --git a/block/snapshot.c b/block/snapshot.c
31
index XXXXXXX..XXXXXXX 100644
32
--- a/block/snapshot.c
33
+++ b/block/snapshot.c
34
@@ -XXX,XX +XXX,XX @@
35
#include "qapi/qmp/qerror.h"
36
#include "qapi/qmp/qstring.h"
37
#include "qemu/option.h"
38
+#include "sysemu/block-backend.h"
39
40
QemuOptsList internal_snapshot_opts = {
41
.name = "snapshot",
42
@@ -XXX,XX +XXX,XX @@ int bdrv_snapshot_load_tmp_by_id_or_name(BlockDriverState *bs,
43
return ret;
44
}
45
46
+static bool bdrv_all_snapshots_includes_bs(BlockDriverState *bs)
47
+{
48
+ if (!bdrv_is_inserted(bs) || bdrv_is_read_only(bs)) {
49
+ return false;
50
+ }
51
+
52
+ /* Include all nodes that are either in use by a BlockBackend, or that
53
+ * aren't attached to any node, but owned by the monitor. */
54
+ return bdrv_has_blk(bs) || QLIST_EMPTY(&bs->parents);
55
+}
56
57
/* Group operations. All block drivers are involved.
58
* These functions will properly handle dataplane (take aio_context_acquire
59
@@ -XXX,XX +XXX,XX @@ bool bdrv_all_can_snapshot(BlockDriverState **first_bad_bs)
60
AioContext *ctx = bdrv_get_aio_context(bs);
61
62
aio_context_acquire(ctx);
63
- if (bdrv_is_inserted(bs) && !bdrv_is_read_only(bs)) {
64
+ if (bdrv_all_snapshots_includes_bs(bs)) {
65
ok = bdrv_can_snapshot(bs);
66
}
67
aio_context_release(ctx);
68
@@ -XXX,XX +XXX,XX @@ int bdrv_all_delete_snapshot(const char *name, BlockDriverState **first_bad_bs,
69
AioContext *ctx = bdrv_get_aio_context(bs);
70
71
aio_context_acquire(ctx);
72
- if (bdrv_can_snapshot(bs) &&
73
- bdrv_snapshot_find(bs, snapshot, name) >= 0) {
74
+ if (bdrv_all_snapshots_includes_bs(bs) &&
75
+ bdrv_snapshot_find(bs, snapshot, name) >= 0)
76
+ {
77
ret = bdrv_snapshot_delete(bs, snapshot->id_str,
78
snapshot->name, err);
79
}
80
@@ -XXX,XX +XXX,XX @@ int bdrv_all_goto_snapshot(const char *name, BlockDriverState **first_bad_bs,
81
AioContext *ctx = bdrv_get_aio_context(bs);
82
83
aio_context_acquire(ctx);
84
- if (bdrv_can_snapshot(bs)) {
85
+ if (bdrv_all_snapshots_includes_bs(bs)) {
86
ret = bdrv_snapshot_goto(bs, name, errp);
87
}
88
aio_context_release(ctx);
89
@@ -XXX,XX +XXX,XX @@ int bdrv_all_find_snapshot(const char *name, BlockDriverState **first_bad_bs)
90
AioContext *ctx = bdrv_get_aio_context(bs);
91
92
aio_context_acquire(ctx);
93
- if (bdrv_can_snapshot(bs)) {
94
+ if (bdrv_all_snapshots_includes_bs(bs)) {
95
err = bdrv_snapshot_find(bs, &sn, name);
96
}
97
aio_context_release(ctx);
98
@@ -XXX,XX +XXX,XX @@ int bdrv_all_create_snapshot(QEMUSnapshotInfo *sn,
99
if (bs == vm_state_bs) {
100
sn->vm_state_size = vm_state_size;
101
err = bdrv_snapshot_create(bs, sn);
102
- } else if (bdrv_can_snapshot(bs)) {
103
+ } else if (bdrv_all_snapshots_includes_bs(bs)) {
104
sn->vm_state_size = 0;
105
err = bdrv_snapshot_create(bs, sn);
106
}
107
@@ -XXX,XX +XXX,XX @@ BlockDriverState *bdrv_all_find_vmstate_bs(void)
108
bool found;
109
110
aio_context_acquire(ctx);
111
- found = bdrv_can_snapshot(bs);
112
+ found = bdrv_all_snapshots_includes_bs(bs) && bdrv_can_snapshot(bs);
113
aio_context_release(ctx);
114
115
if (found) {
116
--
117
2.20.1
118
119
diff view generated by jsdifflib
1
bdrv_subtree_drained_end() requires the caller to hold the AioContext
1
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2
lock for the drained node. Not doing this for nodes outside of the main
2
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3
AioContext leads to crashes when AIO_WAIT_WHILE() needs to wait and
3
Tested-by: Peter Krempa <pkrempa@redhat.com>
4
tries to temporarily release the lock.
4
---
5
tests/qemu-iotests/267 | 168 ++++++++++++++++++++++++++++
6
tests/qemu-iotests/267.out | 182 +++++++++++++++++++++++++++++++
7
tests/qemu-iotests/common.filter | 11 +-
8
tests/qemu-iotests/group | 1 +
9
4 files changed, 358 insertions(+), 4 deletions(-)
10
create mode 100755 tests/qemu-iotests/267
11
create mode 100644 tests/qemu-iotests/267.out
5
12
6
Fixes: 3908b7a8994fa5ef7a89aa58cd5a02fc58141592
13
diff --git a/tests/qemu-iotests/267 b/tests/qemu-iotests/267
7
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2046659
14
new file mode 100755
8
Reported-by: Qing Wang <qinwang@redhat.com>
15
index XXXXXXX..XXXXXXX
9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
16
--- /dev/null
10
Message-Id: <20220203140534.36522-2-kwolf@redhat.com>
17
+++ b/tests/qemu-iotests/267
11
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
18
@@ -XXX,XX +XXX,XX @@
12
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
19
+#!/usr/bin/env bash
13
---
20
+#
14
blockdev.c | 11 ++++++++++-
21
+# Test which nodes are involved in internal snapshots
15
1 file changed, 10 insertions(+), 1 deletion(-)
22
+#
16
23
+# Copyright (C) 2019 Red Hat, Inc.
17
diff --git a/blockdev.c b/blockdev.c
24
+#
25
+# This program is free software; you can redistribute it and/or modify
26
+# it under the terms of the GNU General Public License as published by
27
+# the Free Software Foundation; either version 2 of the License, or
28
+# (at your option) any later version.
29
+#
30
+# This program is distributed in the hope that it will be useful,
31
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
32
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33
+# GNU General Public License for more details.
34
+#
35
+# You should have received a copy of the GNU General Public License
36
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
37
+#
38
+
39
+# creator
40
+owner=kwolf@redhat.com
41
+
42
+seq=`basename $0`
43
+echo "QA output created by $seq"
44
+
45
+status=1    # failure is the default!
46
+
47
+_cleanup()
48
+{
49
+ _cleanup_test_img
50
+ rm -f "$TEST_DIR/nbd"
51
+}
52
+trap "_cleanup; exit \$status" 0 1 2 3 15
53
+
54
+# get standard environment, filters and checks
55
+. ./common.rc
56
+. ./common.filter
57
+
58
+_supported_fmt qcow2
59
+_supported_proto file
60
+_supported_os Linux
61
+
62
+# Internal snapshots are (currently) impossible with refcount_bits=1
63
+_unsupported_imgopts 'refcount_bits=1[^0-9]'
64
+
65
+do_run_qemu()
66
+{
67
+ echo Testing: "$@"
68
+ (
69
+ if ! test -t 0; then
70
+ while read cmd; do
71
+ echo $cmd
72
+ done
73
+ fi
74
+ echo quit
75
+ ) | $QEMU -nographic -monitor stdio -nodefaults "$@"
76
+ echo
77
+}
78
+
79
+run_qemu()
80
+{
81
+ do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_hmp |
82
+ _filter_generated_node_ids | _filter_imgfmt | _filter_vmstate_size
83
+}
84
+
85
+size=128M
86
+
87
+run_test()
88
+{
89
+ _make_test_img $size
90
+ printf "savevm snap0\ninfo snapshots\nloadvm snap0\n" | run_qemu "$@" | _filter_date
91
+}
92
+
93
+
94
+echo
95
+echo "=== No block devices at all ==="
96
+echo
97
+
98
+run_test
99
+
100
+echo
101
+echo "=== -drive if=none ==="
102
+echo
103
+
104
+run_test -drive driver=file,file="$TEST_IMG",if=none
105
+run_test -drive driver=$IMGFMT,file="$TEST_IMG",if=none
106
+run_test -drive driver=$IMGFMT,file="$TEST_IMG",if=none -device virtio-blk,drive=none0
107
+
108
+echo
109
+echo "=== -drive if=virtio ==="
110
+echo
111
+
112
+run_test -drive driver=file,file="$TEST_IMG",if=virtio
113
+run_test -drive driver=$IMGFMT,file="$TEST_IMG",if=virtio
114
+
115
+echo
116
+echo "=== Simple -blockdev ==="
117
+echo
118
+
119
+run_test -blockdev driver=file,filename="$TEST_IMG",node-name=file
120
+run_test -blockdev driver=file,filename="$TEST_IMG",node-name=file \
121
+ -blockdev driver=$IMGFMT,file=file,node-name=fmt
122
+run_test -blockdev driver=file,filename="$TEST_IMG",node-name=file \
123
+ -blockdev driver=raw,file=file,node-name=raw \
124
+ -blockdev driver=$IMGFMT,file=raw,node-name=fmt
125
+
126
+echo
127
+echo "=== -blockdev with a filter on top ==="
128
+echo
129
+
130
+run_test -blockdev driver=file,filename="$TEST_IMG",node-name=file \
131
+ -blockdev driver=$IMGFMT,file=file,node-name=fmt \
132
+ -blockdev driver=copy-on-read,file=fmt,node-name=filter
133
+
134
+echo
135
+echo "=== -blockdev with a backing file ==="
136
+echo
137
+
138
+TEST_IMG="$TEST_IMG.base" _make_test_img $size
139
+
140
+IMGOPTS="backing_file=$TEST_IMG.base" \
141
+run_test -blockdev driver=file,filename="$TEST_IMG.base",node-name=backing-file \
142
+ -blockdev driver=file,filename="$TEST_IMG",node-name=file \
143
+ -blockdev driver=$IMGFMT,file=file,backing=backing-file,node-name=fmt
144
+
145
+IMGOPTS="backing_file=$TEST_IMG.base" \
146
+run_test -blockdev driver=file,filename="$TEST_IMG.base",node-name=backing-file \
147
+ -blockdev driver=$IMGFMT,file=backing-file,node-name=backing-fmt \
148
+ -blockdev driver=file,filename="$TEST_IMG",node-name=file \
149
+ -blockdev driver=$IMGFMT,file=file,backing=backing-fmt,node-name=fmt
150
+
151
+# A snapshot should be present on the overlay, but not the backing file
152
+echo Internal snapshots on overlay:
153
+$QEMU_IMG snapshot -l "$TEST_IMG" | _filter_date | _filter_vmstate_size
154
+
155
+echo Internal snapshots on backing file:
156
+$QEMU_IMG snapshot -l "$TEST_IMG.base" | _filter_date | _filter_vmstate_size
157
+
158
+echo
159
+echo "=== -blockdev with NBD server on the backing file ==="
160
+echo
161
+
162
+IMGOPTS="backing_file=$TEST_IMG.base" _make_test_img $size
163
+cat <<EOF |
164
+nbd_server_start unix:$TEST_DIR/nbd
165
+nbd_server_add -w backing-fmt
166
+savevm snap0
167
+info snapshots
168
+loadvm snap0
169
+EOF
170
+run_qemu -blockdev driver=file,filename="$TEST_IMG.base",node-name=backing-file \
171
+ -blockdev driver=$IMGFMT,file=backing-file,node-name=backing-fmt \
172
+ -blockdev driver=file,filename="$TEST_IMG",node-name=file \
173
+ -blockdev driver=$IMGFMT,file=file,backing=backing-fmt,node-name=fmt |
174
+ _filter_date
175
+
176
+# This time, a snapshot should be created on both files
177
+echo Internal snapshots on overlay:
178
+$QEMU_IMG snapshot -l "$TEST_IMG" | _filter_date | _filter_vmstate_size
179
+
180
+echo Internal snapshots on backing file:
181
+$QEMU_IMG snapshot -l "$TEST_IMG.base" | _filter_date | _filter_vmstate_size
182
+
183
+# success, all done
184
+echo "*** done"
185
+rm -f $seq.full
186
+status=0
187
diff --git a/tests/qemu-iotests/267.out b/tests/qemu-iotests/267.out
188
new file mode 100644
189
index XXXXXXX..XXXXXXX
190
--- /dev/null
191
+++ b/tests/qemu-iotests/267.out
192
@@ -XXX,XX +XXX,XX @@
193
+QA output created by 267
194
+
195
+=== No block devices at all ===
196
+
197
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
198
+Testing:
199
+QEMU X.Y.Z monitor - type 'help' for more information
200
+(qemu) savevm snap0
201
+Error: No block device can accept snapshots
202
+(qemu) info snapshots
203
+No available block device supports snapshots
204
+(qemu) loadvm snap0
205
+Error: No block device supports snapshots
206
+(qemu) quit
207
+
208
+
209
+=== -drive if=none ===
210
+
211
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
212
+Testing: -drive driver=file,file=TEST_DIR/t.IMGFMT,if=none
213
+QEMU X.Y.Z monitor - type 'help' for more information
214
+(qemu) savevm snap0
215
+Error: Device 'none0' is writable but does not support snapshots
216
+(qemu) info snapshots
217
+No available block device supports snapshots
218
+(qemu) loadvm snap0
219
+Error: Device 'none0' is writable but does not support snapshots
220
+(qemu) quit
221
+
222
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
223
+Testing: -drive driver=IMGFMT,file=TEST_DIR/t.IMGFMT,if=none
224
+QEMU X.Y.Z monitor - type 'help' for more information
225
+(qemu) savevm snap0
226
+(qemu) info snapshots
227
+List of snapshots present on all disks:
228
+ID TAG VM SIZE DATE VM CLOCK
229
+-- snap0 SIZE yyyy-mm-dd hh:mm:ss 00:00:00.000
230
+(qemu) loadvm snap0
231
+(qemu) quit
232
+
233
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
234
+Testing: -drive driver=IMGFMT,file=TEST_DIR/t.IMGFMT,if=none -device virtio-blk,drive=none0
235
+QEMU X.Y.Z monitor - type 'help' for more information
236
+(qemu) savevm snap0
237
+(qemu) info snapshots
238
+List of snapshots present on all disks:
239
+ID TAG VM SIZE DATE VM CLOCK
240
+-- snap0 SIZE yyyy-mm-dd hh:mm:ss 00:00:00.000
241
+(qemu) loadvm snap0
242
+(qemu) quit
243
+
244
+
245
+=== -drive if=virtio ===
246
+
247
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
248
+Testing: -drive driver=file,file=TEST_DIR/t.IMGFMT,if=virtio
249
+QEMU X.Y.Z monitor - type 'help' for more information
250
+(qemu) savevm snap0
251
+Error: Device 'virtio0' is writable but does not support snapshots
252
+(qemu) info snapshots
253
+No available block device supports snapshots
254
+(qemu) loadvm snap0
255
+Error: Device 'virtio0' is writable but does not support snapshots
256
+(qemu) quit
257
+
258
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
259
+Testing: -drive driver=IMGFMT,file=TEST_DIR/t.IMGFMT,if=virtio
260
+QEMU X.Y.Z monitor - type 'help' for more information
261
+(qemu) savevm snap0
262
+(qemu) info snapshots
263
+List of snapshots present on all disks:
264
+ID TAG VM SIZE DATE VM CLOCK
265
+-- snap0 SIZE yyyy-mm-dd hh:mm:ss 00:00:00.000
266
+(qemu) loadvm snap0
267
+(qemu) quit
268
+
269
+
270
+=== Simple -blockdev ===
271
+
272
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
273
+Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=file
274
+QEMU X.Y.Z monitor - type 'help' for more information
275
+(qemu) savevm snap0
276
+Error: Device '' is writable but does not support snapshots
277
+(qemu) info snapshots
278
+No available block device supports snapshots
279
+(qemu) loadvm snap0
280
+Error: Device '' is writable but does not support snapshots
281
+(qemu) quit
282
+
283
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
284
+Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=file -blockdev driver=IMGFMT,file=file,node-name=fmt
285
+QEMU X.Y.Z monitor - type 'help' for more information
286
+(qemu) savevm snap0
287
+(qemu) info snapshots
288
+List of snapshots present on all disks:
289
+ID TAG VM SIZE DATE VM CLOCK
290
+-- snap0 SIZE yyyy-mm-dd hh:mm:ss 00:00:00.000
291
+(qemu) loadvm snap0
292
+(qemu) quit
293
+
294
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
295
+Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=file -blockdev driver=raw,file=file,node-name=raw -blockdev driver=IMGFMT,file=raw,node-name=fmt
296
+QEMU X.Y.Z monitor - type 'help' for more information
297
+(qemu) savevm snap0
298
+(qemu) info snapshots
299
+List of snapshots present on all disks:
300
+ID TAG VM SIZE DATE VM CLOCK
301
+-- snap0 SIZE yyyy-mm-dd hh:mm:ss 00:00:00.000
302
+(qemu) loadvm snap0
303
+(qemu) quit
304
+
305
+
306
+=== -blockdev with a filter on top ===
307
+
308
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
309
+Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=file -blockdev driver=IMGFMT,file=file,node-name=fmt -blockdev driver=copy-on-read,file=fmt,node-name=filter
310
+QEMU X.Y.Z monitor - type 'help' for more information
311
+(qemu) savevm snap0
312
+(qemu) info snapshots
313
+List of snapshots present on all disks:
314
+ID TAG VM SIZE DATE VM CLOCK
315
+-- snap0 SIZE yyyy-mm-dd hh:mm:ss 00:00:00.000
316
+(qemu) loadvm snap0
317
+(qemu) quit
318
+
319
+
320
+=== -blockdev with a backing file ===
321
+
322
+Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=134217728
323
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/t.IMGFMT.base
324
+Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT.base,node-name=backing-file -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=file -blockdev driver=IMGFMT,file=file,backing=backing-file,node-name=fmt
325
+QEMU X.Y.Z monitor - type 'help' for more information
326
+(qemu) savevm snap0
327
+(qemu) info snapshots
328
+List of snapshots present on all disks:
329
+ID TAG VM SIZE DATE VM CLOCK
330
+-- snap0 SIZE yyyy-mm-dd hh:mm:ss 00:00:00.000
331
+(qemu) loadvm snap0
332
+(qemu) quit
333
+
334
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/t.IMGFMT.base
335
+Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT.base,node-name=backing-file -blockdev driver=IMGFMT,file=backing-file,node-name=backing-fmt -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=file -blockdev driver=IMGFMT,file=file,backing=backing-fmt,node-name=fmt
336
+QEMU X.Y.Z monitor - type 'help' for more information
337
+(qemu) savevm snap0
338
+(qemu) info snapshots
339
+List of snapshots present on all disks:
340
+ID TAG VM SIZE DATE VM CLOCK
341
+-- snap0 SIZE yyyy-mm-dd hh:mm:ss 00:00:00.000
342
+(qemu) loadvm snap0
343
+(qemu) quit
344
+
345
+Internal snapshots on overlay:
346
+Snapshot list:
347
+ID TAG VM SIZE DATE VM CLOCK
348
+1 snap0 SIZE yyyy-mm-dd hh:mm:ss 00:00:00.000
349
+Internal snapshots on backing file:
350
+
351
+=== -blockdev with NBD server on the backing file ===
352
+
353
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/t.IMGFMT.base
354
+Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT.base,node-name=backing-file -blockdev driver=IMGFMT,file=backing-file,node-name=backing-fmt -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=file -blockdev driver=IMGFMT,file=file,backing=backing-fmt,node-name=fmt
355
+QEMU X.Y.Z monitor - type 'help' for more information
356
+(qemu) nbd_server_start unix:TEST_DIR/nbd
357
+(qemu) nbd_server_add -w backing-fmt
358
+(qemu) savevm snap0
359
+(qemu) info snapshots
360
+List of snapshots present on all disks:
361
+ID TAG VM SIZE DATE VM CLOCK
362
+-- snap0 SIZE yyyy-mm-dd hh:mm:ss 00:00:00.000
363
+(qemu) loadvm snap0
364
+(qemu) quit
365
+
366
+Internal snapshots on overlay:
367
+Snapshot list:
368
+ID TAG VM SIZE DATE VM CLOCK
369
+1 snap0 SIZE yyyy-mm-dd hh:mm:ss 00:00:00.000
370
+Internal snapshots on backing file:
371
+Snapshot list:
372
+ID TAG VM SIZE DATE VM CLOCK
373
+1 snap0 SIZE yyyy-mm-dd hh:mm:ss 00:00:00.000
374
+*** done
375
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
18
index XXXXXXX..XXXXXXX 100644
376
index XXXXXXX..XXXXXXX 100644
19
--- a/blockdev.c
377
--- a/tests/qemu-iotests/common.filter
20
+++ b/blockdev.c
378
+++ b/tests/qemu-iotests/common.filter
21
@@ -XXX,XX +XXX,XX @@ void qmp_blockdev_reopen(BlockdevOptionsList *reopen_list, Error **errp)
379
@@ -XXX,XX +XXX,XX @@
380
# standard filters
381
#
382
383
-# ctime(3) dates
384
-#
385
_filter_date()
22
{
386
{
23
BlockReopenQueue *queue = NULL;
387
- $SED \
24
GSList *drained = NULL;
388
- -e 's/[A-Z][a-z][a-z] [A-z][a-z][a-z] *[0-9][0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9][0-9][0-9][0-9]$/DATE/'
25
+ GSList *p;
389
+ $SED -re 's/[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/yyyy-mm-dd hh:mm:ss/'
26
390
+}
27
/* Add each one of the BDS that we want to reopen to the queue */
391
+
28
for (; reopen_list != NULL; reopen_list = reopen_list->next) {
392
+_filter_vmstate_size()
29
@@ -XXX,XX +XXX,XX @@ void qmp_blockdev_reopen(BlockdevOptionsList *reopen_list, Error **errp)
393
+{
30
394
+ $SED -r -e 's/[0-9. ]{5} [KMGT]iB/ SIZE/' \
31
fail:
395
+ -e 's/[0-9. ]{5} B/ SIZE/'
32
bdrv_reopen_queue_free(queue);
33
- g_slist_free_full(drained, (GDestroyNotify) bdrv_subtree_drained_end);
34
+ for (p = drained; p; p = p->next) {
35
+ BlockDriverState *bs = p->data;
36
+ AioContext *ctx = bdrv_get_aio_context(bs);
37
+
38
+ aio_context_acquire(ctx);
39
+ bdrv_subtree_drained_end(bs);
40
+ aio_context_release(ctx);
41
+ }
42
+ g_slist_free(drained);
43
}
396
}
44
397
45
void qmp_blockdev_del(const char *node_name, Error **errp)
398
_filter_generated_node_ids()
399
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
400
index XXXXXXX..XXXXXXX 100644
401
--- a/tests/qemu-iotests/group
402
+++ b/tests/qemu-iotests/group
403
@@ -XXX,XX +XXX,XX @@
404
263 rw quick
405
265 rw auto quick
406
266 rw quick
407
+267 rw auto quick snapshot
46
--
408
--
47
2.34.1
409
2.20.1
48
410
49
411
diff view generated by jsdifflib
1
From: Bernhard Beschow <shentey@gmail.com>
1
Running iotests is not required to build QEMU, so we can have stricter
2
version requirements for Python here and can make use of new features
3
and drop compatibility code earlier.
2
4
3
Other ISA devices such as serial-isa use the properties in their
5
This makes qemu-iotests skip all Python tests if a Python version before
4
build_aml functions. fdc-isa not using them is probably an oversight.
6
3.6 is used for the build.
5
7
6
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
8
Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
7
Message-Id: <20220209191558.30393-1-shentey@gmail.com>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
11
Reviewed-by: Thomas Huth <thuth@redhat.com>
12
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
13
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
10
---
14
---
11
hw/block/fdc-isa.c | 11 +++++++----
15
tests/qemu-iotests/check | 13 ++++++++++++-
12
1 file changed, 7 insertions(+), 4 deletions(-)
16
1 file changed, 12 insertions(+), 1 deletion(-)
13
17
14
diff --git a/hw/block/fdc-isa.c b/hw/block/fdc-isa.c
18
diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
15
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100755
16
--- a/hw/block/fdc-isa.c
20
--- a/tests/qemu-iotests/check
17
+++ b/hw/block/fdc-isa.c
21
+++ b/tests/qemu-iotests/check
18
@@ -XXX,XX +XXX,XX @@ int cmos_get_fd_drive_type(FloppyDriveType fd0)
22
@@ -XXX,XX +XXX,XX @@ then
19
23
export SOCKET_SCM_HELPER="$build_iotests/socket_scm_helper"
20
static void fdc_isa_build_aml(ISADevice *isadev, Aml *scope)
24
fi
21
{
25
22
+ FDCtrlISABus *isa = ISA_FDC(isadev);
26
+python_usable=false
23
Aml *dev;
27
+if $PYTHON -c 'import sys; sys.exit(0 if sys.version_info >= (3,6) else 1)'
24
Aml *crs;
28
+then
25
int i;
29
+ python_usable=true
26
@@ -XXX,XX +XXX,XX @@ static void fdc_isa_build_aml(ISADevice *isadev, Aml *scope)
30
+fi
27
};
31
+
28
32
default_machine=$($QEMU_PROG -machine help | sed -n '/(default)/ s/ .*//p')
29
crs = aml_resource_template();
33
default_alias_machine=$($QEMU_PROG -machine help | \
30
- aml_append(crs, aml_io(AML_DECODE16, 0x03F2, 0x03F2, 0x00, 0x04));
34
sed -n "/(alias of $default_machine)/ { s/ .*//p; q; }")
31
- aml_append(crs, aml_io(AML_DECODE16, 0x03F7, 0x03F7, 0x00, 0x01));
35
@@ -XXX,XX +XXX,XX @@ do
32
- aml_append(crs, aml_irq_no_flags(6));
36
start=$(_wallclock)
33
aml_append(crs,
37
34
- aml_dma(AML_COMPATIBILITY, AML_NOTBUSMASTER, AML_TRANSFER8, 2));
38
if [ "$(head -n 1 "$source_iotests/$seq")" == "#!/usr/bin/env python" ]; then
35
+ aml_io(AML_DECODE16, isa->iobase + 2, isa->iobase + 2, 0x00, 0x04));
39
- run_command="$PYTHON $seq"
36
+ aml_append(crs,
40
+ if $python_usable; then
37
+ aml_io(AML_DECODE16, isa->iobase + 7, isa->iobase + 7, 0x00, 0x01));
41
+ run_command="$PYTHON $seq"
38
+ aml_append(crs, aml_irq_no_flags(isa->irq));
42
+ else
39
+ aml_append(crs,
43
+ run_command="false"
40
+ aml_dma(AML_COMPATIBILITY, AML_NOTBUSMASTER, AML_TRANSFER8, isa->dma));
44
+ echo "Unsupported Python version" > $seq.notrun
41
45
+ fi
42
dev = aml_device("FDC0");
46
else
43
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0700")));
47
run_command="./$seq"
48
fi
44
--
49
--
45
2.34.1
50
2.20.1
46
51
47
52
diff view generated by jsdifflib
1
The 'throttle' block driver implements .bdrv_co_drain_end, so
1
Some scripts check the Python version number and have two code paths to
2
blockdev-reopen will have to wait for it to complete in the polling
2
accomodate both Python 2 and 3. Remove the code specific to Python 2 and
3
loop at the end of qmp_blockdev_reopen(). This makes AIO_WAIT_WHILE()
3
assert the minimum version of 3.6 instead (check skips Python tests in
4
release the AioContext lock, which causes a crash if the lock hasn't
4
this case, so the assertion would only ever trigger if a Python script
5
correctly been taken.
5
is executed manually).
6
6
7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
Message-Id: <20220203140534.36522-3-kwolf@redhat.com>
8
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
9
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
9
Reviewed-by: Thomas Huth <thuth@redhat.com>
10
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
Reviewed-by: John Snow <jsnow@redhat.com>
12
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
11
---
13
---
12
tests/qemu-iotests/245 | 36 +++++++++++++++++++++++++++++++++---
14
tests/qemu-iotests/044 | 3 ---
13
tests/qemu-iotests/245.out | 4 ++--
15
tests/qemu-iotests/163 | 3 ---
14
2 files changed, 35 insertions(+), 5 deletions(-)
16
tests/qemu-iotests/iotests.py | 13 +++----------
17
3 files changed, 3 insertions(+), 16 deletions(-)
15
18
16
diff --git a/tests/qemu-iotests/245 b/tests/qemu-iotests/245
19
diff --git a/tests/qemu-iotests/044 b/tests/qemu-iotests/044
17
index XXXXXXX..XXXXXXX 100755
20
index XXXXXXX..XXXXXXX 100755
18
--- a/tests/qemu-iotests/245
21
--- a/tests/qemu-iotests/044
19
+++ b/tests/qemu-iotests/245
22
+++ b/tests/qemu-iotests/044
20
@@ -XXX,XX +XXX,XX @@ class TestBlockdevReopen(iotests.QMPTestCase):
23
@@ -XXX,XX +XXX,XX @@ import struct
21
self.assertEqual(self.get_node('hd1'), None)
24
import subprocess
22
self.assert_qmp(self.get_node('hd2'), 'ro', True)
25
import sys
23
26
24
- def run_test_iothreads(self, iothread_a, iothread_b, errmsg = None):
27
-if sys.version_info.major == 2:
25
- opts = hd_opts(0)
28
- range = xrange
26
+ def run_test_iothreads(self, iothread_a, iothread_b, errmsg = None,
29
-
27
+ opts_a = None, opts_b = None):
30
test_img = os.path.join(iotests.test_dir, 'test.img')
28
+ opts = opts_a or hd_opts(0)
31
29
result = self.vm.qmp('blockdev-add', conv_keys = False, **opts)
32
class TestRefcountTableGrowth(iotests.QMPTestCase):
30
self.assert_qmp(result, 'return', {})
33
diff --git a/tests/qemu-iotests/163 b/tests/qemu-iotests/163
31
34
index XXXXXXX..XXXXXXX 100755
32
- opts2 = hd_opts(2)
35
--- a/tests/qemu-iotests/163
33
+ opts2 = opts_b or hd_opts(2)
36
+++ b/tests/qemu-iotests/163
34
result = self.vm.qmp('blockdev-add', conv_keys = False, **opts2)
37
@@ -XXX,XX +XXX,XX @@
35
self.assert_qmp(result, 'return', {})
38
import os, random, iotests, struct, qcow2, sys
36
39
from iotests import qemu_img, qemu_io, image_size
37
@@ -XXX,XX +XXX,XX @@ class TestBlockdevReopen(iotests.QMPTestCase):
40
38
def test_iothreads_switch_overlay(self):
41
-if sys.version_info.major == 2:
39
self.run_test_iothreads('', 'iothread0')
42
- range = xrange
40
43
-
41
+ def test_iothreads_with_throttling(self):
44
test_img = os.path.join(iotests.test_dir, 'test.img')
42
+ # Create a throttle-group object
45
check_img = os.path.join(iotests.test_dir, 'check.img')
43
+ opts = { 'qom-type': 'throttle-group', 'id': 'group0',
46
44
+ 'limits': { 'iops-total': 1000 } }
47
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
45
+ result = self.vm.qmp('object-add', conv_keys = False, **opts)
46
+ self.assert_qmp(result, 'return', {})
47
+
48
+ # Options with a throttle filter between format and protocol
49
+ opts = [
50
+ {
51
+ 'driver': iotests.imgfmt,
52
+ 'node-name': f'hd{idx}',
53
+ 'file' : {
54
+ 'node-name': f'hd{idx}-throttle',
55
+ 'driver': 'throttle',
56
+ 'throttle-group': 'group0',
57
+ 'file': {
58
+ 'driver': 'file',
59
+ 'node-name': f'hd{idx}-file',
60
+ 'filename': hd_path[idx],
61
+ },
62
+ },
63
+ }
64
+ for idx in (0, 2)
65
+ ]
66
+
67
+ self.run_test_iothreads('iothread0', 'iothread0', None,
68
+ opts[0], opts[1])
69
+
70
if __name__ == '__main__':
71
iotests.activate_logging()
72
iotests.main(supported_fmts=["qcow2"],
73
diff --git a/tests/qemu-iotests/245.out b/tests/qemu-iotests/245.out
74
index XXXXXXX..XXXXXXX 100644
48
index XXXXXXX..XXXXXXX 100644
75
--- a/tests/qemu-iotests/245.out
49
--- a/tests/qemu-iotests/iotests.py
76
+++ b/tests/qemu-iotests/245.out
50
+++ b/tests/qemu-iotests/iotests.py
77
@@ -XXX,XX +XXX,XX @@ read 1/1 bytes at offset 262152
51
@@ -XXX,XX +XXX,XX @@ from collections import OrderedDict
78
read 1/1 bytes at offset 262160
52
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
79
1 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
53
from qemu import qtest
80
54
81
-...............
55
+assert sys.version_info >= (3,6)
82
+................
56
83
----------------------------------------------------------------------
57
# This will not work if arguments contain spaces but is necessary if we
84
-Ran 25 tests
58
# want to support the override options that ./check supports.
85
+Ran 26 tests
59
@@ -XXX,XX +XXX,XX @@ def image_size(img):
86
60
return json.loads(r)['virtual-size']
87
OK
61
62
def is_str(val):
63
- if sys.version_info.major >= 3:
64
- return isinstance(val, str)
65
- else:
66
- return isinstance(val, str) or isinstance(val, unicode)
67
+ return isinstance(val, str)
68
69
test_dir_re = re.compile(r"%s" % test_dir)
70
def filter_test_dir(msg):
71
@@ -XXX,XX +XXX,XX @@ def execute_test(test_function=None,
72
else:
73
# We need to filter out the time taken from the output so that
74
# qemu-iotest can reliably diff the results against master output.
75
- if sys.version_info.major >= 3:
76
- output = io.StringIO()
77
- else:
78
- # io.StringIO is for unicode strings, which is not what
79
- # 2.x's test runner emits.
80
- output = io.BytesIO()
81
+ output = io.StringIO()
82
83
logging.basicConfig(level=(logging.DEBUG if debug else logging.WARN))
84
88
--
85
--
89
2.34.1
86
2.20.1
90
87
91
88
diff view generated by jsdifflib