1 | The following changes since commit b2f7a038bb4c4fc5ce6b8486e8513dfd97665e2a: | 1 | The following changes since commit b2896c1b09878fd1c4b485b3662f8beecbe0fef4: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/rth/tags/pull-softfloat-20181104' into staging (2018-11-05 10:32:49 +0000) | 3 | Merge tag 'vfio-updates-20230509.0' of https://gitlab.com/alex.williamson/qemu into staging (2023-05-10 11:20:35 +0100) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | git://repo.or.cz/qemu/kevin.git tags/for-upstream | 7 | https://repo.or.cz/qemu/kevin.git tags/for-upstream |
8 | 8 | ||
9 | for you to fetch changes up to 1240ac558d348f6c7a5752b1a57c1da58e4efe3e: | 9 | for you to fetch changes up to 58a2e3f5c37be02dac3086b81bdda9414b931edf: |
10 | 10 | ||
11 | include: Add a comment to explain the origin of sizes' lookup table (2018-11-05 15:29:59 +0100) | 11 | block: compile out assert_bdrv_graph_readable() by default (2023-05-10 14:16:54 +0200) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Block layer patches: | 14 | Block layer patches |
15 | 15 | ||
16 | - auto-read-only option to fix commit job when used with -blockdev | 16 | - Graph locking, part 3 (more block drivers) |
17 | - Fix help text related qemu-iotests failure (by improving the help text | 17 | - Compile out assert_bdrv_graph_readable() by default |
18 | and updating the reference output) | 18 | - Add configure options for vmdk, vhdx and vpc |
19 | - quorum: Add missing checks when adding/removing child nodes | 19 | - Fix use after free in blockdev_mark_auto_del() |
20 | - Don't take address of fields in packed structs | 20 | - migration: Attempt disk reactivation in more failure scenarios |
21 | - vvfat: Fix crash when reporting error about too many files in directory | 21 | - Coroutine correctness fixes |
22 | 22 | ||
23 | ---------------------------------------------------------------- | 23 | ---------------------------------------------------------------- |
24 | Alberto Garcia (7): | 24 | Emanuele Giuseppe Esposito (5): |
25 | block: replace "discard" literal with BDRV_OPT_DISCARD macro | 25 | nbd: Mark nbd_co_do_establish_connection() and callers GRAPH_RDLOCK |
26 | qcow2: Get the request alignment for encrypted images from QCryptoBlock | 26 | block: Mark bdrv_co_get_allocated_file_size() and callers GRAPH_RDLOCK |
27 | quorum: Remove quorum_err() | 27 | block: Mark bdrv_co_get_info() and callers GRAPH_RDLOCK |
28 | quorum: Return an error if the blkverify mode has invalid settings | 28 | block: Mark bdrv_co_debug_event() GRAPH_RDLOCK |
29 | iotest: Test the blkverify mode of the Quorum driver | 29 | block: Mark BlockDriver callbacks for amend job GRAPH_RDLOCK |
30 | quorum: Forbid adding children in blkverify mode | ||
31 | iotest: Test x-blockdev-change on a Quorum | ||
32 | 30 | ||
33 | Cleber Rosa (1): | 31 | Eric Blake (1): |
34 | iotests: make 083 specific to raw | 32 | migration: Attempt disk reactivation in more failure scenarios |
35 | 33 | ||
36 | Daniel P. Berrangé (1): | 34 | Kevin Wolf (18): |
37 | crypto: initialize sector size even when opening with no IO flag | 35 | block: Fix use after free in blockdev_mark_auto_del() |
36 | iotests/nbd-reconnect-on-open: Fix NBD socket path | ||
37 | qcow2: Don't call bdrv_getlength() in coroutine_fns | ||
38 | block: Consistently call bdrv_activate() outside coroutine | ||
39 | block: bdrv/blk_co_unref() for calls in coroutine context | ||
40 | block: Don't call no_coroutine_fns in qmp_block_resize() | ||
41 | iotests: Test resizing image attached to an iothread | ||
42 | test-bdrv-drain: Don't modify the graph in coroutines | ||
43 | graph-lock: Add GRAPH_UNLOCKED(_PTR) | ||
44 | graph-lock: Fix GRAPH_RDLOCK_GUARD*() to be reader lock | ||
45 | block: .bdrv_open is non-coroutine and unlocked | ||
46 | nbd: Remove nbd_co_flush() wrapper function | ||
47 | vhdx: Require GRAPH_RDLOCK for accessing a node's parent list | ||
48 | mirror: Require GRAPH_RDLOCK for accessing a node's parent list | ||
49 | block: Mark bdrv_query_bds_stats() and callers GRAPH_RDLOCK | ||
50 | block: Mark bdrv_query_block_graph_info() and callers GRAPH_RDLOCK | ||
51 | block: Mark bdrv_recurse_can_replace() and callers GRAPH_RDLOCK | ||
52 | block: Mark bdrv_refresh_limits() and callers GRAPH_RDLOCK | ||
38 | 53 | ||
39 | Kevin Wolf (12): | 54 | Paolo Bonzini (1): |
40 | vpc: Don't leak opts in vpc_open() | 55 | block: add missing coroutine_fn annotations |
41 | block: Update flags in bdrv_set_read_only() | ||
42 | block: Add auto-read-only option | ||
43 | rbd: Close image in qemu_rbd_open() error path | ||
44 | block: Require auto-read-only for existing fallbacks | ||
45 | nbd: Support auto-read-only option | ||
46 | file-posix: Support auto-read-only option | ||
47 | curl: Support auto-read-only option | ||
48 | gluster: Support auto-read-only option | ||
49 | iscsi: Support auto-read-only option | ||
50 | block: Make auto-read-only=on default for -drive | ||
51 | qemu-iotests: Test auto-read-only with -drive and -blockdev | ||
52 | 56 | ||
53 | Leonid Bloch (2): | 57 | Stefan Hajnoczi (2): |
54 | vdi: Use a literal number of bytes for DEFAULT_CLUSTER_SIZE | 58 | aio-wait: avoid AioContext lock in aio_wait_bh_oneshot() |
55 | include: Add a comment to explain the origin of sizes' lookup table | 59 | block: compile out assert_bdrv_graph_readable() by default |
56 | 60 | ||
57 | Li Qiang (1): | 61 | Vladimir Sementsov-Ogievskiy (1): |
58 | block: change some function return type to bool | 62 | block: add configure options for excluding vmdk, vhdx and vpc |
59 | 63 | ||
60 | Max Reitz (5): | 64 | meson_options.txt | 8 ++ |
61 | option: Make option help nicer to read | 65 | configure | 1 + |
62 | chardev: Indent list of chardevs | 66 | block/coroutines.h | 5 +- |
63 | qdev-monitor: Make device options help nicer | 67 | block/qcow2.h | 4 +- |
64 | object: Make option help nicer to read | 68 | include/block/aio-wait.h | 2 +- |
65 | fw_cfg: Drop newline in @file description | 69 | include/block/block-global-state.h | 19 +++- |
66 | 70 | include/block/block-io.h | 23 +++-- | |
67 | Peter Maydell (5): | 71 | include/block/block_int-common.h | 37 +++---- |
68 | block/qcow2: Don't take address of fields in packed structs | 72 | include/block/block_int-global-state.h | 4 +- |
69 | block/qcow: Don't take address of fields in packed structs | 73 | include/block/graph-lock.h | 20 ++-- |
70 | block/qcow2-bitmap: Don't take address of fields in packed structs | 74 | include/block/qapi.h | 7 +- |
71 | block/vhdx: Don't take address of fields in packed structs | 75 | include/sysemu/block-backend-global-state.h | 5 +- |
72 | block/vdi: Don't take address of fields in packed structs | 76 | block.c | 25 ++++- |
73 | 77 | block/amend.c | 8 +- | |
74 | Stefan Weil (1): | 78 | block/blkverify.c | 5 +- |
75 | qemu-io-cmds: Fix two format strings | 79 | block/block-backend.c | 10 +- |
76 | 80 | block/crypto.c | 8 +- | |
77 | Thomas Huth (1): | 81 | block/graph-lock.c | 3 + |
78 | block/vvfat: Fix crash when reporting error about too many files in directory | 82 | block/io.c | 12 +-- |
79 | 83 | block/mirror.c | 18 +++- | |
80 | qapi/block-core.json | 7 + | 84 | block/nbd.c | 50 +++++---- |
81 | block/vhdx.h | 12 +- | 85 | block/parallels.c | 6 +- |
82 | include/block/block.h | 5 +- | 86 | block/qapi.c | 6 +- |
83 | include/qemu/option.h | 2 +- | 87 | block/qcow.c | 6 +- |
84 | include/qemu/units.h | 18 + | 88 | block/qcow2-refcount.c | 2 +- |
85 | include/sysemu/block-backend.h | 6 +- | 89 | block/qcow2.c | 48 ++++----- |
86 | block.c | 60 ++- | 90 | block/qed.c | 24 ++--- |
87 | block/block-backend.c | 8 +- | 91 | block/quorum.c | 4 +- |
88 | block/bochs.c | 17 +- | 92 | block/raw-format.c | 2 +- |
89 | block/cloop.c | 16 +- | 93 | block/vdi.c | 6 +- |
90 | block/curl.c | 8 +- | 94 | block/vhdx.c | 15 +-- |
91 | block/dmg.c | 16 +- | 95 | block/vmdk.c | 20 ++-- |
92 | block/file-posix.c | 19 +- | 96 | block/vpc.c | 6 +- |
93 | block/gluster.c | 12 +- | 97 | blockdev.c | 25 +++-- |
94 | block/iscsi.c | 8 +- | 98 | hw/block/dataplane/virtio-blk.c | 3 +- |
95 | block/nbd-client.c | 10 +- | 99 | hw/scsi/virtio-scsi-dataplane.c | 2 - |
96 | block/qcow.c | 18 +- | 100 | migration/migration.c | 24 +++-- |
97 | block/qcow2-bitmap.c | 24 +- | 101 | qemu-img.c | 2 + |
98 | block/qcow2.c | 66 +-- | 102 | tests/unit/test-bdrv-drain.c | 112 ++++++++++++++------- |
99 | block/quorum.c | 45 +- | 103 | util/aio-wait.c | 2 +- |
100 | block/rbd.c | 14 +- | 104 | block/meson.build | 18 +++- |
101 | block/vdi.c | 68 +-- | 105 | meson.build | 5 + |
102 | block/vhdx-endian.c | 118 ++--- | 106 | scripts/meson-buildoptions.sh | 13 +++ |
103 | block/vhdx-log.c | 4 +- | 107 | tests/qemu-iotests/tests/iothreads-resize | 71 +++++++++++++ |
104 | block/vhdx.c | 18 +- | 108 | tests/qemu-iotests/tests/iothreads-resize.out | 11 ++ |
105 | block/vpc.c | 2 + | 109 | tests/qemu-iotests/tests/nbd-reconnect-on-open | 3 +- |
106 | block/vvfat.c | 15 +- | 110 | tests/qemu-iotests/tests/nbd-reconnect-on-open.out | 4 +- |
107 | blockdev.c | 3 +- | 111 | 47 files changed, 474 insertions(+), 240 deletions(-) |
108 | chardev/char.c | 2 +- | 112 | create mode 100755 tests/qemu-iotests/tests/iothreads-resize |
109 | crypto/block-qcow.c | 2 + | 113 | create mode 100644 tests/qemu-iotests/tests/iothreads-resize.out |
110 | qdev-monitor.c | 13 +- | ||
111 | qemu-img.c | 4 +- | ||
112 | qemu-io-cmds.c | 4 +- | ||
113 | util/qemu-option.c | 32 +- | ||
114 | vl.c | 15 +- | ||
115 | tests/qemu-iotests/081 | 116 +++++ | ||
116 | tests/qemu-iotests/081.out | 70 +++ | ||
117 | tests/qemu-iotests/082.out | 956 ++++++++++++++++++++--------------------- | ||
118 | tests/qemu-iotests/083 | 2 +- | ||
119 | tests/qemu-iotests/232 | 147 +++++++ | ||
120 | tests/qemu-iotests/232.out | 59 +++ | ||
121 | tests/qemu-iotests/group | 1 + | ||
122 | 42 files changed, 1266 insertions(+), 776 deletions(-) | ||
123 | create mode 100755 tests/qemu-iotests/232 | ||
124 | create mode 100644 tests/qemu-iotests/232.out | ||
125 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Thomas Huth <thuth@redhat.com> | ||
2 | 1 | ||
3 | When using the vvfat driver with a directory that contains too many files, | ||
4 | QEMU currently crashes. This can be triggered like this for example: | ||
5 | |||
6 | mkdir /tmp/vvfattest | ||
7 | cd /tmp/vvfattest | ||
8 | for ((x=0;x<=513;x++)); do mkdir $x; done | ||
9 | qemu-system-x86_64 -drive \ | ||
10 | file.driver=vvfat,file.dir=.,read-only=on,media=cdrom | ||
11 | |||
12 | Seems like read_directory() is changing the mapping->path variable. Make | ||
13 | sure we use the right pointer instead. | ||
14 | |||
15 | Signed-off-by: Thomas Huth <thuth@redhat.com> | ||
16 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
17 | --- | ||
18 | block/vvfat.c | 4 ++-- | ||
19 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
20 | |||
21 | diff --git a/block/vvfat.c b/block/vvfat.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/block/vvfat.c | ||
24 | +++ b/block/vvfat.c | ||
25 | @@ -XXX,XX +XXX,XX @@ static int init_directories(BDRVVVFATState* s, | ||
26 | mapping = array_get(&(s->mapping), i); | ||
27 | |||
28 | if (mapping->mode & MODE_DIRECTORY) { | ||
29 | + char *path = mapping->path; | ||
30 | mapping->begin = cluster; | ||
31 | if(read_directory(s, i)) { | ||
32 | - error_setg(errp, "Could not read directory %s", | ||
33 | - mapping->path); | ||
34 | + error_setg(errp, "Could not read directory %s", path); | ||
35 | return -1; | ||
36 | } | ||
37 | mapping = array_get(&(s->mapping), i); | ||
38 | -- | ||
39 | 2.19.1 | ||
40 | |||
41 | diff view generated by jsdifflib |
1 | From: Leonid Bloch <lbloch@janustech.com> | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> |
---|---|---|---|
2 | 2 | ||
3 | The lookup table for power-of-two sizes was added in commit 540b8492618eb | 3 | Let's add --enable / --disable configure options for these formats, |
4 | for the purpose of having convenient shortcuts for these sizes in cases | 4 | so that those who don't need them may not build them. |
5 | when the literal number has to be present at compile time, and | ||
6 | expressions as '(1 * KiB)' can not be used. One such case is the | ||
7 | stringification of sizes. Beyond that, it is convenient to use these | ||
8 | shortcuts for all power-of-two sizes, even if they don't have to be | ||
9 | literal numbers. | ||
10 | 5 | ||
11 | Despite its convenience, this table introduced 55 lines of "dumb" code, | 6 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> |
12 | the purpose and origin of which are obscure without reading the message | 7 | Message-Id: <20230421092758.814122-1-vsementsov@yandex-team.ru> |
13 | of the commit which introduced it. This patch fixes that by adding a | 8 | Reviewed-by: Kevin Wolf <kwolf@redhat.com> |
14 | comment to the code itself with a brief explanation for the reasoning | ||
15 | behind this table. This comment includes the short AWK script that | ||
16 | generated the table, so that anyone who's interested could make sure | ||
17 | that the values in it are correct (otherwise these values look as if | ||
18 | they were typed manually). | ||
19 | |||
20 | Signed-off-by: Leonid Bloch <lbloch@janustech.com> | ||
21 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
22 | --- | 10 | --- |
23 | include/qemu/units.h | 18 ++++++++++++++++++ | 11 | meson_options.txt | 6 ++++++ |
24 | 1 file changed, 18 insertions(+) | 12 | block/meson.build | 18 +++++++++++++----- |
13 | meson.build | 3 +++ | ||
14 | scripts/meson-buildoptions.sh | 9 +++++++++ | ||
15 | 4 files changed, 31 insertions(+), 5 deletions(-) | ||
25 | 16 | ||
26 | diff --git a/include/qemu/units.h b/include/qemu/units.h | 17 | diff --git a/meson_options.txt b/meson_options.txt |
27 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/include/qemu/units.h | 19 | --- a/meson_options.txt |
29 | +++ b/include/qemu/units.h | 20 | +++ b/meson_options.txt |
30 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ option('qcow1', type: 'feature', value: 'auto', |
31 | #define PiB (INT64_C(1) << 50) | 22 | description: 'qcow1 image format support') |
32 | #define EiB (INT64_C(1) << 60) | 23 | option('vdi', type: 'feature', value: 'auto', |
33 | 24 | description: 'vdi image format support') | |
34 | +/* | 25 | +option('vhdx', type: 'feature', value: 'auto', |
35 | + * The following lookup table is intended to be used when a literal string of | 26 | + description: 'vhdx image format support') |
36 | + * the number of bytes is required (for example if it needs to be stringified). | 27 | +option('vmdk', type: 'feature', value: 'auto', |
37 | + * It can also be used for generic shortcuts of power-of-two sizes. | 28 | + description: 'vmdk image format support') |
38 | + * This table is generated using the AWK script below: | 29 | +option('vpc', type: 'feature', value: 'auto', |
39 | + * | 30 | + description: 'vpc image format support') |
40 | + * BEGIN { | 31 | option('vvfat', type: 'feature', value: 'auto', |
41 | + * suffix="KMGTPE"; | 32 | description: 'vvfat image format support') |
42 | + * for(i=10; i<64; i++) { | 33 | option('qed', type: 'feature', value: 'auto', |
43 | + * val=2**i; | 34 | diff --git a/block/meson.build b/block/meson.build |
44 | + * s=substr(suffix, int(i/10), 1); | 35 | index XXXXXXX..XXXXXXX 100644 |
45 | + * n=2**(i%10); | 36 | --- a/block/meson.build |
46 | + * pad=21-int(log(n)/log(10)); | 37 | +++ b/block/meson.build |
47 | + * printf("#define S_%d%siB %*d\n", n, s, pad, val); | 38 | @@ -XXX,XX +XXX,XX @@ block_ss.add(files( |
48 | + * } | 39 | 'snapshot-access.c', |
49 | + * } | 40 | 'throttle-groups.c', |
50 | + */ | 41 | 'throttle.c', |
51 | + | 42 | - 'vhdx-endian.c', |
52 | #define S_1KiB 1024 | 43 | - 'vhdx-log.c', |
53 | #define S_2KiB 2048 | 44 | - 'vhdx.c', |
54 | #define S_4KiB 4096 | 45 | - 'vmdk.c', |
46 | - 'vpc.c', | ||
47 | 'write-threshold.c', | ||
48 | ), zstd, zlib, gnutls) | ||
49 | |||
50 | @@ -XXX,XX +XXX,XX @@ endif | ||
51 | if get_option('vdi').allowed() | ||
52 | block_ss.add(files('vdi.c')) | ||
53 | endif | ||
54 | +if get_option('vhdx').allowed() | ||
55 | + block_ss.add(files( | ||
56 | + 'vhdx-endian.c', | ||
57 | + 'vhdx-log.c', | ||
58 | + 'vhdx.c' | ||
59 | + )) | ||
60 | +endif | ||
61 | +if get_option('vmdk').allowed() | ||
62 | + block_ss.add(files('vmdk.c')) | ||
63 | +endif | ||
64 | +if get_option('vpc').allowed() | ||
65 | + block_ss.add(files('vpc.c')) | ||
66 | +endif | ||
67 | if get_option('cloop').allowed() | ||
68 | block_ss.add(files('cloop.c')) | ||
69 | endif | ||
70 | diff --git a/meson.build b/meson.build | ||
71 | index XXXXXXX..XXXXXXX 100644 | ||
72 | --- a/meson.build | ||
73 | +++ b/meson.build | ||
74 | @@ -XXX,XX +XXX,XX @@ if have_block | ||
75 | summary_info += {'dmg support': get_option('dmg').allowed()} | ||
76 | summary_info += {'qcow v1 support': get_option('qcow1').allowed()} | ||
77 | summary_info += {'vdi support': get_option('vdi').allowed()} | ||
78 | + summary_info += {'vhdx support': get_option('vhdx').allowed()} | ||
79 | + summary_info += {'vmdk support': get_option('vmdk').allowed()} | ||
80 | + summary_info += {'vpc support': get_option('vpc').allowed()} | ||
81 | summary_info += {'vvfat support': get_option('vvfat').allowed()} | ||
82 | summary_info += {'qed support': get_option('qed').allowed()} | ||
83 | summary_info += {'parallels support': get_option('parallels').allowed()} | ||
84 | diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh | ||
85 | index XXXXXXX..XXXXXXX 100644 | ||
86 | --- a/scripts/meson-buildoptions.sh | ||
87 | +++ b/scripts/meson-buildoptions.sh | ||
88 | @@ -XXX,XX +XXX,XX @@ meson_options_help() { | ||
89 | printf "%s\n" ' VDUSE block export support' | ||
90 | printf "%s\n" ' vfio-user-server' | ||
91 | printf "%s\n" ' vfio-user server support' | ||
92 | + printf "%s\n" ' vhdx vhdx image format support' | ||
93 | printf "%s\n" ' vhost-crypto vhost-user crypto backend support' | ||
94 | printf "%s\n" ' vhost-kernel vhost kernel backend support' | ||
95 | printf "%s\n" ' vhost-net vhost-net kernel acceleration support' | ||
96 | @@ -XXX,XX +XXX,XX @@ meson_options_help() { | ||
97 | printf "%s\n" ' vhost-vdpa vhost-vdpa kernel backend support' | ||
98 | printf "%s\n" ' virglrenderer virgl rendering support' | ||
99 | printf "%s\n" ' virtfs virtio-9p support' | ||
100 | + printf "%s\n" ' vmdk vmdk image format support' | ||
101 | printf "%s\n" ' vmnet vmnet.framework network backend support' | ||
102 | printf "%s\n" ' vnc VNC server' | ||
103 | printf "%s\n" ' vnc-jpeg JPEG lossy compression for VNC server' | ||
104 | printf "%s\n" ' vnc-sasl SASL authentication for VNC server' | ||
105 | + printf "%s\n" ' vpc vpc image format support' | ||
106 | printf "%s\n" ' vte vte support for the gtk UI' | ||
107 | printf "%s\n" ' vvfat vvfat image format support' | ||
108 | printf "%s\n" ' whpx WHPX acceleration support' | ||
109 | @@ -XXX,XX +XXX,XX @@ _meson_option_parse() { | ||
110 | --disable-vduse-blk-export) printf "%s" -Dvduse_blk_export=disabled ;; | ||
111 | --enable-vfio-user-server) printf "%s" -Dvfio_user_server=enabled ;; | ||
112 | --disable-vfio-user-server) printf "%s" -Dvfio_user_server=disabled ;; | ||
113 | + --enable-vhdx) printf "%s" -Dvhdx=enabled ;; | ||
114 | + --disable-vhdx) printf "%s" -Dvhdx=disabled ;; | ||
115 | --enable-vhost-crypto) printf "%s" -Dvhost_crypto=enabled ;; | ||
116 | --disable-vhost-crypto) printf "%s" -Dvhost_crypto=disabled ;; | ||
117 | --enable-vhost-kernel) printf "%s" -Dvhost_kernel=enabled ;; | ||
118 | @@ -XXX,XX +XXX,XX @@ _meson_option_parse() { | ||
119 | --disable-virglrenderer) printf "%s" -Dvirglrenderer=disabled ;; | ||
120 | --enable-virtfs) printf "%s" -Dvirtfs=enabled ;; | ||
121 | --disable-virtfs) printf "%s" -Dvirtfs=disabled ;; | ||
122 | + --enable-vmdk) printf "%s" -Dvmdk=enabled ;; | ||
123 | + --disable-vmdk) printf "%s" -Dvmdk=disabled ;; | ||
124 | --enable-vmnet) printf "%s" -Dvmnet=enabled ;; | ||
125 | --disable-vmnet) printf "%s" -Dvmnet=disabled ;; | ||
126 | --enable-vnc) printf "%s" -Dvnc=enabled ;; | ||
127 | @@ -XXX,XX +XXX,XX @@ _meson_option_parse() { | ||
128 | --disable-vnc-jpeg) printf "%s" -Dvnc_jpeg=disabled ;; | ||
129 | --enable-vnc-sasl) printf "%s" -Dvnc_sasl=enabled ;; | ||
130 | --disable-vnc-sasl) printf "%s" -Dvnc_sasl=disabled ;; | ||
131 | + --enable-vpc) printf "%s" -Dvpc=enabled ;; | ||
132 | + --disable-vpc) printf "%s" -Dvpc=disabled ;; | ||
133 | --enable-vte) printf "%s" -Dvte=enabled ;; | ||
134 | --disable-vte) printf "%s" -Dvte=disabled ;; | ||
135 | --enable-vvfat) printf "%s" -Dvvfat=enabled ;; | ||
55 | -- | 136 | -- |
56 | 2.19.1 | 137 | 2.40.1 |
57 | |||
58 | diff view generated by jsdifflib |
1 | From: Leonid Bloch <lbloch@janustech.com> | 1 | From: Paolo Bonzini <pbonzini@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | If an expression is used to define DEFAULT_CLUSTER_SIZE, when compiled, | 3 | After the recent introduction of many new coroutine callbacks, |
4 | it will be embedded as a literal expression in the binary (as the | 4 | a couple calls from non-coroutine_fn to coroutine_fn have sneaked |
5 | default value) because it is stringified to mark the size of the default | 5 | in; fix them. |
6 | value. Now this is fixed by using a defined number to define this value. | ||
7 | 6 | ||
8 | Signed-off-by: Leonid Bloch <lbloch@janustech.com> | 7 | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> |
9 | Reviewed-by: Stefan Weil <sw@weilnetz.de> | 8 | Message-Id: <20230406101752.242125-1-pbonzini@redhat.com> |
9 | Reviewed-by: Kevin Wolf <kwolf@redhat.com> | ||
10 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 10 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
11 | --- | 11 | --- |
12 | block/vdi.c | 4 ++-- | 12 | include/block/graph-lock.h | 4 ++-- |
13 | 1 file changed, 2 insertions(+), 2 deletions(-) | 13 | block/mirror.c | 4 ++-- |
14 | 2 files changed, 4 insertions(+), 4 deletions(-) | ||
14 | 15 | ||
15 | diff --git a/block/vdi.c b/block/vdi.c | 16 | diff --git a/include/block/graph-lock.h b/include/block/graph-lock.h |
16 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/block/vdi.c | 18 | --- a/include/block/graph-lock.h |
18 | +++ b/block/vdi.c | 19 | +++ b/include/block/graph-lock.h |
19 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ typedef struct GraphLockable { } GraphLockable; |
20 | #define BLOCK_OPT_STATIC "static" | 21 | * unlocked. TSA_ASSERT() makes sure that the following calls know that we |
21 | 22 | * hold the lock while unlocking is left unchecked. | |
22 | #define SECTOR_SIZE 512 | 23 | */ |
23 | -#define DEFAULT_CLUSTER_SIZE (1 * MiB) | 24 | -static inline GraphLockable * TSA_ASSERT(graph_lock) TSA_NO_TSA |
24 | +#define DEFAULT_CLUSTER_SIZE S_1MiB | 25 | +static inline GraphLockable * TSA_ASSERT(graph_lock) TSA_NO_TSA coroutine_fn |
25 | 26 | graph_lockable_auto_lock(GraphLockable *x) | |
26 | #if defined(CONFIG_VDI_DEBUG) | 27 | { |
27 | #define VDI_DEBUG 1 | 28 | bdrv_graph_co_rdlock(); |
28 | @@ -XXX,XX +XXX,XX @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags, | 29 | return x; |
29 | goto fail; | 30 | } |
30 | } else if (header.block_size != DEFAULT_CLUSTER_SIZE) { | 31 | |
31 | error_setg(errp, "unsupported VDI image (block size %" PRIu32 | 32 | -static inline void TSA_NO_TSA |
32 | - " is not %" PRIu64 ")", | 33 | +static inline void TSA_NO_TSA coroutine_fn |
33 | + " is not %" PRIu32 ")", | 34 | graph_lockable_auto_unlock(GraphLockable *x) |
34 | header.block_size, DEFAULT_CLUSTER_SIZE); | 35 | { |
35 | ret = -ENOTSUP; | 36 | bdrv_graph_co_rdunlock(); |
36 | goto fail; | 37 | diff --git a/block/mirror.c b/block/mirror.c |
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/block/mirror.c | ||
40 | +++ b/block/mirror.c | ||
41 | @@ -XXX,XX +XXX,XX @@ static inline int64_t mirror_clip_bytes(MirrorBlockJob *s, | ||
42 | |||
43 | /* Round offset and/or bytes to target cluster if COW is needed, and | ||
44 | * return the offset of the adjusted tail against original. */ | ||
45 | -static int mirror_cow_align(MirrorBlockJob *s, int64_t *offset, | ||
46 | - uint64_t *bytes) | ||
47 | +static int coroutine_fn mirror_cow_align(MirrorBlockJob *s, int64_t *offset, | ||
48 | + uint64_t *bytes) | ||
49 | { | ||
50 | bool need_cow; | ||
51 | int ret = 0; | ||
37 | -- | 52 | -- |
38 | 2.19.1 | 53 | 2.40.1 |
39 | |||
40 | diff view generated by jsdifflib |
1 | From: Max Reitz <mreitz@redhat.com> | 1 | From: Stefan Hajnoczi <stefanha@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | There is no good reason why there should be a newline in this | 3 | There is no need for the AioContext lock in aio_wait_bh_oneshot(). |
4 | description, so remove it. | 4 | It's easy to remove the lock from existing callers and then switch from |
5 | AIO_WAIT_WHILE() to AIO_WAIT_WHILE_UNLOCKED() in aio_wait_bh_oneshot(). | ||
5 | 6 | ||
6 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 7 | Document that the AioContext lock should not be held across |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 8 | aio_wait_bh_oneshot(). Holding a lock across aio_poll() can cause |
8 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | 9 | deadlock so we don't want callers to do that. |
10 | |||
11 | This is a step towards getting rid of the AioContext lock. | ||
12 | |||
13 | Cc: Paolo Bonzini <pbonzini@redhat.com> | ||
14 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
15 | Message-Id: <20230404153307.458883-1-stefanha@redhat.com> | ||
16 | Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> | ||
17 | Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> | ||
18 | Reviewed-by: Kevin Wolf <kwolf@redhat.com> | ||
9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 19 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
10 | --- | 20 | --- |
11 | vl.c | 2 +- | 21 | include/block/aio-wait.h | 2 +- |
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | 22 | hw/block/dataplane/virtio-blk.c | 3 ++- |
23 | hw/scsi/virtio-scsi-dataplane.c | 2 -- | ||
24 | util/aio-wait.c | 2 +- | ||
25 | 4 files changed, 4 insertions(+), 5 deletions(-) | ||
13 | 26 | ||
14 | diff --git a/vl.c b/vl.c | 27 | diff --git a/include/block/aio-wait.h b/include/block/aio-wait.h |
15 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/vl.c | 29 | --- a/include/block/aio-wait.h |
17 | +++ b/vl.c | 30 | +++ b/include/block/aio-wait.h |
18 | @@ -XXX,XX +XXX,XX @@ static QemuOptsList qemu_fw_cfg_opts = { | 31 | @@ -XXX,XX +XXX,XX @@ void aio_wait_kick(void); |
19 | }, { | 32 | * |
20 | .name = "file", | 33 | * Run a BH in @ctx and wait for it to complete. |
21 | .type = QEMU_OPT_STRING, | 34 | * |
22 | - .help = "Sets the name of the file from which\n" | 35 | - * Must be called from the main loop thread with @ctx acquired exactly once. |
23 | + .help = "Sets the name of the file from which " | 36 | + * Must be called from the main loop thread without @ctx acquired. |
24 | "the fw_cfg blob will be loaded", | 37 | * Note that main loop event processing may occur. |
25 | }, { | 38 | */ |
26 | .name = "string", | 39 | void aio_wait_bh_oneshot(AioContext *ctx, QEMUBHFunc *cb, void *opaque); |
40 | diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/hw/block/dataplane/virtio-blk.c | ||
43 | +++ b/hw/block/dataplane/virtio-blk.c | ||
44 | @@ -XXX,XX +XXX,XX @@ void virtio_blk_data_plane_stop(VirtIODevice *vdev) | ||
45 | s->stopping = true; | ||
46 | trace_virtio_blk_data_plane_stop(s); | ||
47 | |||
48 | - aio_context_acquire(s->ctx); | ||
49 | aio_wait_bh_oneshot(s->ctx, virtio_blk_data_plane_stop_bh, s); | ||
50 | |||
51 | + aio_context_acquire(s->ctx); | ||
52 | + | ||
53 | /* Wait for virtio_blk_dma_restart_bh() and in flight I/O to complete */ | ||
54 | blk_drain(s->conf->conf.blk); | ||
55 | |||
56 | diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/hw/scsi/virtio-scsi-dataplane.c | ||
59 | +++ b/hw/scsi/virtio-scsi-dataplane.c | ||
60 | @@ -XXX,XX +XXX,XX @@ void virtio_scsi_dataplane_stop(VirtIODevice *vdev) | ||
61 | } | ||
62 | s->dataplane_stopping = true; | ||
63 | |||
64 | - aio_context_acquire(s->ctx); | ||
65 | aio_wait_bh_oneshot(s->ctx, virtio_scsi_dataplane_stop_bh, s); | ||
66 | - aio_context_release(s->ctx); | ||
67 | |||
68 | blk_drain_all(); /* ensure there are no in-flight requests */ | ||
69 | |||
70 | diff --git a/util/aio-wait.c b/util/aio-wait.c | ||
71 | index XXXXXXX..XXXXXXX 100644 | ||
72 | --- a/util/aio-wait.c | ||
73 | +++ b/util/aio-wait.c | ||
74 | @@ -XXX,XX +XXX,XX @@ void aio_wait_bh_oneshot(AioContext *ctx, QEMUBHFunc *cb, void *opaque) | ||
75 | assert(qemu_get_current_aio_context() == qemu_get_aio_context()); | ||
76 | |||
77 | aio_bh_schedule_oneshot(ctx, aio_wait_bh, &data); | ||
78 | - AIO_WAIT_WHILE(ctx, !data.done); | ||
79 | + AIO_WAIT_WHILE_UNLOCKED(NULL, !data.done); | ||
80 | } | ||
27 | -- | 81 | -- |
28 | 2.19.1 | 82 | 2.40.1 |
29 | |||
30 | diff view generated by jsdifflib |
1 | From: Peter Maydell <peter.maydell@linaro.org> | 1 | job_cancel_locked() drops the job list lock temporarily and it may call |
---|---|---|---|
2 | aio_poll(). We must assume that the list has changed after this call. | ||
3 | Also, with unlucky timing, it can end up freeing the job during | ||
4 | job_completed_txn_abort_locked(), making the job pointer invalid, too. | ||
2 | 5 | ||
3 | Taking the address of a field in a packed struct is a bad idea, because | 6 | For both reasons, we can't just continue at block_job_next_locked(job). |
4 | it might not be actually aligned enough for that pointer type (and | 7 | Instead, start at the head of the list again after job_cancel_locked() |
5 | thus cause a crash on dereference on some host architectures). Newer | 8 | and skip those jobs that we already cancelled (or that are completing |
6 | versions of clang warn about this. Avoid the bug by not using the | 9 | anyway). |
7 | "modify in place" byte swapping functions. | ||
8 | 10 | ||
9 | There are a few places where the in-place swap function is | 11 | Cc: qemu-stable@nongnu.org |
10 | used on something other than a packed struct field; we convert | 12 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
11 | those anyway, for consistency. | 13 | Message-Id: <20230503140142.474404-1-kwolf@redhat.com> |
12 | |||
13 | Patch produced with scripts/coccinelle/inplace-byteswaps.cocci. | ||
14 | |||
15 | There are other places where we take the address of a packed member | ||
16 | in this file for other purposes than passing it to a byteswap | ||
17 | function (all the calls to qemu_uuid_*()); we leave those for now. | ||
18 | |||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | 14 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> |
21 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 15 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
22 | --- | 16 | --- |
23 | block/vdi.c | 64 ++++++++++++++++++++++++++--------------------------- | 17 | blockdev.c | 18 ++++++++++++++---- |
24 | 1 file changed, 32 insertions(+), 32 deletions(-) | 18 | 1 file changed, 14 insertions(+), 4 deletions(-) |
25 | 19 | ||
26 | diff --git a/block/vdi.c b/block/vdi.c | 20 | diff --git a/blockdev.c b/blockdev.c |
27 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/block/vdi.c | 22 | --- a/blockdev.c |
29 | +++ b/block/vdi.c | 23 | +++ b/blockdev.c |
30 | @@ -XXX,XX +XXX,XX @@ typedef struct { | 24 | @@ -XXX,XX +XXX,XX @@ void blockdev_mark_auto_del(BlockBackend *blk) |
31 | 25 | ||
32 | static void vdi_header_to_cpu(VdiHeader *header) | 26 | JOB_LOCK_GUARD(); |
33 | { | 27 | |
34 | - le32_to_cpus(&header->signature); | 28 | - for (job = block_job_next_locked(NULL); job; |
35 | - le32_to_cpus(&header->version); | 29 | - job = block_job_next_locked(job)) { |
36 | - le32_to_cpus(&header->header_size); | 30 | - if (block_job_has_bdrv(job, blk_bs(blk))) { |
37 | - le32_to_cpus(&header->image_type); | 31 | + do { |
38 | - le32_to_cpus(&header->image_flags); | 32 | + job = block_job_next_locked(NULL); |
39 | - le32_to_cpus(&header->offset_bmap); | 33 | + while (job && (job->job.cancelled || |
40 | - le32_to_cpus(&header->offset_data); | 34 | + job->job.deferred_to_main_loop || |
41 | - le32_to_cpus(&header->cylinders); | 35 | + !block_job_has_bdrv(job, blk_bs(blk)))) |
42 | - le32_to_cpus(&header->heads); | 36 | + { |
43 | - le32_to_cpus(&header->sectors); | 37 | + job = block_job_next_locked(job); |
44 | - le32_to_cpus(&header->sector_size); | 38 | + } |
45 | - le64_to_cpus(&header->disk_size); | 39 | + if (job) { |
46 | - le32_to_cpus(&header->block_size); | 40 | + /* |
47 | - le32_to_cpus(&header->block_extra); | 41 | + * This drops the job lock temporarily and polls, so we need to |
48 | - le32_to_cpus(&header->blocks_in_image); | 42 | + * restart processing the list from the start after this. |
49 | - le32_to_cpus(&header->blocks_allocated); | 43 | + */ |
50 | + header->signature = le32_to_cpu(header->signature); | 44 | job_cancel_locked(&job->job, false); |
51 | + header->version = le32_to_cpu(header->version); | 45 | } |
52 | + header->header_size = le32_to_cpu(header->header_size); | 46 | - } |
53 | + header->image_type = le32_to_cpu(header->image_type); | 47 | + } while (job); |
54 | + header->image_flags = le32_to_cpu(header->image_flags); | 48 | |
55 | + header->offset_bmap = le32_to_cpu(header->offset_bmap); | 49 | dinfo->auto_del = 1; |
56 | + header->offset_data = le32_to_cpu(header->offset_data); | 50 | } |
57 | + header->cylinders = le32_to_cpu(header->cylinders); | ||
58 | + header->heads = le32_to_cpu(header->heads); | ||
59 | + header->sectors = le32_to_cpu(header->sectors); | ||
60 | + header->sector_size = le32_to_cpu(header->sector_size); | ||
61 | + header->disk_size = le64_to_cpu(header->disk_size); | ||
62 | + header->block_size = le32_to_cpu(header->block_size); | ||
63 | + header->block_extra = le32_to_cpu(header->block_extra); | ||
64 | + header->blocks_in_image = le32_to_cpu(header->blocks_in_image); | ||
65 | + header->blocks_allocated = le32_to_cpu(header->blocks_allocated); | ||
66 | qemu_uuid_bswap(&header->uuid_image); | ||
67 | qemu_uuid_bswap(&header->uuid_last_snap); | ||
68 | qemu_uuid_bswap(&header->uuid_link); | ||
69 | @@ -XXX,XX +XXX,XX @@ static void vdi_header_to_cpu(VdiHeader *header) | ||
70 | |||
71 | static void vdi_header_to_le(VdiHeader *header) | ||
72 | { | ||
73 | - cpu_to_le32s(&header->signature); | ||
74 | - cpu_to_le32s(&header->version); | ||
75 | - cpu_to_le32s(&header->header_size); | ||
76 | - cpu_to_le32s(&header->image_type); | ||
77 | - cpu_to_le32s(&header->image_flags); | ||
78 | - cpu_to_le32s(&header->offset_bmap); | ||
79 | - cpu_to_le32s(&header->offset_data); | ||
80 | - cpu_to_le32s(&header->cylinders); | ||
81 | - cpu_to_le32s(&header->heads); | ||
82 | - cpu_to_le32s(&header->sectors); | ||
83 | - cpu_to_le32s(&header->sector_size); | ||
84 | - cpu_to_le64s(&header->disk_size); | ||
85 | - cpu_to_le32s(&header->block_size); | ||
86 | - cpu_to_le32s(&header->block_extra); | ||
87 | - cpu_to_le32s(&header->blocks_in_image); | ||
88 | - cpu_to_le32s(&header->blocks_allocated); | ||
89 | + header->signature = cpu_to_le32(header->signature); | ||
90 | + header->version = cpu_to_le32(header->version); | ||
91 | + header->header_size = cpu_to_le32(header->header_size); | ||
92 | + header->image_type = cpu_to_le32(header->image_type); | ||
93 | + header->image_flags = cpu_to_le32(header->image_flags); | ||
94 | + header->offset_bmap = cpu_to_le32(header->offset_bmap); | ||
95 | + header->offset_data = cpu_to_le32(header->offset_data); | ||
96 | + header->cylinders = cpu_to_le32(header->cylinders); | ||
97 | + header->heads = cpu_to_le32(header->heads); | ||
98 | + header->sectors = cpu_to_le32(header->sectors); | ||
99 | + header->sector_size = cpu_to_le32(header->sector_size); | ||
100 | + header->disk_size = cpu_to_le64(header->disk_size); | ||
101 | + header->block_size = cpu_to_le32(header->block_size); | ||
102 | + header->block_extra = cpu_to_le32(header->block_extra); | ||
103 | + header->blocks_in_image = cpu_to_le32(header->blocks_in_image); | ||
104 | + header->blocks_allocated = cpu_to_le32(header->blocks_allocated); | ||
105 | qemu_uuid_bswap(&header->uuid_image); | ||
106 | qemu_uuid_bswap(&header->uuid_last_snap); | ||
107 | qemu_uuid_bswap(&header->uuid_link); | ||
108 | -- | 51 | -- |
109 | 2.19.1 | 52 | 2.40.1 |
110 | |||
111 | diff view generated by jsdifflib |
1 | From: Max Reitz <mreitz@redhat.com> | 1 | Socket paths need to be short to avoid failures. This is why there is a |
---|---|---|---|
2 | iotests.sock_dir (defaulting to /tmp) separate from the disk image base | ||
3 | directory. | ||
2 | 4 | ||
3 | Just like in qemu_opts_print_help(), print the object name as a caption | 5 | Make use of it to fix failures in too deeply nested test directories. |
4 | instead of on every single line, indent all options, add angle brackets | ||
5 | around types, and align the descriptions after 24 characters. | ||
6 | 6 | ||
7 | Also, indent every object name in the list of available objects. | 7 | Fixes: ab7f7e67a7e7b49964109501dfcde4ec29bae60e |
8 | 8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | |
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 9 | Message-Id: <20230503165019.8867-1-kwolf@redhat.com> |
10 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | 10 | Reviewed-by: Eric Blake <eblake@redhat.com> |
11 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> | ||
11 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 12 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
12 | --- | 13 | --- |
13 | vl.c | 13 ++++++++++--- | 14 | tests/qemu-iotests/tests/nbd-reconnect-on-open | 3 ++- |
14 | 1 file changed, 10 insertions(+), 3 deletions(-) | 15 | tests/qemu-iotests/tests/nbd-reconnect-on-open.out | 4 ++-- |
16 | 2 files changed, 4 insertions(+), 3 deletions(-) | ||
15 | 17 | ||
16 | diff --git a/vl.c b/vl.c | 18 | diff --git a/tests/qemu-iotests/tests/nbd-reconnect-on-open b/tests/qemu-iotests/tests/nbd-reconnect-on-open |
19 | index XXXXXXX..XXXXXXX 100755 | ||
20 | --- a/tests/qemu-iotests/tests/nbd-reconnect-on-open | ||
21 | +++ b/tests/qemu-iotests/tests/nbd-reconnect-on-open | ||
22 | @@ -XXX,XX +XXX,XX @@ from iotests import qemu_img_create, file_path, qemu_io_popen, qemu_nbd, \ | ||
23 | |||
24 | iotests.script_initialize(supported_fmts=['qcow2']) | ||
25 | |||
26 | -disk, nbd_sock = file_path('disk', 'nbd-sock') | ||
27 | +disk = file_path('disk') | ||
28 | +nbd_sock = file_path('nbd-sock', base_dir=iotests.sock_dir) | ||
29 | |||
30 | |||
31 | def create_args(open_timeout): | ||
32 | diff --git a/tests/qemu-iotests/tests/nbd-reconnect-on-open.out b/tests/qemu-iotests/tests/nbd-reconnect-on-open.out | ||
17 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/vl.c | 34 | --- a/tests/qemu-iotests/tests/nbd-reconnect-on-open.out |
19 | +++ b/vl.c | 35 | +++ b/tests/qemu-iotests/tests/nbd-reconnect-on-open.out |
20 | @@ -XXX,XX +XXX,XX @@ static bool object_create_initial(const char *type, QemuOpts *opts) | 36 | @@ -XXX,XX +XXX,XX @@ read 1048576/1048576 bytes at offset 0 |
21 | list = object_class_get_list_sorted(TYPE_USER_CREATABLE, false); | 37 | 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) |
22 | for (l = list; l != NULL; l = l->next) { | 38 | |
23 | ObjectClass *oc = OBJECT_CLASS(l->data); | 39 | Check fail to connect with 0 seconds of timeout |
24 | - printf("%s\n", object_class_get_name(oc)); | 40 | -qemu-io: can't open: Failed to connect to 'TEST_DIR/PID-nbd-sock': No such file or directory |
25 | + printf(" %s\n", object_class_get_name(oc)); | 41 | +qemu-io: can't open: Failed to connect to 'SOCK_DIR/PID-nbd-sock': No such file or directory |
26 | } | 42 | |
27 | g_slist_free(list); | 43 | qemu_io finished in 0..0.2 seconds, OK |
28 | exit(0); | 44 | Check fail to connect with 1 seconds of timeout |
29 | @@ -XXX,XX +XXX,XX @@ static bool object_create_initial(const char *type, QemuOpts *opts) | 45 | -qemu-io: can't open: Failed to connect to 'TEST_DIR/PID-nbd-sock': No such file or directory |
30 | } | 46 | +qemu-io: can't open: Failed to connect to 'SOCK_DIR/PID-nbd-sock': No such file or directory |
31 | 47 | ||
32 | str = g_string_new(NULL); | 48 | qemu_io finished in 1..1.2 seconds, OK |
33 | - g_string_append_printf(str, "%s.%s=%s", type, | ||
34 | - prop->name, prop->type); | ||
35 | + g_string_append_printf(str, " %s=<%s>", prop->name, prop->type); | ||
36 | if (prop->description) { | ||
37 | + if (str->len < 24) { | ||
38 | + g_string_append_printf(str, "%*s", 24 - (int)str->len, ""); | ||
39 | + } | ||
40 | g_string_append_printf(str, " - %s", prop->description); | ||
41 | } | ||
42 | g_ptr_array_add(array, g_string_free(str, false)); | ||
43 | } | ||
44 | g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0); | ||
45 | + if (array->len > 0) { | ||
46 | + printf("%s options:\n", type); | ||
47 | + } else { | ||
48 | + printf("There are no options for %s.\n", type); | ||
49 | + } | ||
50 | for (i = 0; i < array->len; i++) { | ||
51 | printf("%s\n", (char *)array->pdata[i]); | ||
52 | } | ||
53 | -- | 49 | -- |
54 | 2.19.1 | 50 | 2.40.1 |
55 | |||
56 | diff view generated by jsdifflib |
1 | From: Peter Maydell <peter.maydell@linaro.org> | 1 | From: Eric Blake <eblake@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Taking the address of a field in a packed struct is a bad idea, because | 3 | Commit fe904ea824 added a fail_inactivate label, which tries to |
4 | it might not be actually aligned enough for that pointer type (and | 4 | reactivate disks on the source after a failure while s->state == |
5 | thus cause a crash on dereference on some host architectures). Newer | 5 | MIGRATION_STATUS_ACTIVE, but didn't actually use the label if |
6 | versions of clang warn about this. Avoid the bug by not using the | 6 | qemu_savevm_state_complete_precopy() failed. This failure to |
7 | "modify in place" byte swapping functions. | 7 | reactivate is also present in commit 6039dd5b1c (also covering the new |
8 | s->state == MIGRATION_STATUS_DEVICE state) and 403d18ae (ensuring | ||
9 | s->block_inactive is set more reliably). | ||
8 | 10 | ||
9 | There are a few places where the in-place swap function is | 11 | Consolidate the two labels back into one - no matter HOW migration is |
10 | used on something other than a packed struct field; we convert | 12 | failed, if there is any chance we can reach vm_start() after having |
11 | those anyway, for consistency. | 13 | attempted inactivation, it is essential that we have tried to restart |
14 | disks before then. This also makes the cleanup more like | ||
15 | migrate_fd_cancel(). | ||
12 | 16 | ||
13 | This patch was produced with the following spatch script: | 17 | Suggested-by: Kevin Wolf <kwolf@redhat.com> |
14 | 18 | Signed-off-by: Eric Blake <eblake@redhat.com> | |
15 | @@ | 19 | Message-Id: <20230502205212.134680-1-eblake@redhat.com> |
16 | expression E; | 20 | Acked-by: Peter Xu <peterx@redhat.com> |
17 | @@ | 21 | Reviewed-by: Juan Quintela <quintela@redhat.com> |
18 | -be16_to_cpus(&E); | 22 | Reviewed-by: Kevin Wolf <kwolf@redhat.com> |
19 | +E = be16_to_cpu(E); | ||
20 | @@ | ||
21 | expression E; | ||
22 | @@ | ||
23 | -be32_to_cpus(&E); | ||
24 | +E = be32_to_cpu(E); | ||
25 | @@ | ||
26 | expression E; | ||
27 | @@ | ||
28 | -be64_to_cpus(&E); | ||
29 | +E = be64_to_cpu(E); | ||
30 | @@ | ||
31 | expression E; | ||
32 | @@ | ||
33 | -cpu_to_be16s(&E); | ||
34 | +E = cpu_to_be16(E); | ||
35 | @@ | ||
36 | expression E; | ||
37 | @@ | ||
38 | -cpu_to_be32s(&E); | ||
39 | +E = cpu_to_be32(E); | ||
40 | @@ | ||
41 | expression E; | ||
42 | @@ | ||
43 | -cpu_to_be64s(&E); | ||
44 | +E = cpu_to_be64(E); | ||
45 | |||
46 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
47 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
48 | Tested-by: John Snow <jsnow@redhat.com> | ||
49 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
50 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 23 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
51 | --- | 24 | --- |
52 | block/qcow.c | 18 +++++++++--------- | 25 | migration/migration.c | 24 ++++++++++++++---------- |
53 | 1 file changed, 9 insertions(+), 9 deletions(-) | 26 | 1 file changed, 14 insertions(+), 10 deletions(-) |
54 | 27 | ||
55 | diff --git a/block/qcow.c b/block/qcow.c | 28 | diff --git a/migration/migration.c b/migration/migration.c |
56 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
57 | --- a/block/qcow.c | 30 | --- a/migration/migration.c |
58 | +++ b/block/qcow.c | 31 | +++ b/migration/migration.c |
59 | @@ -XXX,XX +XXX,XX @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags, | 32 | @@ -XXX,XX +XXX,XX @@ static void migration_completion(MigrationState *s) |
60 | if (ret < 0) { | 33 | MIGRATION_STATUS_DEVICE); |
61 | goto fail; | 34 | } |
35 | if (ret >= 0) { | ||
36 | + /* | ||
37 | + * Inactivate disks except in COLO, and track that we | ||
38 | + * have done so in order to remember to reactivate | ||
39 | + * them if migration fails or is cancelled. | ||
40 | + */ | ||
41 | s->block_inactive = !migrate_colo(); | ||
42 | qemu_file_set_rate_limit(s->to_dst_file, INT64_MAX); | ||
43 | ret = qemu_savevm_state_complete_precopy(s->to_dst_file, false, | ||
44 | @@ -XXX,XX +XXX,XX @@ static void migration_completion(MigrationState *s) | ||
45 | rp_error = await_return_path_close_on_source(s); | ||
46 | trace_migration_return_path_end_after(rp_error); | ||
47 | if (rp_error) { | ||
48 | - goto fail_invalidate; | ||
49 | + goto fail; | ||
50 | } | ||
62 | } | 51 | } |
63 | - be32_to_cpus(&header.magic); | 52 | |
64 | - be32_to_cpus(&header.version); | 53 | if (qemu_file_get_error(s->to_dst_file)) { |
65 | - be64_to_cpus(&header.backing_file_offset); | 54 | trace_migration_completion_file_err(); |
66 | - be32_to_cpus(&header.backing_file_size); | 55 | - goto fail_invalidate; |
67 | - be32_to_cpus(&header.mtime); | 56 | + goto fail; |
68 | - be64_to_cpus(&header.size); | ||
69 | - be32_to_cpus(&header.crypt_method); | ||
70 | - be64_to_cpus(&header.l1_table_offset); | ||
71 | + header.magic = be32_to_cpu(header.magic); | ||
72 | + header.version = be32_to_cpu(header.version); | ||
73 | + header.backing_file_offset = be64_to_cpu(header.backing_file_offset); | ||
74 | + header.backing_file_size = be32_to_cpu(header.backing_file_size); | ||
75 | + header.mtime = be32_to_cpu(header.mtime); | ||
76 | + header.size = be64_to_cpu(header.size); | ||
77 | + header.crypt_method = be32_to_cpu(header.crypt_method); | ||
78 | + header.l1_table_offset = be64_to_cpu(header.l1_table_offset); | ||
79 | |||
80 | if (header.magic != QCOW_MAGIC) { | ||
81 | error_setg(errp, "Image not in qcow format"); | ||
82 | @@ -XXX,XX +XXX,XX @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags, | ||
83 | } | 57 | } |
84 | 58 | ||
85 | for(i = 0;i < s->l1_size; i++) { | 59 | if (migrate_colo() && s->state == MIGRATION_STATUS_ACTIVE) { |
86 | - be64_to_cpus(&s->l1_table[i]); | 60 | @@ -XXX,XX +XXX,XX @@ static void migration_completion(MigrationState *s) |
87 | + s->l1_table[i] = be64_to_cpu(s->l1_table[i]); | 61 | |
62 | return; | ||
63 | |||
64 | -fail_invalidate: | ||
65 | - /* If not doing postcopy, vm_start() will be called: let's regain | ||
66 | - * control on images. | ||
67 | - */ | ||
68 | - if (s->state == MIGRATION_STATUS_ACTIVE || | ||
69 | - s->state == MIGRATION_STATUS_DEVICE) { | ||
70 | +fail: | ||
71 | + if (s->block_inactive && (s->state == MIGRATION_STATUS_ACTIVE || | ||
72 | + s->state == MIGRATION_STATUS_DEVICE)) { | ||
73 | + /* | ||
74 | + * If not doing postcopy, vm_start() will be called: let's | ||
75 | + * regain control on images. | ||
76 | + */ | ||
77 | Error *local_err = NULL; | ||
78 | |||
79 | qemu_mutex_lock_iothread(); | ||
80 | bdrv_activate_all(&local_err); | ||
81 | if (local_err) { | ||
82 | error_report_err(local_err); | ||
83 | - s->block_inactive = true; | ||
84 | } else { | ||
85 | s->block_inactive = false; | ||
86 | } | ||
87 | qemu_mutex_unlock_iothread(); | ||
88 | } | 88 | } |
89 | 89 | ||
90 | /* alloc L2 cache (max. 64k * 16 * 8 = 8 MB) */ | 90 | -fail: |
91 | migrate_set_state(&s->state, current_active_state, | ||
92 | MIGRATION_STATUS_FAILED); | ||
93 | } | ||
91 | -- | 94 | -- |
92 | 2.19.1 | 95 | 2.40.1 |
93 | |||
94 | diff view generated by jsdifflib |
1 | From: Peter Maydell <peter.maydell@linaro.org> | 1 | There is a bdrv_co_getlength() now, which should be used in coroutine |
---|---|---|---|
2 | context. | ||
2 | 3 | ||
3 | Taking the address of a field in a packed struct is a bad idea, because | 4 | This requires adding GRAPH_RDLOCK to some functions so that this still |
4 | it might not be actually aligned enough for that pointer type (and | 5 | compiles with TSA because bdrv_co_getlength() is GRAPH_RDLOCK. |
5 | thus cause a crash on dereference on some host architectures). Newer | ||
6 | versions of clang warn about this. Avoid the bug by not using the | ||
7 | "modify in place" byte swapping functions. | ||
8 | 6 | ||
9 | There are a few places where the in-place swap function is | 7 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
10 | used on something other than a packed struct field; we convert | 8 | Reviewed-by: Eric Blake <eblake@redhat.com> |
11 | those anyway, for consistency. | 9 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> |
12 | 10 | Message-Id: <20230504115750.54437-2-kwolf@redhat.com> | |
13 | This patch was produced with the following spatch script | ||
14 | (and hand-editing to fold a few resulting overlength lines): | ||
15 | |||
16 | @@ | ||
17 | expression E; | ||
18 | @@ | ||
19 | -be16_to_cpus(&E); | ||
20 | +E = be16_to_cpu(E); | ||
21 | @@ | ||
22 | expression E; | ||
23 | @@ | ||
24 | -be32_to_cpus(&E); | ||
25 | +E = be32_to_cpu(E); | ||
26 | @@ | ||
27 | expression E; | ||
28 | @@ | ||
29 | -be64_to_cpus(&E); | ||
30 | +E = be64_to_cpu(E); | ||
31 | @@ | ||
32 | expression E; | ||
33 | @@ | ||
34 | -cpu_to_be16s(&E); | ||
35 | +E = cpu_to_be16(E); | ||
36 | @@ | ||
37 | expression E; | ||
38 | @@ | ||
39 | -cpu_to_be32s(&E); | ||
40 | +E = cpu_to_be32(E); | ||
41 | @@ | ||
42 | expression E; | ||
43 | @@ | ||
44 | -cpu_to_be64s(&E); | ||
45 | +E = cpu_to_be64(E); | ||
46 | |||
47 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
48 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
49 | Tested-by: John Snow <jsnow@redhat.com> | ||
50 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
51 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 11 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
52 | --- | 12 | --- |
53 | block/qcow2.c | 64 +++++++++++++++++++++++++++------------------------ | 13 | block/qcow2.h | 4 +++- |
54 | 1 file changed, 34 insertions(+), 30 deletions(-) | 14 | block/qcow2-refcount.c | 2 +- |
15 | block/qcow2.c | 19 +++++++++---------- | ||
16 | 3 files changed, 13 insertions(+), 12 deletions(-) | ||
55 | 17 | ||
18 | diff --git a/block/qcow2.h b/block/qcow2.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/block/qcow2.h | ||
21 | +++ b/block/qcow2.h | ||
22 | @@ -XXX,XX +XXX,XX @@ int qcow2_change_refcount_order(BlockDriverState *bs, int refcount_order, | ||
23 | void *cb_opaque, Error **errp); | ||
24 | int coroutine_fn GRAPH_RDLOCK qcow2_shrink_reftable(BlockDriverState *bs); | ||
25 | int64_t coroutine_fn qcow2_get_last_cluster(BlockDriverState *bs, int64_t size); | ||
26 | -int coroutine_fn qcow2_detect_metadata_preallocation(BlockDriverState *bs); | ||
27 | + | ||
28 | +int coroutine_fn GRAPH_RDLOCK | ||
29 | +qcow2_detect_metadata_preallocation(BlockDriverState *bs); | ||
30 | |||
31 | /* qcow2-cluster.c functions */ | ||
32 | int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, | ||
33 | diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/block/qcow2-refcount.c | ||
36 | +++ b/block/qcow2-refcount.c | ||
37 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn qcow2_detect_metadata_preallocation(BlockDriverState *bs) | ||
38 | |||
39 | qemu_co_mutex_assert_locked(&s->lock); | ||
40 | |||
41 | - file_length = bdrv_getlength(bs->file->bs); | ||
42 | + file_length = bdrv_co_getlength(bs->file->bs); | ||
43 | if (file_length < 0) { | ||
44 | return file_length; | ||
45 | } | ||
56 | diff --git a/block/qcow2.c b/block/qcow2.c | 46 | diff --git a/block/qcow2.c b/block/qcow2.c |
57 | index XXXXXXX..XXXXXXX 100644 | 47 | index XXXXXXX..XXXXXXX 100644 |
58 | --- a/block/qcow2.c | 48 | --- a/block/qcow2.c |
59 | +++ b/block/qcow2.c | 49 | +++ b/block/qcow2.c |
60 | @@ -XXX,XX +XXX,XX @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, | 50 | @@ -XXX,XX +XXX,XX @@ static void qcow2_join_options(QDict *options, QDict *old_options) |
61 | "pread fail from offset %" PRIu64, offset); | ||
62 | return 1; | ||
63 | } | ||
64 | - be32_to_cpus(&ext.magic); | ||
65 | - be32_to_cpus(&ext.len); | ||
66 | + ext.magic = be32_to_cpu(ext.magic); | ||
67 | + ext.len = be32_to_cpu(ext.len); | ||
68 | offset += sizeof(ext); | ||
69 | #ifdef DEBUG_EXT | ||
70 | printf("ext.magic = 0x%x\n", ext.magic); | ||
71 | @@ -XXX,XX +XXX,XX @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, | ||
72 | "Unable to read CRYPTO header extension"); | ||
73 | return ret; | ||
74 | } | ||
75 | - be64_to_cpus(&s->crypto_header.offset); | ||
76 | - be64_to_cpus(&s->crypto_header.length); | ||
77 | + s->crypto_header.offset = be64_to_cpu(s->crypto_header.offset); | ||
78 | + s->crypto_header.length = be64_to_cpu(s->crypto_header.length); | ||
79 | |||
80 | if ((s->crypto_header.offset % s->cluster_size) != 0) { | ||
81 | error_setg(errp, "Encryption header offset '%" PRIu64 "' is " | ||
82 | @@ -XXX,XX +XXX,XX @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, | ||
83 | return -EINVAL; | ||
84 | } | ||
85 | |||
86 | - be32_to_cpus(&bitmaps_ext.nb_bitmaps); | ||
87 | - be64_to_cpus(&bitmaps_ext.bitmap_directory_size); | ||
88 | - be64_to_cpus(&bitmaps_ext.bitmap_directory_offset); | ||
89 | + bitmaps_ext.nb_bitmaps = be32_to_cpu(bitmaps_ext.nb_bitmaps); | ||
90 | + bitmaps_ext.bitmap_directory_size = | ||
91 | + be64_to_cpu(bitmaps_ext.bitmap_directory_size); | ||
92 | + bitmaps_ext.bitmap_directory_offset = | ||
93 | + be64_to_cpu(bitmaps_ext.bitmap_directory_offset); | ||
94 | |||
95 | if (bitmaps_ext.nb_bitmaps > QCOW2_MAX_BITMAPS) { | ||
96 | error_setg(errp, | ||
97 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, | ||
98 | error_setg_errno(errp, -ret, "Could not read qcow2 header"); | ||
99 | goto fail; | ||
100 | } | 51 | } |
101 | - be32_to_cpus(&header.magic); | 52 | } |
102 | - be32_to_cpus(&header.version); | 53 | |
103 | - be64_to_cpus(&header.backing_file_offset); | 54 | -static int coroutine_fn qcow2_co_block_status(BlockDriverState *bs, |
104 | - be32_to_cpus(&header.backing_file_size); | 55 | - bool want_zero, |
105 | - be64_to_cpus(&header.size); | 56 | - int64_t offset, int64_t count, |
106 | - be32_to_cpus(&header.cluster_bits); | 57 | - int64_t *pnum, int64_t *map, |
107 | - be32_to_cpus(&header.crypt_method); | 58 | - BlockDriverState **file) |
108 | - be64_to_cpus(&header.l1_table_offset); | 59 | +static int coroutine_fn GRAPH_RDLOCK |
109 | - be32_to_cpus(&header.l1_size); | 60 | +qcow2_co_block_status(BlockDriverState *bs, bool want_zero, int64_t offset, |
110 | - be64_to_cpus(&header.refcount_table_offset); | 61 | + int64_t count, int64_t *pnum, int64_t *map, |
111 | - be32_to_cpus(&header.refcount_table_clusters); | 62 | + BlockDriverState **file) |
112 | - be64_to_cpus(&header.snapshots_offset); | 63 | { |
113 | - be32_to_cpus(&header.nb_snapshots); | 64 | BDRVQcow2State *s = bs->opaque; |
114 | + header.magic = be32_to_cpu(header.magic); | 65 | uint64_t host_offset; |
115 | + header.version = be32_to_cpu(header.version); | 66 | @@ -XXX,XX +XXX,XX @@ preallocate_co(BlockDriverState *bs, uint64_t offset, uint64_t new_length, |
116 | + header.backing_file_offset = be64_to_cpu(header.backing_file_offset); | 67 | * all of the allocated clusters (otherwise we get failing reads after |
117 | + header.backing_file_size = be32_to_cpu(header.backing_file_size); | 68 | * EOF). Extend the image to the last allocated sector. |
118 | + header.size = be64_to_cpu(header.size); | 69 | */ |
119 | + header.cluster_bits = be32_to_cpu(header.cluster_bits); | 70 | - file_length = bdrv_getlength(s->data_file->bs); |
120 | + header.crypt_method = be32_to_cpu(header.crypt_method); | 71 | + file_length = bdrv_co_getlength(s->data_file->bs); |
121 | + header.l1_table_offset = be64_to_cpu(header.l1_table_offset); | 72 | if (file_length < 0) { |
122 | + header.l1_size = be32_to_cpu(header.l1_size); | 73 | error_setg_errno(errp, -file_length, "Could not get file size"); |
123 | + header.refcount_table_offset = be64_to_cpu(header.refcount_table_offset); | 74 | ret = file_length; |
124 | + header.refcount_table_clusters = | 75 | @@ -XXX,XX +XXX,XX @@ qcow2_co_copy_range_from(BlockDriverState *bs, |
125 | + be32_to_cpu(header.refcount_table_clusters); | 76 | case QCOW2_SUBCLUSTER_UNALLOCATED_PLAIN: |
126 | + header.snapshots_offset = be64_to_cpu(header.snapshots_offset); | 77 | case QCOW2_SUBCLUSTER_UNALLOCATED_ALLOC: |
127 | + header.nb_snapshots = be32_to_cpu(header.nb_snapshots); | 78 | if (bs->backing && bs->backing->bs) { |
128 | 79 | - int64_t backing_length = bdrv_getlength(bs->backing->bs); | |
129 | if (header.magic != QCOW_MAGIC) { | 80 | + int64_t backing_length = bdrv_co_getlength(bs->backing->bs); |
130 | error_setg(errp, "Image is not in qcow2 format"); | 81 | if (src_offset >= backing_length) { |
131 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, | 82 | cur_write_flags |= BDRV_REQ_ZERO_WRITE; |
132 | header.refcount_order = 4; | 83 | } else { |
133 | header.header_length = 72; | 84 | @@ -XXX,XX +XXX,XX @@ qcow2_co_truncate(BlockDriverState *bs, int64_t offset, bool exact, |
134 | } else { | ||
135 | - be64_to_cpus(&header.incompatible_features); | ||
136 | - be64_to_cpus(&header.compatible_features); | ||
137 | - be64_to_cpus(&header.autoclear_features); | ||
138 | - be32_to_cpus(&header.refcount_order); | ||
139 | - be32_to_cpus(&header.header_length); | ||
140 | + header.incompatible_features = | ||
141 | + be64_to_cpu(header.incompatible_features); | ||
142 | + header.compatible_features = be64_to_cpu(header.compatible_features); | ||
143 | + header.autoclear_features = be64_to_cpu(header.autoclear_features); | ||
144 | + header.refcount_order = be32_to_cpu(header.refcount_order); | ||
145 | + header.header_length = be32_to_cpu(header.header_length); | ||
146 | |||
147 | if (header.header_length < 104) { | ||
148 | error_setg(errp, "qcow2 header too short"); | ||
149 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, | ||
150 | goto fail; | 85 | goto fail; |
151 | } | 86 | } |
152 | for(i = 0;i < s->l1_size; i++) { | 87 | |
153 | - be64_to_cpus(&s->l1_table[i]); | 88 | - old_file_size = bdrv_getlength(bs->file->bs); |
154 | + s->l1_table[i] = be64_to_cpu(s->l1_table[i]); | 89 | + old_file_size = bdrv_co_getlength(bs->file->bs); |
90 | if (old_file_size < 0) { | ||
91 | error_setg_errno(errp, -old_file_size, | ||
92 | "Failed to inquire current file length"); | ||
93 | @@ -XXX,XX +XXX,XX @@ qcow2_co_truncate(BlockDriverState *bs, int64_t offset, bool exact, | ||
94 | break; | ||
155 | } | 95 | } |
156 | } | 96 | |
157 | 97 | - old_file_size = bdrv_getlength(bs->file->bs); | |
158 | @@ -XXX,XX +XXX,XX @@ int qcow2_update_header(BlockDriverState *bs) | 98 | + old_file_size = bdrv_co_getlength(bs->file->bs); |
159 | 99 | if (old_file_size < 0) { | |
160 | /* Full disk encryption header pointer extension */ | 100 | error_setg_errno(errp, -old_file_size, |
161 | if (s->crypto_header.offset != 0) { | 101 | "Failed to inquire current file length"); |
162 | - cpu_to_be64s(&s->crypto_header.offset); | 102 | @@ -XXX,XX +XXX,XX @@ qcow2_co_pwritev_compressed_part(BlockDriverState *bs, |
163 | - cpu_to_be64s(&s->crypto_header.length); | 103 | * align end of file to a sector boundary to ease reading with |
164 | + s->crypto_header.offset = cpu_to_be64(s->crypto_header.offset); | 104 | * sector based I/Os |
165 | + s->crypto_header.length = cpu_to_be64(s->crypto_header.length); | 105 | */ |
166 | ret = header_ext_add(buf, QCOW2_EXT_MAGIC_CRYPTO_HEADER, | 106 | - int64_t len = bdrv_getlength(bs->file->bs); |
167 | &s->crypto_header, sizeof(s->crypto_header), | 107 | + int64_t len = bdrv_co_getlength(bs->file->bs); |
168 | buflen); | 108 | if (len < 0) { |
169 | - be64_to_cpus(&s->crypto_header.offset); | 109 | return len; |
170 | - be64_to_cpus(&s->crypto_header.length); | ||
171 | + s->crypto_header.offset = be64_to_cpu(s->crypto_header.offset); | ||
172 | + s->crypto_header.length = be64_to_cpu(s->crypto_header.length); | ||
173 | if (ret < 0) { | ||
174 | goto fail; | ||
175 | } | 110 | } |
176 | -- | 111 | -- |
177 | 2.19.1 | 112 | 2.40.1 |
178 | |||
179 | diff view generated by jsdifflib |
1 | From: Alberto Garcia <berto@igalia.com> | 1 | Migration code can call bdrv_activate() in coroutine context, whereas |
---|---|---|---|
2 | other callers call it outside of coroutines. As it calls other code that | ||
3 | is not supposed to run in coroutines, standardise on running outside of | ||
4 | coroutines. | ||
2 | 5 | ||
3 | The blkverify mode of Quorum only works when the number of children is | 6 | This adds a no_co_wrapper to switch to the main loop before calling |
4 | exactly two, so any attempt to add a new one must return an error. | 7 | bdrv_activate(). |
5 | 8 | ||
6 | quorum_del_child() on the other hand doesn't need any additional check | 9 | Cc: qemu-stable@nongnu.org |
7 | because decreasing the number of children would make it go under the | 10 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
8 | vote threshold. | 11 | Reviewed-by: Eric Blake <eblake@redhat.com> |
9 | 12 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | |
10 | Signed-off-by: Alberto Garcia <berto@igalia.com> | 13 | Message-Id: <20230504115750.54437-3-kwolf@redhat.com> |
11 | Reported-by: Kevin Wolf <kwolf@redhat.com> | ||
12 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 14 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
13 | --- | 15 | --- |
14 | block/quorum.c | 8 ++++++++ | 16 | include/block/block-global-state.h | 6 +++++- |
15 | 1 file changed, 8 insertions(+) | 17 | block/block-backend.c | 10 +++++++++- |
18 | 2 files changed, 14 insertions(+), 2 deletions(-) | ||
16 | 19 | ||
17 | diff --git a/block/quorum.c b/block/quorum.c | 20 | diff --git a/include/block/block-global-state.h b/include/block/block-global-state.h |
18 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/block/quorum.c | 22 | --- a/include/block/block-global-state.h |
20 | +++ b/block/quorum.c | 23 | +++ b/include/block/block-global-state.h |
21 | @@ -XXX,XX +XXX,XX @@ static void quorum_add_child(BlockDriverState *bs, BlockDriverState *child_bs, | 24 | @@ -XXX,XX +XXX,XX @@ int bdrv_amend_options(BlockDriverState *bs_new, QemuOpts *opts, |
22 | char indexstr[32]; | 25 | BlockDriverState *check_to_replace_node(BlockDriverState *parent_bs, |
23 | int ret; | 26 | const char *node_name, Error **errp); |
24 | 27 | ||
25 | + if (s->is_blkverify) { | 28 | -int bdrv_activate(BlockDriverState *bs, Error **errp); |
26 | + error_setg(errp, "Cannot add a child to a quorum in blkverify mode"); | 29 | +int no_coroutine_fn bdrv_activate(BlockDriverState *bs, Error **errp); |
27 | + return; | ||
28 | + } | ||
29 | + | 30 | + |
30 | assert(s->num_children <= INT_MAX / sizeof(BdrvChild *)); | 31 | +int coroutine_fn no_co_wrapper |
31 | if (s->num_children == INT_MAX / sizeof(BdrvChild *) || | 32 | +bdrv_co_activate(BlockDriverState *bs, Error **errp); |
32 | s->next_child_index == UINT_MAX) { | 33 | + |
33 | @@ -XXX,XX +XXX,XX @@ static void quorum_del_child(BlockDriverState *bs, BdrvChild *child, | 34 | void bdrv_activate_all(Error **errp); |
35 | int bdrv_inactivate_all(void); | ||
36 | |||
37 | diff --git a/block/block-backend.c b/block/block-backend.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/block/block-backend.c | ||
40 | +++ b/block/block-backend.c | ||
41 | @@ -XXX,XX +XXX,XX @@ void blk_activate(BlockBackend *blk, Error **errp) | ||
34 | return; | 42 | return; |
35 | } | 43 | } |
36 | 44 | ||
37 | + /* We know now that num_children > threshold, so blkverify must be false */ | 45 | - bdrv_activate(bs, errp); |
38 | + assert(!s->is_blkverify); | 46 | + /* |
39 | + | 47 | + * Migration code can call this function in coroutine context, so leave |
40 | bdrv_drained_begin(bs); | 48 | + * coroutine context if necessary. |
41 | 49 | + */ | |
42 | /* We can safely remove this child now */ | 50 | + if (qemu_in_coroutine()) { |
51 | + bdrv_co_activate(bs, errp); | ||
52 | + } else { | ||
53 | + bdrv_activate(bs, errp); | ||
54 | + } | ||
55 | } | ||
56 | |||
57 | bool coroutine_fn blk_co_is_inserted(BlockBackend *blk) | ||
43 | -- | 58 | -- |
44 | 2.19.1 | 59 | 2.40.1 |
45 | |||
46 | diff view generated by jsdifflib |
1 | From: Alberto Garcia <berto@igalia.com> | 1 | These functions must not be called in coroutine context, because they |
---|---|---|---|
2 | need write access to the graph. | ||
2 | 3 | ||
3 | This doesn't have any practical effect at the moment because the | 4 | Cc: qemu-stable@nongnu.org |
4 | values of BDRV_SECTOR_SIZE, QCRYPTO_BLOCK_LUKS_SECTOR_SIZE and | 5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
5 | QCRYPTO_BLOCK_QCOW_SECTOR_SIZE are all the same (512 bytes), but | 6 | Reviewed-by: Eric Blake <eblake@redhat.com> |
6 | future encryption methods could have different requirements. | 7 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> |
7 | 8 | Message-Id: <20230504115750.54437-4-kwolf@redhat.com> | |
8 | Signed-off-by: Alberto Garcia <berto@igalia.com> | ||
9 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
10 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
11 | --- | 10 | --- |
12 | block/qcow2.c | 2 +- | 11 | include/block/block-global-state.h | 3 ++- |
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | 12 | include/sysemu/block-backend-global-state.h | 5 ++++- |
13 | block.c | 2 +- | ||
14 | block/crypto.c | 6 +++--- | ||
15 | block/parallels.c | 6 +++--- | ||
16 | block/qcow.c | 6 +++--- | ||
17 | block/qcow2.c | 14 +++++++------- | ||
18 | block/qed.c | 6 +++--- | ||
19 | block/vdi.c | 6 +++--- | ||
20 | block/vhdx.c | 6 +++--- | ||
21 | block/vmdk.c | 18 +++++++++--------- | ||
22 | block/vpc.c | 6 +++--- | ||
23 | 12 files changed, 44 insertions(+), 40 deletions(-) | ||
14 | 24 | ||
25 | diff --git a/include/block/block-global-state.h b/include/block/block-global-state.h | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/include/block/block-global-state.h | ||
28 | +++ b/include/block/block-global-state.h | ||
29 | @@ -XXX,XX +XXX,XX @@ void bdrv_img_create(const char *filename, const char *fmt, | ||
30 | bool quiet, Error **errp); | ||
31 | |||
32 | void bdrv_ref(BlockDriverState *bs); | ||
33 | -void bdrv_unref(BlockDriverState *bs); | ||
34 | +void no_coroutine_fn bdrv_unref(BlockDriverState *bs); | ||
35 | +void coroutine_fn no_co_wrapper bdrv_co_unref(BlockDriverState *bs); | ||
36 | void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child); | ||
37 | BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs, | ||
38 | BlockDriverState *child_bs, | ||
39 | diff --git a/include/sysemu/block-backend-global-state.h b/include/sysemu/block-backend-global-state.h | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/include/sysemu/block-backend-global-state.h | ||
42 | +++ b/include/sysemu/block-backend-global-state.h | ||
43 | @@ -XXX,XX +XXX,XX @@ blk_co_new_open(const char *filename, const char *reference, QDict *options, | ||
44 | |||
45 | int blk_get_refcnt(BlockBackend *blk); | ||
46 | void blk_ref(BlockBackend *blk); | ||
47 | -void blk_unref(BlockBackend *blk); | ||
48 | + | ||
49 | +void no_coroutine_fn blk_unref(BlockBackend *blk); | ||
50 | +void coroutine_fn no_co_wrapper blk_co_unref(BlockBackend *blk); | ||
51 | + | ||
52 | void blk_remove_all_bs(void); | ||
53 | BlockBackend *blk_by_name(const char *name); | ||
54 | BlockBackend *blk_next(BlockBackend *blk); | ||
55 | diff --git a/block.c b/block.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/block.c | ||
58 | +++ b/block.c | ||
59 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_create_opts_simple(BlockDriver *drv, | ||
60 | |||
61 | ret = 0; | ||
62 | out: | ||
63 | - blk_unref(blk); | ||
64 | + blk_co_unref(blk); | ||
65 | return ret; | ||
66 | } | ||
67 | |||
68 | diff --git a/block/crypto.c b/block/crypto.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/block/crypto.c | ||
71 | +++ b/block/crypto.c | ||
72 | @@ -XXX,XX +XXX,XX @@ block_crypto_co_create_generic(BlockDriverState *bs, int64_t size, | ||
73 | ret = 0; | ||
74 | cleanup: | ||
75 | qcrypto_block_free(crypto); | ||
76 | - blk_unref(blk); | ||
77 | + blk_co_unref(blk); | ||
78 | return ret; | ||
79 | } | ||
80 | |||
81 | @@ -XXX,XX +XXX,XX @@ block_crypto_co_create_luks(BlockdevCreateOptions *create_options, Error **errp) | ||
82 | |||
83 | ret = 0; | ||
84 | fail: | ||
85 | - bdrv_unref(bs); | ||
86 | + bdrv_co_unref(bs); | ||
87 | return ret; | ||
88 | } | ||
89 | |||
90 | @@ -XXX,XX +XXX,XX @@ fail: | ||
91 | bdrv_co_delete_file_noerr(bs); | ||
92 | } | ||
93 | |||
94 | - bdrv_unref(bs); | ||
95 | + bdrv_co_unref(bs); | ||
96 | qapi_free_QCryptoBlockCreateOptions(create_opts); | ||
97 | qobject_unref(cryptoopts); | ||
98 | return ret; | ||
99 | diff --git a/block/parallels.c b/block/parallels.c | ||
100 | index XXXXXXX..XXXXXXX 100644 | ||
101 | --- a/block/parallels.c | ||
102 | +++ b/block/parallels.c | ||
103 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn parallels_co_create(BlockdevCreateOptions* opts, | ||
104 | |||
105 | ret = 0; | ||
106 | out: | ||
107 | - blk_unref(blk); | ||
108 | - bdrv_unref(bs); | ||
109 | + blk_co_unref(blk); | ||
110 | + bdrv_co_unref(bs); | ||
111 | return ret; | ||
112 | |||
113 | exit: | ||
114 | @@ -XXX,XX +XXX,XX @@ parallels_co_create_opts(BlockDriver *drv, const char *filename, | ||
115 | |||
116 | done: | ||
117 | qobject_unref(qdict); | ||
118 | - bdrv_unref(bs); | ||
119 | + bdrv_co_unref(bs); | ||
120 | qapi_free_BlockdevCreateOptions(create_options); | ||
121 | return ret; | ||
122 | } | ||
123 | diff --git a/block/qcow.c b/block/qcow.c | ||
124 | index XXXXXXX..XXXXXXX 100644 | ||
125 | --- a/block/qcow.c | ||
126 | +++ b/block/qcow.c | ||
127 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow_co_create(BlockdevCreateOptions *opts, | ||
128 | g_free(tmp); | ||
129 | ret = 0; | ||
130 | exit: | ||
131 | - blk_unref(qcow_blk); | ||
132 | - bdrv_unref(bs); | ||
133 | + blk_co_unref(qcow_blk); | ||
134 | + bdrv_co_unref(bs); | ||
135 | qcrypto_block_free(crypto); | ||
136 | return ret; | ||
137 | } | ||
138 | @@ -XXX,XX +XXX,XX @@ qcow_co_create_opts(BlockDriver *drv, const char *filename, | ||
139 | fail: | ||
140 | g_free(backing_fmt); | ||
141 | qobject_unref(qdict); | ||
142 | - bdrv_unref(bs); | ||
143 | + bdrv_co_unref(bs); | ||
144 | qapi_free_BlockdevCreateOptions(create_options); | ||
145 | return ret; | ||
146 | } | ||
15 | diff --git a/block/qcow2.c b/block/qcow2.c | 147 | diff --git a/block/qcow2.c b/block/qcow2.c |
16 | index XXXXXXX..XXXXXXX 100644 | 148 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/block/qcow2.c | 149 | --- a/block/qcow2.c |
18 | +++ b/block/qcow2.c | 150 | +++ b/block/qcow2.c |
19 | @@ -XXX,XX +XXX,XX @@ static void qcow2_refresh_limits(BlockDriverState *bs, Error **errp) | 151 | @@ -XXX,XX +XXX,XX @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp) |
20 | 152 | goto out; | |
21 | if (bs->encrypted) { | 153 | } |
22 | /* Encryption works on a sector granularity */ | 154 | |
23 | - bs->bl.request_alignment = BDRV_SECTOR_SIZE; | 155 | - blk_unref(blk); |
24 | + bs->bl.request_alignment = qcrypto_block_get_sector_size(s->crypto); | 156 | + blk_co_unref(blk); |
25 | } | 157 | blk = NULL; |
26 | bs->bl.pwrite_zeroes_alignment = s->cluster_size; | 158 | |
27 | bs->bl.pdiscard_alignment = s->cluster_size; | 159 | /* |
160 | @@ -XXX,XX +XXX,XX @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp) | ||
161 | } | ||
162 | } | ||
163 | |||
164 | - blk_unref(blk); | ||
165 | + blk_co_unref(blk); | ||
166 | blk = NULL; | ||
167 | |||
168 | /* Reopen the image without BDRV_O_NO_FLUSH to flush it before returning. | ||
169 | @@ -XXX,XX +XXX,XX @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp) | ||
170 | |||
171 | ret = 0; | ||
172 | out: | ||
173 | - blk_unref(blk); | ||
174 | - bdrv_unref(bs); | ||
175 | - bdrv_unref(data_bs); | ||
176 | + blk_co_unref(blk); | ||
177 | + bdrv_co_unref(bs); | ||
178 | + bdrv_co_unref(data_bs); | ||
179 | return ret; | ||
180 | } | ||
181 | |||
182 | @@ -XXX,XX +XXX,XX @@ finish: | ||
183 | } | ||
184 | |||
185 | qobject_unref(qdict); | ||
186 | - bdrv_unref(bs); | ||
187 | - bdrv_unref(data_bs); | ||
188 | + bdrv_co_unref(bs); | ||
189 | + bdrv_co_unref(data_bs); | ||
190 | qapi_free_BlockdevCreateOptions(create_options); | ||
191 | return ret; | ||
192 | } | ||
193 | diff --git a/block/qed.c b/block/qed.c | ||
194 | index XXXXXXX..XXXXXXX 100644 | ||
195 | --- a/block/qed.c | ||
196 | +++ b/block/qed.c | ||
197 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_qed_co_create(BlockdevCreateOptions *opts, | ||
198 | ret = 0; /* success */ | ||
199 | out: | ||
200 | g_free(l1_table); | ||
201 | - blk_unref(blk); | ||
202 | - bdrv_unref(bs); | ||
203 | + blk_co_unref(blk); | ||
204 | + bdrv_co_unref(bs); | ||
205 | return ret; | ||
206 | } | ||
207 | |||
208 | @@ -XXX,XX +XXX,XX @@ bdrv_qed_co_create_opts(BlockDriver *drv, const char *filename, | ||
209 | |||
210 | fail: | ||
211 | qobject_unref(qdict); | ||
212 | - bdrv_unref(bs); | ||
213 | + bdrv_co_unref(bs); | ||
214 | qapi_free_BlockdevCreateOptions(create_options); | ||
215 | return ret; | ||
216 | } | ||
217 | diff --git a/block/vdi.c b/block/vdi.c | ||
218 | index XXXXXXX..XXXXXXX 100644 | ||
219 | --- a/block/vdi.c | ||
220 | +++ b/block/vdi.c | ||
221 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn vdi_co_do_create(BlockdevCreateOptions *create_options, | ||
222 | |||
223 | ret = 0; | ||
224 | exit: | ||
225 | - blk_unref(blk); | ||
226 | - bdrv_unref(bs_file); | ||
227 | + blk_co_unref(blk); | ||
228 | + bdrv_co_unref(bs_file); | ||
229 | g_free(bmap); | ||
230 | return ret; | ||
231 | } | ||
232 | @@ -XXX,XX +XXX,XX @@ vdi_co_create_opts(BlockDriver *drv, const char *filename, | ||
233 | done: | ||
234 | qobject_unref(qdict); | ||
235 | qapi_free_BlockdevCreateOptions(create_options); | ||
236 | - bdrv_unref(bs_file); | ||
237 | + bdrv_co_unref(bs_file); | ||
238 | return ret; | ||
239 | } | ||
240 | |||
241 | diff --git a/block/vhdx.c b/block/vhdx.c | ||
242 | index XXXXXXX..XXXXXXX 100644 | ||
243 | --- a/block/vhdx.c | ||
244 | +++ b/block/vhdx.c | ||
245 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn vhdx_co_create(BlockdevCreateOptions *opts, | ||
246 | |||
247 | ret = 0; | ||
248 | delete_and_exit: | ||
249 | - blk_unref(blk); | ||
250 | - bdrv_unref(bs); | ||
251 | + blk_co_unref(blk); | ||
252 | + bdrv_co_unref(bs); | ||
253 | g_free(creator); | ||
254 | return ret; | ||
255 | } | ||
256 | @@ -XXX,XX +XXX,XX @@ vhdx_co_create_opts(BlockDriver *drv, const char *filename, | ||
257 | |||
258 | fail: | ||
259 | qobject_unref(qdict); | ||
260 | - bdrv_unref(bs); | ||
261 | + bdrv_co_unref(bs); | ||
262 | qapi_free_BlockdevCreateOptions(create_options); | ||
263 | return ret; | ||
264 | } | ||
265 | diff --git a/block/vmdk.c b/block/vmdk.c | ||
266 | index XXXXXXX..XXXXXXX 100644 | ||
267 | --- a/block/vmdk.c | ||
268 | +++ b/block/vmdk.c | ||
269 | @@ -XXX,XX +XXX,XX @@ exit: | ||
270 | if (pbb) { | ||
271 | *pbb = blk; | ||
272 | } else { | ||
273 | - blk_unref(blk); | ||
274 | + blk_co_unref(blk); | ||
275 | blk = NULL; | ||
276 | } | ||
277 | } | ||
278 | @@ -XXX,XX +XXX,XX @@ vmdk_co_do_create(int64_t size, | ||
279 | if (strcmp(blk_bs(backing)->drv->format_name, "vmdk")) { | ||
280 | error_setg(errp, "Invalid backing file format: %s. Must be vmdk", | ||
281 | blk_bs(backing)->drv->format_name); | ||
282 | - blk_unref(backing); | ||
283 | + blk_co_unref(backing); | ||
284 | ret = -EINVAL; | ||
285 | goto exit; | ||
286 | } | ||
287 | ret = vmdk_read_cid(blk_bs(backing), 0, &parent_cid); | ||
288 | - blk_unref(backing); | ||
289 | + blk_co_unref(backing); | ||
290 | if (ret) { | ||
291 | error_setg(errp, "Failed to read parent CID"); | ||
292 | goto exit; | ||
293 | @@ -XXX,XX +XXX,XX @@ vmdk_co_do_create(int64_t size, | ||
294 | blk_bs(extent_blk)->filename); | ||
295 | created_size += cur_size; | ||
296 | extent_idx++; | ||
297 | - blk_unref(extent_blk); | ||
298 | + blk_co_unref(extent_blk); | ||
299 | } | ||
300 | |||
301 | /* Check whether we got excess extents */ | ||
302 | extent_blk = extent_fn(-1, extent_idx, flat, split, compress, zeroed_grain, | ||
303 | opaque, NULL); | ||
304 | if (extent_blk) { | ||
305 | - blk_unref(extent_blk); | ||
306 | + blk_co_unref(extent_blk); | ||
307 | error_setg(errp, "List of extents contains unused extents"); | ||
308 | ret = -EINVAL; | ||
309 | goto exit; | ||
310 | @@ -XXX,XX +XXX,XX @@ vmdk_co_do_create(int64_t size, | ||
311 | ret = 0; | ||
312 | exit: | ||
313 | if (blk) { | ||
314 | - blk_unref(blk); | ||
315 | + blk_co_unref(blk); | ||
316 | } | ||
317 | g_free(desc); | ||
318 | g_free(parent_desc_line); | ||
319 | @@ -XXX,XX +XXX,XX @@ vmdk_co_create_opts_cb(int64_t size, int idx, bool flat, bool split, | ||
320 | errp)) { | ||
321 | goto exit; | ||
322 | } | ||
323 | - bdrv_unref(bs); | ||
324 | + bdrv_co_unref(bs); | ||
325 | exit: | ||
326 | g_free(ext_filename); | ||
327 | return blk; | ||
328 | @@ -XXX,XX +XXX,XX @@ static BlockBackend * coroutine_fn vmdk_co_create_cb(int64_t size, int idx, | ||
329 | return NULL; | ||
330 | } | ||
331 | blk_set_allow_write_beyond_eof(blk, true); | ||
332 | - bdrv_unref(bs); | ||
333 | + bdrv_co_unref(bs); | ||
334 | |||
335 | if (size != -1) { | ||
336 | ret = vmdk_init_extent(blk, size, flat, compress, zeroed_grain, errp); | ||
337 | if (ret) { | ||
338 | - blk_unref(blk); | ||
339 | + blk_co_unref(blk); | ||
340 | blk = NULL; | ||
341 | } | ||
342 | } | ||
343 | diff --git a/block/vpc.c b/block/vpc.c | ||
344 | index XXXXXXX..XXXXXXX 100644 | ||
345 | --- a/block/vpc.c | ||
346 | +++ b/block/vpc.c | ||
347 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn vpc_co_create(BlockdevCreateOptions *opts, | ||
348 | } | ||
349 | |||
350 | out: | ||
351 | - blk_unref(blk); | ||
352 | - bdrv_unref(bs); | ||
353 | + blk_co_unref(blk); | ||
354 | + bdrv_co_unref(bs); | ||
355 | return ret; | ||
356 | } | ||
357 | |||
358 | @@ -XXX,XX +XXX,XX @@ vpc_co_create_opts(BlockDriver *drv, const char *filename, | ||
359 | |||
360 | fail: | ||
361 | qobject_unref(qdict); | ||
362 | - bdrv_unref(bs); | ||
363 | + bdrv_co_unref(bs); | ||
364 | qapi_free_BlockdevCreateOptions(create_options); | ||
365 | return ret; | ||
366 | } | ||
28 | -- | 367 | -- |
29 | 2.19.1 | 368 | 2.40.1 |
30 | |||
31 | diff view generated by jsdifflib |
1 | While we want machine interfaces like -blockdev and QMP blockdev-add to | 1 | This QMP handler runs in a coroutine, so it must use the corresponding |
---|---|---|---|
2 | add as little auto-detection as possible so that management tools are | 2 | no_co_wrappers instead. |
3 | explicit about their needs, -drive is a convenience option for human | ||
4 | users. Enabling auto-read-only=on by default there enables users to use | ||
5 | read-only images for read-only guest devices without having to specify | ||
6 | read-only=on explicitly. If they try to attach the image to a read-write | ||
7 | device, they will still get an error message. | ||
8 | 3 | ||
4 | Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2185688 | ||
5 | Cc: qemu-stable@nongnu.org | ||
9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 6 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
10 | Reviewed-by: Eric Blake <eblake@redhat.com> | 7 | Reviewed-by: Eric Blake <eblake@redhat.com> |
8 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
9 | Message-Id: <20230504115750.54437-5-kwolf@redhat.com> | ||
10 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
11 | --- | 11 | --- |
12 | blockdev.c | 1 + | 12 | blockdev.c | 4 ++-- |
13 | 1 file changed, 1 insertion(+) | 13 | 1 file changed, 2 insertions(+), 2 deletions(-) |
14 | 14 | ||
15 | diff --git a/blockdev.c b/blockdev.c | 15 | diff --git a/blockdev.c b/blockdev.c |
16 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/blockdev.c | 17 | --- a/blockdev.c |
18 | +++ b/blockdev.c | 18 | +++ b/blockdev.c |
19 | @@ -XXX,XX +XXX,XX @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts, | 19 | @@ -XXX,XX +XXX,XX @@ void coroutine_fn qmp_block_resize(const char *device, const char *node_name, |
20 | qdict_set_default_str(bs_opts, BDRV_OPT_CACHE_NO_FLUSH, "off"); | 20 | return; |
21 | qdict_set_default_str(bs_opts, BDRV_OPT_READ_ONLY, | 21 | } |
22 | read_only ? "on" : "off"); | 22 | |
23 | + qdict_set_default_str(bs_opts, BDRV_OPT_AUTO_READ_ONLY, "on"); | 23 | - blk = blk_new_with_bs(bs, BLK_PERM_RESIZE, BLK_PERM_ALL, errp); |
24 | assert((bdrv_flags & BDRV_O_CACHE_MASK) == 0); | 24 | + blk = blk_co_new_with_bs(bs, BLK_PERM_RESIZE, BLK_PERM_ALL, errp); |
25 | 25 | if (!blk) { | |
26 | if (runstate_check(RUN_STATE_INMIGRATE)) { | 26 | return; |
27 | } | ||
28 | @@ -XXX,XX +XXX,XX @@ void coroutine_fn qmp_block_resize(const char *device, const char *node_name, | ||
29 | |||
30 | bdrv_co_lock(bs); | ||
31 | bdrv_drained_end(bs); | ||
32 | - blk_unref(blk); | ||
33 | + blk_co_unref(blk); | ||
34 | bdrv_co_unlock(bs); | ||
35 | } | ||
36 | |||
27 | -- | 37 | -- |
28 | 2.19.1 | 38 | 2.40.1 |
29 | |||
30 | diff view generated by jsdifflib |
1 | This tests that trying to resize an image with QMP block_resize doesn't | ||
---|---|---|---|
2 | hang or otherwise fail when the image is attached to a device running in | ||
3 | an iothread. | ||
4 | |||
5 | This is a regression test for the recent fix that changed | ||
6 | qmp_block_resize, which is a coroutine based QMP handler, to avoid | ||
7 | calling no_coroutine_fns directly. | ||
8 | |||
1 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
10 | Message-Id: <20230509134133.373408-1-kwolf@redhat.com> | ||
2 | Reviewed-by: Eric Blake <eblake@redhat.com> | 11 | Reviewed-by: Eric Blake <eblake@redhat.com> |
12 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
3 | --- | 13 | --- |
4 | tests/qemu-iotests/232 | 147 +++++++++++++++++++++++++++++++++++++ | 14 | tests/qemu-iotests/tests/iothreads-resize | 71 +++++++++++++++++++ |
5 | tests/qemu-iotests/232.out | 59 +++++++++++++++ | 15 | tests/qemu-iotests/tests/iothreads-resize.out | 11 +++ |
6 | tests/qemu-iotests/group | 1 + | 16 | 2 files changed, 82 insertions(+) |
7 | 3 files changed, 207 insertions(+) | 17 | create mode 100755 tests/qemu-iotests/tests/iothreads-resize |
8 | create mode 100755 tests/qemu-iotests/232 | 18 | create mode 100644 tests/qemu-iotests/tests/iothreads-resize.out |
9 | create mode 100644 tests/qemu-iotests/232.out | ||
10 | 19 | ||
11 | diff --git a/tests/qemu-iotests/232 b/tests/qemu-iotests/232 | 20 | diff --git a/tests/qemu-iotests/tests/iothreads-resize b/tests/qemu-iotests/tests/iothreads-resize |
12 | new file mode 100755 | 21 | new file mode 100755 |
13 | index XXXXXXX..XXXXXXX | 22 | index XXXXXXX..XXXXXXX |
14 | --- /dev/null | 23 | --- /dev/null |
15 | +++ b/tests/qemu-iotests/232 | 24 | +++ b/tests/qemu-iotests/tests/iothreads-resize |
16 | @@ -XXX,XX +XXX,XX @@ | 25 | @@ -XXX,XX +XXX,XX @@ |
17 | +#!/bin/bash | 26 | +#!/usr/bin/env bash |
27 | +# group: rw auto quick | ||
18 | +# | 28 | +# |
19 | +# Test for auto-read-only | 29 | +# Test resizing an image that is attached to a separate iothread |
20 | +# | 30 | +# |
21 | +# Copyright (C) 2018 Red Hat, Inc. | 31 | +# Copyright (C) 2023 Red Hat, Inc. |
22 | +# | 32 | +# |
23 | +# This program is free software; you can redistribute it and/or modify | 33 | +# This program is free software; you can redistribute it and/or modify |
24 | +# it under the terms of the GNU General Public License as published by | 34 | +# it under the terms of the GNU General Public License as published by |
25 | +# the Free Software Foundation; either version 2 of the License, or | 35 | +# the Free Software Foundation; either version 2 of the License, or |
26 | +# (at your option) any later version. | 36 | +# (at your option) any later version. |
... | ... | ||
38 | +owner=kwolf@redhat.com | 48 | +owner=kwolf@redhat.com |
39 | + | 49 | + |
40 | +seq=`basename $0` | 50 | +seq=`basename $0` |
41 | +echo "QA output created by $seq" | 51 | +echo "QA output created by $seq" |
42 | + | 52 | + |
43 | +here=`pwd` | 53 | +status=1 # failure is the default! |
44 | +status=1 # failure is the default! | ||
45 | + | 54 | + |
46 | +_cleanup() | 55 | +_cleanup() |
47 | +{ | 56 | +{ |
48 | + _cleanup_test_img | 57 | + _cleanup_test_img |
49 | + rm -f $TEST_IMG.snap | ||
50 | +} | 58 | +} |
51 | +trap "_cleanup; exit \$status" 0 1 2 3 15 | 59 | +trap "_cleanup; exit \$status" 0 1 2 3 15 |
52 | + | 60 | + |
53 | +# get standard environment, filters and checks | 61 | +# get standard environment, filters and checks |
62 | +cd .. | ||
54 | +. ./common.rc | 63 | +. ./common.rc |
55 | +. ./common.filter | 64 | +. ./common.filter |
56 | + | 65 | + |
57 | +_supported_fmt generic | 66 | +# Resizing images is only supported by a few block drivers |
67 | +_supported_fmt raw qcow2 qed | ||
58 | +_supported_proto file | 68 | +_supported_proto file |
59 | +_supported_os Linux | 69 | +_require_devices virtio-scsi-pci |
60 | + | 70 | + |
61 | +function do_run_qemu() | 71 | +size=64M |
62 | +{ | 72 | +_make_test_img $size |
63 | + echo Testing: "$@" | 73 | + |
64 | + ( | 74 | +qmp() { |
65 | + if ! test -t 0; then | 75 | +cat <<EOF |
66 | + while read cmd; do | 76 | +{"execute":"qmp_capabilities"} |
67 | + echo $cmd | 77 | +{'execute': 'block_resize', |
68 | + done | 78 | + 'arguments': {'node-name': 'img', 'size': 134217728}} |
69 | + fi | 79 | +{"execute":"quit"} |
70 | + echo quit | 80 | +EOF |
71 | + ) | $QEMU -nographic -monitor stdio -nodefaults "$@" | ||
72 | + echo | ||
73 | +} | 81 | +} |
74 | + | 82 | + |
75 | +function run_qemu() | 83 | +qmp | $QEMU -S -display none \ |
76 | +{ | 84 | + -drive if=none,format=$IMGFMT,file="$TEST_IMG",node-name=img \ |
77 | + do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_hmp | | 85 | + -object iothread,id=t0 \ |
78 | + _filter_generated_node_ids | _filter_imgfmt | 86 | + -device virtio-scsi-pci,iothread=t0 \ |
79 | +} | 87 | + -device scsi-hd,drive=none0 \ |
88 | + -qmp stdio \ | ||
89 | + | _filter_qmp | ||
80 | + | 90 | + |
81 | +function run_qemu_info_block() | 91 | +_img_info | _filter_img_info |
82 | +{ | ||
83 | + echo "info block -n" | run_qemu "$@" | grep -e "(file" -e "QEMU_PROG" | ||
84 | +} | ||
85 | + | ||
86 | +size=128M | ||
87 | + | ||
88 | +_make_test_img $size | ||
89 | + | ||
90 | +echo | ||
91 | +echo "=== -drive with read-write image: read-only/auto-read-only combinations ===" | ||
92 | +echo | ||
93 | + | ||
94 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=off | ||
95 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=on | ||
96 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on | ||
97 | +echo | ||
98 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=off | ||
99 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=on | ||
100 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off | ||
101 | +echo | ||
102 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=off | ||
103 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=on | ||
104 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none | ||
105 | + | ||
106 | +echo | ||
107 | +echo "=== -drive with read-only image: read-only/auto-read-only combinations ===" | ||
108 | +echo | ||
109 | + | ||
110 | +chmod a-w $TEST_IMG | ||
111 | + | ||
112 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=off | ||
113 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=on | ||
114 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on | ||
115 | +echo | ||
116 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=off | ||
117 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=on | ||
118 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off | ||
119 | +echo | ||
120 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=off | ||
121 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=on | ||
122 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none | ||
123 | + | ||
124 | +echo | ||
125 | +echo "=== -blockdev with read-write image: read-only/auto-read-only combinations ===" | ||
126 | +echo | ||
127 | + | ||
128 | +chmod a+w $TEST_IMG | ||
129 | + | ||
130 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=off | ||
131 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=on | ||
132 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on | ||
133 | +echo | ||
134 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=off | ||
135 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=on | ||
136 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off | ||
137 | +echo | ||
138 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=off | ||
139 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=on | ||
140 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0 | ||
141 | + | ||
142 | +echo | ||
143 | +echo "=== -blockdev with read-only image: read-only/auto-read-only combinations ===" | ||
144 | +echo | ||
145 | + | ||
146 | +chmod a-w $TEST_IMG | ||
147 | + | ||
148 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=off | ||
149 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=on | ||
150 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on | ||
151 | +echo | ||
152 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=off | ||
153 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=on | ||
154 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off | ||
155 | +echo | ||
156 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=off | ||
157 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=on | ||
158 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0 | ||
159 | + | 92 | + |
160 | +# success, all done | 93 | +# success, all done |
161 | +echo "*** done" | 94 | +echo "*** done" |
162 | +rm -f $seq.full | 95 | +rm -f $seq.full |
163 | +status=0 | 96 | +status=0 |
164 | diff --git a/tests/qemu-iotests/232.out b/tests/qemu-iotests/232.out | 97 | diff --git a/tests/qemu-iotests/tests/iothreads-resize.out b/tests/qemu-iotests/tests/iothreads-resize.out |
165 | new file mode 100644 | 98 | new file mode 100644 |
166 | index XXXXXXX..XXXXXXX | 99 | index XXXXXXX..XXXXXXX |
167 | --- /dev/null | 100 | --- /dev/null |
168 | +++ b/tests/qemu-iotests/232.out | 101 | +++ b/tests/qemu-iotests/tests/iothreads-resize.out |
169 | @@ -XXX,XX +XXX,XX @@ | 102 | @@ -XXX,XX +XXX,XX @@ |
170 | +QA output created by 232 | 103 | +QA output created by iothreads-resize |
171 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | 104 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 |
172 | + | 105 | +QMP_VERSION |
173 | +=== -drive with read-write image: read-only/auto-read-only combinations === | 106 | +{"return": {}} |
174 | + | 107 | +{"return": {}} |
175 | +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) | 108 | +{"return": {}} |
176 | +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) | 109 | +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} |
177 | +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) | 110 | +image: TEST_DIR/t.IMGFMT |
178 | + | 111 | +file format: IMGFMT |
179 | +NODE_NAME: TEST_DIR/t.IMGFMT (file) | 112 | +virtual size: 128 MiB (134217728 bytes) |
180 | +NODE_NAME: TEST_DIR/t.IMGFMT (file) | ||
181 | +NODE_NAME: TEST_DIR/t.IMGFMT (file) | ||
182 | + | ||
183 | +NODE_NAME: TEST_DIR/t.IMGFMT (file) | ||
184 | +NODE_NAME: TEST_DIR/t.IMGFMT (file) | ||
185 | +NODE_NAME: TEST_DIR/t.IMGFMT (file) | ||
186 | + | ||
187 | +=== -drive with read-only image: read-only/auto-read-only combinations === | ||
188 | + | ||
189 | +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) | ||
190 | +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) | ||
191 | +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) | ||
192 | + | ||
193 | +QEMU_PROG: -drive driver=file,file=TEST_DIR/t.IMGFMT,if=none,read-only=off,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied | ||
194 | +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) | ||
195 | +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) | ||
196 | + | ||
197 | +QEMU_PROG: -drive driver=file,file=TEST_DIR/t.IMGFMT,if=none,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied | ||
198 | +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) | ||
199 | +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) | ||
200 | + | ||
201 | +=== -blockdev with read-write image: read-only/auto-read-only combinations === | ||
202 | + | ||
203 | +node0: TEST_DIR/t.IMGFMT (file, read-only) | ||
204 | +node0: TEST_DIR/t.IMGFMT (file, read-only) | ||
205 | +node0: TEST_DIR/t.IMGFMT (file, read-only) | ||
206 | + | ||
207 | +node0: TEST_DIR/t.IMGFMT (file) | ||
208 | +node0: TEST_DIR/t.IMGFMT (file) | ||
209 | +node0: TEST_DIR/t.IMGFMT (file) | ||
210 | + | ||
211 | +node0: TEST_DIR/t.IMGFMT (file) | ||
212 | +node0: TEST_DIR/t.IMGFMT (file) | ||
213 | +node0: TEST_DIR/t.IMGFMT (file) | ||
214 | + | ||
215 | +=== -blockdev with read-only image: read-only/auto-read-only combinations === | ||
216 | + | ||
217 | +node0: TEST_DIR/t.IMGFMT (file, read-only) | ||
218 | +node0: TEST_DIR/t.IMGFMT (file, read-only) | ||
219 | +node0: TEST_DIR/t.IMGFMT (file, read-only) | ||
220 | + | ||
221 | +QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0,read-only=off,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied | ||
222 | +node0: TEST_DIR/t.IMGFMT (file, read-only) | ||
223 | +QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0,read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied | ||
224 | + | ||
225 | +QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied | ||
226 | +node0: TEST_DIR/t.IMGFMT (file, read-only) | ||
227 | +QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0: Could not open 'TEST_DIR/t.IMGFMT': Permission denied | ||
228 | +*** done | 113 | +*** done |
229 | diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group | ||
230 | index XXXXXXX..XXXXXXX 100644 | ||
231 | --- a/tests/qemu-iotests/group | ||
232 | +++ b/tests/qemu-iotests/group | ||
233 | @@ -XXX,XX +XXX,XX @@ | ||
234 | 227 auto quick | ||
235 | 229 auto quick | ||
236 | 231 auto quick | ||
237 | +232 auto quick | ||
238 | -- | 114 | -- |
239 | 2.19.1 | 115 | 2.40.1 |
240 | |||
241 | diff view generated by jsdifflib |
1 | From: Li Qiang <liq3ea@163.com> | 1 | test-bdrv-drain contains a few test cases that are run both in coroutine |
---|---|---|---|
2 | and non-coroutine context. Running the entire code including the setup | ||
3 | and shutdown in coroutines is incorrect because graph modifications can | ||
4 | generally not happen in coroutines. | ||
2 | 5 | ||
3 | Signed-off-by: Li Qiang <liq3ea@163.com> | 6 | Change the test so that creating and destroying the test nodes and |
4 | Reviewed-by: Alberto Garcia <berto@igalia.com> | 7 | BlockBackends always happens outside of coroutine context. |
8 | |||
9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
10 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
11 | Message-Id: <20230504115750.54437-6-kwolf@redhat.com> | ||
12 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 13 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
6 | --- | 14 | --- |
7 | include/sysemu/block-backend.h | 6 +++--- | 15 | tests/unit/test-bdrv-drain.c | 112 +++++++++++++++++++++++------------ |
8 | block/block-backend.c | 8 ++++---- | 16 | 1 file changed, 75 insertions(+), 37 deletions(-) |
9 | 2 files changed, 7 insertions(+), 7 deletions(-) | ||
10 | 17 | ||
11 | diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h | 18 | diff --git a/tests/unit/test-bdrv-drain.c b/tests/unit/test-bdrv-drain.c |
12 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/include/sysemu/block-backend.h | 20 | --- a/tests/unit/test-bdrv-drain.c |
14 | +++ b/include/sysemu/block-backend.h | 21 | +++ b/tests/unit/test-bdrv-drain.c |
15 | @@ -XXX,XX +XXX,XX @@ BlockErrorAction blk_get_error_action(BlockBackend *blk, bool is_read, | 22 | @@ -XXX,XX +XXX,XX @@ static void do_drain_begin_unlocked(enum drain_type drain_type, BlockDriverState |
16 | int error); | ||
17 | void blk_error_action(BlockBackend *blk, BlockErrorAction action, | ||
18 | bool is_read, int error); | ||
19 | -int blk_is_read_only(BlockBackend *blk); | ||
20 | -int blk_is_sg(BlockBackend *blk); | ||
21 | -int blk_enable_write_cache(BlockBackend *blk); | ||
22 | +bool blk_is_read_only(BlockBackend *blk); | ||
23 | +bool blk_is_sg(BlockBackend *blk); | ||
24 | +bool blk_enable_write_cache(BlockBackend *blk); | ||
25 | void blk_set_enable_write_cache(BlockBackend *blk, bool wce); | ||
26 | void blk_invalidate_cache(BlockBackend *blk, Error **errp); | ||
27 | bool blk_is_inserted(BlockBackend *blk); | ||
28 | diff --git a/block/block-backend.c b/block/block-backend.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/block/block-backend.c | ||
31 | +++ b/block/block-backend.c | ||
32 | @@ -XXX,XX +XXX,XX @@ void blk_error_action(BlockBackend *blk, BlockErrorAction action, | ||
33 | } | 23 | } |
34 | } | 24 | } |
35 | 25 | ||
36 | -int blk_is_read_only(BlockBackend *blk) | 26 | +static BlockBackend * no_coroutine_fn test_setup(void) |
37 | +bool blk_is_read_only(BlockBackend *blk) | 27 | +{ |
38 | { | 28 | + BlockBackend *blk; |
39 | BlockDriverState *bs = blk_bs(blk); | 29 | + BlockDriverState *bs, *backing; |
40 | 30 | + | |
41 | @@ -XXX,XX +XXX,XX @@ int blk_is_read_only(BlockBackend *blk) | 31 | + blk = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL); |
32 | + bs = bdrv_new_open_driver(&bdrv_test, "test-node", BDRV_O_RDWR, | ||
33 | + &error_abort); | ||
34 | + blk_insert_bs(blk, bs, &error_abort); | ||
35 | + | ||
36 | + backing = bdrv_new_open_driver(&bdrv_test, "backing", 0, &error_abort); | ||
37 | + bdrv_set_backing_hd(bs, backing, &error_abort); | ||
38 | + | ||
39 | + bdrv_unref(backing); | ||
40 | + bdrv_unref(bs); | ||
41 | + | ||
42 | + return blk; | ||
43 | +} | ||
44 | + | ||
45 | static void do_drain_end_unlocked(enum drain_type drain_type, BlockDriverState *bs) | ||
46 | { | ||
47 | if (drain_type != BDRV_DRAIN_ALL) { | ||
48 | @@ -XXX,XX +XXX,XX @@ static void do_drain_end_unlocked(enum drain_type drain_type, BlockDriverState * | ||
42 | } | 49 | } |
43 | } | 50 | } |
44 | 51 | ||
45 | -int blk_is_sg(BlockBackend *blk) | 52 | -static void test_drv_cb_common(enum drain_type drain_type, bool recursive) |
46 | +bool blk_is_sg(BlockBackend *blk) | 53 | +static void test_drv_cb_common(BlockBackend *blk, enum drain_type drain_type, |
47 | { | 54 | + bool recursive) |
48 | BlockDriverState *bs = blk_bs(blk); | 55 | { |
49 | 56 | - BlockBackend *blk; | |
50 | if (!bs) { | 57 | - BlockDriverState *bs, *backing; |
51 | - return 0; | 58 | + BlockDriverState *bs = blk_bs(blk); |
52 | + return false; | 59 | + BlockDriverState *backing = bs->backing->bs; |
53 | } | 60 | BDRVTestState *s, *backing_s; |
54 | 61 | BlockAIOCB *acb; | |
55 | return bdrv_is_sg(bs); | 62 | int aio_ret; |
56 | } | 63 | |
57 | 64 | QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, NULL, 0); | |
58 | -int blk_enable_write_cache(BlockBackend *blk) | 65 | |
59 | +bool blk_enable_write_cache(BlockBackend *blk) | 66 | - blk = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL); |
60 | { | 67 | - bs = bdrv_new_open_driver(&bdrv_test, "test-node", BDRV_O_RDWR, |
61 | return blk->enable_write_cache; | 68 | - &error_abort); |
62 | } | 69 | s = bs->opaque; |
70 | - blk_insert_bs(blk, bs, &error_abort); | ||
71 | - | ||
72 | - backing = bdrv_new_open_driver(&bdrv_test, "backing", 0, &error_abort); | ||
73 | backing_s = backing->opaque; | ||
74 | - bdrv_set_backing_hd(bs, backing, &error_abort); | ||
75 | |||
76 | /* Simple bdrv_drain_all_begin/end pair, check that CBs are called */ | ||
77 | g_assert_cmpint(s->drain_count, ==, 0); | ||
78 | @@ -XXX,XX +XXX,XX @@ static void test_drv_cb_common(enum drain_type drain_type, bool recursive) | ||
79 | |||
80 | g_assert_cmpint(s->drain_count, ==, 0); | ||
81 | g_assert_cmpint(backing_s->drain_count, ==, 0); | ||
82 | - | ||
83 | - bdrv_unref(backing); | ||
84 | - bdrv_unref(bs); | ||
85 | - blk_unref(blk); | ||
86 | } | ||
87 | |||
88 | static void test_drv_cb_drain_all(void) | ||
89 | { | ||
90 | - test_drv_cb_common(BDRV_DRAIN_ALL, true); | ||
91 | + BlockBackend *blk = test_setup(); | ||
92 | + test_drv_cb_common(blk, BDRV_DRAIN_ALL, true); | ||
93 | + blk_unref(blk); | ||
94 | } | ||
95 | |||
96 | static void test_drv_cb_drain(void) | ||
97 | { | ||
98 | - test_drv_cb_common(BDRV_DRAIN, false); | ||
99 | + BlockBackend *blk = test_setup(); | ||
100 | + test_drv_cb_common(blk, BDRV_DRAIN, false); | ||
101 | + blk_unref(blk); | ||
102 | +} | ||
103 | + | ||
104 | +static void coroutine_fn test_drv_cb_co_drain_all_entry(void) | ||
105 | +{ | ||
106 | + BlockBackend *blk = blk_all_next(NULL); | ||
107 | + test_drv_cb_common(blk, BDRV_DRAIN_ALL, true); | ||
108 | } | ||
109 | |||
110 | static void test_drv_cb_co_drain_all(void) | ||
111 | { | ||
112 | - call_in_coroutine(test_drv_cb_drain_all); | ||
113 | + BlockBackend *blk = test_setup(); | ||
114 | + call_in_coroutine(test_drv_cb_co_drain_all_entry); | ||
115 | + blk_unref(blk); | ||
116 | } | ||
117 | |||
118 | -static void test_drv_cb_co_drain(void) | ||
119 | +static void coroutine_fn test_drv_cb_co_drain_entry(void) | ||
120 | { | ||
121 | - call_in_coroutine(test_drv_cb_drain); | ||
122 | + BlockBackend *blk = blk_all_next(NULL); | ||
123 | + test_drv_cb_common(blk, BDRV_DRAIN, false); | ||
124 | } | ||
125 | |||
126 | -static void test_quiesce_common(enum drain_type drain_type, bool recursive) | ||
127 | +static void test_drv_cb_co_drain(void) | ||
128 | { | ||
129 | - BlockBackend *blk; | ||
130 | - BlockDriverState *bs, *backing; | ||
131 | - | ||
132 | - blk = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL); | ||
133 | - bs = bdrv_new_open_driver(&bdrv_test, "test-node", BDRV_O_RDWR, | ||
134 | - &error_abort); | ||
135 | - blk_insert_bs(blk, bs, &error_abort); | ||
136 | + BlockBackend *blk = test_setup(); | ||
137 | + call_in_coroutine(test_drv_cb_co_drain_entry); | ||
138 | + blk_unref(blk); | ||
139 | +} | ||
140 | |||
141 | - backing = bdrv_new_open_driver(&bdrv_test, "backing", 0, &error_abort); | ||
142 | - bdrv_set_backing_hd(bs, backing, &error_abort); | ||
143 | +static void test_quiesce_common(BlockBackend *blk, enum drain_type drain_type, | ||
144 | + bool recursive) | ||
145 | +{ | ||
146 | + BlockDriverState *bs = blk_bs(blk); | ||
147 | + BlockDriverState *backing = bs->backing->bs; | ||
148 | |||
149 | g_assert_cmpint(bs->quiesce_counter, ==, 0); | ||
150 | g_assert_cmpint(backing->quiesce_counter, ==, 0); | ||
151 | @@ -XXX,XX +XXX,XX @@ static void test_quiesce_common(enum drain_type drain_type, bool recursive) | ||
152 | |||
153 | g_assert_cmpint(bs->quiesce_counter, ==, 0); | ||
154 | g_assert_cmpint(backing->quiesce_counter, ==, 0); | ||
155 | - | ||
156 | - bdrv_unref(backing); | ||
157 | - bdrv_unref(bs); | ||
158 | - blk_unref(blk); | ||
159 | } | ||
160 | |||
161 | static void test_quiesce_drain_all(void) | ||
162 | { | ||
163 | - test_quiesce_common(BDRV_DRAIN_ALL, true); | ||
164 | + BlockBackend *blk = test_setup(); | ||
165 | + test_quiesce_common(blk, BDRV_DRAIN_ALL, true); | ||
166 | + blk_unref(blk); | ||
167 | } | ||
168 | |||
169 | static void test_quiesce_drain(void) | ||
170 | { | ||
171 | - test_quiesce_common(BDRV_DRAIN, false); | ||
172 | + BlockBackend *blk = test_setup(); | ||
173 | + test_quiesce_common(blk, BDRV_DRAIN, false); | ||
174 | + blk_unref(blk); | ||
175 | +} | ||
176 | + | ||
177 | +static void coroutine_fn test_quiesce_co_drain_all_entry(void) | ||
178 | +{ | ||
179 | + BlockBackend *blk = blk_all_next(NULL); | ||
180 | + test_quiesce_common(blk, BDRV_DRAIN_ALL, true); | ||
181 | } | ||
182 | |||
183 | static void test_quiesce_co_drain_all(void) | ||
184 | { | ||
185 | - call_in_coroutine(test_quiesce_drain_all); | ||
186 | + BlockBackend *blk = test_setup(); | ||
187 | + call_in_coroutine(test_quiesce_co_drain_all_entry); | ||
188 | + blk_unref(blk); | ||
189 | +} | ||
190 | + | ||
191 | +static void coroutine_fn test_quiesce_co_drain_entry(void) | ||
192 | +{ | ||
193 | + BlockBackend *blk = blk_all_next(NULL); | ||
194 | + test_quiesce_common(blk, BDRV_DRAIN, false); | ||
195 | } | ||
196 | |||
197 | static void test_quiesce_co_drain(void) | ||
198 | { | ||
199 | - call_in_coroutine(test_quiesce_drain); | ||
200 | + BlockBackend *blk = test_setup(); | ||
201 | + call_in_coroutine(test_quiesce_co_drain_entry); | ||
202 | + blk_unref(blk); | ||
203 | } | ||
204 | |||
205 | static void test_nested(void) | ||
63 | -- | 206 | -- |
64 | 2.19.1 | 207 | 2.40.1 |
65 | |||
66 | diff view generated by jsdifflib |
1 | If read-only=off, but auto-read-only=on is given, open the volume | 1 | For some functions, it is part of their interface to be called without |
---|---|---|---|
2 | read-write if we have the permissions, but instead of erroring out for | 2 | holding the graph lock. Add a new macro to document this. |
3 | read-only volumes, just degrade to read-only. | 3 | |
4 | The macro expands to TSA_EXCLUDES(), which is a relatively weak check | ||
5 | because it passes in cases where the compiler just doesn't know if the | ||
6 | lock is held. Function pointers can't be checked at all. Therefore, its | ||
7 | primary purpose is documentation. | ||
4 | 8 | ||
5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
6 | Reviewed-by: Eric Blake <eblake@redhat.com> | 10 | Reviewed-by: Eric Blake <eblake@redhat.com> |
11 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
12 | Message-Id: <20230504115750.54437-7-kwolf@redhat.com> | ||
13 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
7 | --- | 14 | --- |
8 | block/iscsi.c | 8 +++++--- | 15 | include/block/graph-lock.h | 2 ++ |
9 | 1 file changed, 5 insertions(+), 3 deletions(-) | 16 | 1 file changed, 2 insertions(+) |
10 | 17 | ||
11 | diff --git a/block/iscsi.c b/block/iscsi.c | 18 | diff --git a/include/block/graph-lock.h b/include/block/graph-lock.h |
12 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/block/iscsi.c | 20 | --- a/include/block/graph-lock.h |
14 | +++ b/block/iscsi.c | 21 | +++ b/include/block/graph-lock.h |
15 | @@ -XXX,XX +XXX,XX @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags, | 22 | @@ -XXX,XX +XXX,XX @@ extern BdrvGraphLock graph_lock; |
16 | /* Check the write protect flag of the LUN if we want to write */ | 23 | */ |
17 | if (iscsilun->type == TYPE_DISK && (flags & BDRV_O_RDWR) && | 24 | #define GRAPH_WRLOCK TSA_REQUIRES(graph_lock) |
18 | iscsilun->write_protected) { | 25 | #define GRAPH_RDLOCK TSA_REQUIRES_SHARED(graph_lock) |
19 | - error_setg(errp, "Cannot open a write protected LUN as read-write"); | 26 | +#define GRAPH_UNLOCKED TSA_EXCLUDES(graph_lock) |
20 | - ret = -EACCES; | 27 | |
21 | - goto out; | 28 | /* |
22 | + ret = bdrv_apply_auto_read_only(bs, "LUN is write protected", errp); | 29 | * TSA annotations are not part of function types, so checks are defeated when |
23 | + if (ret < 0) { | 30 | @@ -XXX,XX +XXX,XX @@ extern BdrvGraphLock graph_lock; |
24 | + goto out; | 31 | */ |
25 | + } | 32 | #define GRAPH_RDLOCK_PTR TSA_GUARDED_BY(graph_lock) |
26 | + flags &= ~BDRV_O_RDWR; | 33 | #define GRAPH_WRLOCK_PTR TSA_GUARDED_BY(graph_lock) |
27 | } | 34 | +#define GRAPH_UNLOCKED_PTR |
28 | 35 | ||
29 | iscsi_readcapacity_sync(iscsilun, &local_err); | 36 | /* |
37 | * register_aiocontext: | ||
30 | -- | 38 | -- |
31 | 2.19.1 | 39 | 2.40.1 |
32 | |||
33 | diff view generated by jsdifflib |
1 | If read-only=off, but auto-read-only=on is given, just degrade to | 1 | GRAPH_RDLOCK_GUARD() and GRAPH_RDLOCK_GUARD_MAINLOOP() only take a |
---|---|---|---|
2 | read-only. | 2 | reader lock for the graph, so the correct annotation for them to use is |
3 | TSA_ASSERT_SHARED rather than TSA_ASSERT. | ||
3 | 4 | ||
4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
5 | Reviewed-by: Eric Blake <eblake@redhat.com> | 6 | Reviewed-by: Eric Blake <eblake@redhat.com> |
7 | Message-Id: <20230504115750.54437-8-kwolf@redhat.com> | ||
8 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
6 | --- | 10 | --- |
7 | block/curl.c | 8 ++++---- | 11 | include/block/graph-lock.h | 16 ++++++++-------- |
8 | 1 file changed, 4 insertions(+), 4 deletions(-) | 12 | 1 file changed, 8 insertions(+), 8 deletions(-) |
9 | 13 | ||
10 | diff --git a/block/curl.c b/block/curl.c | 14 | diff --git a/include/block/graph-lock.h b/include/block/graph-lock.h |
11 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
12 | --- a/block/curl.c | 16 | --- a/include/block/graph-lock.h |
13 | +++ b/block/curl.c | 17 | +++ b/include/block/graph-lock.h |
14 | @@ -XXX,XX +XXX,XX @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags, | 18 | @@ -XXX,XX +XXX,XX @@ typedef struct GraphLockable { } GraphLockable; |
15 | const char *protocol_delimiter; | 19 | #define GML_OBJ_() (&(GraphLockable) { }) |
16 | int ret; | 20 | |
17 | 21 | /* | |
18 | - | 22 | - * This is not marked as TSA_ACQUIRE() because TSA doesn't understand the |
19 | - if (flags & BDRV_O_RDWR) { | 23 | + * This is not marked as TSA_ACQUIRE_SHARED() because TSA doesn't understand the |
20 | - error_setg(errp, "curl block device does not support writes"); | 24 | * cleanup attribute and would therefore complain that the graph is never |
21 | - return -EROFS; | 25 | - * unlocked. TSA_ASSERT() makes sure that the following calls know that we |
22 | + ret = bdrv_apply_auto_read_only(bs, "curl driver does not support writes", | 26 | - * hold the lock while unlocking is left unchecked. |
23 | + errp); | 27 | + * unlocked. TSA_ASSERT_SHARED() makes sure that the following calls know that |
24 | + if (ret < 0) { | 28 | + * we hold the lock while unlocking is left unchecked. |
25 | + return ret; | 29 | */ |
26 | } | 30 | -static inline GraphLockable * TSA_ASSERT(graph_lock) TSA_NO_TSA coroutine_fn |
27 | 31 | +static inline GraphLockable * TSA_ASSERT_SHARED(graph_lock) TSA_NO_TSA coroutine_fn | |
28 | if (!libcurl_initialized) { | 32 | graph_lockable_auto_lock(GraphLockable *x) |
33 | { | ||
34 | bdrv_graph_co_rdlock(); | ||
35 | @@ -XXX,XX +XXX,XX @@ typedef struct GraphLockableMainloop { } GraphLockableMainloop; | ||
36 | #define GMLML_OBJ_() (&(GraphLockableMainloop) { }) | ||
37 | |||
38 | /* | ||
39 | - * This is not marked as TSA_ACQUIRE() because TSA doesn't understand the | ||
40 | + * This is not marked as TSA_ACQUIRE_SHARED() because TSA doesn't understand the | ||
41 | * cleanup attribute and would therefore complain that the graph is never | ||
42 | - * unlocked. TSA_ASSERT() makes sure that the following calls know that we | ||
43 | - * hold the lock while unlocking is left unchecked. | ||
44 | + * unlocked. TSA_ASSERT_SHARED() makes sure that the following calls know that | ||
45 | + * we hold the lock while unlocking is left unchecked. | ||
46 | */ | ||
47 | -static inline GraphLockableMainloop * TSA_ASSERT(graph_lock) TSA_NO_TSA | ||
48 | +static inline GraphLockableMainloop * TSA_ASSERT_SHARED(graph_lock) TSA_NO_TSA | ||
49 | graph_lockable_auto_lock_mainloop(GraphLockableMainloop *x) | ||
50 | { | ||
51 | bdrv_graph_rdlock_main_loop(); | ||
29 | -- | 52 | -- |
30 | 2.19.1 | 53 | 2.40.1 |
31 | |||
32 | diff view generated by jsdifflib |
1 | To fully change the read-only state of a node, we must not only change | 1 | Drivers were a bit confused about whether .bdrv_open can run in a |
---|---|---|---|
2 | bs->read_only, but also update bs->open_flags. | 2 | coroutine and whether or not it holds a graph lock. |
3 | |||
4 | It cannot keep a graph lock from the caller across the whole function | ||
5 | because it both changes the graph (requires a writer lock) and does I/O | ||
6 | (requires a reader lock). Therefore, it should take these locks | ||
7 | internally as needed. | ||
8 | |||
9 | The functions used to be called in coroutine context during image | ||
10 | creation. This was buggy for other reasons, and as of commit 32192301, | ||
11 | all block drivers go through no_co_wrappers. So it is not called in | ||
12 | coroutine context any more. | ||
13 | |||
14 | Fix qcow2 and qed to work with the correct assumptions: The graph lock | ||
15 | needs to be taken internally instead of just assuming it's already | ||
16 | there, and the coroutine path is dead code that can be removed. | ||
3 | 17 | ||
4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 18 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
5 | Reviewed-by: Eric Blake <eblake@redhat.com> | 19 | Reviewed-by: Eric Blake <eblake@redhat.com> |
6 | Reviewed-by: Alberto Garcia <berto@igalia.com> | 20 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> |
21 | Message-Id: <20230504115750.54437-9-kwolf@redhat.com> | ||
22 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
7 | --- | 23 | --- |
8 | block.c | 7 +++++++ | 24 | include/block/block_int-common.h | 8 ++++---- |
9 | 1 file changed, 7 insertions(+) | 25 | block.c | 6 +++--- |
26 | block/qcow2.c | 15 ++++++--------- | ||
27 | block/qed.c | 18 ++++++++---------- | ||
28 | 4 files changed, 21 insertions(+), 26 deletions(-) | ||
10 | 29 | ||
30 | diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/include/block/block_int-common.h | ||
33 | +++ b/include/block/block_int-common.h | ||
34 | @@ -XXX,XX +XXX,XX @@ struct BlockDriver { | ||
35 | void (*bdrv_reopen_abort)(BDRVReopenState *reopen_state); | ||
36 | void (*bdrv_join_options)(QDict *options, QDict *old_options); | ||
37 | |||
38 | - int (*bdrv_open)(BlockDriverState *bs, QDict *options, int flags, | ||
39 | - Error **errp); | ||
40 | + int GRAPH_UNLOCKED_PTR (*bdrv_open)( | ||
41 | + BlockDriverState *bs, QDict *options, int flags, Error **errp); | ||
42 | |||
43 | /* Protocol drivers should implement this instead of bdrv_open */ | ||
44 | - int (*bdrv_file_open)(BlockDriverState *bs, QDict *options, int flags, | ||
45 | - Error **errp); | ||
46 | + int GRAPH_UNLOCKED_PTR (*bdrv_file_open)( | ||
47 | + BlockDriverState *bs, QDict *options, int flags, Error **errp); | ||
48 | void (*bdrv_close)(BlockDriverState *bs); | ||
49 | |||
50 | int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_create)( | ||
11 | diff --git a/block.c b/block.c | 51 | diff --git a/block.c b/block.c |
12 | index XXXXXXX..XXXXXXX 100644 | 52 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/block.c | 53 | --- a/block.c |
14 | +++ b/block.c | 54 | +++ b/block.c |
15 | @@ -XXX,XX +XXX,XX @@ int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp) | 55 | @@ -XXX,XX +XXX,XX @@ out: |
56 | * bdrv_refresh_total_sectors() which polls when called from non-coroutine | ||
57 | * context. | ||
58 | */ | ||
59 | -static int bdrv_open_driver(BlockDriverState *bs, BlockDriver *drv, | ||
60 | - const char *node_name, QDict *options, | ||
61 | - int open_flags, Error **errp) | ||
62 | +static int no_coroutine_fn GRAPH_UNLOCKED | ||
63 | +bdrv_open_driver(BlockDriverState *bs, BlockDriver *drv, const char *node_name, | ||
64 | + QDict *options, int open_flags, Error **errp) | ||
65 | { | ||
66 | Error *local_err = NULL; | ||
67 | int i, ret; | ||
68 | diff --git a/block/qcow2.c b/block/qcow2.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/block/qcow2.c | ||
71 | +++ b/block/qcow2.c | ||
72 | @@ -XXX,XX +XXX,XX @@ static void coroutine_fn qcow2_open_entry(void *opaque) | ||
73 | QCow2OpenCo *qoc = opaque; | ||
74 | BDRVQcow2State *s = qoc->bs->opaque; | ||
75 | |||
76 | - assume_graph_lock(); /* FIXME */ | ||
77 | + GRAPH_RDLOCK_GUARD(); | ||
78 | |||
79 | qemu_co_mutex_lock(&s->lock); | ||
80 | qoc->ret = qcow2_do_open(qoc->bs, qoc->options, qoc->flags, true, | ||
81 | @@ -XXX,XX +XXX,XX @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, | ||
82 | /* Initialise locks */ | ||
83 | qemu_co_mutex_init(&s->lock); | ||
84 | |||
85 | - if (qemu_in_coroutine()) { | ||
86 | - /* From bdrv_co_create. */ | ||
87 | - qcow2_open_entry(&qoc); | ||
88 | - } else { | ||
89 | - assert(qemu_get_current_aio_context() == qemu_get_aio_context()); | ||
90 | - qemu_coroutine_enter(qemu_coroutine_create(qcow2_open_entry, &qoc)); | ||
91 | - BDRV_POLL_WHILE(bs, qoc.ret == -EINPROGRESS); | ||
92 | - } | ||
93 | + assert(!qemu_in_coroutine()); | ||
94 | + assert(qemu_get_current_aio_context() == qemu_get_aio_context()); | ||
95 | + qemu_coroutine_enter(qemu_coroutine_create(qcow2_open_entry, &qoc)); | ||
96 | + BDRV_POLL_WHILE(bs, qoc.ret == -EINPROGRESS); | ||
97 | + | ||
98 | return qoc.ret; | ||
99 | } | ||
100 | |||
101 | diff --git a/block/qed.c b/block/qed.c | ||
102 | index XXXXXXX..XXXXXXX 100644 | ||
103 | --- a/block/qed.c | ||
104 | +++ b/block/qed.c | ||
105 | @@ -XXX,XX +XXX,XX @@ typedef struct QEDOpenCo { | ||
106 | int ret; | ||
107 | } QEDOpenCo; | ||
108 | |||
109 | -static void coroutine_fn GRAPH_RDLOCK bdrv_qed_open_entry(void *opaque) | ||
110 | +static void coroutine_fn bdrv_qed_open_entry(void *opaque) | ||
111 | { | ||
112 | QEDOpenCo *qoc = opaque; | ||
113 | BDRVQEDState *s = qoc->bs->opaque; | ||
114 | |||
115 | + GRAPH_RDLOCK_GUARD(); | ||
116 | + | ||
117 | qemu_co_mutex_lock(&s->table_lock); | ||
118 | qoc->ret = bdrv_qed_do_open(qoc->bs, qoc->options, qoc->flags, qoc->errp); | ||
119 | qemu_co_mutex_unlock(&s->table_lock); | ||
120 | @@ -XXX,XX +XXX,XX @@ static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags, | ||
121 | }; | ||
122 | int ret; | ||
123 | |||
124 | - assume_graph_lock(); /* FIXME */ | ||
125 | - | ||
126 | ret = bdrv_open_file_child(NULL, options, "file", bs, errp); | ||
127 | if (ret < 0) { | ||
128 | return ret; | ||
16 | } | 129 | } |
17 | 130 | ||
18 | bs->read_only = read_only; | 131 | bdrv_qed_init_state(bs); |
132 | - if (qemu_in_coroutine()) { | ||
133 | - bdrv_qed_open_entry(&qoc); | ||
134 | - } else { | ||
135 | - assert(qemu_get_current_aio_context() == qemu_get_aio_context()); | ||
136 | - qemu_coroutine_enter(qemu_coroutine_create(bdrv_qed_open_entry, &qoc)); | ||
137 | - BDRV_POLL_WHILE(bs, qoc.ret == -EINPROGRESS); | ||
138 | - } | ||
139 | + assert(!qemu_in_coroutine()); | ||
140 | + assert(qemu_get_current_aio_context() == qemu_get_aio_context()); | ||
141 | + qemu_coroutine_enter(qemu_coroutine_create(bdrv_qed_open_entry, &qoc)); | ||
142 | + BDRV_POLL_WHILE(bs, qoc.ret == -EINPROGRESS); | ||
19 | + | 143 | + |
20 | + if (read_only) { | 144 | return qoc.ret; |
21 | + bs->open_flags &= ~BDRV_O_RDWR; | ||
22 | + } else { | ||
23 | + bs->open_flags |= BDRV_O_RDWR; | ||
24 | + } | ||
25 | + | ||
26 | return 0; | ||
27 | } | 145 | } |
28 | 146 | ||
29 | -- | 147 | -- |
30 | 2.19.1 | 148 | 2.40.1 |
31 | |||
32 | diff view generated by jsdifflib |
1 | If read-only=off, but auto-read-only=on is given, open the file | 1 | The only thing nbd_co_flush() does is call nbd_client_co_flush(). Just |
---|---|---|---|
2 | read-write if we have the permissions, but instead of erroring out for | 2 | use that function directly in the BlockDriver definitions and remove the |
3 | read-only files, just degrade to read-only. | 3 | wrapper. |
4 | 4 | ||
5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
6 | Reviewed-by: Eric Blake <eblake@redhat.com> | 6 | Reviewed-by: Eric Blake <eblake@redhat.com> |
7 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
8 | Message-Id: <20230504115750.54437-10-kwolf@redhat.com> | ||
9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
7 | --- | 10 | --- |
8 | block/file-posix.c | 19 ++++++++++++++++--- | 11 | block/nbd.c | 11 +++-------- |
9 | 1 file changed, 16 insertions(+), 3 deletions(-) | 12 | 1 file changed, 3 insertions(+), 8 deletions(-) |
10 | 13 | ||
11 | diff --git a/block/file-posix.c b/block/file-posix.c | 14 | diff --git a/block/nbd.c b/block/nbd.c |
12 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/block/file-posix.c | 16 | --- a/block/nbd.c |
14 | +++ b/block/file-posix.c | 17 | +++ b/block/nbd.c |
15 | @@ -XXX,XX +XXX,XX @@ static int raw_open_common(BlockDriverState *bs, QDict *options, | 18 | @@ -XXX,XX +XXX,XX @@ fail: |
16 | 19 | return ret; | |
17 | s->fd = -1; | 20 | } |
18 | fd = qemu_open(filename, s->open_flags, 0644); | 21 | |
19 | - if (fd < 0) { | 22 | -static int coroutine_fn nbd_co_flush(BlockDriverState *bs) |
20 | - ret = -errno; | 23 | -{ |
21 | - error_setg_errno(errp, errno, "Could not open '%s'", filename); | 24 | - return nbd_client_co_flush(bs); |
22 | + ret = fd < 0 ? -errno : 0; | 25 | -} |
23 | + | 26 | - |
24 | + if (ret == -EACCES || ret == -EROFS) { | 27 | static void nbd_refresh_limits(BlockDriverState *bs, Error **errp) |
25 | + /* Try to degrade to read-only, but if it doesn't work, still use the | 28 | { |
26 | + * normal error message. */ | 29 | BDRVNBDState *s = (BDRVNBDState *)bs->opaque; |
27 | + if (bdrv_apply_auto_read_only(bs, NULL, NULL) == 0) { | 30 | @@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_nbd = { |
28 | + bdrv_flags &= ~BDRV_O_RDWR; | 31 | .bdrv_co_pwritev = nbd_client_co_pwritev, |
29 | + raw_parse_flags(bdrv_flags, &s->open_flags); | 32 | .bdrv_co_pwrite_zeroes = nbd_client_co_pwrite_zeroes, |
30 | + assert(!(s->open_flags & O_CREAT)); | 33 | .bdrv_close = nbd_close, |
31 | + fd = qemu_open(filename, s->open_flags); | 34 | - .bdrv_co_flush_to_os = nbd_co_flush, |
32 | + ret = fd < 0 ? -errno : 0; | 35 | + .bdrv_co_flush_to_os = nbd_client_co_flush, |
33 | + } | 36 | .bdrv_co_pdiscard = nbd_client_co_pdiscard, |
34 | + } | 37 | .bdrv_refresh_limits = nbd_refresh_limits, |
35 | + | 38 | .bdrv_co_truncate = nbd_co_truncate, |
36 | + if (ret < 0) { | 39 | @@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_nbd_tcp = { |
37 | + error_setg_errno(errp, -ret, "Could not open '%s'", filename); | 40 | .bdrv_co_pwritev = nbd_client_co_pwritev, |
38 | if (ret == -EROFS) { | 41 | .bdrv_co_pwrite_zeroes = nbd_client_co_pwrite_zeroes, |
39 | ret = -EACCES; | 42 | .bdrv_close = nbd_close, |
40 | } | 43 | - .bdrv_co_flush_to_os = nbd_co_flush, |
44 | + .bdrv_co_flush_to_os = nbd_client_co_flush, | ||
45 | .bdrv_co_pdiscard = nbd_client_co_pdiscard, | ||
46 | .bdrv_refresh_limits = nbd_refresh_limits, | ||
47 | .bdrv_co_truncate = nbd_co_truncate, | ||
48 | @@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_nbd_unix = { | ||
49 | .bdrv_co_pwritev = nbd_client_co_pwritev, | ||
50 | .bdrv_co_pwrite_zeroes = nbd_client_co_pwrite_zeroes, | ||
51 | .bdrv_close = nbd_close, | ||
52 | - .bdrv_co_flush_to_os = nbd_co_flush, | ||
53 | + .bdrv_co_flush_to_os = nbd_client_co_flush, | ||
54 | .bdrv_co_pdiscard = nbd_client_co_pdiscard, | ||
55 | .bdrv_refresh_limits = nbd_refresh_limits, | ||
56 | .bdrv_co_truncate = nbd_co_truncate, | ||
41 | -- | 57 | -- |
42 | 2.19.1 | 58 | 2.40.1 |
43 | |||
44 | diff view generated by jsdifflib |
1 | From: Peter Maydell <peter.maydell@linaro.org> | 1 | From: Emanuele Giuseppe Esposito <eesposit@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Taking the address of a field in a packed struct is a bad idea, because | 3 | This adds GRAPH_RDLOCK annotations to declare that callers of |
4 | it might not be actually aligned enough for that pointer type (and | 4 | nbd_co_do_establish_connection() need to hold a reader lock for the |
5 | thus cause a crash on dereference on some host architectures). Newer | 5 | graph. |
6 | versions of clang warn about this. Avoid the bug by not using the | ||
7 | "modify in place" byte swapping functions. | ||
8 | 6 | ||
9 | There are a few places where the in-place swap function is | 7 | Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> |
10 | used on something other than a packed struct field; we convert | 8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
11 | those anyway, for consistency. | 9 | Reviewed-by: Eric Blake <eblake@redhat.com> |
12 | |||
13 | Patch produced with scripts/coccinelle/inplace-byteswaps.cocci. | ||
14 | |||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | 10 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> |
11 | Message-Id: <20230504115750.54437-11-kwolf@redhat.com> | ||
17 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 12 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
18 | --- | 13 | --- |
19 | block/vhdx.h | 12 ++--- | 14 | block/coroutines.h | 5 +++-- |
20 | block/vhdx-endian.c | 118 ++++++++++++++++++++++---------------------- | 15 | block/nbd.c | 39 +++++++++++++++++++++------------------ |
21 | block/vhdx-log.c | 4 +- | 16 | 2 files changed, 24 insertions(+), 20 deletions(-) |
22 | block/vhdx.c | 18 +++---- | ||
23 | 4 files changed, 76 insertions(+), 76 deletions(-) | ||
24 | 17 | ||
25 | diff --git a/block/vhdx.h b/block/vhdx.h | 18 | diff --git a/block/coroutines.h b/block/coroutines.h |
26 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/block/vhdx.h | 20 | --- a/block/coroutines.h |
28 | +++ b/block/vhdx.h | 21 | +++ b/block/coroutines.h |
29 | @@ -XXX,XX +XXX,XX @@ int vhdx_log_write_and_flush(BlockDriverState *bs, BDRVVHDXState *s, | 22 | @@ -XXX,XX +XXX,XX @@ bdrv_co_readv_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos); |
30 | 23 | int coroutine_fn GRAPH_RDLOCK | |
31 | static inline void leguid_to_cpus(MSGUID *guid) | 24 | bdrv_co_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos); |
25 | |||
26 | -int coroutine_fn | ||
27 | +int coroutine_fn GRAPH_RDLOCK | ||
28 | nbd_co_do_establish_connection(BlockDriverState *bs, bool blocking, | ||
29 | Error **errp); | ||
30 | |||
31 | @@ -XXX,XX +XXX,XX @@ bdrv_common_block_status_above(BlockDriverState *bs, | ||
32 | int64_t *map, | ||
33 | BlockDriverState **file, | ||
34 | int *depth); | ||
35 | -int co_wrapper_mixed | ||
36 | + | ||
37 | +int co_wrapper_mixed_bdrv_rdlock | ||
38 | nbd_do_establish_connection(BlockDriverState *bs, bool blocking, Error **errp); | ||
39 | |||
40 | #endif /* BLOCK_COROUTINES_H */ | ||
41 | diff --git a/block/nbd.c b/block/nbd.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/block/nbd.c | ||
44 | +++ b/block/nbd.c | ||
45 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn nbd_co_do_establish_connection(BlockDriverState *bs, | ||
46 | int ret; | ||
47 | IO_CODE(); | ||
48 | |||
49 | + assert_bdrv_graph_readable(); | ||
50 | assert(!s->ioc); | ||
51 | |||
52 | s->ioc = nbd_co_establish_connection(s->conn, &s->info, blocking, errp); | ||
53 | @@ -XXX,XX +XXX,XX @@ static bool nbd_client_connecting(BDRVNBDState *s) | ||
54 | } | ||
55 | |||
56 | /* Called with s->requests_lock taken. */ | ||
57 | -static coroutine_fn void nbd_reconnect_attempt(BDRVNBDState *s) | ||
58 | +static void coroutine_fn GRAPH_RDLOCK nbd_reconnect_attempt(BDRVNBDState *s) | ||
32 | { | 59 | { |
33 | - le32_to_cpus(&guid->data1); | 60 | int ret; |
34 | - le16_to_cpus(&guid->data2); | 61 | bool blocking = s->state == NBD_CLIENT_CONNECTING_WAIT; |
35 | - le16_to_cpus(&guid->data3); | 62 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn int nbd_receive_replies(BDRVNBDState *s, uint64_t handle) |
36 | + guid->data1 = le32_to_cpu(guid->data1); | 63 | } |
37 | + guid->data2 = le16_to_cpu(guid->data2); | ||
38 | + guid->data3 = le16_to_cpu(guid->data3); | ||
39 | } | 64 | } |
40 | 65 | ||
41 | static inline void cpu_to_leguids(MSGUID *guid) | 66 | -static int coroutine_fn nbd_co_send_request(BlockDriverState *bs, |
67 | - NBDRequest *request, | ||
68 | - QEMUIOVector *qiov) | ||
69 | +static int coroutine_fn GRAPH_RDLOCK | ||
70 | +nbd_co_send_request(BlockDriverState *bs, NBDRequest *request, | ||
71 | + QEMUIOVector *qiov) | ||
42 | { | 72 | { |
43 | - cpu_to_le32s(&guid->data1); | 73 | BDRVNBDState *s = (BDRVNBDState *)bs->opaque; |
44 | - cpu_to_le16s(&guid->data2); | 74 | int rc, i = -1; |
45 | - cpu_to_le16s(&guid->data3); | 75 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn nbd_co_receive_blockstatus_reply(BDRVNBDState *s, |
46 | + guid->data1 = cpu_to_le32(guid->data1); | 76 | return iter.ret; |
47 | + guid->data2 = cpu_to_le16(guid->data2); | ||
48 | + guid->data3 = cpu_to_le16(guid->data3); | ||
49 | } | 77 | } |
50 | 78 | ||
51 | void vhdx_header_le_import(VHDXHeader *h); | 79 | -static int coroutine_fn nbd_co_request(BlockDriverState *bs, NBDRequest *request, |
52 | diff --git a/block/vhdx-endian.c b/block/vhdx-endian.c | 80 | - QEMUIOVector *write_qiov) |
53 | index XXXXXXX..XXXXXXX 100644 | 81 | +static int coroutine_fn GRAPH_RDLOCK |
54 | --- a/block/vhdx-endian.c | 82 | +nbd_co_request(BlockDriverState *bs, NBDRequest *request, |
55 | +++ b/block/vhdx-endian.c | 83 | + QEMUIOVector *write_qiov) |
56 | @@ -XXX,XX +XXX,XX @@ void vhdx_header_le_import(VHDXHeader *h) | ||
57 | { | 84 | { |
58 | assert(h != NULL); | 85 | int ret, request_ret; |
59 | 86 | Error *local_err = NULL; | |
60 | - le32_to_cpus(&h->signature); | 87 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn nbd_co_request(BlockDriverState *bs, NBDRequest *request |
61 | - le32_to_cpus(&h->checksum); | 88 | return ret ? ret : request_ret; |
62 | - le64_to_cpus(&h->sequence_number); | ||
63 | + h->signature = le32_to_cpu(h->signature); | ||
64 | + h->checksum = le32_to_cpu(h->checksum); | ||
65 | + h->sequence_number = le64_to_cpu(h->sequence_number); | ||
66 | |||
67 | leguid_to_cpus(&h->file_write_guid); | ||
68 | leguid_to_cpus(&h->data_write_guid); | ||
69 | leguid_to_cpus(&h->log_guid); | ||
70 | |||
71 | - le16_to_cpus(&h->log_version); | ||
72 | - le16_to_cpus(&h->version); | ||
73 | - le32_to_cpus(&h->log_length); | ||
74 | - le64_to_cpus(&h->log_offset); | ||
75 | + h->log_version = le16_to_cpu(h->log_version); | ||
76 | + h->version = le16_to_cpu(h->version); | ||
77 | + h->log_length = le32_to_cpu(h->log_length); | ||
78 | + h->log_offset = le64_to_cpu(h->log_offset); | ||
79 | } | 89 | } |
80 | 90 | ||
81 | void vhdx_header_le_export(VHDXHeader *orig_h, VHDXHeader *new_h) | 91 | -static int coroutine_fn nbd_client_co_preadv(BlockDriverState *bs, int64_t offset, |
82 | @@ -XXX,XX +XXX,XX @@ void vhdx_log_desc_le_import(VHDXLogDescriptor *d) | 92 | - int64_t bytes, QEMUIOVector *qiov, |
93 | - BdrvRequestFlags flags) | ||
94 | +static int coroutine_fn GRAPH_RDLOCK | ||
95 | +nbd_client_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, | ||
96 | + QEMUIOVector *qiov, BdrvRequestFlags flags) | ||
83 | { | 97 | { |
84 | assert(d != NULL); | 98 | int ret, request_ret; |
85 | 99 | Error *local_err = NULL; | |
86 | - le32_to_cpus(&d->signature); | 100 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn nbd_client_co_preadv(BlockDriverState *bs, int64_t offse |
87 | - le64_to_cpus(&d->file_offset); | 101 | return ret ? ret : request_ret; |
88 | - le64_to_cpus(&d->sequence_number); | ||
89 | + d->signature = le32_to_cpu(d->signature); | ||
90 | + d->file_offset = le64_to_cpu(d->file_offset); | ||
91 | + d->sequence_number = le64_to_cpu(d->sequence_number); | ||
92 | } | 102 | } |
93 | 103 | ||
94 | void vhdx_log_desc_le_export(VHDXLogDescriptor *d) | 104 | -static int coroutine_fn nbd_client_co_pwritev(BlockDriverState *bs, int64_t offset, |
105 | - int64_t bytes, QEMUIOVector *qiov, | ||
106 | - BdrvRequestFlags flags) | ||
107 | +static int coroutine_fn GRAPH_RDLOCK | ||
108 | +nbd_client_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes, | ||
109 | + QEMUIOVector *qiov, BdrvRequestFlags flags) | ||
95 | { | 110 | { |
96 | assert(d != NULL); | 111 | BDRVNBDState *s = (BDRVNBDState *)bs->opaque; |
97 | 112 | NBDRequest request = { | |
98 | - cpu_to_le32s(&d->signature); | 113 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn nbd_client_co_pwritev(BlockDriverState *bs, int64_t offs |
99 | - cpu_to_le32s(&d->trailing_bytes); | 114 | return nbd_co_request(bs, &request, qiov); |
100 | - cpu_to_le64s(&d->leading_bytes); | ||
101 | - cpu_to_le64s(&d->file_offset); | ||
102 | - cpu_to_le64s(&d->sequence_number); | ||
103 | + d->signature = cpu_to_le32(d->signature); | ||
104 | + d->trailing_bytes = cpu_to_le32(d->trailing_bytes); | ||
105 | + d->leading_bytes = cpu_to_le64(d->leading_bytes); | ||
106 | + d->file_offset = cpu_to_le64(d->file_offset); | ||
107 | + d->sequence_number = cpu_to_le64(d->sequence_number); | ||
108 | } | 115 | } |
109 | 116 | ||
110 | void vhdx_log_data_le_import(VHDXLogDataSector *d) | 117 | -static int coroutine_fn nbd_client_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, |
118 | - int64_t bytes, BdrvRequestFlags flags) | ||
119 | +static int coroutine_fn GRAPH_RDLOCK | ||
120 | +nbd_client_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes, | ||
121 | + BdrvRequestFlags flags) | ||
111 | { | 122 | { |
112 | assert(d != NULL); | 123 | BDRVNBDState *s = (BDRVNBDState *)bs->opaque; |
113 | 124 | NBDRequest request = { | |
114 | - le32_to_cpus(&d->data_signature); | 125 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn nbd_client_co_pwrite_zeroes(BlockDriverState *bs, int64_ |
115 | - le32_to_cpus(&d->sequence_high); | 126 | return nbd_co_request(bs, &request, NULL); |
116 | - le32_to_cpus(&d->sequence_low); | ||
117 | + d->data_signature = le32_to_cpu(d->data_signature); | ||
118 | + d->sequence_high = le32_to_cpu(d->sequence_high); | ||
119 | + d->sequence_low = le32_to_cpu(d->sequence_low); | ||
120 | } | 127 | } |
121 | 128 | ||
122 | void vhdx_log_data_le_export(VHDXLogDataSector *d) | 129 | -static int coroutine_fn nbd_client_co_flush(BlockDriverState *bs) |
130 | +static int coroutine_fn GRAPH_RDLOCK nbd_client_co_flush(BlockDriverState *bs) | ||
123 | { | 131 | { |
124 | assert(d != NULL); | 132 | BDRVNBDState *s = (BDRVNBDState *)bs->opaque; |
125 | 133 | NBDRequest request = { .type = NBD_CMD_FLUSH }; | |
126 | - cpu_to_le32s(&d->data_signature); | 134 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn nbd_client_co_flush(BlockDriverState *bs) |
127 | - cpu_to_le32s(&d->sequence_high); | 135 | return nbd_co_request(bs, &request, NULL); |
128 | - cpu_to_le32s(&d->sequence_low); | ||
129 | + d->data_signature = cpu_to_le32(d->data_signature); | ||
130 | + d->sequence_high = cpu_to_le32(d->sequence_high); | ||
131 | + d->sequence_low = cpu_to_le32(d->sequence_low); | ||
132 | } | 136 | } |
133 | 137 | ||
134 | void vhdx_log_entry_hdr_le_import(VHDXLogEntryHeader *hdr) | 138 | -static int coroutine_fn nbd_client_co_pdiscard(BlockDriverState *bs, int64_t offset, |
139 | - int64_t bytes) | ||
140 | +static int coroutine_fn GRAPH_RDLOCK | ||
141 | +nbd_client_co_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes) | ||
135 | { | 142 | { |
136 | assert(hdr != NULL); | 143 | BDRVNBDState *s = (BDRVNBDState *)bs->opaque; |
137 | 144 | NBDRequest request = { | |
138 | - le32_to_cpus(&hdr->signature); | 145 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn nbd_client_co_pdiscard(BlockDriverState *bs, int64_t off |
139 | - le32_to_cpus(&hdr->checksum); | 146 | return nbd_co_request(bs, &request, NULL); |
140 | - le32_to_cpus(&hdr->entry_length); | ||
141 | - le32_to_cpus(&hdr->tail); | ||
142 | - le64_to_cpus(&hdr->sequence_number); | ||
143 | - le32_to_cpus(&hdr->descriptor_count); | ||
144 | + hdr->signature = le32_to_cpu(hdr->signature); | ||
145 | + hdr->checksum = le32_to_cpu(hdr->checksum); | ||
146 | + hdr->entry_length = le32_to_cpu(hdr->entry_length); | ||
147 | + hdr->tail = le32_to_cpu(hdr->tail); | ||
148 | + hdr->sequence_number = le64_to_cpu(hdr->sequence_number); | ||
149 | + hdr->descriptor_count = le32_to_cpu(hdr->descriptor_count); | ||
150 | leguid_to_cpus(&hdr->log_guid); | ||
151 | - le64_to_cpus(&hdr->flushed_file_offset); | ||
152 | - le64_to_cpus(&hdr->last_file_offset); | ||
153 | + hdr->flushed_file_offset = le64_to_cpu(hdr->flushed_file_offset); | ||
154 | + hdr->last_file_offset = le64_to_cpu(hdr->last_file_offset); | ||
155 | } | 147 | } |
156 | 148 | ||
157 | void vhdx_log_entry_hdr_le_export(VHDXLogEntryHeader *hdr) | 149 | -static int coroutine_fn nbd_client_co_block_status( |
150 | +static int coroutine_fn GRAPH_RDLOCK nbd_client_co_block_status( | ||
151 | BlockDriverState *bs, bool want_zero, int64_t offset, int64_t bytes, | ||
152 | int64_t *pnum, int64_t *map, BlockDriverState **file) | ||
158 | { | 153 | { |
159 | assert(hdr != NULL); | ||
160 | |||
161 | - cpu_to_le32s(&hdr->signature); | ||
162 | - cpu_to_le32s(&hdr->checksum); | ||
163 | - cpu_to_le32s(&hdr->entry_length); | ||
164 | - cpu_to_le32s(&hdr->tail); | ||
165 | - cpu_to_le64s(&hdr->sequence_number); | ||
166 | - cpu_to_le32s(&hdr->descriptor_count); | ||
167 | + hdr->signature = cpu_to_le32(hdr->signature); | ||
168 | + hdr->checksum = cpu_to_le32(hdr->checksum); | ||
169 | + hdr->entry_length = cpu_to_le32(hdr->entry_length); | ||
170 | + hdr->tail = cpu_to_le32(hdr->tail); | ||
171 | + hdr->sequence_number = cpu_to_le64(hdr->sequence_number); | ||
172 | + hdr->descriptor_count = cpu_to_le32(hdr->descriptor_count); | ||
173 | cpu_to_leguids(&hdr->log_guid); | ||
174 | - cpu_to_le64s(&hdr->flushed_file_offset); | ||
175 | - cpu_to_le64s(&hdr->last_file_offset); | ||
176 | + hdr->flushed_file_offset = cpu_to_le64(hdr->flushed_file_offset); | ||
177 | + hdr->last_file_offset = cpu_to_le64(hdr->last_file_offset); | ||
178 | } | ||
179 | |||
180 | |||
181 | @@ -XXX,XX +XXX,XX @@ void vhdx_region_header_le_import(VHDXRegionTableHeader *hdr) | ||
182 | { | ||
183 | assert(hdr != NULL); | ||
184 | |||
185 | - le32_to_cpus(&hdr->signature); | ||
186 | - le32_to_cpus(&hdr->checksum); | ||
187 | - le32_to_cpus(&hdr->entry_count); | ||
188 | + hdr->signature = le32_to_cpu(hdr->signature); | ||
189 | + hdr->checksum = le32_to_cpu(hdr->checksum); | ||
190 | + hdr->entry_count = le32_to_cpu(hdr->entry_count); | ||
191 | } | ||
192 | |||
193 | void vhdx_region_header_le_export(VHDXRegionTableHeader *hdr) | ||
194 | { | ||
195 | assert(hdr != NULL); | ||
196 | |||
197 | - cpu_to_le32s(&hdr->signature); | ||
198 | - cpu_to_le32s(&hdr->checksum); | ||
199 | - cpu_to_le32s(&hdr->entry_count); | ||
200 | + hdr->signature = cpu_to_le32(hdr->signature); | ||
201 | + hdr->checksum = cpu_to_le32(hdr->checksum); | ||
202 | + hdr->entry_count = cpu_to_le32(hdr->entry_count); | ||
203 | } | ||
204 | |||
205 | void vhdx_region_entry_le_import(VHDXRegionTableEntry *e) | ||
206 | @@ -XXX,XX +XXX,XX @@ void vhdx_region_entry_le_import(VHDXRegionTableEntry *e) | ||
207 | assert(e != NULL); | ||
208 | |||
209 | leguid_to_cpus(&e->guid); | ||
210 | - le64_to_cpus(&e->file_offset); | ||
211 | - le32_to_cpus(&e->length); | ||
212 | - le32_to_cpus(&e->data_bits); | ||
213 | + e->file_offset = le64_to_cpu(e->file_offset); | ||
214 | + e->length = le32_to_cpu(e->length); | ||
215 | + e->data_bits = le32_to_cpu(e->data_bits); | ||
216 | } | ||
217 | |||
218 | void vhdx_region_entry_le_export(VHDXRegionTableEntry *e) | ||
219 | @@ -XXX,XX +XXX,XX @@ void vhdx_region_entry_le_export(VHDXRegionTableEntry *e) | ||
220 | assert(e != NULL); | ||
221 | |||
222 | cpu_to_leguids(&e->guid); | ||
223 | - cpu_to_le64s(&e->file_offset); | ||
224 | - cpu_to_le32s(&e->length); | ||
225 | - cpu_to_le32s(&e->data_bits); | ||
226 | + e->file_offset = cpu_to_le64(e->file_offset); | ||
227 | + e->length = cpu_to_le32(e->length); | ||
228 | + e->data_bits = cpu_to_le32(e->data_bits); | ||
229 | } | ||
230 | |||
231 | |||
232 | @@ -XXX,XX +XXX,XX @@ void vhdx_metadata_header_le_import(VHDXMetadataTableHeader *hdr) | ||
233 | { | ||
234 | assert(hdr != NULL); | ||
235 | |||
236 | - le64_to_cpus(&hdr->signature); | ||
237 | - le16_to_cpus(&hdr->entry_count); | ||
238 | + hdr->signature = le64_to_cpu(hdr->signature); | ||
239 | + hdr->entry_count = le16_to_cpu(hdr->entry_count); | ||
240 | } | ||
241 | |||
242 | void vhdx_metadata_header_le_export(VHDXMetadataTableHeader *hdr) | ||
243 | { | ||
244 | assert(hdr != NULL); | ||
245 | |||
246 | - cpu_to_le64s(&hdr->signature); | ||
247 | - cpu_to_le16s(&hdr->entry_count); | ||
248 | + hdr->signature = cpu_to_le64(hdr->signature); | ||
249 | + hdr->entry_count = cpu_to_le16(hdr->entry_count); | ||
250 | } | ||
251 | |||
252 | void vhdx_metadata_entry_le_import(VHDXMetadataTableEntry *e) | ||
253 | @@ -XXX,XX +XXX,XX @@ void vhdx_metadata_entry_le_import(VHDXMetadataTableEntry *e) | ||
254 | assert(e != NULL); | ||
255 | |||
256 | leguid_to_cpus(&e->item_id); | ||
257 | - le32_to_cpus(&e->offset); | ||
258 | - le32_to_cpus(&e->length); | ||
259 | - le32_to_cpus(&e->data_bits); | ||
260 | + e->offset = le32_to_cpu(e->offset); | ||
261 | + e->length = le32_to_cpu(e->length); | ||
262 | + e->data_bits = le32_to_cpu(e->data_bits); | ||
263 | } | ||
264 | void vhdx_metadata_entry_le_export(VHDXMetadataTableEntry *e) | ||
265 | { | ||
266 | assert(e != NULL); | ||
267 | |||
268 | cpu_to_leguids(&e->item_id); | ||
269 | - cpu_to_le32s(&e->offset); | ||
270 | - cpu_to_le32s(&e->length); | ||
271 | - cpu_to_le32s(&e->data_bits); | ||
272 | + e->offset = cpu_to_le32(e->offset); | ||
273 | + e->length = cpu_to_le32(e->length); | ||
274 | + e->data_bits = cpu_to_le32(e->data_bits); | ||
275 | } | ||
276 | diff --git a/block/vhdx-log.c b/block/vhdx-log.c | ||
277 | index XXXXXXX..XXXXXXX 100644 | ||
278 | --- a/block/vhdx-log.c | ||
279 | +++ b/block/vhdx-log.c | ||
280 | @@ -XXX,XX +XXX,XX @@ static void vhdx_log_raw_to_le_sector(VHDXLogDescriptor *desc, | ||
281 | /* 8 + 4084 + 4 = 4096, 1 log sector */ | ||
282 | memcpy(&desc->leading_bytes, data, 8); | ||
283 | data += 8; | ||
284 | - cpu_to_le64s(&desc->leading_bytes); | ||
285 | + desc->leading_bytes = cpu_to_le64(desc->leading_bytes); | ||
286 | memcpy(sector->data, data, 4084); | ||
287 | data += 4084; | ||
288 | memcpy(&desc->trailing_bytes, data, 4); | ||
289 | - cpu_to_le32s(&desc->trailing_bytes); | ||
290 | + desc->trailing_bytes = cpu_to_le32(desc->trailing_bytes); | ||
291 | data += 4; | ||
292 | |||
293 | sector->sequence_high = (uint32_t) (seq >> 32); | ||
294 | diff --git a/block/vhdx.c b/block/vhdx.c | ||
295 | index XXXXXXX..XXXXXXX 100644 | ||
296 | --- a/block/vhdx.c | ||
297 | +++ b/block/vhdx.c | ||
298 | @@ -XXX,XX +XXX,XX @@ uint32_t vhdx_update_checksum(uint8_t *buf, size_t size, int crc_offset) | ||
299 | |||
300 | memset(buf + crc_offset, 0, sizeof(crc)); | ||
301 | crc = crc32c(0xffffffff, buf, size); | ||
302 | - cpu_to_le32s(&crc); | ||
303 | + crc = cpu_to_le32(crc); | ||
304 | memcpy(buf + crc_offset, &crc, sizeof(crc)); | ||
305 | |||
306 | return crc; | ||
307 | @@ -XXX,XX +XXX,XX @@ static int vhdx_parse_metadata(BlockDriverState *bs, BDRVVHDXState *s) | ||
308 | goto exit; | ||
309 | } | ||
310 | |||
311 | - le32_to_cpus(&s->params.block_size); | ||
312 | - le32_to_cpus(&s->params.data_bits); | ||
313 | + s->params.block_size = le32_to_cpu(s->params.block_size); | ||
314 | + s->params.data_bits = le32_to_cpu(s->params.data_bits); | ||
315 | |||
316 | |||
317 | /* We now have the file parameters, so we can tell if this is a | ||
318 | @@ -XXX,XX +XXX,XX @@ static int vhdx_parse_metadata(BlockDriverState *bs, BDRVVHDXState *s) | ||
319 | goto exit; | ||
320 | } | ||
321 | |||
322 | - le64_to_cpus(&s->virtual_disk_size); | ||
323 | - le32_to_cpus(&s->logical_sector_size); | ||
324 | - le32_to_cpus(&s->physical_sector_size); | ||
325 | + s->virtual_disk_size = le64_to_cpu(s->virtual_disk_size); | ||
326 | + s->logical_sector_size = le32_to_cpu(s->logical_sector_size); | ||
327 | + s->physical_sector_size = le32_to_cpu(s->physical_sector_size); | ||
328 | |||
329 | if (s->params.block_size < VHDX_BLOCK_SIZE_MIN || | ||
330 | s->params.block_size > VHDX_BLOCK_SIZE_MAX) { | ||
331 | @@ -XXX,XX +XXX,XX @@ static int vhdx_open(BlockDriverState *bs, QDict *options, int flags, | ||
332 | /* endian convert, and verify populated BAT field file offsets against | ||
333 | * region table and log entries */ | ||
334 | for (i = 0; i < s->bat_entries; i++) { | ||
335 | - le64_to_cpus(&s->bat[i]); | ||
336 | + s->bat[i] = le64_to_cpu(s->bat[i]); | ||
337 | if (payblocks--) { | ||
338 | /* payload bat entries */ | ||
339 | if ((s->bat[i] & VHDX_BAT_STATE_BIT_MASK) == | ||
340 | @@ -XXX,XX +XXX,XX @@ static int vhdx_create_new_metadata(BlockBackend *blk, | ||
341 | mt_file_params->block_size = cpu_to_le32(block_size); | ||
342 | if (type == VHDX_TYPE_FIXED) { | ||
343 | mt_file_params->data_bits |= VHDX_PARAMS_LEAVE_BLOCKS_ALLOCED; | ||
344 | - cpu_to_le32s(&mt_file_params->data_bits); | ||
345 | + mt_file_params->data_bits = cpu_to_le32(mt_file_params->data_bits); | ||
346 | } | ||
347 | |||
348 | vhdx_guid_generate(&mt_page83->page_83_data); | ||
349 | @@ -XXX,XX +XXX,XX @@ static int vhdx_create_bat(BlockBackend *blk, BDRVVHDXState *s, | ||
350 | sinfo.file_offset = ROUND_UP(sinfo.file_offset, MiB); | ||
351 | vhdx_update_bat_table_entry(blk_bs(blk), s, &sinfo, &unused, &unused, | ||
352 | block_state); | ||
353 | - cpu_to_le64s(&s->bat[sinfo.bat_idx]); | ||
354 | + s->bat[sinfo.bat_idx] = cpu_to_le64(s->bat[sinfo.bat_idx]); | ||
355 | sector_num += s->sectors_per_block; | ||
356 | } | ||
357 | ret = blk_pwrite(blk, file_offset, s->bat, length, 0); | ||
358 | -- | 154 | -- |
359 | 2.19.1 | 155 | 2.40.1 |
360 | |||
361 | diff view generated by jsdifflib |
1 | Commit e2b8247a322 introduced an error path in qemu_rbd_open() after | 1 | This adds GRAPH_RDLOCK annotations to declare that functions accessing |
---|---|---|---|
2 | calling rbd_open(), but neglected to close the image again in this error | 2 | the parent list of a node need to hold a reader lock for the graph. As |
3 | path. The error path should contain everything that the regular close | 3 | it happens, they already do. |
4 | function qemu_rbd_close() contains. | ||
5 | |||
6 | This adds the missing rbd_close() call. | ||
7 | 4 | ||
8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
9 | Reviewed-by: Eric Blake <eblake@redhat.com> | 6 | Reviewed-by: Eric Blake <eblake@redhat.com> |
7 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
8 | Message-Id: <20230504115750.54437-12-kwolf@redhat.com> | ||
9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
10 | --- | 10 | --- |
11 | block/rbd.c | 1 + | 11 | block/vhdx.c | 9 +++++---- |
12 | 1 file changed, 1 insertion(+) | 12 | 1 file changed, 5 insertions(+), 4 deletions(-) |
13 | 13 | ||
14 | diff --git a/block/rbd.c b/block/rbd.c | 14 | diff --git a/block/vhdx.c b/block/vhdx.c |
15 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/block/rbd.c | 16 | --- a/block/vhdx.c |
17 | +++ b/block/rbd.c | 17 | +++ b/block/vhdx.c |
18 | @@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags, | 18 | @@ -XXX,XX +XXX,XX @@ exit: |
19 | "automatically marking the image read-only."); | 19 | * There are 2 headers, and the highest sequence number will represent |
20 | r = bdrv_set_read_only(bs, true, &local_err); | 20 | * the active header |
21 | if (r < 0) { | 21 | */ |
22 | + rbd_close(s->image); | 22 | -static int vhdx_create_new_headers(BlockBackend *blk, uint64_t image_size, |
23 | error_propagate(errp, local_err); | 23 | - uint32_t log_size) |
24 | goto failed_open; | 24 | +static int coroutine_fn GRAPH_RDLOCK |
25 | } | 25 | +vhdx_create_new_headers(BlockBackend *blk, uint64_t image_size, |
26 | + uint32_t log_size) | ||
27 | { | ||
28 | BlockDriverState *bs = blk_bs(blk); | ||
29 | BdrvChild *child; | ||
30 | @@ -XXX,XX +XXX,XX @@ exit: | ||
31 | * .---- ~ ----------- ~ ------------ ~ ---------------- ~ -----------. | ||
32 | * 1MB | ||
33 | */ | ||
34 | -static int coroutine_fn vhdx_co_create(BlockdevCreateOptions *opts, | ||
35 | - Error **errp) | ||
36 | +static int coroutine_fn GRAPH_RDLOCK | ||
37 | +vhdx_co_create(BlockdevCreateOptions *opts, Error **errp) | ||
38 | { | ||
39 | BlockdevCreateOptionsVhdx *vhdx_opts; | ||
40 | BlockBackend *blk = NULL; | ||
26 | -- | 41 | -- |
27 | 2.19.1 | 42 | 2.40.1 |
28 | |||
29 | diff view generated by jsdifflib |
1 | From: Cleber Rosa <crosa@redhat.com> | 1 | This adds GRAPH_RDLOCK annotations to declare that functions accessing |
---|---|---|---|
2 | the parent list of a node need to hold a reader lock for the graph. As | ||
3 | it happens, they already do. | ||
2 | 4 | ||
3 | While testing the Python 3 changes which touch the 083 test, I noticed | 5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
4 | that it would fail with qcow2. Expanding the testing, I noticed it | 6 | Message-Id: <20230504115750.54437-13-kwolf@redhat.com> |
5 | had nothing to do with the Python 3 changes, and in fact, it would not | 7 | Reviewed-by: Eric Blake <eblake@redhat.com> |
6 | pass on anything but raw: | 8 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> |
7 | |||
8 | raw: pass | ||
9 | bochs: not generic | ||
10 | cloop: not generic | ||
11 | parallels: fail | ||
12 | qcow: fail | ||
13 | qcow2: fail | ||
14 | qed: fail | ||
15 | vdi: fail | ||
16 | vhdx: fail | ||
17 | vmdk: fail | ||
18 | vpc: fail | ||
19 | luks: fail | ||
20 | |||
21 | The errors are a mixture I/O and "image not in xxx format", such as: | ||
22 | |||
23 | === Check disconnect before data === | ||
24 | |||
25 | Unexpected end-of-file before all bytes were read | ||
26 | -read failed: Input/output error | ||
27 | +can't open device nbd+tcp://127.0.0.1:PORT/foo: Could not open 'nbd://127.0.0.1:PORT/foo': Input/output error | ||
28 | |||
29 | === Check disconnect after data === | ||
30 | |||
31 | -read 512/512 bytes at offset 0 | ||
32 | -512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
33 | +can't open device nbd+tcp://127.0.0.1:PORT/foo: Image not in qcow format | ||
34 | |||
35 | I'm not aware if there's a quick fix, so, for the time being, it looks | ||
36 | like the honest approach is to make the test known to work on raw | ||
37 | only. | ||
38 | |||
39 | Signed-off-by: Cleber Rosa <crosa@redhat.com> | ||
40 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
41 | --- | 10 | --- |
42 | tests/qemu-iotests/083 | 2 +- | 11 | block/mirror.c | 2 +- |
43 | 1 file changed, 1 insertion(+), 1 deletion(-) | 12 | 1 file changed, 1 insertion(+), 1 deletion(-) |
44 | 13 | ||
45 | diff --git a/tests/qemu-iotests/083 b/tests/qemu-iotests/083 | 14 | diff --git a/block/mirror.c b/block/mirror.c |
46 | index XXXXXXX..XXXXXXX 100755 | 15 | index XXXXXXX..XXXXXXX 100644 |
47 | --- a/tests/qemu-iotests/083 | 16 | --- a/block/mirror.c |
48 | +++ b/tests/qemu-iotests/083 | 17 | +++ b/block/mirror.c |
49 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | 18 | @@ -XXX,XX +XXX,XX @@ static MirrorOp *coroutine_fn active_write_prepare(MirrorBlockJob *s, |
50 | . ./common.rc | 19 | return op; |
51 | . ./common.filter | 20 | } |
52 | 21 | ||
53 | -_supported_fmt generic | 22 | -static void coroutine_fn active_write_settle(MirrorOp *op) |
54 | +_supported_fmt raw | 23 | +static void coroutine_fn GRAPH_RDLOCK active_write_settle(MirrorOp *op) |
55 | _supported_proto nbd | 24 | { |
56 | _supported_os Linux | 25 | uint64_t start_chunk = op->offset / op->s->granularity; |
57 | 26 | uint64_t end_chunk = DIV_ROUND_UP(op->offset + op->bytes, | |
58 | -- | 27 | -- |
59 | 2.19.1 | 28 | 2.40.1 |
60 | |||
61 | diff view generated by jsdifflib |
1 | From: Alberto Garcia <berto@igalia.com> | 1 | From: Emanuele Giuseppe Esposito <eesposit@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Alberto Garcia <berto@igalia.com> | 3 | This adds GRAPH_RDLOCK annotations to declare that callers of |
4 | bdrv_co_get_allocated_file_size() need to hold a reader lock for the | ||
5 | graph. | ||
6 | |||
7 | Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> | ||
8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
9 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
10 | Message-Id: <20230504115750.54437-14-kwolf@redhat.com> | ||
11 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 12 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
5 | --- | 13 | --- |
6 | block.c | 6 +++--- | 14 | include/block/block-io.h | 7 +++++-- |
7 | 1 file changed, 3 insertions(+), 3 deletions(-) | 15 | include/block/block_int-common.h | 2 +- |
16 | block.c | 4 +++- | ||
17 | block/vmdk.c | 2 +- | ||
18 | 4 files changed, 10 insertions(+), 5 deletions(-) | ||
8 | 19 | ||
20 | diff --git a/include/block/block-io.h b/include/block/block-io.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/include/block/block-io.h | ||
23 | +++ b/include/block/block-io.h | ||
24 | @@ -XXX,XX +XXX,XX @@ int64_t coroutine_mixed_fn bdrv_nb_sectors(BlockDriverState *bs); | ||
25 | int64_t coroutine_fn GRAPH_RDLOCK bdrv_co_getlength(BlockDriverState *bs); | ||
26 | int64_t co_wrapper_mixed_bdrv_rdlock bdrv_getlength(BlockDriverState *bs); | ||
27 | |||
28 | -int64_t coroutine_fn bdrv_co_get_allocated_file_size(BlockDriverState *bs); | ||
29 | -int64_t co_wrapper bdrv_get_allocated_file_size(BlockDriverState *bs); | ||
30 | +int64_t coroutine_fn GRAPH_RDLOCK | ||
31 | +bdrv_co_get_allocated_file_size(BlockDriverState *bs); | ||
32 | + | ||
33 | +int64_t co_wrapper_bdrv_rdlock | ||
34 | +bdrv_get_allocated_file_size(BlockDriverState *bs); | ||
35 | |||
36 | BlockMeasureInfo *bdrv_measure(BlockDriver *drv, QemuOpts *opts, | ||
37 | BlockDriverState *in_bs, Error **errp); | ||
38 | diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/include/block/block_int-common.h | ||
41 | +++ b/include/block/block_int-common.h | ||
42 | @@ -XXX,XX +XXX,XX @@ struct BlockDriver { | ||
43 | int64_t coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_getlength)( | ||
44 | BlockDriverState *bs); | ||
45 | |||
46 | - int64_t coroutine_fn (*bdrv_co_get_allocated_file_size)( | ||
47 | + int64_t coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_get_allocated_file_size)( | ||
48 | BlockDriverState *bs); | ||
49 | |||
50 | BlockMeasureInfo *(*bdrv_measure)(QemuOpts *opts, BlockDriverState *in_bs, | ||
9 | diff --git a/block.c b/block.c | 51 | diff --git a/block.c b/block.c |
10 | index XXXXXXX..XXXXXXX 100644 | 52 | index XXXXXXX..XXXXXXX 100644 |
11 | --- a/block.c | 53 | --- a/block.c |
12 | +++ b/block.c | 54 | +++ b/block.c |
13 | @@ -XXX,XX +XXX,XX @@ QemuOptsList bdrv_runtime_opts = { | 55 | @@ -XXX,XX +XXX,XX @@ exit: |
14 | .help = "try to optimize zero writes (off, on, unmap)", | 56 | * sums the size of all data-bearing children. (This excludes backing |
15 | }, | 57 | * children.) |
16 | { | 58 | */ |
17 | - .name = "discard", | 59 | -static int64_t coroutine_fn bdrv_sum_allocated_file_size(BlockDriverState *bs) |
18 | + .name = BDRV_OPT_DISCARD, | 60 | +static int64_t coroutine_fn GRAPH_RDLOCK |
19 | .type = QEMU_OPT_STRING, | 61 | +bdrv_sum_allocated_file_size(BlockDriverState *bs) |
20 | .help = "discard operation (ignore/off, unmap/on)", | 62 | { |
21 | }, | 63 | BdrvChild *child; |
22 | @@ -XXX,XX +XXX,XX @@ static int bdrv_open_common(BlockDriverState *bs, BlockBackend *file, | 64 | int64_t child_size, sum = 0; |
23 | } | 65 | @@ -XXX,XX +XXX,XX @@ int64_t coroutine_fn bdrv_co_get_allocated_file_size(BlockDriverState *bs) |
24 | } | 66 | { |
25 | 67 | BlockDriver *drv = bs->drv; | |
26 | - discard = qemu_opt_get(opts, "discard"); | 68 | IO_CODE(); |
27 | + discard = qemu_opt_get(opts, BDRV_OPT_DISCARD); | 69 | + assert_bdrv_graph_readable(); |
28 | if (discard != NULL) { | 70 | |
29 | if (bdrv_parse_discard_flags(discard, &bs->open_flags) != 0) { | 71 | if (!drv) { |
30 | error_setg(errp, "Invalid discard option"); | 72 | return -ENOMEDIUM; |
31 | @@ -XXX,XX +XXX,XX @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue, | 73 | diff --git a/block/vmdk.c b/block/vmdk.c |
32 | 74 | index XXXXXXX..XXXXXXX 100644 | |
33 | update_flags_from_options(&reopen_state->flags, opts); | 75 | --- a/block/vmdk.c |
34 | 76 | +++ b/block/vmdk.c | |
35 | - discard = qemu_opt_get_del(opts, "discard"); | 77 | @@ -XXX,XX +XXX,XX @@ static void vmdk_close(BlockDriverState *bs) |
36 | + discard = qemu_opt_get_del(opts, BDRV_OPT_DISCARD); | 78 | error_free(s->migration_blocker); |
37 | if (discard != NULL) { | 79 | } |
38 | if (bdrv_parse_discard_flags(discard, &reopen_state->flags) != 0) { | 80 | |
39 | error_setg(errp, "Invalid discard option"); | 81 | -static int64_t coroutine_fn |
82 | +static int64_t coroutine_fn GRAPH_RDLOCK | ||
83 | vmdk_co_get_allocated_file_size(BlockDriverState *bs) | ||
84 | { | ||
85 | int i; | ||
40 | -- | 86 | -- |
41 | 2.19.1 | 87 | 2.40.1 |
42 | |||
43 | diff view generated by jsdifflib |
1 | Some block drivers have traditionally changed their node to read-only | 1 | From: Emanuele Giuseppe Esposito <eesposit@redhat.com> |
---|---|---|---|
2 | mode without asking the user. This behaviour has been marked deprecated | ||
3 | since 2.11, expecting users to provide an explicit read-only=on option. | ||
4 | 2 | ||
5 | Now that we have auto-read-only=on, enable these drivers to make use of | 3 | This adds GRAPH_RDLOCK annotations to declare that callers of |
6 | the option. | 4 | bdrv_co_get_info() need to hold a reader lock for the graph. |
7 | 5 | ||
8 | This is the only use of bdrv_set_read_only(), so we can make it a bit | 6 | Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> |
9 | more specific and turn it into a bdrv_apply_auto_read_only() that is | ||
10 | more convenient for drivers to use. | ||
11 | |||
12 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 7 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
13 | Reviewed-by: Eric Blake <eblake@redhat.com> | 8 | Reviewed-by: Eric Blake <eblake@redhat.com> |
9 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
10 | Message-Id: <20230504115750.54437-15-kwolf@redhat.com> | ||
11 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
14 | --- | 12 | --- |
15 | include/block/block.h | 3 ++- | 13 | include/block/block-io.h | 7 +++++-- |
16 | block.c | 42 +++++++++++++++++++++++++++--------------- | 14 | include/block/block_int-common.h | 4 ++-- |
17 | block/bochs.c | 17 ++++++----------- | 15 | block.c | 2 ++ |
18 | block/cloop.c | 16 +++++----------- | 16 | block/crypto.c | 2 +- |
19 | block/dmg.c | 16 +++++----------- | 17 | block/io.c | 11 +++++------ |
20 | block/rbd.c | 15 ++++----------- | 18 | block/mirror.c | 8 ++++++-- |
21 | block/vvfat.c | 10 ++-------- | 19 | block/raw-format.c | 2 +- |
22 | 7 files changed, 51 insertions(+), 68 deletions(-) | 20 | 7 files changed, 22 insertions(+), 14 deletions(-) |
23 | 21 | ||
24 | diff --git a/include/block/block.h b/include/block/block.h | 22 | diff --git a/include/block/block-io.h b/include/block/block-io.h |
25 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/block/block.h | 24 | --- a/include/block/block-io.h |
27 | +++ b/include/block/block.h | 25 | +++ b/include/block/block-io.h |
28 | @@ -XXX,XX +XXX,XX @@ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base, | 26 | @@ -XXX,XX +XXX,XX @@ const char *bdrv_get_node_name(const BlockDriverState *bs); |
29 | bool bdrv_is_read_only(BlockDriverState *bs); | 27 | const char *bdrv_get_device_name(const BlockDriverState *bs); |
30 | int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, | 28 | const char *bdrv_get_device_or_node_name(const BlockDriverState *bs); |
31 | bool ignore_allow_rdw, Error **errp); | 29 | |
32 | -int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp); | 30 | -int coroutine_fn bdrv_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi); |
33 | +int bdrv_apply_auto_read_only(BlockDriverState *bs, const char *errmsg, | 31 | -int co_wrapper_mixed bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi); |
34 | + Error **errp); | 32 | +int coroutine_fn GRAPH_RDLOCK |
35 | bool bdrv_is_writable(BlockDriverState *bs); | 33 | +bdrv_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi); |
36 | bool bdrv_is_sg(BlockDriverState *bs); | 34 | + |
37 | bool bdrv_is_inserted(BlockDriverState *bs); | 35 | +int co_wrapper_mixed_bdrv_rdlock |
36 | +bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi); | ||
37 | |||
38 | ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs, | ||
39 | Error **errp); | ||
40 | diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/include/block/block_int-common.h | ||
43 | +++ b/include/block/block_int-common.h | ||
44 | @@ -XXX,XX +XXX,XX @@ struct BlockDriver { | ||
45 | BlockDriverState *bs, int64_t offset, int64_t bytes, | ||
46 | QEMUIOVector *qiov, size_t qiov_offset); | ||
47 | |||
48 | - int coroutine_fn (*bdrv_co_get_info)(BlockDriverState *bs, | ||
49 | - BlockDriverInfo *bdi); | ||
50 | + int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_get_info)( | ||
51 | + BlockDriverState *bs, BlockDriverInfo *bdi); | ||
52 | |||
53 | ImageInfoSpecific *(*bdrv_get_specific_info)(BlockDriverState *bs, | ||
54 | Error **errp); | ||
38 | diff --git a/block.c b/block.c | 55 | diff --git a/block.c b/block.c |
39 | index XXXXXXX..XXXXXXX 100644 | 56 | index XXXXXXX..XXXXXXX 100644 |
40 | --- a/block.c | 57 | --- a/block.c |
41 | +++ b/block.c | 58 | +++ b/block.c |
42 | @@ -XXX,XX +XXX,XX @@ int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, | 59 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) |
43 | return 0; | 60 | int ret; |
61 | BlockDriver *drv = bs->drv; | ||
62 | IO_CODE(); | ||
63 | + assert_bdrv_graph_readable(); | ||
64 | + | ||
65 | /* if bs->drv == NULL, bs is closed, so there's nothing to do here */ | ||
66 | if (!drv) { | ||
67 | return -ENOMEDIUM; | ||
68 | diff --git a/block/crypto.c b/block/crypto.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/block/crypto.c | ||
71 | +++ b/block/crypto.c | ||
72 | @@ -XXX,XX +XXX,XX @@ fail: | ||
73 | return ret; | ||
44 | } | 74 | } |
45 | 75 | ||
46 | -/* TODO Remove (deprecated since 2.11) | 76 | -static int coroutine_fn |
47 | - * Block drivers are not supposed to automatically change bs->read_only. | 77 | +static int coroutine_fn GRAPH_RDLOCK |
48 | - * Instead, they should just check whether they can provide what the user | 78 | block_crypto_co_get_info_luks(BlockDriverState *bs, BlockDriverInfo *bdi) |
49 | - * explicitly requested and error out if read-write is requested, but they can | ||
50 | - * only provide read-only access. */ | ||
51 | -int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp) | ||
52 | +/* | ||
53 | + * Called by a driver that can only provide a read-only image. | ||
54 | + * | ||
55 | + * Returns 0 if the node is already read-only or it could switch the node to | ||
56 | + * read-only because BDRV_O_AUTO_RDONLY is set. | ||
57 | + * | ||
58 | + * Returns -EACCES if the node is read-write and BDRV_O_AUTO_RDONLY is not set | ||
59 | + * or bdrv_can_set_read_only() forbids making the node read-only. If @errmsg | ||
60 | + * is not NULL, it is used as the error message for the Error object. | ||
61 | + */ | ||
62 | +int bdrv_apply_auto_read_only(BlockDriverState *bs, const char *errmsg, | ||
63 | + Error **errp) | ||
64 | { | 79 | { |
65 | int ret = 0; | 80 | BlockDriverInfo subbdi; |
66 | 81 | diff --git a/block/io.c b/block/io.c | |
67 | - ret = bdrv_can_set_read_only(bs, read_only, false, errp); | 82 | index XXXXXXX..XXXXXXX 100644 |
68 | - if (ret < 0) { | 83 | --- a/block/io.c |
69 | - return ret; | 84 | +++ b/block/io.c |
70 | + if (!(bs->open_flags & BDRV_O_RDWR)) { | 85 | @@ -XXX,XX +XXX,XX @@ BdrvTrackedRequest *coroutine_fn bdrv_co_get_self_request(BlockDriverState *bs) |
71 | + return 0; | 86 | /** |
72 | + } | 87 | * Round a region to cluster boundaries |
73 | + if (!(bs->open_flags & BDRV_O_AUTO_RDONLY)) { | 88 | */ |
74 | + goto fail; | 89 | -void coroutine_fn bdrv_round_to_clusters(BlockDriverState *bs, |
90 | - int64_t offset, int64_t bytes, | ||
91 | - int64_t *cluster_offset, | ||
92 | - int64_t *cluster_bytes) | ||
93 | +void coroutine_fn GRAPH_RDLOCK | ||
94 | +bdrv_round_to_clusters(BlockDriverState *bs, int64_t offset, int64_t bytes, | ||
95 | + int64_t *cluster_offset, int64_t *cluster_bytes) | ||
96 | { | ||
97 | BlockDriverInfo bdi; | ||
98 | IO_CODE(); | ||
99 | @@ -XXX,XX +XXX,XX @@ void coroutine_fn bdrv_round_to_clusters(BlockDriverState *bs, | ||
75 | } | 100 | } |
76 | 101 | } | |
77 | - bs->read_only = read_only; | 102 | |
78 | - | 103 | -static coroutine_fn int bdrv_get_cluster_size(BlockDriverState *bs) |
79 | - if (read_only) { | 104 | +static int coroutine_fn GRAPH_RDLOCK bdrv_get_cluster_size(BlockDriverState *bs) |
80 | - bs->open_flags &= ~BDRV_O_RDWR; | 105 | { |
81 | - } else { | 106 | BlockDriverInfo bdi; |
82 | - bs->open_flags |= BDRV_O_RDWR; | 107 | int ret; |
83 | + ret = bdrv_can_set_read_only(bs, true, false, NULL); | 108 | @@ -XXX,XX +XXX,XX @@ fail: |
84 | + if (ret < 0) { | 109 | return ret; |
85 | + goto fail; | 110 | } |
111 | |||
112 | -static inline int coroutine_fn | ||
113 | +static inline int coroutine_fn GRAPH_RDLOCK | ||
114 | bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, int64_t bytes, | ||
115 | BdrvTrackedRequest *req, int flags) | ||
116 | { | ||
117 | diff --git a/block/mirror.c b/block/mirror.c | ||
118 | index XXXXXXX..XXXXXXX 100644 | ||
119 | --- a/block/mirror.c | ||
120 | +++ b/block/mirror.c | ||
121 | @@ -XXX,XX +XXX,XX @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) | ||
122 | } else if (ret >= 0 && !(ret & BDRV_BLOCK_DATA)) { | ||
123 | int64_t target_offset; | ||
124 | int64_t target_bytes; | ||
125 | - bdrv_round_to_clusters(blk_bs(s->target), offset, io_bytes, | ||
126 | - &target_offset, &target_bytes); | ||
127 | + WITH_GRAPH_RDLOCK_GUARD() { | ||
128 | + bdrv_round_to_clusters(blk_bs(s->target), offset, io_bytes, | ||
129 | + &target_offset, &target_bytes); | ||
130 | + } | ||
131 | if (target_offset == offset && | ||
132 | target_bytes == io_bytes) { | ||
133 | mirror_method = ret & BDRV_BLOCK_ZERO ? | ||
134 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn mirror_run(Job *job, Error **errp) | ||
135 | */ | ||
136 | bdrv_get_backing_filename(target_bs, backing_filename, | ||
137 | sizeof(backing_filename)); | ||
138 | + bdrv_graph_co_rdlock(); | ||
139 | if (!bdrv_co_get_info(target_bs, &bdi) && bdi.cluster_size) { | ||
140 | s->target_cluster_size = bdi.cluster_size; | ||
141 | } else { | ||
142 | s->target_cluster_size = BDRV_SECTOR_SIZE; | ||
86 | } | 143 | } |
87 | 144 | + bdrv_graph_co_rdunlock(); | |
88 | + bs->read_only = true; | 145 | if (backing_filename[0] && !bdrv_backing_chain_next(target_bs) && |
89 | + bs->open_flags &= ~BDRV_O_RDWR; | 146 | s->granularity < s->target_cluster_size) { |
90 | + | 147 | s->buf_size = MAX(s->buf_size, s->target_cluster_size); |
91 | return 0; | 148 | diff --git a/block/raw-format.c b/block/raw-format.c |
92 | + | 149 | index XXXXXXX..XXXXXXX 100644 |
93 | +fail: | 150 | --- a/block/raw-format.c |
94 | + error_setg(errp, "%s", errmsg ?: "Image is read-only"); | 151 | +++ b/block/raw-format.c |
95 | + return -EACCES; | 152 | @@ -XXX,XX +XXX,XX @@ static BlockMeasureInfo *raw_measure(QemuOpts *opts, BlockDriverState *in_bs, |
153 | return info; | ||
96 | } | 154 | } |
97 | 155 | ||
98 | void bdrv_get_full_backing_filename_from_filename(const char *backed, | 156 | -static int coroutine_fn |
99 | diff --git a/block/bochs.c b/block/bochs.c | 157 | +static int coroutine_fn GRAPH_RDLOCK |
100 | index XXXXXXX..XXXXXXX 100644 | 158 | raw_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) |
101 | --- a/block/bochs.c | 159 | { |
102 | +++ b/block/bochs.c | 160 | return bdrv_co_get_info(bs->file->bs, bdi); |
103 | @@ -XXX,XX +XXX,XX @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags, | ||
104 | struct bochs_header bochs; | ||
105 | int ret; | ||
106 | |||
107 | + /* No write support yet */ | ||
108 | + ret = bdrv_apply_auto_read_only(bs, NULL, errp); | ||
109 | + if (ret < 0) { | ||
110 | + return ret; | ||
111 | + } | ||
112 | + | ||
113 | bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, | ||
114 | false, errp); | ||
115 | if (!bs->file) { | ||
116 | return -EINVAL; | ||
117 | } | ||
118 | |||
119 | - if (!bdrv_is_read_only(bs)) { | ||
120 | - error_report("Opening bochs images without an explicit read-only=on " | ||
121 | - "option is deprecated. Future versions will refuse to " | ||
122 | - "open the image instead of automatically marking the " | ||
123 | - "image read-only."); | ||
124 | - ret = bdrv_set_read_only(bs, true, errp); /* no write support yet */ | ||
125 | - if (ret < 0) { | ||
126 | - return ret; | ||
127 | - } | ||
128 | - } | ||
129 | - | ||
130 | ret = bdrv_pread(bs->file, 0, &bochs, sizeof(bochs)); | ||
131 | if (ret < 0) { | ||
132 | return ret; | ||
133 | diff --git a/block/cloop.c b/block/cloop.c | ||
134 | index XXXXXXX..XXXXXXX 100644 | ||
135 | --- a/block/cloop.c | ||
136 | +++ b/block/cloop.c | ||
137 | @@ -XXX,XX +XXX,XX @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags, | ||
138 | uint32_t offsets_size, max_compressed_block_size = 1, i; | ||
139 | int ret; | ||
140 | |||
141 | + ret = bdrv_apply_auto_read_only(bs, NULL, errp); | ||
142 | + if (ret < 0) { | ||
143 | + return ret; | ||
144 | + } | ||
145 | + | ||
146 | bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, | ||
147 | false, errp); | ||
148 | if (!bs->file) { | ||
149 | return -EINVAL; | ||
150 | } | ||
151 | |||
152 | - if (!bdrv_is_read_only(bs)) { | ||
153 | - error_report("Opening cloop images without an explicit read-only=on " | ||
154 | - "option is deprecated. Future versions will refuse to " | ||
155 | - "open the image instead of automatically marking the " | ||
156 | - "image read-only."); | ||
157 | - ret = bdrv_set_read_only(bs, true, errp); | ||
158 | - if (ret < 0) { | ||
159 | - return ret; | ||
160 | - } | ||
161 | - } | ||
162 | - | ||
163 | /* read header */ | ||
164 | ret = bdrv_pread(bs->file, 128, &s->block_size, 4); | ||
165 | if (ret < 0) { | ||
166 | diff --git a/block/dmg.c b/block/dmg.c | ||
167 | index XXXXXXX..XXXXXXX 100644 | ||
168 | --- a/block/dmg.c | ||
169 | +++ b/block/dmg.c | ||
170 | @@ -XXX,XX +XXX,XX @@ static int dmg_open(BlockDriverState *bs, QDict *options, int flags, | ||
171 | int64_t offset; | ||
172 | int ret; | ||
173 | |||
174 | + ret = bdrv_apply_auto_read_only(bs, NULL, errp); | ||
175 | + if (ret < 0) { | ||
176 | + return ret; | ||
177 | + } | ||
178 | + | ||
179 | bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, | ||
180 | false, errp); | ||
181 | if (!bs->file) { | ||
182 | return -EINVAL; | ||
183 | } | ||
184 | |||
185 | - if (!bdrv_is_read_only(bs)) { | ||
186 | - error_report("Opening dmg images without an explicit read-only=on " | ||
187 | - "option is deprecated. Future versions will refuse to " | ||
188 | - "open the image instead of automatically marking the " | ||
189 | - "image read-only."); | ||
190 | - ret = bdrv_set_read_only(bs, true, errp); | ||
191 | - if (ret < 0) { | ||
192 | - return ret; | ||
193 | - } | ||
194 | - } | ||
195 | - | ||
196 | block_module_load_one("dmg-bz2"); | ||
197 | |||
198 | s->n_chunks = 0; | ||
199 | diff --git a/block/rbd.c b/block/rbd.c | ||
200 | index XXXXXXX..XXXXXXX 100644 | ||
201 | --- a/block/rbd.c | ||
202 | +++ b/block/rbd.c | ||
203 | @@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags, | ||
204 | /* If we are using an rbd snapshot, we must be r/o, otherwise | ||
205 | * leave as-is */ | ||
206 | if (s->snap != NULL) { | ||
207 | - if (!bdrv_is_read_only(bs)) { | ||
208 | - error_report("Opening rbd snapshots without an explicit " | ||
209 | - "read-only=on option is deprecated. Future versions " | ||
210 | - "will refuse to open the image instead of " | ||
211 | - "automatically marking the image read-only."); | ||
212 | - r = bdrv_set_read_only(bs, true, &local_err); | ||
213 | - if (r < 0) { | ||
214 | - rbd_close(s->image); | ||
215 | - error_propagate(errp, local_err); | ||
216 | - goto failed_open; | ||
217 | - } | ||
218 | + r = bdrv_apply_auto_read_only(bs, "rbd snapshots are read-only", errp); | ||
219 | + if (r < 0) { | ||
220 | + rbd_close(s->image); | ||
221 | + goto failed_open; | ||
222 | } | ||
223 | } | ||
224 | |||
225 | diff --git a/block/vvfat.c b/block/vvfat.c | ||
226 | index XXXXXXX..XXXXXXX 100644 | ||
227 | --- a/block/vvfat.c | ||
228 | +++ b/block/vvfat.c | ||
229 | @@ -XXX,XX +XXX,XX @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags, | ||
230 | "Unable to set VVFAT to 'rw' when drive is read-only"); | ||
231 | goto fail; | ||
232 | } | ||
233 | - } else if (!bdrv_is_read_only(bs)) { | ||
234 | - error_report("Opening non-rw vvfat images without an explicit " | ||
235 | - "read-only=on option is deprecated. Future versions " | ||
236 | - "will refuse to open the image instead of " | ||
237 | - "automatically marking the image read-only."); | ||
238 | - /* read only is the default for safety */ | ||
239 | - ret = bdrv_set_read_only(bs, true, &local_err); | ||
240 | + } else { | ||
241 | + ret = bdrv_apply_auto_read_only(bs, NULL, errp); | ||
242 | if (ret < 0) { | ||
243 | - error_propagate(errp, local_err); | ||
244 | goto fail; | ||
245 | } | ||
246 | } | ||
247 | -- | 161 | -- |
248 | 2.19.1 | 162 | 2.40.1 |
249 | |||
250 | diff view generated by jsdifflib |
1 | From: Stefan Weil <sw@weilnetz.de> | 1 | From: Emanuele Giuseppe Esposito <eesposit@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Use %zu instead of %zd for unsigned numbers. | 3 | This adds GRAPH_RDLOCK annotations to declare that callers of |
4 | bdrv_co_debug_event() need to hold a reader lock for the graph. | ||
4 | 5 | ||
5 | This fixes two error messages from the LSTM static code analyzer: | 6 | Unfortunately we cannot use a co_wrapper_bdrv_rdlock (i.e. make the |
7 | coroutine wrapper a no_coroutine_fn), because the function is called | ||
8 | (using the BLKDBG_EVENT macro) by mixed functions that run both in | ||
9 | coroutine and non-coroutine context (for example many of the functions | ||
10 | in qcow2-cluster.c and qcow2-refcount.c). | ||
6 | 11 | ||
7 | This argument should be of type 'ssize_t' but is of type 'unsigned long' | 12 | Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> |
8 | 13 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | |
9 | Signed-off-by: Stefan Weil <sw@weilnetz.de> | 14 | Reviewed-by: Eric Blake <eblake@redhat.com> |
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 15 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> |
16 | Message-Id: <20230504115750.54437-16-kwolf@redhat.com> | ||
11 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 17 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
12 | --- | 18 | --- |
13 | qemu-io-cmds.c | 4 ++-- | 19 | include/block/block-io.h | 9 +++++---- |
14 | 1 file changed, 2 insertions(+), 2 deletions(-) | 20 | include/block/block_int-common.h | 4 ++-- |
21 | block.c | 2 ++ | ||
22 | 3 files changed, 9 insertions(+), 6 deletions(-) | ||
15 | 23 | ||
16 | diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c | 24 | diff --git a/include/block/block-io.h b/include/block/block-io.h |
17 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/qemu-io-cmds.c | 26 | --- a/include/block/block-io.h |
19 | +++ b/qemu-io-cmds.c | 27 | +++ b/include/block/block-io.h |
20 | @@ -XXX,XX +XXX,XX @@ static int readv_f(BlockBackend *blk, int argc, char **argv) | 28 | @@ -XXX,XX +XXX,XX @@ void *qemu_try_blockalign0(BlockDriverState *bs, size_t size); |
21 | memset(cmp_buf, pattern, qiov.size); | 29 | void bdrv_enable_copy_on_read(BlockDriverState *bs); |
22 | if (memcmp(buf, cmp_buf, qiov.size)) { | 30 | void bdrv_disable_copy_on_read(BlockDriverState *bs); |
23 | printf("Pattern verification failed at offset %" | 31 | |
24 | - PRId64 ", %zd bytes\n", offset, qiov.size); | 32 | -void coroutine_fn bdrv_co_debug_event(BlockDriverState *bs, |
25 | + PRId64 ", %zu bytes\n", offset, qiov.size); | 33 | - BlkdebugEvent event); |
26 | ret = -EINVAL; | 34 | -void co_wrapper_mixed bdrv_debug_event(BlockDriverState *bs, |
27 | } | 35 | - BlkdebugEvent event); |
28 | g_free(cmp_buf); | 36 | +void coroutine_fn GRAPH_RDLOCK |
29 | @@ -XXX,XX +XXX,XX @@ static void aio_read_done(void *opaque, int ret) | 37 | +bdrv_co_debug_event(BlockDriverState *bs, BlkdebugEvent event); |
30 | memset(cmp_buf, ctx->pattern, ctx->qiov.size); | 38 | + |
31 | if (memcmp(ctx->buf, cmp_buf, ctx->qiov.size)) { | 39 | +void co_wrapper_mixed_bdrv_rdlock |
32 | printf("Pattern verification failed at offset %" | 40 | +bdrv_debug_event(BlockDriverState *bs, BlkdebugEvent event); |
33 | - PRId64 ", %zd bytes\n", ctx->offset, ctx->qiov.size); | 41 | |
34 | + PRId64 ", %zu bytes\n", ctx->offset, ctx->qiov.size); | 42 | #define BLKDBG_EVENT(child, evt) \ |
35 | } | 43 | do { \ |
36 | g_free(cmp_buf); | 44 | diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h |
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/include/block/block_int-common.h | ||
47 | +++ b/include/block/block_int-common.h | ||
48 | @@ -XXX,XX +XXX,XX @@ struct BlockDriver { | ||
49 | int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_check)( | ||
50 | BlockDriverState *bs, BdrvCheckResult *result, BdrvCheckMode fix); | ||
51 | |||
52 | - void coroutine_fn (*bdrv_co_debug_event)(BlockDriverState *bs, | ||
53 | - BlkdebugEvent event); | ||
54 | + void coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_debug_event)( | ||
55 | + BlockDriverState *bs, BlkdebugEvent event); | ||
56 | |||
57 | /* io queue for linux-aio */ | ||
58 | void coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_io_plug)(BlockDriverState *bs); | ||
59 | diff --git a/block.c b/block.c | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/block.c | ||
62 | +++ b/block.c | ||
63 | @@ -XXX,XX +XXX,XX @@ BlockStatsSpecific *bdrv_get_specific_stats(BlockDriverState *bs) | ||
64 | void coroutine_fn bdrv_co_debug_event(BlockDriverState *bs, BlkdebugEvent event) | ||
65 | { | ||
66 | IO_CODE(); | ||
67 | + assert_bdrv_graph_readable(); | ||
68 | + | ||
69 | if (!bs || !bs->drv || !bs->drv->bdrv_co_debug_event) { | ||
70 | return; | ||
37 | } | 71 | } |
38 | -- | 72 | -- |
39 | 2.19.1 | 73 | 2.40.1 |
40 | |||
41 | diff view generated by jsdifflib |
1 | From: Max Reitz <mreitz@redhat.com> | 1 | From: Emanuele Giuseppe Esposito <eesposit@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Following the example of qemu_opts_print_help(), indent all entries in | 3 | This adds GRAPH_RDLOCK annotations to declare that callers of amend |
4 | the list of character devices. | 4 | callbacks in BlockDriver need to hold a reader lock for the graph. |
5 | 5 | ||
6 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 6 | Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> |
7 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | 7 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
8 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
9 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
10 | Message-Id: <20230504115750.54437-17-kwolf@redhat.com> | ||
8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 11 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
9 | --- | 12 | --- |
10 | chardev/char.c | 2 +- | 13 | include/block/block_int-common.h | 12 ++++++------ |
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | 14 | block/amend.c | 8 +++++++- |
15 | 2 files changed, 13 insertions(+), 7 deletions(-) | ||
12 | 16 | ||
13 | diff --git a/chardev/char.c b/chardev/char.c | 17 | diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h |
14 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/chardev/char.c | 19 | --- a/include/block/block_int-common.h |
16 | +++ b/chardev/char.c | 20 | +++ b/include/block/block_int-common.h |
17 | @@ -XXX,XX +XXX,XX @@ help_string_append(const char *name, void *opaque) | 21 | @@ -XXX,XX +XXX,XX @@ struct BlockDriver { |
22 | * to allow driver-specific initialization code that requires | ||
23 | * the BQL, like setting up specific permission flags. | ||
24 | */ | ||
25 | - int (*bdrv_amend_pre_run)(BlockDriverState *bs, Error **errp); | ||
26 | + int GRAPH_RDLOCK_PTR (*bdrv_amend_pre_run)( | ||
27 | + BlockDriverState *bs, Error **errp); | ||
28 | /* | ||
29 | * This function is invoked under BQL after .bdrv_co_amend() | ||
30 | * to allow cleaning up what was done in .bdrv_amend_pre_run(). | ||
31 | */ | ||
32 | - void (*bdrv_amend_clean)(BlockDriverState *bs); | ||
33 | + void GRAPH_RDLOCK_PTR (*bdrv_amend_clean)(BlockDriverState *bs); | ||
34 | |||
35 | /* | ||
36 | * Return true if @to_replace can be replaced by a BDS with the | ||
37 | @@ -XXX,XX +XXX,XX @@ struct BlockDriver { | ||
38 | |||
39 | int (*bdrv_probe)(const uint8_t *buf, int buf_size, const char *filename); | ||
40 | |||
41 | - int coroutine_fn (*bdrv_co_amend)(BlockDriverState *bs, | ||
42 | - BlockdevAmendOptions *opts, | ||
43 | - bool force, | ||
44 | - Error **errp); | ||
45 | + int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_amend)( | ||
46 | + BlockDriverState *bs, BlockdevAmendOptions *opts, bool force, | ||
47 | + Error **errp); | ||
48 | |||
49 | /* aio */ | ||
50 | BlockAIOCB * GRAPH_RDLOCK_PTR (*bdrv_aio_preadv)(BlockDriverState *bs, | ||
51 | diff --git a/block/amend.c b/block/amend.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/block/amend.c | ||
54 | +++ b/block/amend.c | ||
55 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn blockdev_amend_run(Job *job, Error **errp) | ||
18 | { | 56 | { |
19 | GString *str = opaque; | 57 | BlockdevAmendJob *s = container_of(job, BlockdevAmendJob, common); |
20 | 58 | int ret; | |
21 | - g_string_append_printf(str, "\n%s", name); | 59 | + GRAPH_RDLOCK_GUARD(); |
22 | + g_string_append_printf(str, "\n %s", name); | 60 | |
61 | job_progress_set_remaining(&s->common, 1); | ||
62 | ret = s->bs->drv->bdrv_co_amend(s->bs, s->opts, s->force, errp); | ||
63 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn blockdev_amend_run(Job *job, Error **errp) | ||
64 | return ret; | ||
23 | } | 65 | } |
24 | 66 | ||
25 | static const char *chardev_alias_translate(const char *name) | 67 | -static int blockdev_amend_pre_run(BlockdevAmendJob *s, Error **errp) |
68 | +static int GRAPH_RDLOCK | ||
69 | +blockdev_amend_pre_run(BlockdevAmendJob *s, Error **errp) | ||
70 | { | ||
71 | if (s->bs->drv->bdrv_amend_pre_run) { | ||
72 | return s->bs->drv->bdrv_amend_pre_run(s->bs, errp); | ||
73 | @@ -XXX,XX +XXX,XX @@ static void blockdev_amend_free(Job *job) | ||
74 | { | ||
75 | BlockdevAmendJob *s = container_of(job, BlockdevAmendJob, common); | ||
76 | |||
77 | + bdrv_graph_rdlock_main_loop(); | ||
78 | if (s->bs->drv->bdrv_amend_clean) { | ||
79 | s->bs->drv->bdrv_amend_clean(s->bs); | ||
80 | } | ||
81 | + bdrv_graph_rdunlock_main_loop(); | ||
82 | |||
83 | bdrv_unref(s->bs); | ||
84 | } | ||
85 | @@ -XXX,XX +XXX,XX @@ void qmp_x_blockdev_amend(const char *job_id, | ||
86 | BlockDriver *drv = bdrv_find_format(fmt); | ||
87 | BlockDriverState *bs; | ||
88 | |||
89 | + GRAPH_RDLOCK_GUARD_MAINLOOP(); | ||
90 | + | ||
91 | bs = bdrv_lookup_bs(NULL, node_name, errp); | ||
92 | if (!bs) { | ||
93 | return; | ||
26 | -- | 94 | -- |
27 | 2.19.1 | 95 | 2.40.1 |
28 | |||
29 | diff view generated by jsdifflib |
1 | If read-only=off, but auto-read-only=on is given, open a read-write NBD | 1 | This adds GRAPH_RDLOCK annotations to declare that callers of |
---|---|---|---|
2 | connection if the server provides a read-write export, but instead of | 2 | bdrv_query_bds_stats() need to hold a reader lock for the graph because |
3 | erroring out for read-only exports, just degrade to read-only. | 3 | it accesses the children list of a node. |
4 | 4 | ||
5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
6 | Reviewed-by: Eric Blake <eblake@redhat.com> | 6 | Reviewed-by: Eric Blake <eblake@redhat.com> |
7 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
8 | Message-Id: <20230504115750.54437-18-kwolf@redhat.com> | ||
9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
7 | --- | 10 | --- |
8 | block/nbd-client.c | 10 +++++----- | 11 | block/qapi.c | 6 ++++-- |
9 | 1 file changed, 5 insertions(+), 5 deletions(-) | 12 | 1 file changed, 4 insertions(+), 2 deletions(-) |
10 | 13 | ||
11 | diff --git a/block/nbd-client.c b/block/nbd-client.c | 14 | diff --git a/block/qapi.c b/block/qapi.c |
12 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/block/nbd-client.c | 16 | --- a/block/qapi.c |
14 | +++ b/block/nbd-client.c | 17 | +++ b/block/qapi.c |
15 | @@ -XXX,XX +XXX,XX @@ int nbd_client_init(BlockDriverState *bs, | 18 | @@ -XXX,XX +XXX,XX @@ static void bdrv_query_blk_stats(BlockDeviceStats *ds, BlockBackend *blk) |
16 | logout("Failed to negotiate with the NBD server\n"); | 19 | = bdrv_latency_histogram_stats(&hgram[BLOCK_ACCT_FLUSH]); |
17 | return ret; | 20 | } |
18 | } | 21 | |
19 | - if (client->info.flags & NBD_FLAG_READ_ONLY && | 22 | -static BlockStats *bdrv_query_bds_stats(BlockDriverState *bs, |
20 | - !bdrv_is_read_only(bs)) { | 23 | - bool blk_level) |
21 | - error_setg(errp, | 24 | +static BlockStats * GRAPH_RDLOCK |
22 | - "request for write access conflicts with read-only export"); | 25 | +bdrv_query_bds_stats(BlockDriverState *bs, bool blk_level) |
23 | - return -EACCES; | 26 | { |
24 | + if (client->info.flags & NBD_FLAG_READ_ONLY) { | 27 | BdrvChild *parent_child; |
25 | + ret = bdrv_apply_auto_read_only(bs, "NBD export is read-only", errp); | 28 | BlockDriverState *filter_or_cow_bs; |
26 | + if (ret < 0) { | 29 | @@ -XXX,XX +XXX,XX @@ BlockStatsList *qmp_query_blockstats(bool has_query_nodes, |
27 | + return ret; | 30 | BlockBackend *blk; |
28 | + } | 31 | BlockDriverState *bs; |
29 | } | 32 | |
30 | if (client->info.flags & NBD_FLAG_SEND_FUA) { | 33 | + GRAPH_RDLOCK_GUARD_MAINLOOP(); |
31 | bs->supported_write_flags = BDRV_REQ_FUA; | 34 | + |
35 | /* Just to be safe if query_nodes is not always initialized */ | ||
36 | if (has_query_nodes && query_nodes) { | ||
37 | for (bs = bdrv_next_node(NULL); bs; bs = bdrv_next_node(bs)) { | ||
32 | -- | 38 | -- |
33 | 2.19.1 | 39 | 2.40.1 |
34 | |||
35 | diff view generated by jsdifflib |
1 | From: Max Reitz <mreitz@redhat.com> | 1 | This adds GRAPH_RDLOCK annotations to declare that callers of |
---|---|---|---|
2 | bdrv_query_block_graph_info() need to hold a reader lock for the graph | ||
3 | because it accesses the children list of a node. | ||
2 | 4 | ||
3 | This adds some whitespace into the option help (including indentation) | 5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
4 | and puts angle brackets around the type names. Furthermore, the list | 6 | Reviewed-by: Eric Blake <eblake@redhat.com> |
5 | name is no longer printed as part of every line, but only once in | 7 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> |
6 | advance, and only if the caller did not print a caption already. | 8 | Message-Id: <20230504115750.54437-19-kwolf@redhat.com> |
7 | |||
8 | This patch also restores the description alignment we had before commit | ||
9 | 9cbef9d68ee1d8d0, just at 24 instead of 16 characters like we used to. | ||
10 | This increase is because now we have the type and two spaces of | ||
11 | indentation before the description, and with a usual type name length of | ||
12 | three chracters, this sums up to eight additional characters -- which | ||
13 | means that we now need 24 characters to get the same amount of padding | ||
14 | for most options. Also, 24 is a third of 80, which makes it kind of a | ||
15 | round number in terminal terms. | ||
16 | |||
17 | Finally, this patch amends the reference output of iotest 082 to match | ||
18 | the changes (and thus makes it pass again). | ||
19 | |||
20 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
21 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | ||
22 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
23 | --- | 10 | --- |
24 | include/qemu/option.h | 2 +- | 11 | include/block/qapi.h | 7 ++++--- |
25 | qemu-img.c | 4 +- | 12 | qemu-img.c | 2 ++ |
26 | util/qemu-option.c | 32 +- | 13 | 2 files changed, 6 insertions(+), 3 deletions(-) |
27 | tests/qemu-iotests/082.out | 956 ++++++++++++++++++------------------- | ||
28 | 4 files changed, 507 insertions(+), 487 deletions(-) | ||
29 | 14 | ||
30 | diff --git a/include/qemu/option.h b/include/qemu/option.h | 15 | diff --git a/include/block/qapi.h b/include/block/qapi.h |
31 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/include/qemu/option.h | 17 | --- a/include/block/qapi.h |
33 | +++ b/include/qemu/option.h | 18 | +++ b/include/block/qapi.h |
34 | @@ -XXX,XX +XXX,XX @@ typedef int (*qemu_opts_loopfunc)(void *opaque, QemuOpts *opts, Error **errp); | 19 | @@ -XXX,XX +XXX,XX @@ |
35 | int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, | 20 | #ifndef BLOCK_QAPI_H |
36 | void *opaque, Error **errp); | 21 | #define BLOCK_QAPI_H |
37 | void qemu_opts_print(QemuOpts *opts, const char *sep); | 22 | |
38 | -void qemu_opts_print_help(QemuOptsList *list); | 23 | +#include "block/graph-lock.h" |
39 | +void qemu_opts_print_help(QemuOptsList *list, bool print_caption); | 24 | #include "block/snapshot.h" |
40 | void qemu_opts_free(QemuOptsList *list); | 25 | #include "qapi/qapi-types-block-core.h" |
41 | QemuOptsList *qemu_opts_append(QemuOptsList *dst, QemuOptsList *list); | 26 | |
42 | 27 | @@ -XXX,XX +XXX,XX @@ void bdrv_query_image_info(BlockDriverState *bs, | |
28 | bool flat, | ||
29 | bool skip_implicit_filters, | ||
30 | Error **errp); | ||
31 | -void bdrv_query_block_graph_info(BlockDriverState *bs, | ||
32 | - BlockGraphInfo **p_info, | ||
33 | - Error **errp); | ||
34 | +void GRAPH_RDLOCK | ||
35 | +bdrv_query_block_graph_info(BlockDriverState *bs, BlockGraphInfo **p_info, | ||
36 | + Error **errp); | ||
37 | |||
38 | void bdrv_snapshot_dump(QEMUSnapshotInfo *sn); | ||
39 | void bdrv_image_info_specific_dump(ImageInfoSpecific *info_spec, | ||
43 | diff --git a/qemu-img.c b/qemu-img.c | 40 | diff --git a/qemu-img.c b/qemu-img.c |
44 | index XXXXXXX..XXXXXXX 100644 | 41 | index XXXXXXX..XXXXXXX 100644 |
45 | --- a/qemu-img.c | 42 | --- a/qemu-img.c |
46 | +++ b/qemu-img.c | 43 | +++ b/qemu-img.c |
47 | @@ -XXX,XX +XXX,XX @@ static int print_block_option_help(const char *filename, const char *fmt) | 44 | @@ -XXX,XX +XXX,XX @@ static BlockGraphInfoList *collect_image_info_list(bool image_opts, |
48 | } | ||
49 | |||
50 | printf("Supported options:\n"); | ||
51 | - qemu_opts_print_help(create_opts); | ||
52 | + qemu_opts_print_help(create_opts, false); | ||
53 | qemu_opts_free(create_opts); | ||
54 | return 0; | ||
55 | } | ||
56 | @@ -XXX,XX +XXX,XX @@ static int print_amend_option_help(const char *format) | ||
57 | assert(drv->create_opts); | ||
58 | |||
59 | printf("Creation options for '%s':\n", format); | ||
60 | - qemu_opts_print_help(drv->create_opts); | ||
61 | + qemu_opts_print_help(drv->create_opts, false); | ||
62 | printf("\nNote that not all of these options may be amendable.\n"); | ||
63 | return 0; | ||
64 | } | ||
65 | diff --git a/util/qemu-option.c b/util/qemu-option.c | ||
66 | index XXXXXXX..XXXXXXX 100644 | ||
67 | --- a/util/qemu-option.c | ||
68 | +++ b/util/qemu-option.c | ||
69 | @@ -XXX,XX +XXX,XX @@ static const char *opt_type_to_string(enum QemuOptType type) | ||
70 | g_assert_not_reached(); | ||
71 | } | ||
72 | |||
73 | -void qemu_opts_print_help(QemuOptsList *list) | ||
74 | +/** | ||
75 | + * Print the list of options available in the given list. If | ||
76 | + * @print_caption is true, a caption (including the list name, if it | ||
77 | + * exists) is printed. The options itself will be indented, so | ||
78 | + * @print_caption should only be set to false if the caller prints its | ||
79 | + * own custom caption (so that the indentation makes sense). | ||
80 | + */ | ||
81 | +void qemu_opts_print_help(QemuOptsList *list, bool print_caption) | ||
82 | { | ||
83 | QemuOptDesc *desc; | ||
84 | int i; | ||
85 | @@ -XXX,XX +XXX,XX @@ void qemu_opts_print_help(QemuOptsList *list) | ||
86 | desc = list->desc; | ||
87 | while (desc && desc->name) { | ||
88 | GString *str = g_string_new(NULL); | ||
89 | - if (list->name) { | ||
90 | - g_string_append_printf(str, "%s.", list->name); | ||
91 | - } | ||
92 | - g_string_append_printf(str, "%s=%s", desc->name, | ||
93 | + g_string_append_printf(str, " %s=<%s>", desc->name, | ||
94 | opt_type_to_string(desc->type)); | ||
95 | if (desc->help) { | ||
96 | + if (str->len < 24) { | ||
97 | + g_string_append_printf(str, "%*s", 24 - (int)str->len, ""); | ||
98 | + } | ||
99 | g_string_append_printf(str, " - %s", desc->help); | ||
100 | } | 45 | } |
101 | g_ptr_array_add(array, g_string_free(str, false)); | 46 | bs = blk_bs(blk); |
102 | @@ -XXX,XX +XXX,XX @@ void qemu_opts_print_help(QemuOptsList *list) | 47 | |
103 | } | 48 | + GRAPH_RDLOCK_GUARD_MAINLOOP(); |
104 | 49 | + | |
105 | g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0); | 50 | /* |
106 | + if (print_caption && array->len > 0) { | 51 | * Note that the returned BlockGraphInfo object will not have |
107 | + if (list->name) { | 52 | * information about this image's backing node, because we have opened |
108 | + printf("%s options:\n", list->name); | ||
109 | + } else { | ||
110 | + printf("Options:\n"); | ||
111 | + } | ||
112 | + } else if (array->len == 0) { | ||
113 | + if (list->name) { | ||
114 | + printf("There are no options for %s.\n", list->name); | ||
115 | + } else { | ||
116 | + printf("No options available.\n"); | ||
117 | + } | ||
118 | + } | ||
119 | for (i = 0; i < array->len; i++) { | ||
120 | printf("%s\n", (char *)array->pdata[i]); | ||
121 | } | ||
122 | @@ -XXX,XX +XXX,XX @@ QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, const char *params, | ||
123 | opts = opts_parse(list, params, permit_abbrev, false, &invalidp, &err); | ||
124 | if (err) { | ||
125 | if (invalidp && has_help_option(params)) { | ||
126 | - qemu_opts_print_help(list); | ||
127 | + qemu_opts_print_help(list, true); | ||
128 | error_free(err); | ||
129 | } else { | ||
130 | error_report_err(err); | ||
131 | diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out | ||
132 | index XXXXXXX..XXXXXXX 100644 | ||
133 | --- a/tests/qemu-iotests/082.out | ||
134 | +++ b/tests/qemu-iotests/082.out | ||
135 | @@ -XXX,XX +XXX,XX @@ cluster_size: 8192 | ||
136 | |||
137 | Testing: create -f qcow2 -o help TEST_DIR/t.qcow2 128M | ||
138 | Supported options: | ||
139 | -size Virtual disk size | ||
140 | -compat Compatibility level (0.10 or 1.1) | ||
141 | -backing_file File name of a base image | ||
142 | -backing_fmt Image format of the base image | ||
143 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
144 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
145 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
146 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
147 | -encrypt.cipher-mode Name of encryption cipher mode | ||
148 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
149 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
150 | -encrypt.hash-alg Name of encryption hash algorithm | ||
151 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
152 | -cluster_size qcow2 cluster size | ||
153 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
154 | -lazy_refcounts Postpone refcount updates | ||
155 | -refcount_bits Width of a reference count entry in bits | ||
156 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
157 | + backing_file=<str> - File name of a base image | ||
158 | + backing_fmt=<str> - Image format of the base image | ||
159 | + cluster_size=<size> - qcow2 cluster size | ||
160 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
161 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
162 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
163 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
164 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
165 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
166 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
167 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
168 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
169 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
170 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
171 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
172 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
173 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
174 | + size=<size> - Virtual disk size | ||
175 | |||
176 | Testing: create -f qcow2 -o ? TEST_DIR/t.qcow2 128M | ||
177 | Supported options: | ||
178 | -size Virtual disk size | ||
179 | -compat Compatibility level (0.10 or 1.1) | ||
180 | -backing_file File name of a base image | ||
181 | -backing_fmt Image format of the base image | ||
182 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
183 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
184 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
185 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
186 | -encrypt.cipher-mode Name of encryption cipher mode | ||
187 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
188 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
189 | -encrypt.hash-alg Name of encryption hash algorithm | ||
190 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
191 | -cluster_size qcow2 cluster size | ||
192 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
193 | -lazy_refcounts Postpone refcount updates | ||
194 | -refcount_bits Width of a reference count entry in bits | ||
195 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
196 | + backing_file=<str> - File name of a base image | ||
197 | + backing_fmt=<str> - Image format of the base image | ||
198 | + cluster_size=<size> - qcow2 cluster size | ||
199 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
200 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
201 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
202 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
203 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
204 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
205 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
206 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
207 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
208 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
209 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
210 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
211 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
212 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
213 | + size=<size> - Virtual disk size | ||
214 | |||
215 | Testing: create -f qcow2 -o cluster_size=4k,help TEST_DIR/t.qcow2 128M | ||
216 | Supported options: | ||
217 | -size Virtual disk size | ||
218 | -compat Compatibility level (0.10 or 1.1) | ||
219 | -backing_file File name of a base image | ||
220 | -backing_fmt Image format of the base image | ||
221 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
222 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
223 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
224 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
225 | -encrypt.cipher-mode Name of encryption cipher mode | ||
226 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
227 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
228 | -encrypt.hash-alg Name of encryption hash algorithm | ||
229 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
230 | -cluster_size qcow2 cluster size | ||
231 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
232 | -lazy_refcounts Postpone refcount updates | ||
233 | -refcount_bits Width of a reference count entry in bits | ||
234 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
235 | + backing_file=<str> - File name of a base image | ||
236 | + backing_fmt=<str> - Image format of the base image | ||
237 | + cluster_size=<size> - qcow2 cluster size | ||
238 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
239 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
240 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
241 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
242 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
243 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
244 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
245 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
246 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
247 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
248 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
249 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
250 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
251 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
252 | + size=<size> - Virtual disk size | ||
253 | |||
254 | Testing: create -f qcow2 -o cluster_size=4k,? TEST_DIR/t.qcow2 128M | ||
255 | Supported options: | ||
256 | -size Virtual disk size | ||
257 | -compat Compatibility level (0.10 or 1.1) | ||
258 | -backing_file File name of a base image | ||
259 | -backing_fmt Image format of the base image | ||
260 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
261 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
262 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
263 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
264 | -encrypt.cipher-mode Name of encryption cipher mode | ||
265 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
266 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
267 | -encrypt.hash-alg Name of encryption hash algorithm | ||
268 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
269 | -cluster_size qcow2 cluster size | ||
270 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
271 | -lazy_refcounts Postpone refcount updates | ||
272 | -refcount_bits Width of a reference count entry in bits | ||
273 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
274 | + backing_file=<str> - File name of a base image | ||
275 | + backing_fmt=<str> - Image format of the base image | ||
276 | + cluster_size=<size> - qcow2 cluster size | ||
277 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
278 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
279 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
280 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
281 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
282 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
283 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
284 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
285 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
286 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
287 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
288 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
289 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
290 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
291 | + size=<size> - Virtual disk size | ||
292 | |||
293 | Testing: create -f qcow2 -o help,cluster_size=4k TEST_DIR/t.qcow2 128M | ||
294 | Supported options: | ||
295 | -size Virtual disk size | ||
296 | -compat Compatibility level (0.10 or 1.1) | ||
297 | -backing_file File name of a base image | ||
298 | -backing_fmt Image format of the base image | ||
299 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
300 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
301 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
302 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
303 | -encrypt.cipher-mode Name of encryption cipher mode | ||
304 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
305 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
306 | -encrypt.hash-alg Name of encryption hash algorithm | ||
307 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
308 | -cluster_size qcow2 cluster size | ||
309 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
310 | -lazy_refcounts Postpone refcount updates | ||
311 | -refcount_bits Width of a reference count entry in bits | ||
312 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
313 | + backing_file=<str> - File name of a base image | ||
314 | + backing_fmt=<str> - Image format of the base image | ||
315 | + cluster_size=<size> - qcow2 cluster size | ||
316 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
317 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
318 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
319 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
320 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
321 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
322 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
323 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
324 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
325 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
326 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
327 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
328 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
329 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
330 | + size=<size> - Virtual disk size | ||
331 | |||
332 | Testing: create -f qcow2 -o ?,cluster_size=4k TEST_DIR/t.qcow2 128M | ||
333 | Supported options: | ||
334 | -size Virtual disk size | ||
335 | -compat Compatibility level (0.10 or 1.1) | ||
336 | -backing_file File name of a base image | ||
337 | -backing_fmt Image format of the base image | ||
338 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
339 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
340 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
341 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
342 | -encrypt.cipher-mode Name of encryption cipher mode | ||
343 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
344 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
345 | -encrypt.hash-alg Name of encryption hash algorithm | ||
346 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
347 | -cluster_size qcow2 cluster size | ||
348 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
349 | -lazy_refcounts Postpone refcount updates | ||
350 | -refcount_bits Width of a reference count entry in bits | ||
351 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
352 | + backing_file=<str> - File name of a base image | ||
353 | + backing_fmt=<str> - Image format of the base image | ||
354 | + cluster_size=<size> - qcow2 cluster size | ||
355 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
356 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
357 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
358 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
359 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
360 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
361 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
362 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
363 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
364 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
365 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
366 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
367 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
368 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
369 | + size=<size> - Virtual disk size | ||
370 | |||
371 | Testing: create -f qcow2 -o cluster_size=4k -o help TEST_DIR/t.qcow2 128M | ||
372 | Supported options: | ||
373 | -size Virtual disk size | ||
374 | -compat Compatibility level (0.10 or 1.1) | ||
375 | -backing_file File name of a base image | ||
376 | -backing_fmt Image format of the base image | ||
377 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
378 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
379 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
380 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
381 | -encrypt.cipher-mode Name of encryption cipher mode | ||
382 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
383 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
384 | -encrypt.hash-alg Name of encryption hash algorithm | ||
385 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
386 | -cluster_size qcow2 cluster size | ||
387 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
388 | -lazy_refcounts Postpone refcount updates | ||
389 | -refcount_bits Width of a reference count entry in bits | ||
390 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
391 | + backing_file=<str> - File name of a base image | ||
392 | + backing_fmt=<str> - Image format of the base image | ||
393 | + cluster_size=<size> - qcow2 cluster size | ||
394 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
395 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
396 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
397 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
398 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
399 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
400 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
401 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
402 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
403 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
404 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
405 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
406 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
407 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
408 | + size=<size> - Virtual disk size | ||
409 | |||
410 | Testing: create -f qcow2 -o cluster_size=4k -o ? TEST_DIR/t.qcow2 128M | ||
411 | Supported options: | ||
412 | -size Virtual disk size | ||
413 | -compat Compatibility level (0.10 or 1.1) | ||
414 | -backing_file File name of a base image | ||
415 | -backing_fmt Image format of the base image | ||
416 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
417 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
418 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
419 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
420 | -encrypt.cipher-mode Name of encryption cipher mode | ||
421 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
422 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
423 | -encrypt.hash-alg Name of encryption hash algorithm | ||
424 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
425 | -cluster_size qcow2 cluster size | ||
426 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
427 | -lazy_refcounts Postpone refcount updates | ||
428 | -refcount_bits Width of a reference count entry in bits | ||
429 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
430 | + backing_file=<str> - File name of a base image | ||
431 | + backing_fmt=<str> - Image format of the base image | ||
432 | + cluster_size=<size> - qcow2 cluster size | ||
433 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
434 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
435 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
436 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
437 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
438 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
439 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
440 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
441 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
442 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
443 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
444 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
445 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
446 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
447 | + size=<size> - Virtual disk size | ||
448 | |||
449 | Testing: create -f qcow2 -u -o backing_file=TEST_DIR/t.qcow2,,help TEST_DIR/t.qcow2 128M | ||
450 | Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/t.qcow2,,help cluster_size=65536 lazy_refcounts=off refcount_bits=16 | ||
451 | @@ -XXX,XX +XXX,XX @@ qemu-img: Invalid option list: ,, | ||
452 | |||
453 | Testing: create -f qcow2 -o help | ||
454 | Supported options: | ||
455 | -size Virtual disk size | ||
456 | -compat Compatibility level (0.10 or 1.1) | ||
457 | -backing_file File name of a base image | ||
458 | -backing_fmt Image format of the base image | ||
459 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
460 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
461 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
462 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
463 | -encrypt.cipher-mode Name of encryption cipher mode | ||
464 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
465 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
466 | -encrypt.hash-alg Name of encryption hash algorithm | ||
467 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
468 | -cluster_size qcow2 cluster size | ||
469 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
470 | -lazy_refcounts Postpone refcount updates | ||
471 | -refcount_bits Width of a reference count entry in bits | ||
472 | + backing_file=<str> - File name of a base image | ||
473 | + backing_fmt=<str> - Image format of the base image | ||
474 | + cluster_size=<size> - qcow2 cluster size | ||
475 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
476 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
477 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
478 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
479 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
480 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
481 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
482 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
483 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
484 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
485 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
486 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
487 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
488 | + size=<size> - Virtual disk size | ||
489 | |||
490 | Testing: create -o help | ||
491 | Supported options: | ||
492 | -size Virtual disk size | ||
493 | + size=<size> - Virtual disk size | ||
494 | |||
495 | Testing: create -f bochs -o help | ||
496 | qemu-img: Format driver 'bochs' does not support image creation | ||
497 | @@ -XXX,XX +XXX,XX @@ cluster_size: 8192 | ||
498 | |||
499 | Testing: convert -O qcow2 -o help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base | ||
500 | Supported options: | ||
501 | -size Virtual disk size | ||
502 | -compat Compatibility level (0.10 or 1.1) | ||
503 | -backing_file File name of a base image | ||
504 | -backing_fmt Image format of the base image | ||
505 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
506 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
507 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
508 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
509 | -encrypt.cipher-mode Name of encryption cipher mode | ||
510 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
511 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
512 | -encrypt.hash-alg Name of encryption hash algorithm | ||
513 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
514 | -cluster_size qcow2 cluster size | ||
515 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
516 | -lazy_refcounts Postpone refcount updates | ||
517 | -refcount_bits Width of a reference count entry in bits | ||
518 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
519 | + backing_file=<str> - File name of a base image | ||
520 | + backing_fmt=<str> - Image format of the base image | ||
521 | + cluster_size=<size> - qcow2 cluster size | ||
522 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
523 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
524 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
525 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
526 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
527 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
528 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
529 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
530 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
531 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
532 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
533 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
534 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
535 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
536 | + size=<size> - Virtual disk size | ||
537 | |||
538 | Testing: convert -O qcow2 -o ? TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base | ||
539 | Supported options: | ||
540 | -size Virtual disk size | ||
541 | -compat Compatibility level (0.10 or 1.1) | ||
542 | -backing_file File name of a base image | ||
543 | -backing_fmt Image format of the base image | ||
544 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
545 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
546 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
547 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
548 | -encrypt.cipher-mode Name of encryption cipher mode | ||
549 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
550 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
551 | -encrypt.hash-alg Name of encryption hash algorithm | ||
552 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
553 | -cluster_size qcow2 cluster size | ||
554 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
555 | -lazy_refcounts Postpone refcount updates | ||
556 | -refcount_bits Width of a reference count entry in bits | ||
557 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
558 | + backing_file=<str> - File name of a base image | ||
559 | + backing_fmt=<str> - Image format of the base image | ||
560 | + cluster_size=<size> - qcow2 cluster size | ||
561 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
562 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
563 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
564 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
565 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
566 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
567 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
568 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
569 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
570 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
571 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
572 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
573 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
574 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
575 | + size=<size> - Virtual disk size | ||
576 | |||
577 | Testing: convert -O qcow2 -o cluster_size=4k,help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base | ||
578 | Supported options: | ||
579 | -size Virtual disk size | ||
580 | -compat Compatibility level (0.10 or 1.1) | ||
581 | -backing_file File name of a base image | ||
582 | -backing_fmt Image format of the base image | ||
583 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
584 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
585 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
586 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
587 | -encrypt.cipher-mode Name of encryption cipher mode | ||
588 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
589 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
590 | -encrypt.hash-alg Name of encryption hash algorithm | ||
591 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
592 | -cluster_size qcow2 cluster size | ||
593 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
594 | -lazy_refcounts Postpone refcount updates | ||
595 | -refcount_bits Width of a reference count entry in bits | ||
596 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
597 | + backing_file=<str> - File name of a base image | ||
598 | + backing_fmt=<str> - Image format of the base image | ||
599 | + cluster_size=<size> - qcow2 cluster size | ||
600 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
601 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
602 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
603 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
604 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
605 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
606 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
607 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
608 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
609 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
610 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
611 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
612 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
613 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
614 | + size=<size> - Virtual disk size | ||
615 | |||
616 | Testing: convert -O qcow2 -o cluster_size=4k,? TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base | ||
617 | Supported options: | ||
618 | -size Virtual disk size | ||
619 | -compat Compatibility level (0.10 or 1.1) | ||
620 | -backing_file File name of a base image | ||
621 | -backing_fmt Image format of the base image | ||
622 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
623 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
624 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
625 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
626 | -encrypt.cipher-mode Name of encryption cipher mode | ||
627 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
628 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
629 | -encrypt.hash-alg Name of encryption hash algorithm | ||
630 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
631 | -cluster_size qcow2 cluster size | ||
632 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
633 | -lazy_refcounts Postpone refcount updates | ||
634 | -refcount_bits Width of a reference count entry in bits | ||
635 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
636 | + backing_file=<str> - File name of a base image | ||
637 | + backing_fmt=<str> - Image format of the base image | ||
638 | + cluster_size=<size> - qcow2 cluster size | ||
639 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
640 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
641 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
642 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
643 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
644 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
645 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
646 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
647 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
648 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
649 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
650 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
651 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
652 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
653 | + size=<size> - Virtual disk size | ||
654 | |||
655 | Testing: convert -O qcow2 -o help,cluster_size=4k TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base | ||
656 | Supported options: | ||
657 | -size Virtual disk size | ||
658 | -compat Compatibility level (0.10 or 1.1) | ||
659 | -backing_file File name of a base image | ||
660 | -backing_fmt Image format of the base image | ||
661 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
662 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
663 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
664 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
665 | -encrypt.cipher-mode Name of encryption cipher mode | ||
666 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
667 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
668 | -encrypt.hash-alg Name of encryption hash algorithm | ||
669 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
670 | -cluster_size qcow2 cluster size | ||
671 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
672 | -lazy_refcounts Postpone refcount updates | ||
673 | -refcount_bits Width of a reference count entry in bits | ||
674 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
675 | + backing_file=<str> - File name of a base image | ||
676 | + backing_fmt=<str> - Image format of the base image | ||
677 | + cluster_size=<size> - qcow2 cluster size | ||
678 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
679 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
680 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
681 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
682 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
683 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
684 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
685 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
686 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
687 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
688 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
689 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
690 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
691 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
692 | + size=<size> - Virtual disk size | ||
693 | |||
694 | Testing: convert -O qcow2 -o ?,cluster_size=4k TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base | ||
695 | Supported options: | ||
696 | -size Virtual disk size | ||
697 | -compat Compatibility level (0.10 or 1.1) | ||
698 | -backing_file File name of a base image | ||
699 | -backing_fmt Image format of the base image | ||
700 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
701 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
702 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
703 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
704 | -encrypt.cipher-mode Name of encryption cipher mode | ||
705 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
706 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
707 | -encrypt.hash-alg Name of encryption hash algorithm | ||
708 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
709 | -cluster_size qcow2 cluster size | ||
710 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
711 | -lazy_refcounts Postpone refcount updates | ||
712 | -refcount_bits Width of a reference count entry in bits | ||
713 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
714 | + backing_file=<str> - File name of a base image | ||
715 | + backing_fmt=<str> - Image format of the base image | ||
716 | + cluster_size=<size> - qcow2 cluster size | ||
717 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
718 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
719 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
720 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
721 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
722 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
723 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
724 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
725 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
726 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
727 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
728 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
729 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
730 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
731 | + size=<size> - Virtual disk size | ||
732 | |||
733 | Testing: convert -O qcow2 -o cluster_size=4k -o help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base | ||
734 | Supported options: | ||
735 | -size Virtual disk size | ||
736 | -compat Compatibility level (0.10 or 1.1) | ||
737 | -backing_file File name of a base image | ||
738 | -backing_fmt Image format of the base image | ||
739 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
740 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
741 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
742 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
743 | -encrypt.cipher-mode Name of encryption cipher mode | ||
744 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
745 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
746 | -encrypt.hash-alg Name of encryption hash algorithm | ||
747 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
748 | -cluster_size qcow2 cluster size | ||
749 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
750 | -lazy_refcounts Postpone refcount updates | ||
751 | -refcount_bits Width of a reference count entry in bits | ||
752 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
753 | + backing_file=<str> - File name of a base image | ||
754 | + backing_fmt=<str> - Image format of the base image | ||
755 | + cluster_size=<size> - qcow2 cluster size | ||
756 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
757 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
758 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
759 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
760 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
761 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
762 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
763 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
764 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
765 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
766 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
767 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
768 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
769 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
770 | + size=<size> - Virtual disk size | ||
771 | |||
772 | Testing: convert -O qcow2 -o cluster_size=4k -o ? TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base | ||
773 | Supported options: | ||
774 | -size Virtual disk size | ||
775 | -compat Compatibility level (0.10 or 1.1) | ||
776 | -backing_file File name of a base image | ||
777 | -backing_fmt Image format of the base image | ||
778 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
779 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
780 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
781 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
782 | -encrypt.cipher-mode Name of encryption cipher mode | ||
783 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
784 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
785 | -encrypt.hash-alg Name of encryption hash algorithm | ||
786 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
787 | -cluster_size qcow2 cluster size | ||
788 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
789 | -lazy_refcounts Postpone refcount updates | ||
790 | -refcount_bits Width of a reference count entry in bits | ||
791 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
792 | + backing_file=<str> - File name of a base image | ||
793 | + backing_fmt=<str> - Image format of the base image | ||
794 | + cluster_size=<size> - qcow2 cluster size | ||
795 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
796 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
797 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
798 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
799 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
800 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
801 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
802 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
803 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
804 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
805 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
806 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
807 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
808 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
809 | + size=<size> - Virtual disk size | ||
810 | |||
811 | Testing: convert -O qcow2 -o backing_file=TEST_DIR/t.qcow2,,help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base | ||
812 | qemu-img: Could not open 'TEST_DIR/t.qcow2.base': Could not open backing file: Could not open 'TEST_DIR/t.qcow2,help': No such file or directory | ||
813 | @@ -XXX,XX +XXX,XX @@ qemu-img: Invalid option list: ,, | ||
814 | |||
815 | Testing: convert -O qcow2 -o help | ||
816 | Supported options: | ||
817 | -size Virtual disk size | ||
818 | -compat Compatibility level (0.10 or 1.1) | ||
819 | -backing_file File name of a base image | ||
820 | -backing_fmt Image format of the base image | ||
821 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
822 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
823 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
824 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
825 | -encrypt.cipher-mode Name of encryption cipher mode | ||
826 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
827 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
828 | -encrypt.hash-alg Name of encryption hash algorithm | ||
829 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
830 | -cluster_size qcow2 cluster size | ||
831 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
832 | -lazy_refcounts Postpone refcount updates | ||
833 | -refcount_bits Width of a reference count entry in bits | ||
834 | + backing_file=<str> - File name of a base image | ||
835 | + backing_fmt=<str> - Image format of the base image | ||
836 | + cluster_size=<size> - qcow2 cluster size | ||
837 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
838 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
839 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
840 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
841 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
842 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
843 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
844 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
845 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
846 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
847 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
848 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
849 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
850 | + size=<size> - Virtual disk size | ||
851 | |||
852 | Testing: convert -o help | ||
853 | Supported options: | ||
854 | -size Virtual disk size | ||
855 | + size=<size> - Virtual disk size | ||
856 | |||
857 | Testing: convert -O bochs -o help | ||
858 | qemu-img: Format driver 'bochs' does not support image creation | ||
859 | @@ -XXX,XX +XXX,XX @@ cluster_size: 65536 | ||
860 | |||
861 | Testing: amend -f qcow2 -o help TEST_DIR/t.qcow2 | ||
862 | Creation options for 'qcow2': | ||
863 | -size Virtual disk size | ||
864 | -compat Compatibility level (0.10 or 1.1) | ||
865 | -backing_file File name of a base image | ||
866 | -backing_fmt Image format of the base image | ||
867 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
868 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
869 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
870 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
871 | -encrypt.cipher-mode Name of encryption cipher mode | ||
872 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
873 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
874 | -encrypt.hash-alg Name of encryption hash algorithm | ||
875 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
876 | -cluster_size qcow2 cluster size | ||
877 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
878 | -lazy_refcounts Postpone refcount updates | ||
879 | -refcount_bits Width of a reference count entry in bits | ||
880 | + backing_file=<str> - File name of a base image | ||
881 | + backing_fmt=<str> - Image format of the base image | ||
882 | + cluster_size=<size> - qcow2 cluster size | ||
883 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
884 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
885 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
886 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
887 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
888 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
889 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
890 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
891 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
892 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
893 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
894 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
895 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
896 | + size=<size> - Virtual disk size | ||
897 | |||
898 | Note that not all of these options may be amendable. | ||
899 | |||
900 | Testing: amend -f qcow2 -o ? TEST_DIR/t.qcow2 | ||
901 | Creation options for 'qcow2': | ||
902 | -size Virtual disk size | ||
903 | -compat Compatibility level (0.10 or 1.1) | ||
904 | -backing_file File name of a base image | ||
905 | -backing_fmt Image format of the base image | ||
906 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
907 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
908 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
909 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
910 | -encrypt.cipher-mode Name of encryption cipher mode | ||
911 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
912 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
913 | -encrypt.hash-alg Name of encryption hash algorithm | ||
914 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
915 | -cluster_size qcow2 cluster size | ||
916 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
917 | -lazy_refcounts Postpone refcount updates | ||
918 | -refcount_bits Width of a reference count entry in bits | ||
919 | + backing_file=<str> - File name of a base image | ||
920 | + backing_fmt=<str> - Image format of the base image | ||
921 | + cluster_size=<size> - qcow2 cluster size | ||
922 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
923 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
924 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
925 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
926 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
927 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
928 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
929 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
930 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
931 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
932 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
933 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
934 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
935 | + size=<size> - Virtual disk size | ||
936 | |||
937 | Note that not all of these options may be amendable. | ||
938 | |||
939 | Testing: amend -f qcow2 -o cluster_size=4k,help TEST_DIR/t.qcow2 | ||
940 | Creation options for 'qcow2': | ||
941 | -size Virtual disk size | ||
942 | -compat Compatibility level (0.10 or 1.1) | ||
943 | -backing_file File name of a base image | ||
944 | -backing_fmt Image format of the base image | ||
945 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
946 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
947 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
948 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
949 | -encrypt.cipher-mode Name of encryption cipher mode | ||
950 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
951 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
952 | -encrypt.hash-alg Name of encryption hash algorithm | ||
953 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
954 | -cluster_size qcow2 cluster size | ||
955 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
956 | -lazy_refcounts Postpone refcount updates | ||
957 | -refcount_bits Width of a reference count entry in bits | ||
958 | + backing_file=<str> - File name of a base image | ||
959 | + backing_fmt=<str> - Image format of the base image | ||
960 | + cluster_size=<size> - qcow2 cluster size | ||
961 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
962 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
963 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
964 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
965 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
966 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
967 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
968 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
969 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
970 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
971 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
972 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
973 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
974 | + size=<size> - Virtual disk size | ||
975 | |||
976 | Note that not all of these options may be amendable. | ||
977 | |||
978 | Testing: amend -f qcow2 -o cluster_size=4k,? TEST_DIR/t.qcow2 | ||
979 | Creation options for 'qcow2': | ||
980 | -size Virtual disk size | ||
981 | -compat Compatibility level (0.10 or 1.1) | ||
982 | -backing_file File name of a base image | ||
983 | -backing_fmt Image format of the base image | ||
984 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
985 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
986 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
987 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
988 | -encrypt.cipher-mode Name of encryption cipher mode | ||
989 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
990 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
991 | -encrypt.hash-alg Name of encryption hash algorithm | ||
992 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
993 | -cluster_size qcow2 cluster size | ||
994 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
995 | -lazy_refcounts Postpone refcount updates | ||
996 | -refcount_bits Width of a reference count entry in bits | ||
997 | + backing_file=<str> - File name of a base image | ||
998 | + backing_fmt=<str> - Image format of the base image | ||
999 | + cluster_size=<size> - qcow2 cluster size | ||
1000 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
1001 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
1002 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
1003 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
1004 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
1005 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
1006 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
1007 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
1008 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
1009 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
1010 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
1011 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
1012 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
1013 | + size=<size> - Virtual disk size | ||
1014 | |||
1015 | Note that not all of these options may be amendable. | ||
1016 | |||
1017 | Testing: amend -f qcow2 -o help,cluster_size=4k TEST_DIR/t.qcow2 | ||
1018 | Creation options for 'qcow2': | ||
1019 | -size Virtual disk size | ||
1020 | -compat Compatibility level (0.10 or 1.1) | ||
1021 | -backing_file File name of a base image | ||
1022 | -backing_fmt Image format of the base image | ||
1023 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
1024 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
1025 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
1026 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
1027 | -encrypt.cipher-mode Name of encryption cipher mode | ||
1028 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
1029 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
1030 | -encrypt.hash-alg Name of encryption hash algorithm | ||
1031 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
1032 | -cluster_size qcow2 cluster size | ||
1033 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
1034 | -lazy_refcounts Postpone refcount updates | ||
1035 | -refcount_bits Width of a reference count entry in bits | ||
1036 | + backing_file=<str> - File name of a base image | ||
1037 | + backing_fmt=<str> - Image format of the base image | ||
1038 | + cluster_size=<size> - qcow2 cluster size | ||
1039 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
1040 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
1041 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
1042 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
1043 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
1044 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
1045 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
1046 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
1047 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
1048 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
1049 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
1050 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
1051 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
1052 | + size=<size> - Virtual disk size | ||
1053 | |||
1054 | Note that not all of these options may be amendable. | ||
1055 | |||
1056 | Testing: amend -f qcow2 -o ?,cluster_size=4k TEST_DIR/t.qcow2 | ||
1057 | Creation options for 'qcow2': | ||
1058 | -size Virtual disk size | ||
1059 | -compat Compatibility level (0.10 or 1.1) | ||
1060 | -backing_file File name of a base image | ||
1061 | -backing_fmt Image format of the base image | ||
1062 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
1063 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
1064 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
1065 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
1066 | -encrypt.cipher-mode Name of encryption cipher mode | ||
1067 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
1068 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
1069 | -encrypt.hash-alg Name of encryption hash algorithm | ||
1070 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
1071 | -cluster_size qcow2 cluster size | ||
1072 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
1073 | -lazy_refcounts Postpone refcount updates | ||
1074 | -refcount_bits Width of a reference count entry in bits | ||
1075 | + backing_file=<str> - File name of a base image | ||
1076 | + backing_fmt=<str> - Image format of the base image | ||
1077 | + cluster_size=<size> - qcow2 cluster size | ||
1078 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
1079 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
1080 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
1081 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
1082 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
1083 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
1084 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
1085 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
1086 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
1087 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
1088 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
1089 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
1090 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
1091 | + size=<size> - Virtual disk size | ||
1092 | |||
1093 | Note that not all of these options may be amendable. | ||
1094 | |||
1095 | Testing: amend -f qcow2 -o cluster_size=4k -o help TEST_DIR/t.qcow2 | ||
1096 | Creation options for 'qcow2': | ||
1097 | -size Virtual disk size | ||
1098 | -compat Compatibility level (0.10 or 1.1) | ||
1099 | -backing_file File name of a base image | ||
1100 | -backing_fmt Image format of the base image | ||
1101 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
1102 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
1103 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
1104 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
1105 | -encrypt.cipher-mode Name of encryption cipher mode | ||
1106 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
1107 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
1108 | -encrypt.hash-alg Name of encryption hash algorithm | ||
1109 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
1110 | -cluster_size qcow2 cluster size | ||
1111 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
1112 | -lazy_refcounts Postpone refcount updates | ||
1113 | -refcount_bits Width of a reference count entry in bits | ||
1114 | + backing_file=<str> - File name of a base image | ||
1115 | + backing_fmt=<str> - Image format of the base image | ||
1116 | + cluster_size=<size> - qcow2 cluster size | ||
1117 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
1118 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
1119 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
1120 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
1121 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
1122 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
1123 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
1124 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
1125 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
1126 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
1127 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
1128 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
1129 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
1130 | + size=<size> - Virtual disk size | ||
1131 | |||
1132 | Note that not all of these options may be amendable. | ||
1133 | |||
1134 | Testing: amend -f qcow2 -o cluster_size=4k -o ? TEST_DIR/t.qcow2 | ||
1135 | Creation options for 'qcow2': | ||
1136 | -size Virtual disk size | ||
1137 | -compat Compatibility level (0.10 or 1.1) | ||
1138 | -backing_file File name of a base image | ||
1139 | -backing_fmt Image format of the base image | ||
1140 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
1141 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
1142 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
1143 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
1144 | -encrypt.cipher-mode Name of encryption cipher mode | ||
1145 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
1146 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
1147 | -encrypt.hash-alg Name of encryption hash algorithm | ||
1148 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
1149 | -cluster_size qcow2 cluster size | ||
1150 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
1151 | -lazy_refcounts Postpone refcount updates | ||
1152 | -refcount_bits Width of a reference count entry in bits | ||
1153 | + backing_file=<str> - File name of a base image | ||
1154 | + backing_fmt=<str> - Image format of the base image | ||
1155 | + cluster_size=<size> - qcow2 cluster size | ||
1156 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
1157 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
1158 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
1159 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
1160 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
1161 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
1162 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
1163 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
1164 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
1165 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
1166 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
1167 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
1168 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
1169 | + size=<size> - Virtual disk size | ||
1170 | |||
1171 | Note that not all of these options may be amendable. | ||
1172 | |||
1173 | @@ -XXX,XX +XXX,XX @@ qemu-img: Invalid option list: ,, | ||
1174 | |||
1175 | Testing: amend -f qcow2 -o help | ||
1176 | Creation options for 'qcow2': | ||
1177 | -size Virtual disk size | ||
1178 | -compat Compatibility level (0.10 or 1.1) | ||
1179 | -backing_file File name of a base image | ||
1180 | -backing_fmt Image format of the base image | ||
1181 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
1182 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
1183 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
1184 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
1185 | -encrypt.cipher-mode Name of encryption cipher mode | ||
1186 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
1187 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
1188 | -encrypt.hash-alg Name of encryption hash algorithm | ||
1189 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
1190 | -cluster_size qcow2 cluster size | ||
1191 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
1192 | -lazy_refcounts Postpone refcount updates | ||
1193 | -refcount_bits Width of a reference count entry in bits | ||
1194 | + backing_file=<str> - File name of a base image | ||
1195 | + backing_fmt=<str> - Image format of the base image | ||
1196 | + cluster_size=<size> - qcow2 cluster size | ||
1197 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
1198 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
1199 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
1200 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
1201 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
1202 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
1203 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
1204 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
1205 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
1206 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
1207 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
1208 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
1209 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
1210 | + size=<size> - Virtual disk size | ||
1211 | |||
1212 | Note that not all of these options may be amendable. | ||
1213 | |||
1214 | Testing: convert -o help | ||
1215 | Supported options: | ||
1216 | -size Virtual disk size | ||
1217 | + size=<size> - Virtual disk size | ||
1218 | |||
1219 | Testing: amend -f bochs -o help | ||
1220 | qemu-img: Format driver 'bochs' does not support option amendment | ||
1221 | -- | 53 | -- |
1222 | 2.19.1 | 54 | 2.40.1 |
1223 | |||
1224 | diff view generated by jsdifflib |
1 | From: Alberto Garcia <berto@igalia.com> | 1 | This adds GRAPH_RDLOCK annotations to declare that callers of |
---|---|---|---|
2 | bdrv_recurse_can_replace() need to hold a reader lock for the graph | ||
3 | because it accesses the children list of a node. | ||
2 | 4 | ||
3 | This is a static function with only one caller, so there's no need to | 5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
4 | keep it. Inlining the code in quorum_compare() makes it much simpler. | 6 | Reviewed-by: Eric Blake <eblake@redhat.com> |
5 | 7 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | |
6 | Signed-off-by: Alberto Garcia <berto@igalia.com> | 8 | Message-Id: <20230504115750.54437-20-kwolf@redhat.com> |
7 | Reported-by: Markus Armbruster <armbru@redhat.com> | ||
8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
9 | --- | 10 | --- |
10 | block/quorum.c | 24 +++++------------------- | 11 | include/block/block-global-state.h | 5 +++-- |
11 | 1 file changed, 5 insertions(+), 19 deletions(-) | 12 | include/block/block_int-common.h | 4 ++-- |
13 | include/block/block_int-global-state.h | 4 ++-- | ||
14 | block/blkverify.c | 5 +++-- | ||
15 | block/mirror.c | 4 ++++ | ||
16 | block/quorum.c | 4 ++-- | ||
17 | blockdev.c | 3 +++ | ||
18 | 7 files changed, 19 insertions(+), 10 deletions(-) | ||
12 | 19 | ||
20 | diff --git a/include/block/block-global-state.h b/include/block/block-global-state.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/include/block/block-global-state.h | ||
23 | +++ b/include/block/block-global-state.h | ||
24 | @@ -XXX,XX +XXX,XX @@ int bdrv_amend_options(BlockDriverState *bs_new, QemuOpts *opts, | ||
25 | Error **errp); | ||
26 | |||
27 | /* check if a named node can be replaced when doing drive-mirror */ | ||
28 | -BlockDriverState *check_to_replace_node(BlockDriverState *parent_bs, | ||
29 | - const char *node_name, Error **errp); | ||
30 | +BlockDriverState * GRAPH_RDLOCK | ||
31 | +check_to_replace_node(BlockDriverState *parent_bs, const char *node_name, | ||
32 | + Error **errp); | ||
33 | |||
34 | int no_coroutine_fn bdrv_activate(BlockDriverState *bs, Error **errp); | ||
35 | |||
36 | diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/include/block/block_int-common.h | ||
39 | +++ b/include/block/block_int-common.h | ||
40 | @@ -XXX,XX +XXX,XX @@ struct BlockDriver { | ||
41 | * same data as @bs without it affecting @bs's behavior (that is, | ||
42 | * without it being visible to @bs's parents). | ||
43 | */ | ||
44 | - bool (*bdrv_recurse_can_replace)(BlockDriverState *bs, | ||
45 | - BlockDriverState *to_replace); | ||
46 | + bool GRAPH_RDLOCK_PTR (*bdrv_recurse_can_replace)( | ||
47 | + BlockDriverState *bs, BlockDriverState *to_replace); | ||
48 | |||
49 | int (*bdrv_probe_device)(const char *filename); | ||
50 | |||
51 | diff --git a/include/block/block_int-global-state.h b/include/block/block_int-global-state.h | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/include/block/block_int-global-state.h | ||
54 | +++ b/include/block/block_int-global-state.h | ||
55 | @@ -XXX,XX +XXX,XX @@ int bdrv_child_try_set_perm(BdrvChild *c, uint64_t perm, uint64_t shared, | ||
56 | */ | ||
57 | int bdrv_child_refresh_perms(BlockDriverState *bs, BdrvChild *c, Error **errp); | ||
58 | |||
59 | -bool bdrv_recurse_can_replace(BlockDriverState *bs, | ||
60 | - BlockDriverState *to_replace); | ||
61 | +bool GRAPH_RDLOCK bdrv_recurse_can_replace(BlockDriverState *bs, | ||
62 | + BlockDriverState *to_replace); | ||
63 | |||
64 | /* | ||
65 | * Default implementation for BlockDriver.bdrv_child_perm() that can | ||
66 | diff --git a/block/blkverify.c b/block/blkverify.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/block/blkverify.c | ||
69 | +++ b/block/blkverify.c | ||
70 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn GRAPH_RDLOCK blkverify_co_flush(BlockDriverState *bs) | ||
71 | return bdrv_co_flush(s->test_file->bs); | ||
72 | } | ||
73 | |||
74 | -static bool blkverify_recurse_can_replace(BlockDriverState *bs, | ||
75 | - BlockDriverState *to_replace) | ||
76 | +static bool GRAPH_RDLOCK | ||
77 | +blkverify_recurse_can_replace(BlockDriverState *bs, | ||
78 | + BlockDriverState *to_replace) | ||
79 | { | ||
80 | BDRVBlkverifyState *s = bs->opaque; | ||
81 | |||
82 | diff --git a/block/mirror.c b/block/mirror.c | ||
83 | index XXXXXXX..XXXXXXX 100644 | ||
84 | --- a/block/mirror.c | ||
85 | +++ b/block/mirror.c | ||
86 | @@ -XXX,XX +XXX,XX @@ static int mirror_exit_common(Job *job) | ||
87 | * Cannot use check_to_replace_node() here, because that would | ||
88 | * check for an op blocker on @to_replace, and we have our own | ||
89 | * there. | ||
90 | + * | ||
91 | + * TODO Pull out the writer lock from bdrv_replace_node() to here | ||
92 | */ | ||
93 | + bdrv_graph_rdlock_main_loop(); | ||
94 | if (bdrv_recurse_can_replace(src, to_replace)) { | ||
95 | bdrv_replace_node(to_replace, target_bs, &local_err); | ||
96 | } else { | ||
97 | @@ -XXX,XX +XXX,XX @@ static int mirror_exit_common(Job *job) | ||
98 | "would not lead to an abrupt change of visible data", | ||
99 | to_replace->node_name, target_bs->node_name); | ||
100 | } | ||
101 | + bdrv_graph_rdunlock_main_loop(); | ||
102 | bdrv_drained_end(target_bs); | ||
103 | if (local_err) { | ||
104 | error_report_err(local_err); | ||
13 | diff --git a/block/quorum.c b/block/quorum.c | 105 | diff --git a/block/quorum.c b/block/quorum.c |
14 | index XXXXXXX..XXXXXXX 100644 | 106 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/block/quorum.c | 107 | --- a/block/quorum.c |
16 | +++ b/block/quorum.c | 108 | +++ b/block/quorum.c |
17 | @@ -XXX,XX +XXX,XX @@ static bool quorum_iovec_compare(QEMUIOVector *a, QEMUIOVector *b) | 109 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn GRAPH_RDLOCK int quorum_co_flush(BlockDriverState *bs) |
18 | return true; | 110 | return result; |
19 | } | 111 | } |
20 | 112 | ||
21 | -static void GCC_FMT_ATTR(2, 3) quorum_err(QuorumAIOCB *acb, | 113 | -static bool quorum_recurse_can_replace(BlockDriverState *bs, |
22 | - const char *fmt, ...) | 114 | - BlockDriverState *to_replace) |
23 | -{ | 115 | +static bool GRAPH_RDLOCK |
24 | - va_list ap; | 116 | +quorum_recurse_can_replace(BlockDriverState *bs, BlockDriverState *to_replace) |
25 | - | ||
26 | - va_start(ap, fmt); | ||
27 | - fprintf(stderr, "quorum: offset=%" PRIu64 " bytes=%" PRIu64 " ", | ||
28 | - acb->offset, acb->bytes); | ||
29 | - vfprintf(stderr, fmt, ap); | ||
30 | - fprintf(stderr, "\n"); | ||
31 | - va_end(ap); | ||
32 | - exit(1); | ||
33 | -} | ||
34 | - | ||
35 | -static bool quorum_compare(QuorumAIOCB *acb, | ||
36 | - QEMUIOVector *a, | ||
37 | - QEMUIOVector *b) | ||
38 | +static bool quorum_compare(QuorumAIOCB *acb, QEMUIOVector *a, QEMUIOVector *b) | ||
39 | { | 117 | { |
40 | BDRVQuorumState *s = acb->bs->opaque; | 118 | BDRVQuorumState *s = bs->opaque; |
41 | ssize_t offset; | 119 | int i; |
42 | @@ -XXX,XX +XXX,XX @@ static bool quorum_compare(QuorumAIOCB *acb, | 120 | diff --git a/blockdev.c b/blockdev.c |
43 | if (s->is_blkverify) { | 121 | index XXXXXXX..XXXXXXX 100644 |
44 | offset = qemu_iovec_compare(a, b); | 122 | --- a/blockdev.c |
45 | if (offset != -1) { | 123 | +++ b/blockdev.c |
46 | - quorum_err(acb, "contents mismatch at offset %" PRIu64, | 124 | @@ -XXX,XX +XXX,XX @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs, |
47 | - acb->offset + offset); | 125 | BlockDriverState *unfiltered_bs; |
48 | + fprintf(stderr, "quorum: offset=%" PRIu64 " bytes=%" PRIu64 | 126 | int job_flags = JOB_DEFAULT; |
49 | + " contents mismatch at offset %" PRIu64 "\n", | 127 | |
50 | + acb->offset, acb->bytes, acb->offset + offset); | 128 | + GLOBAL_STATE_CODE(); |
51 | + exit(1); | 129 | + GRAPH_RDLOCK_GUARD_MAINLOOP(); |
52 | } | 130 | + |
53 | return true; | 131 | if (!has_speed) { |
132 | speed = 0; | ||
54 | } | 133 | } |
55 | -- | 134 | -- |
56 | 2.19.1 | 135 | 2.40.1 |
57 | |||
58 | diff view generated by jsdifflib |
1 | If a management application builds the block graph node by node, the | 1 | This adds GRAPH_RDLOCK annotations to declare that callers of |
---|---|---|---|
2 | protocol layer doesn't inherit its read-only option from the format | 2 | bdrv_refresh_limits() need to hold a reader lock for the graph because |
3 | layer any more, so it must be set explicitly. | 3 | it accesses the children list of a node. |
4 | |||
5 | Backing files should work on read-only storage, but at the same time, a | ||
6 | block job like commit should be able to reopen them read-write if they | ||
7 | are on read-write storage. However, without option inheritance, reopen | ||
8 | only changes the read-only option for the root node (typically the | ||
9 | format layer), but not the protocol layer, so reopening fails (the | ||
10 | format layer wants to get write permissions, but the protocol layer is | ||
11 | still read-only). | ||
12 | |||
13 | A simple workaround for the problem in the management tool would be to | ||
14 | open the protocol layer always read-write and to make only the format | ||
15 | layer read-only for backing files. However, sometimes the file is | ||
16 | actually stored on read-only storage and we don't know whether the image | ||
17 | can be opened read-write (for example, for NBD it depends on the server | ||
18 | we're trying to connect to). This adds an option that makes QEMU try to | ||
19 | open the image read-write, but allows it to degrade to a read-only mode | ||
20 | without returning an error. | ||
21 | |||
22 | The documentation for this option is consciously phrased in a way that | ||
23 | allows QEMU to switch to a better model eventually: Instead of trying | ||
24 | when the image is first opened, making the read-only flag dynamic and | ||
25 | changing it automatically whenever the first BLK_PERM_WRITE user is | ||
26 | attached or the last one is detached would be much more useful | ||
27 | behaviour. | ||
28 | |||
29 | Unfortunately, this more useful behaviour is also a lot harder to | ||
30 | implement, and libvirt needs a solution now before it can switch to | ||
31 | -blockdev, so let's start with this easier approach for now. | ||
32 | |||
33 | Instead of adding a new auto-read-only option, turning the existing | ||
34 | read-only into an enum (with a bool alternate for compatibility) was | ||
35 | considered, but it complicated the implementation to the point that it | ||
36 | didn't seem to be worth it. | ||
37 | 4 | ||
38 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
39 | Reviewed-by: Eric Blake <eblake@redhat.com> | 6 | Reviewed-by: Eric Blake <eblake@redhat.com> |
7 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
8 | Message-Id: <20230504115750.54437-21-kwolf@redhat.com> | ||
9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
40 | --- | 10 | --- |
41 | qapi/block-core.json | 7 +++++++ | 11 | include/block/block-global-state.h | 5 ++++- |
42 | include/block/block.h | 2 ++ | 12 | include/block/block_int-common.h | 3 ++- |
43 | block.c | 17 +++++++++++++++++ | 13 | block.c | 9 +++++++++ |
44 | block/vvfat.c | 1 + | 14 | block/io.c | 1 - |
45 | blockdev.c | 2 +- | 15 | 4 files changed, 15 insertions(+), 3 deletions(-) |
46 | 5 files changed, 28 insertions(+), 1 deletion(-) | ||
47 | 16 | ||
48 | diff --git a/qapi/block-core.json b/qapi/block-core.json | 17 | diff --git a/include/block/block-global-state.h b/include/block/block-global-state.h |
49 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
50 | --- a/qapi/block-core.json | 19 | --- a/include/block/block-global-state.h |
51 | +++ b/qapi/block-core.json | 20 | +++ b/include/block/block-global-state.h |
52 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ int bdrv_reopen_set_read_only(BlockDriverState *bs, bool read_only, |
53 | # either generally or in certain configurations. In this case, | 22 | BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs, |
54 | # the default value does not work and the option must be | 23 | const char *backing_file); |
55 | # specified explicitly. | 24 | void bdrv_refresh_filename(BlockDriverState *bs); |
56 | +# @auto-read-only: if true and @read-only is false, QEMU may automatically | 25 | -void bdrv_refresh_limits(BlockDriverState *bs, Transaction *tran, Error **errp); |
57 | +# decide not to open the image read-write as requested, but | 26 | + |
58 | +# fall back to read-only instead (and switch between the modes | 27 | +void GRAPH_RDLOCK |
59 | +# later), e.g. depending on whether the image file is writable | 28 | +bdrv_refresh_limits(BlockDriverState *bs, Transaction *tran, Error **errp); |
60 | +# or whether a writing user is attached to the node | 29 | + |
61 | +# (default: false, since 3.1) | 30 | int bdrv_commit(BlockDriverState *bs); |
62 | # @detect-zeroes: detect and optimize zero writes (Since 2.1) | 31 | int bdrv_make_empty(BdrvChild *c, Error **errp); |
63 | # (default: off) | 32 | int bdrv_change_backing_file(BlockDriverState *bs, const char *backing_file, |
64 | # @force-share: force share all permission on added nodes. | 33 | diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h |
65 | @@ -XXX,XX +XXX,XX @@ | ||
66 | '*discard': 'BlockdevDiscardOptions', | ||
67 | '*cache': 'BlockdevCacheOptions', | ||
68 | '*read-only': 'bool', | ||
69 | + '*auto-read-only': 'bool', | ||
70 | '*force-share': 'bool', | ||
71 | '*detect-zeroes': 'BlockdevDetectZeroesOptions' }, | ||
72 | 'discriminator': 'driver', | ||
73 | diff --git a/include/block/block.h b/include/block/block.h | ||
74 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
75 | --- a/include/block/block.h | 35 | --- a/include/block/block_int-common.h |
76 | +++ b/include/block/block.h | 36 | +++ b/include/block/block_int-common.h |
77 | @@ -XXX,XX +XXX,XX @@ typedef struct HDGeometry { | 37 | @@ -XXX,XX +XXX,XX @@ struct BlockDriver { |
78 | select an appropriate protocol driver, | 38 | int (*bdrv_debug_resume)(BlockDriverState *bs, const char *tag); |
79 | ignoring the format layer */ | 39 | bool (*bdrv_debug_is_suspended)(BlockDriverState *bs, const char *tag); |
80 | #define BDRV_O_NO_IO 0x10000 /* don't initialize for I/O */ | 40 | |
81 | +#define BDRV_O_AUTO_RDONLY 0x20000 /* degrade to read-only if opening read-write fails */ | 41 | - void (*bdrv_refresh_limits)(BlockDriverState *bs, Error **errp); |
82 | 42 | + void GRAPH_RDLOCK_PTR (*bdrv_refresh_limits)( | |
83 | #define BDRV_O_CACHE_MASK (BDRV_O_NOCACHE | BDRV_O_NO_FLUSH) | 43 | + BlockDriverState *bs, Error **errp); |
84 | 44 | ||
85 | @@ -XXX,XX +XXX,XX @@ typedef struct HDGeometry { | 45 | /* |
86 | #define BDRV_OPT_CACHE_DIRECT "cache.direct" | 46 | * Returns 1 if newly created images are guaranteed to contain only |
87 | #define BDRV_OPT_CACHE_NO_FLUSH "cache.no-flush" | ||
88 | #define BDRV_OPT_READ_ONLY "read-only" | ||
89 | +#define BDRV_OPT_AUTO_READ_ONLY "auto-read-only" | ||
90 | #define BDRV_OPT_DISCARD "discard" | ||
91 | #define BDRV_OPT_FORCE_SHARE "force-share" | ||
92 | |||
93 | diff --git a/block.c b/block.c | 47 | diff --git a/block.c b/block.c |
94 | index XXXXXXX..XXXXXXX 100644 | 48 | index XXXXXXX..XXXXXXX 100644 |
95 | --- a/block.c | 49 | --- a/block.c |
96 | +++ b/block.c | 50 | +++ b/block.c |
97 | @@ -XXX,XX +XXX,XX @@ static void bdrv_inherited_options(int *child_flags, QDict *child_options, | 51 | @@ -XXX,XX +XXX,XX @@ bdrv_open_driver(BlockDriverState *bs, BlockDriver *drv, const char *node_name, |
98 | 52 | return ret; | |
99 | /* Inherit the read-only option from the parent if it's not set */ | ||
100 | qdict_copy_default(child_options, parent_options, BDRV_OPT_READ_ONLY); | ||
101 | + qdict_copy_default(child_options, parent_options, BDRV_OPT_AUTO_READ_ONLY); | ||
102 | |||
103 | /* Our block drivers take care to send flushes and respect unmap policy, | ||
104 | * so we can default to enable both on lower layers regardless of the | ||
105 | @@ -XXX,XX +XXX,XX @@ static void bdrv_backing_options(int *child_flags, QDict *child_options, | ||
106 | |||
107 | /* backing files always opened read-only */ | ||
108 | qdict_set_default_str(child_options, BDRV_OPT_READ_ONLY, "on"); | ||
109 | + qdict_set_default_str(child_options, BDRV_OPT_AUTO_READ_ONLY, "off"); | ||
110 | flags &= ~BDRV_O_COPY_ON_READ; | ||
111 | |||
112 | /* snapshot=on is handled on the top layer */ | ||
113 | @@ -XXX,XX +XXX,XX @@ static void update_flags_from_options(int *flags, QemuOpts *opts) | ||
114 | *flags |= BDRV_O_RDWR; | ||
115 | } | 53 | } |
116 | 54 | ||
117 | + assert(qemu_opt_find(opts, BDRV_OPT_AUTO_READ_ONLY)); | 55 | + bdrv_graph_rdlock_main_loop(); |
118 | + if (qemu_opt_get_bool_del(opts, BDRV_OPT_AUTO_READ_ONLY, false)) { | 56 | bdrv_refresh_limits(bs, NULL, &local_err); |
119 | + *flags |= BDRV_O_AUTO_RDONLY; | 57 | + bdrv_graph_rdunlock_main_loop(); |
120 | + } | 58 | + |
59 | if (local_err) { | ||
60 | error_propagate(errp, local_err); | ||
61 | return -EINVAL; | ||
62 | @@ -XXX,XX +XXX,XX @@ static int bdrv_set_file_or_backing_noperm(BlockDriverState *parent_bs, | ||
63 | } | ||
64 | |||
65 | out: | ||
66 | + bdrv_graph_rdlock_main_loop(); | ||
67 | bdrv_refresh_limits(parent_bs, tran, NULL); | ||
68 | + bdrv_graph_rdunlock_main_loop(); | ||
69 | |||
70 | return 0; | ||
121 | } | 71 | } |
122 | 72 | @@ -XXX,XX +XXX,XX @@ static void bdrv_reopen_commit(BDRVReopenState *reopen_state) | |
123 | static void update_options_from_flags(QDict *options, int flags) | 73 | qdict_del(bs->explicit_options, "backing"); |
124 | @@ -XXX,XX +XXX,XX @@ static void update_options_from_flags(QDict *options, int flags) | 74 | qdict_del(bs->options, "backing"); |
125 | if (!qdict_haskey(options, BDRV_OPT_READ_ONLY)) { | 75 | |
126 | qdict_put_bool(options, BDRV_OPT_READ_ONLY, !(flags & BDRV_O_RDWR)); | 76 | + bdrv_graph_rdlock_main_loop(); |
127 | } | 77 | bdrv_refresh_limits(bs, NULL, NULL); |
128 | + if (!qdict_haskey(options, BDRV_OPT_AUTO_READ_ONLY)) { | 78 | + bdrv_graph_rdunlock_main_loop(); |
129 | + qdict_put_bool(options, BDRV_OPT_AUTO_READ_ONLY, | 79 | bdrv_refresh_total_sectors(bs, bs->total_sectors); |
130 | + flags & BDRV_O_AUTO_RDONLY); | ||
131 | + } | ||
132 | } | 80 | } |
133 | 81 | ||
134 | static void bdrv_assign_node_name(BlockDriverState *bs, | 82 | @@ -XXX,XX +XXX,XX @@ int bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top, |
135 | @@ -XXX,XX +XXX,XX @@ QemuOptsList bdrv_runtime_opts = { | 83 | out: |
136 | .type = QEMU_OPT_BOOL, | 84 | tran_finalize(tran, ret); |
137 | .help = "Node is opened in read-only mode", | 85 | |
138 | }, | 86 | + bdrv_graph_rdlock_main_loop(); |
139 | + { | 87 | bdrv_refresh_limits(bs_top, NULL, NULL); |
140 | + .name = BDRV_OPT_AUTO_READ_ONLY, | 88 | + bdrv_graph_rdunlock_main_loop(); |
141 | + .type = QEMU_OPT_BOOL, | 89 | |
142 | + .help = "Node can become read-only if opening read-write fails", | 90 | if (new_context && old_context != new_context) { |
143 | + }, | 91 | aio_context_release(new_context); |
144 | { | 92 | diff --git a/block/io.c b/block/io.c |
145 | .name = "detect-zeroes", | ||
146 | .type = QEMU_OPT_STRING, | ||
147 | @@ -XXX,XX +XXX,XX @@ BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp) | ||
148 | qdict_set_default_str(qdict, BDRV_OPT_CACHE_DIRECT, "off"); | ||
149 | qdict_set_default_str(qdict, BDRV_OPT_CACHE_NO_FLUSH, "off"); | ||
150 | qdict_set_default_str(qdict, BDRV_OPT_READ_ONLY, "off"); | ||
151 | + qdict_set_default_str(qdict, BDRV_OPT_AUTO_READ_ONLY, "off"); | ||
152 | + | ||
153 | } | ||
154 | |||
155 | bs = bdrv_open_inherit(NULL, reference, qdict, 0, NULL, NULL, errp); | ||
156 | diff --git a/block/vvfat.c b/block/vvfat.c | ||
157 | index XXXXXXX..XXXXXXX 100644 | 93 | index XXXXXXX..XXXXXXX 100644 |
158 | --- a/block/vvfat.c | 94 | --- a/block/io.c |
159 | +++ b/block/vvfat.c | 95 | +++ b/block/io.c |
160 | @@ -XXX,XX +XXX,XX @@ static void vvfat_qcow_options(int *child_flags, QDict *child_options, | 96 | @@ -XXX,XX +XXX,XX @@ void bdrv_refresh_limits(BlockDriverState *bs, Transaction *tran, Error **errp) |
161 | int parent_flags, QDict *parent_options) | 97 | bool have_limits; |
162 | { | 98 | |
163 | qdict_set_default_str(child_options, BDRV_OPT_READ_ONLY, "off"); | 99 | GLOBAL_STATE_CODE(); |
164 | + qdict_set_default_str(child_options, BDRV_OPT_AUTO_READ_ONLY, "off"); | 100 | - assume_graph_lock(); /* FIXME */ |
165 | qdict_set_default_str(child_options, BDRV_OPT_CACHE_NO_FLUSH, "on"); | 101 | |
166 | } | 102 | if (tran) { |
167 | 103 | BdrvRefreshLimitsState *s = g_new(BdrvRefreshLimitsState, 1); | |
168 | diff --git a/blockdev.c b/blockdev.c | ||
169 | index XXXXXXX..XXXXXXX 100644 | ||
170 | --- a/blockdev.c | ||
171 | +++ b/blockdev.c | ||
172 | @@ -XXX,XX +XXX,XX @@ void qmp_blockdev_change_medium(bool has_device, const char *device, | ||
173 | |||
174 | bdrv_flags = blk_get_open_flags_from_root_state(blk); | ||
175 | bdrv_flags &= ~(BDRV_O_TEMPORARY | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING | | ||
176 | - BDRV_O_PROTOCOL); | ||
177 | + BDRV_O_PROTOCOL | BDRV_O_AUTO_RDONLY); | ||
178 | |||
179 | if (!has_read_only) { | ||
180 | read_only = BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN; | ||
181 | -- | 104 | -- |
182 | 2.19.1 | 105 | 2.40.1 |
183 | |||
184 | diff view generated by jsdifflib |
1 | From: Peter Maydell <peter.maydell@linaro.org> | 1 | From: Stefan Hajnoczi <stefanha@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Taking the address of a field in a packed struct is a bad idea, because | 3 | reader_count() is a performance bottleneck because the global |
4 | it might not be actually aligned enough for that pointer type (and | 4 | aio_context_list_lock mutex causes thread contention. Put this debugging |
5 | thus cause a crash on dereference on some host architectures). Newer | 5 | assertion behind a new ./configure --enable-debug-graph-lock option and |
6 | versions of clang warn about this. Avoid the bug by not using the | 6 | disable it by default. |
7 | "modify in place" byte swapping functions. | ||
8 | 7 | ||
9 | There are a few places where the in-place swap function is | 8 | The --enable-debug-graph-lock option is also enabled by the more general |
10 | used on something other than a packed struct field; we convert | 9 | --enable-debug option. |
11 | those anyway, for consistency. | ||
12 | 10 | ||
13 | This patch was produced with the following spatch script: | 11 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
14 | 12 | Message-Id: <20230501173443.153062-1-stefanha@redhat.com> | |
15 | @@ | 13 | Reviewed-by: Kevin Wolf <kwolf@redhat.com> |
16 | expression E; | ||
17 | @@ | ||
18 | -be16_to_cpus(&E); | ||
19 | +E = be16_to_cpu(E); | ||
20 | @@ | ||
21 | expression E; | ||
22 | @@ | ||
23 | -be32_to_cpus(&E); | ||
24 | +E = be32_to_cpu(E); | ||
25 | @@ | ||
26 | expression E; | ||
27 | @@ | ||
28 | -be64_to_cpus(&E); | ||
29 | +E = be64_to_cpu(E); | ||
30 | @@ | ||
31 | expression E; | ||
32 | @@ | ||
33 | -cpu_to_be16s(&E); | ||
34 | +E = cpu_to_be16(E); | ||
35 | @@ | ||
36 | expression E; | ||
37 | @@ | ||
38 | -cpu_to_be32s(&E); | ||
39 | +E = cpu_to_be32(E); | ||
40 | @@ | ||
41 | expression E; | ||
42 | @@ | ||
43 | -cpu_to_be64s(&E); | ||
44 | +E = cpu_to_be64(E); | ||
45 | |||
46 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
47 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
48 | Tested-by: John Snow <jsnow@redhat.com> | ||
49 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
50 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 14 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
51 | --- | 15 | --- |
52 | block/qcow2-bitmap.c | 24 ++++++++++++------------ | 16 | meson_options.txt | 2 ++ |
53 | 1 file changed, 12 insertions(+), 12 deletions(-) | 17 | configure | 1 + |
18 | block/graph-lock.c | 3 +++ | ||
19 | meson.build | 2 ++ | ||
20 | scripts/meson-buildoptions.sh | 4 ++++ | ||
21 | 5 files changed, 12 insertions(+) | ||
54 | 22 | ||
55 | diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c | 23 | diff --git a/meson_options.txt b/meson_options.txt |
56 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
57 | --- a/block/qcow2-bitmap.c | 25 | --- a/meson_options.txt |
58 | +++ b/block/qcow2-bitmap.c | 26 | +++ b/meson_options.txt |
59 | @@ -XXX,XX +XXX,XX @@ static inline void bitmap_table_to_be(uint64_t *bitmap_table, size_t size) | 27 | @@ -XXX,XX +XXX,XX @@ option('rng_none', type: 'boolean', value: false, |
60 | size_t i; | 28 | description: 'dummy RNG, avoid using /dev/(u)random and getrandom()') |
61 | 29 | option('coroutine_pool', type: 'boolean', value: true, | |
62 | for (i = 0; i < size; ++i) { | 30 | description: 'coroutine freelist (better performance)') |
63 | - cpu_to_be64s(&bitmap_table[i]); | 31 | +option('debug_graph_lock', type: 'boolean', value: false, |
64 | + bitmap_table[i] = cpu_to_be64(bitmap_table[i]); | 32 | + description: 'graph lock debugging support') |
65 | } | 33 | option('debug_mutex', type: 'boolean', value: false, |
34 | description: 'mutex debugging support') | ||
35 | option('debug_stack_usage', type: 'boolean', value: false, | ||
36 | diff --git a/configure b/configure | ||
37 | index XXXXXXX..XXXXXXX 100755 | ||
38 | --- a/configure | ||
39 | +++ b/configure | ||
40 | @@ -XXX,XX +XXX,XX @@ for opt do | ||
41 | --enable-debug) | ||
42 | # Enable debugging options that aren't excessively noisy | ||
43 | debug_tcg="yes" | ||
44 | + meson_option_parse --enable-debug-graph-lock "" | ||
45 | meson_option_parse --enable-debug-mutex "" | ||
46 | meson_option_add -Doptimization=0 | ||
47 | fortify_source="no" | ||
48 | diff --git a/block/graph-lock.c b/block/graph-lock.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/block/graph-lock.c | ||
51 | +++ b/block/graph-lock.c | ||
52 | @@ -XXX,XX +XXX,XX @@ void bdrv_graph_rdunlock_main_loop(void) | ||
53 | |||
54 | void assert_bdrv_graph_readable(void) | ||
55 | { | ||
56 | + /* reader_count() is slow due to aio_context_list_lock lock contention */ | ||
57 | +#ifdef CONFIG_DEBUG_GRAPH_LOCK | ||
58 | assert(qemu_in_main_thread() || reader_count()); | ||
59 | +#endif | ||
66 | } | 60 | } |
67 | 61 | ||
68 | @@ -XXX,XX +XXX,XX @@ static int bitmap_table_load(BlockDriverState *bs, Qcow2BitmapTable *tb, | 62 | void assert_bdrv_graph_writable(void) |
69 | } | 63 | diff --git a/meson.build b/meson.build |
70 | 64 | index XXXXXXX..XXXXXXX 100644 | |
71 | for (i = 0; i < tb->size; ++i) { | 65 | --- a/meson.build |
72 | - be64_to_cpus(&table[i]); | 66 | +++ b/meson.build |
73 | + table[i] = be64_to_cpu(table[i]); | 67 | @@ -XXX,XX +XXX,XX @@ if get_option('debug_stack_usage') and have_coroutine_pool |
74 | ret = check_table_entry(table[i], s->cluster_size); | 68 | have_coroutine_pool = false |
75 | if (ret < 0) { | 69 | endif |
76 | goto fail; | 70 | config_host_data.set10('CONFIG_COROUTINE_POOL', have_coroutine_pool) |
77 | @@ -XXX,XX +XXX,XX @@ fail: | 71 | +config_host_data.set('CONFIG_DEBUG_GRAPH_LOCK', get_option('debug_graph_lock')) |
78 | 72 | config_host_data.set('CONFIG_DEBUG_MUTEX', get_option('debug_mutex')) | |
79 | static inline void bitmap_dir_entry_to_cpu(Qcow2BitmapDirEntry *entry) | 73 | config_host_data.set('CONFIG_DEBUG_STACK_USAGE', get_option('debug_stack_usage')) |
80 | { | 74 | config_host_data.set('CONFIG_GPROF', get_option('gprof')) |
81 | - be64_to_cpus(&entry->bitmap_table_offset); | 75 | @@ -XXX,XX +XXX,XX @@ summary_info += {'PIE': get_option('b_pie')} |
82 | - be32_to_cpus(&entry->bitmap_table_size); | 76 | summary_info += {'static build': config_host.has_key('CONFIG_STATIC')} |
83 | - be32_to_cpus(&entry->flags); | 77 | summary_info += {'malloc trim support': has_malloc_trim} |
84 | - be16_to_cpus(&entry->name_size); | 78 | summary_info += {'membarrier': have_membarrier} |
85 | - be32_to_cpus(&entry->extra_data_size); | 79 | +summary_info += {'debug graph lock': get_option('debug_graph_lock')} |
86 | + entry->bitmap_table_offset = be64_to_cpu(entry->bitmap_table_offset); | 80 | summary_info += {'debug stack usage': get_option('debug_stack_usage')} |
87 | + entry->bitmap_table_size = be32_to_cpu(entry->bitmap_table_size); | 81 | summary_info += {'mutex debugging': get_option('debug_mutex')} |
88 | + entry->flags = be32_to_cpu(entry->flags); | 82 | summary_info += {'memory allocator': get_option('malloc')} |
89 | + entry->name_size = be16_to_cpu(entry->name_size); | 83 | diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh |
90 | + entry->extra_data_size = be32_to_cpu(entry->extra_data_size); | 84 | index XXXXXXX..XXXXXXX 100644 |
91 | } | 85 | --- a/scripts/meson-buildoptions.sh |
92 | 86 | +++ b/scripts/meson-buildoptions.sh | |
93 | static inline void bitmap_dir_entry_to_be(Qcow2BitmapDirEntry *entry) | 87 | @@ -XXX,XX +XXX,XX @@ meson_options_help() { |
94 | { | 88 | printf "%s\n" ' QEMU' |
95 | - cpu_to_be64s(&entry->bitmap_table_offset); | 89 | printf "%s\n" ' --enable-cfi Control-Flow Integrity (CFI)' |
96 | - cpu_to_be32s(&entry->bitmap_table_size); | 90 | printf "%s\n" ' --enable-cfi-debug Verbose errors in case of CFI violation' |
97 | - cpu_to_be32s(&entry->flags); | 91 | + printf "%s\n" ' --enable-debug-graph-lock' |
98 | - cpu_to_be16s(&entry->name_size); | 92 | + printf "%s\n" ' graph lock debugging support' |
99 | - cpu_to_be32s(&entry->extra_data_size); | 93 | printf "%s\n" ' --enable-debug-mutex mutex debugging support' |
100 | + entry->bitmap_table_offset = cpu_to_be64(entry->bitmap_table_offset); | 94 | printf "%s\n" ' --enable-debug-stack-usage' |
101 | + entry->bitmap_table_size = cpu_to_be32(entry->bitmap_table_size); | 95 | printf "%s\n" ' measure coroutine stack usage' |
102 | + entry->flags = cpu_to_be32(entry->flags); | 96 | @@ -XXX,XX +XXX,XX @@ _meson_option_parse() { |
103 | + entry->name_size = cpu_to_be16(entry->name_size); | 97 | --datadir=*) quote_sh "-Ddatadir=$2" ;; |
104 | + entry->extra_data_size = cpu_to_be32(entry->extra_data_size); | 98 | --enable-dbus-display) printf "%s" -Ddbus_display=enabled ;; |
105 | } | 99 | --disable-dbus-display) printf "%s" -Ddbus_display=disabled ;; |
106 | 100 | + --enable-debug-graph-lock) printf "%s" -Ddebug_graph_lock=true ;; | |
107 | static inline int calc_dir_entry_size(size_t name_size, size_t extra_data_size) | 101 | + --disable-debug-graph-lock) printf "%s" -Ddebug_graph_lock=false ;; |
102 | --enable-debug-mutex) printf "%s" -Ddebug_mutex=true ;; | ||
103 | --disable-debug-mutex) printf "%s" -Ddebug_mutex=false ;; | ||
104 | --enable-debug-stack-usage) printf "%s" -Ddebug_stack_usage=true ;; | ||
108 | -- | 105 | -- |
109 | 2.19.1 | 106 | 2.40.1 |
110 | |||
111 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Daniel P. Berrangé <berrange@redhat.com> | ||
2 | 1 | ||
3 | The qcow2 block driver expects to see a valid sector size even when it | ||
4 | has opened the crypto layer with QCRYPTO_BLOCK_OPEN_NO_IO. | ||
5 | |||
6 | Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> | ||
7 | Reviewed-by: Alberto Garcia <berto@igalia.com> | ||
8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
9 | --- | ||
10 | crypto/block-qcow.c | 2 ++ | ||
11 | 1 file changed, 2 insertions(+) | ||
12 | |||
13 | diff --git a/crypto/block-qcow.c b/crypto/block-qcow.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/crypto/block-qcow.c | ||
16 | +++ b/crypto/block-qcow.c | ||
17 | @@ -XXX,XX +XXX,XX @@ qcrypto_block_qcow_open(QCryptoBlock *block, | ||
18 | Error **errp) | ||
19 | { | ||
20 | if (flags & QCRYPTO_BLOCK_OPEN_NO_IO) { | ||
21 | + block->sector_size = QCRYPTO_BLOCK_QCOW_SECTOR_SIZE; | ||
22 | + block->payload_offset = 0; | ||
23 | return 0; | ||
24 | } else { | ||
25 | if (!options->u.qcow.key_secret) { | ||
26 | -- | ||
27 | 2.19.1 | ||
28 | |||
29 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
2 | Reviewed-by: Alberto Garcia <berto@igalia.com> | ||
3 | --- | ||
4 | block/vpc.c | 2 ++ | ||
5 | 1 file changed, 2 insertions(+) | ||
6 | 1 | ||
7 | diff --git a/block/vpc.c b/block/vpc.c | ||
8 | index XXXXXXX..XXXXXXX 100644 | ||
9 | --- a/block/vpc.c | ||
10 | +++ b/block/vpc.c | ||
11 | @@ -XXX,XX +XXX,XX @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, | ||
12 | } | ||
13 | |||
14 | qemu_co_mutex_init(&s->lock); | ||
15 | + qemu_opts_del(opts); | ||
16 | |||
17 | return 0; | ||
18 | |||
19 | fail: | ||
20 | + qemu_opts_del(opts); | ||
21 | qemu_vfree(s->pagetable); | ||
22 | #ifdef CACHE | ||
23 | g_free(s->pageentry_u8); | ||
24 | -- | ||
25 | 2.19.1 | ||
26 | |||
27 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alberto Garcia <berto@igalia.com> | ||
2 | 1 | ||
3 | The blkverify mode of Quorum can only be enabled if the number of | ||
4 | children is exactly two and the value of vote-threshold is also two. | ||
5 | |||
6 | If the user tries to enable it but the other settings are incorrect | ||
7 | then QEMU simply prints an error message to stderr and carries on | ||
8 | disabling the blkverify setting. | ||
9 | |||
10 | This patch makes quorum_open() fail and return an error in this case. | ||
11 | |||
12 | Signed-off-by: Alberto Garcia <berto@igalia.com> | ||
13 | Reported-by: Markus Armbruster <armbru@redhat.com> | ||
14 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
15 | --- | ||
16 | block/quorum.c | 13 ++++++------- | ||
17 | 1 file changed, 6 insertions(+), 7 deletions(-) | ||
18 | |||
19 | diff --git a/block/quorum.c b/block/quorum.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/block/quorum.c | ||
22 | +++ b/block/quorum.c | ||
23 | @@ -XXX,XX +XXX,XX @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, | ||
24 | s->read_pattern = ret; | ||
25 | |||
26 | if (s->read_pattern == QUORUM_READ_PATTERN_QUORUM) { | ||
27 | - /* is the driver in blkverify mode */ | ||
28 | - if (qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false) && | ||
29 | - s->num_children == 2 && s->threshold == 2) { | ||
30 | - s->is_blkverify = true; | ||
31 | - } else if (qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false)) { | ||
32 | - fprintf(stderr, "blkverify mode is set by setting blkverify=on " | ||
33 | - "and using two files with vote_threshold=2\n"); | ||
34 | + s->is_blkverify = qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false); | ||
35 | + if (s->is_blkverify && (s->num_children != 2 || s->threshold != 2)) { | ||
36 | + error_setg(&local_err, "blkverify=on can only be set if there are " | ||
37 | + "exactly two files and vote-threshold is 2"); | ||
38 | + ret = -EINVAL; | ||
39 | + goto exit; | ||
40 | } | ||
41 | |||
42 | s->rewrite_corrupted = qemu_opt_get_bool(opts, QUORUM_OPT_REWRITE, | ||
43 | -- | ||
44 | 2.19.1 | ||
45 | |||
46 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alberto Garcia <berto@igalia.com> | ||
2 | 1 | ||
3 | Signed-off-by: Alberto Garcia <berto@igalia.com> | ||
4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
5 | --- | ||
6 | tests/qemu-iotests/081 | 30 ++++++++++++++++++++++++++++++ | ||
7 | tests/qemu-iotests/081.out | 16 ++++++++++++++++ | ||
8 | 2 files changed, 46 insertions(+) | ||
9 | |||
10 | diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081 | ||
11 | index XXXXXXX..XXXXXXX 100755 | ||
12 | --- a/tests/qemu-iotests/081 | ||
13 | +++ b/tests/qemu-iotests/081 | ||
14 | @@ -XXX,XX +XXX,XX @@ echo "== checking that quorum is broken ==" | ||
15 | |||
16 | $QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io | ||
17 | |||
18 | +echo | ||
19 | +echo "== checking the blkverify mode with broken content ==" | ||
20 | + | ||
21 | +quorum="driver=raw,file.driver=quorum,file.vote-threshold=2,file.blkverify=on" | ||
22 | +quorum="$quorum,file.children.0.file.filename=$TEST_DIR/1.raw" | ||
23 | +quorum="$quorum,file.children.1.file.filename=$TEST_DIR/2.raw" | ||
24 | +quorum="$quorum,file.children.0.driver=raw" | ||
25 | +quorum="$quorum,file.children.1.driver=raw" | ||
26 | + | ||
27 | +$QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io | ||
28 | + | ||
29 | +echo | ||
30 | +echo "== writing the same data to both files ==" | ||
31 | + | ||
32 | +$QEMU_IO -c "write -P 0x32 0 $size" "$TEST_DIR/1.raw" | _filter_qemu_io | ||
33 | +$QEMU_IO -c "write -P 0x32 0 $size" "$TEST_DIR/2.raw" | _filter_qemu_io | ||
34 | + | ||
35 | +echo | ||
36 | +echo "== checking the blkverify mode with valid content ==" | ||
37 | + | ||
38 | +$QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io | ||
39 | + | ||
40 | +echo | ||
41 | +echo "== checking the blkverify mode with invalid settings ==" | ||
42 | + | ||
43 | +quorum="$quorum,file.children.2.file.filename=$TEST_DIR/3.raw" | ||
44 | +quorum="$quorum,file.children.2.driver=raw" | ||
45 | + | ||
46 | +$QEMU_IO -c "open -o $quorum" | _filter_qemu_io | ||
47 | + | ||
48 | # success, all done | ||
49 | echo "*** done" | ||
50 | rm -f $seq.full | ||
51 | diff --git a/tests/qemu-iotests/081.out b/tests/qemu-iotests/081.out | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/tests/qemu-iotests/081.out | ||
54 | +++ b/tests/qemu-iotests/081.out | ||
55 | @@ -XXX,XX +XXX,XX @@ wrote 10485760/10485760 bytes at offset 0 | ||
56 | |||
57 | == checking that quorum is broken == | ||
58 | read failed: Input/output error | ||
59 | + | ||
60 | +== checking the blkverify mode with broken content == | ||
61 | +quorum: offset=0 bytes=10485760 contents mismatch at offset 0 | ||
62 | + | ||
63 | +== writing the same data to both files == | ||
64 | +wrote 10485760/10485760 bytes at offset 0 | ||
65 | +10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
66 | +wrote 10485760/10485760 bytes at offset 0 | ||
67 | +10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
68 | + | ||
69 | +== checking the blkverify mode with valid content == | ||
70 | +read 10485760/10485760 bytes at offset 0 | ||
71 | +10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
72 | + | ||
73 | +== checking the blkverify mode with invalid settings == | ||
74 | +can't open: blkverify=on can only be set if there are exactly two files and vote-threshold is 2 | ||
75 | *** done | ||
76 | -- | ||
77 | 2.19.1 | ||
78 | |||
79 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alberto Garcia <berto@igalia.com> | ||
2 | 1 | ||
3 | This patch tests that you can add and remove drives from a Quorum | ||
4 | using the x-blockdev-change command. | ||
5 | |||
6 | Signed-off-by: Alberto Garcia <berto@igalia.com> | ||
7 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
8 | --- | ||
9 | tests/qemu-iotests/081 | 86 ++++++++++++++++++++++++++++++++++++++ | ||
10 | tests/qemu-iotests/081.out | 54 ++++++++++++++++++++++++ | ||
11 | 2 files changed, 140 insertions(+) | ||
12 | |||
13 | diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081 | ||
14 | index XXXXXXX..XXXXXXX 100755 | ||
15 | --- a/tests/qemu-iotests/081 | ||
16 | +++ b/tests/qemu-iotests/081 | ||
17 | @@ -XXX,XX +XXX,XX @@ quorum="$quorum,file.children.2.driver=raw" | ||
18 | |||
19 | $QEMU_IO -c "open -o $quorum" | _filter_qemu_io | ||
20 | |||
21 | +echo | ||
22 | +echo "== dynamically adding a child to a quorum ==" | ||
23 | + | ||
24 | +for verify in false true; do | ||
25 | + run_qemu <<EOF | ||
26 | + { "execute": "qmp_capabilities" } | ||
27 | + { "execute": "blockdev-add", | ||
28 | + "arguments": { | ||
29 | + "driver": "quorum", | ||
30 | + "node-name": "drive0-quorum", | ||
31 | + "vote-threshold": 2, | ||
32 | + "blkverify": ${verify}, | ||
33 | + "children": [ | ||
34 | + { | ||
35 | + "driver": "$IMGFMT", | ||
36 | + "file": { | ||
37 | + "driver": "file", | ||
38 | + "filename": "$TEST_DIR/1.raw" | ||
39 | + } | ||
40 | + }, | ||
41 | + { | ||
42 | + "driver": "$IMGFMT", | ||
43 | + "file": { | ||
44 | + "driver": "file", | ||
45 | + "filename": "$TEST_DIR/2.raw" | ||
46 | + } | ||
47 | + } | ||
48 | + ] | ||
49 | + } | ||
50 | + } | ||
51 | + { "execute": "blockdev-add", | ||
52 | + "arguments": { | ||
53 | + "node-name": "drive3", | ||
54 | + "driver": "$IMGFMT", | ||
55 | + "file": { | ||
56 | + "driver": "file", | ||
57 | + "filename": "$TEST_DIR/2.raw" | ||
58 | + } | ||
59 | + } | ||
60 | + } | ||
61 | + { "execute": "x-blockdev-change", | ||
62 | + "arguments": { "parent": "drive0-quorum", | ||
63 | + "node": "drive3" } } | ||
64 | + { "execute": "quit" } | ||
65 | +EOF | ||
66 | +done | ||
67 | + | ||
68 | +echo | ||
69 | +echo "== dynamically removing a child from a quorum ==" | ||
70 | + | ||
71 | +for verify in false true; do | ||
72 | + for vote_threshold in 1 2; do | ||
73 | + run_qemu <<EOF | ||
74 | + { "execute": "qmp_capabilities" } | ||
75 | + { "execute": "blockdev-add", | ||
76 | + "arguments": { | ||
77 | + "driver": "quorum", | ||
78 | + "node-name": "drive0-quorum", | ||
79 | + "vote-threshold": ${vote_threshold}, | ||
80 | + "blkverify": ${verify}, | ||
81 | + "children": [ | ||
82 | + { | ||
83 | + "driver": "$IMGFMT", | ||
84 | + "file": { | ||
85 | + "driver": "file", | ||
86 | + "filename": "$TEST_DIR/1.raw" | ||
87 | + } | ||
88 | + }, | ||
89 | + { | ||
90 | + "driver": "$IMGFMT", | ||
91 | + "file": { | ||
92 | + "driver": "file", | ||
93 | + "filename": "$TEST_DIR/2.raw" | ||
94 | + } | ||
95 | + } | ||
96 | + ] | ||
97 | + } | ||
98 | + } | ||
99 | + { "execute": "x-blockdev-change", | ||
100 | + "arguments": { "parent": "drive0-quorum", | ||
101 | + "child": "children.1" } } | ||
102 | + { "execute": "quit" } | ||
103 | +EOF | ||
104 | + done | ||
105 | +done | ||
106 | + | ||
107 | # success, all done | ||
108 | echo "*** done" | ||
109 | rm -f $seq.full | ||
110 | diff --git a/tests/qemu-iotests/081.out b/tests/qemu-iotests/081.out | ||
111 | index XXXXXXX..XXXXXXX 100644 | ||
112 | --- a/tests/qemu-iotests/081.out | ||
113 | +++ b/tests/qemu-iotests/081.out | ||
114 | @@ -XXX,XX +XXX,XX @@ read 10485760/10485760 bytes at offset 0 | ||
115 | |||
116 | == checking the blkverify mode with invalid settings == | ||
117 | can't open: blkverify=on can only be set if there are exactly two files and vote-threshold is 2 | ||
118 | + | ||
119 | +== dynamically adding a child to a quorum == | ||
120 | +Testing: | ||
121 | +QMP_VERSION | ||
122 | +{"return": {}} | ||
123 | +{"return": {}} | ||
124 | +{"return": {}} | ||
125 | +{"return": {}} | ||
126 | +{"return": {}} | ||
127 | +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} | ||
128 | + | ||
129 | +Testing: | ||
130 | +QMP_VERSION | ||
131 | +{"return": {}} | ||
132 | +{"return": {}} | ||
133 | +{"return": {}} | ||
134 | +{"error": {"class": "GenericError", "desc": "Cannot add a child to a quorum in blkverify mode"}} | ||
135 | +{"return": {}} | ||
136 | +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} | ||
137 | + | ||
138 | + | ||
139 | +== dynamically removing a child from a quorum == | ||
140 | +Testing: | ||
141 | +QMP_VERSION | ||
142 | +{"return": {}} | ||
143 | +{"return": {}} | ||
144 | +{"return": {}} | ||
145 | +{"return": {}} | ||
146 | +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} | ||
147 | + | ||
148 | +Testing: | ||
149 | +QMP_VERSION | ||
150 | +{"return": {}} | ||
151 | +{"return": {}} | ||
152 | +{"error": {"class": "GenericError", "desc": "The number of children cannot be lower than the vote threshold 2"}} | ||
153 | +{"return": {}} | ||
154 | +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} | ||
155 | + | ||
156 | +Testing: | ||
157 | +QMP_VERSION | ||
158 | +{"return": {}} | ||
159 | +{"error": {"class": "GenericError", "desc": "blkverify=on can only be set if there are exactly two files and vote-threshold is 2"}} | ||
160 | +{"error": {"class": "GenericError", "desc": "Cannot find device=drive0-quorum nor node_name=drive0-quorum"}} | ||
161 | +{"return": {}} | ||
162 | +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} | ||
163 | + | ||
164 | +Testing: | ||
165 | +QMP_VERSION | ||
166 | +{"return": {}} | ||
167 | +{"return": {}} | ||
168 | +{"error": {"class": "GenericError", "desc": "The number of children cannot be lower than the vote threshold 2"}} | ||
169 | +{"return": {}} | ||
170 | +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} | ||
171 | + | ||
172 | *** done | ||
173 | -- | ||
174 | 2.19.1 | ||
175 | |||
176 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | If read-only=off, but auto-read-only=on is given, open the file | ||
2 | read-write if we have the permissions, but instead of erroring out for | ||
3 | read-only files, just degrade to read-only. | ||
4 | 1 | ||
5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
6 | Reviewed-by: Niels de Vos <ndevos@redhat.com> | ||
7 | --- | ||
8 | block/gluster.c | 12 ++++++++++-- | ||
9 | 1 file changed, 10 insertions(+), 2 deletions(-) | ||
10 | |||
11 | diff --git a/block/gluster.c b/block/gluster.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/block/gluster.c | ||
14 | +++ b/block/gluster.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static int qemu_gluster_open(BlockDriverState *bs, QDict *options, | ||
16 | qemu_gluster_parse_flags(bdrv_flags, &open_flags); | ||
17 | |||
18 | s->fd = glfs_open(s->glfs, gconf->path, open_flags); | ||
19 | - if (!s->fd) { | ||
20 | - ret = -errno; | ||
21 | + ret = s->fd ? 0 : -errno; | ||
22 | + | ||
23 | + if (ret == -EACCES || ret == -EROFS) { | ||
24 | + /* Try to degrade to read-only, but if it doesn't work, still use the | ||
25 | + * normal error message. */ | ||
26 | + if (bdrv_apply_auto_read_only(bs, NULL, NULL) == 0) { | ||
27 | + open_flags = (open_flags & ~O_RDWR) | O_RDONLY; | ||
28 | + s->fd = glfs_open(s->glfs, gconf->path, open_flags); | ||
29 | + ret = s->fd ? 0 : -errno; | ||
30 | + } | ||
31 | } | ||
32 | |||
33 | s->supports_seek_data = qemu_gluster_test_seek(s->fd); | ||
34 | -- | ||
35 | 2.19.1 | ||
36 | |||
37 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Max Reitz <mreitz@redhat.com> | ||
2 | 1 | ||
3 | Just like in qemu_opts_print_help(), print the device name as a caption | ||
4 | instead of on every single line, indent all options, add angle brackets | ||
5 | around types, and align the descriptions after 24 characters. Also, | ||
6 | separate the descriptions with " - " instead of putting them in | ||
7 | parentheses, because that is what we do everywhere else. This does look | ||
8 | a bit funny here because basically all bits have the description | ||
9 | "on/off", but funny does not mean it is less readable. | ||
10 | |||
11 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
12 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | ||
13 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
14 | --- | ||
15 | qdev-monitor.c | 13 +++++++++++-- | ||
16 | 1 file changed, 11 insertions(+), 2 deletions(-) | ||
17 | |||
18 | diff --git a/qdev-monitor.c b/qdev-monitor.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/qdev-monitor.c | ||
21 | +++ b/qdev-monitor.c | ||
22 | @@ -XXX,XX +XXX,XX @@ int qdev_device_help(QemuOpts *opts) | ||
23 | goto error; | ||
24 | } | ||
25 | |||
26 | + if (prop_list) { | ||
27 | + out_printf("%s options:\n", driver); | ||
28 | + } else { | ||
29 | + out_printf("There are no options for %s.\n", driver); | ||
30 | + } | ||
31 | for (prop = prop_list; prop; prop = prop->next) { | ||
32 | - out_printf("%s.%s=%s", driver, prop->value->name, prop->value->type); | ||
33 | + int len; | ||
34 | + out_printf(" %s=<%s>%n", prop->value->name, prop->value->type, &len); | ||
35 | if (prop->value->has_description) { | ||
36 | - out_printf(" (%s)\n", prop->value->description); | ||
37 | + if (len < 24) { | ||
38 | + out_printf("%*s", 24 - len, ""); | ||
39 | + } | ||
40 | + out_printf(" - %s\n", prop->value->description); | ||
41 | } else { | ||
42 | out_printf("\n"); | ||
43 | } | ||
44 | -- | ||
45 | 2.19.1 | ||
46 | |||
47 | diff view generated by jsdifflib |