1 | The following changes since commit b2f7a038bb4c4fc5ce6b8486e8513dfd97665e2a: | 1 | The following changes since commit 89ea03a7dc83ca36b670ba7f787802791fcb04b1: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/rth/tags/pull-softfloat-20181104' into staging (2018-11-05 10:32:49 +0000) | 3 | Merge remote-tracking branch 'remotes/huth-gitlab/tags/m68k-pull-2019-09-07' into staging (2019-09-09 09:48:34 +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 | git://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 65f9f0c2a53b1572043501bb4e99500914e88cc6: |
10 | 10 | ||
11 | include: Add a comment to explain the origin of sizes' lookup table (2018-11-05 15:29:59 +0100) | 11 | qcow2: Stop overwriting compressed clusters one by one (2019-09-12 11:26:59 +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 | - qcow2: Allow overwriting multiple compressed clusters at once for |
17 | - Fix help text related qemu-iotests failure (by improving the help text | 17 | better performance |
18 | and updating the reference output) | 18 | - nfs: add support for nfs_umount |
19 | - quorum: Add missing checks when adding/removing child nodes | 19 | - file-posix: write_zeroes fixes |
20 | - Don't take address of fields in packed structs | 20 | - qemu-io, blockdev-create, pr-manager: Fix crashes and memory leaks |
21 | - vvfat: Fix crash when reporting error about too many files in directory | 21 | - qcow2: Fix the calculation of the maximum L2 cache size |
22 | - vpc: Fix return code for vpc_co_create() | ||
23 | - blockjob: Code cleanup | ||
24 | - iotests improvements (e.g. for use with valgrind) | ||
22 | 25 | ||
23 | ---------------------------------------------------------------- | 26 | ---------------------------------------------------------------- |
24 | Alberto Garcia (7): | 27 | Alberto Garcia (2): |
25 | block: replace "discard" literal with BDRV_OPT_DISCARD macro | 28 | qcow2: Fix the calculation of the maximum L2 cache size |
26 | qcow2: Get the request alignment for encrypted images from QCryptoBlock | 29 | qcow2: Stop overwriting compressed clusters one by one |
27 | quorum: Remove quorum_err() | ||
28 | quorum: Return an error if the blkverify mode has invalid settings | ||
29 | iotest: Test the blkverify mode of the Quorum driver | ||
30 | quorum: Forbid adding children in blkverify mode | ||
31 | iotest: Test x-blockdev-change on a Quorum | ||
32 | 30 | ||
33 | Cleber Rosa (1): | 31 | Andrey Shinkevich (6): |
34 | iotests: make 083 specific to raw | 32 | iotests: allow Valgrind checking all QEMU processes |
33 | iotests: exclude killed processes from running under Valgrind | ||
34 | iotests: Add casenotrun report to bash tests | ||
35 | iotests: Valgrind fails with nonexistent directory | ||
36 | iotests: extended timeout under Valgrind | ||
37 | iotests: extend sleeping time under Valgrind | ||
35 | 38 | ||
36 | Daniel P. Berrangé (1): | 39 | Kevin Wolf (2): |
37 | crypto: initialize sector size even when opening with no IO flag | 40 | file-posix: Fix has_write_zeroes after NO_FALLBACK |
41 | qemu-io: Don't leak pattern file in error path | ||
38 | 42 | ||
39 | Kevin Wolf (12): | 43 | Markus Armbruster (1): |
40 | vpc: Don't leak opts in vpc_open() | 44 | pr-manager: Fix invalid g_free() crash bug |
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 | 45 | ||
53 | Leonid Bloch (2): | 46 | Max Reitz (7): |
54 | vdi: Use a literal number of bytes for DEFAULT_CLUSTER_SIZE | 47 | block/file-posix: Reduce xfsctl() use |
55 | include: Add a comment to explain the origin of sizes' lookup table | 48 | iotests: Test reverse sub-cluster qcow2 writes |
49 | vpc: Return 0 from vpc_co_create() on success | ||
50 | iotests: Add supported protocols to execute_test() | ||
51 | iotests: Restrict file Python tests to file | ||
52 | iotests: Restrict nbd Python tests to nbd | ||
53 | iotests: Test blockdev-create for vpc | ||
56 | 54 | ||
57 | Li Qiang (1): | 55 | Peter Lieven (1): |
58 | block: change some function return type to bool | 56 | block/nfs: add support for nfs_umount |
59 | 57 | ||
60 | Max Reitz (5): | 58 | Philippe Mathieu-Daudé (1): |
61 | option: Make option help nicer to read | 59 | block/create: Do not abort if a block driver is not available |
62 | chardev: Indent list of chardevs | ||
63 | qdev-monitor: Make device options help nicer | ||
64 | object: Make option help nicer to read | ||
65 | fw_cfg: Drop newline in @file description | ||
66 | 60 | ||
67 | Peter Maydell (5): | 61 | Vladimir Sementsov-Ogievskiy (2): |
68 | block/qcow2: Don't take address of fields in packed structs | 62 | job: drop job_drain |
69 | block/qcow: Don't take address of fields in packed structs | 63 | iotests: skip 232 when run tests as root |
70 | block/qcow2-bitmap: Don't take address of fields in packed structs | ||
71 | block/vhdx: Don't take address of fields in packed structs | ||
72 | block/vdi: Don't take address of fields in packed structs | ||
73 | 64 | ||
74 | Stefan Weil (1): | 65 | include/block/blockjob_int.h | 19 ------ |
75 | qemu-io-cmds: Fix two format strings | 66 | include/qemu/job.h | 13 ---- |
67 | block/backup.c | 19 +----- | ||
68 | block/commit.c | 1 - | ||
69 | block/create.c | 6 +- | ||
70 | block/file-posix.c | 83 ++--------------------- | ||
71 | block/mirror.c | 28 +------- | ||
72 | block/nfs.c | 5 +- | ||
73 | block/qcow2-cluster.c | 8 +-- | ||
74 | block/qcow2.c | 6 +- | ||
75 | block/stream.c | 1 - | ||
76 | block/vpc.c | 3 +- | ||
77 | blockjob.c | 13 ---- | ||
78 | job.c | 12 +--- | ||
79 | qemu-io-cmds.c | 4 ++ | ||
80 | scsi/pr-manager.c | 1 - | ||
81 | tests/test-bdrv-drain.c | 3 - | ||
82 | tests/test-block-iothread.c | 1 - | ||
83 | tests/test-blockjob-txn.c | 1 - | ||
84 | tests/test-blockjob.c | 2 - | ||
85 | tests/qemu-iotests/028 | 6 +- | ||
86 | tests/qemu-iotests/030 | 3 +- | ||
87 | tests/qemu-iotests/039 | 5 ++ | ||
88 | tests/qemu-iotests/039.out | 30 ++------- | ||
89 | tests/qemu-iotests/040 | 3 +- | ||
90 | tests/qemu-iotests/041 | 3 +- | ||
91 | tests/qemu-iotests/044 | 3 +- | ||
92 | tests/qemu-iotests/045 | 3 +- | ||
93 | tests/qemu-iotests/051 | 4 ++ | ||
94 | tests/qemu-iotests/055 | 3 +- | ||
95 | tests/qemu-iotests/056 | 3 +- | ||
96 | tests/qemu-iotests/057 | 3 +- | ||
97 | tests/qemu-iotests/061 | 2 + | ||
98 | tests/qemu-iotests/061.out | 12 +--- | ||
99 | tests/qemu-iotests/065 | 3 +- | ||
100 | tests/qemu-iotests/096 | 3 +- | ||
101 | tests/qemu-iotests/118 | 3 +- | ||
102 | tests/qemu-iotests/124 | 3 +- | ||
103 | tests/qemu-iotests/129 | 3 +- | ||
104 | tests/qemu-iotests/132 | 3 +- | ||
105 | tests/qemu-iotests/137 | 1 + | ||
106 | tests/qemu-iotests/137.out | 6 +- | ||
107 | tests/qemu-iotests/139 | 3 +- | ||
108 | tests/qemu-iotests/147 | 5 +- | ||
109 | tests/qemu-iotests/148 | 3 +- | ||
110 | tests/qemu-iotests/151 | 3 +- | ||
111 | tests/qemu-iotests/152 | 3 +- | ||
112 | tests/qemu-iotests/155 | 3 +- | ||
113 | tests/qemu-iotests/163 | 3 +- | ||
114 | tests/qemu-iotests/165 | 3 +- | ||
115 | tests/qemu-iotests/169 | 3 +- | ||
116 | tests/qemu-iotests/183 | 9 ++- | ||
117 | tests/qemu-iotests/192 | 6 +- | ||
118 | tests/qemu-iotests/196 | 3 +- | ||
119 | tests/qemu-iotests/199 | 3 +- | ||
120 | tests/qemu-iotests/205 | 3 +- | ||
121 | tests/qemu-iotests/232 | 6 ++ | ||
122 | tests/qemu-iotests/245 | 3 +- | ||
123 | tests/qemu-iotests/247 | 6 +- | ||
124 | tests/qemu-iotests/257 | 3 +- | ||
125 | tests/qemu-iotests/265 | 67 ++++++++++++++++++ | ||
126 | tests/qemu-iotests/265.out | 6 ++ | ||
127 | tests/qemu-iotests/266 | 153 ++++++++++++++++++++++++++++++++++++++++++ | ||
128 | tests/qemu-iotests/266.out | 137 +++++++++++++++++++++++++++++++++++++ | ||
129 | tests/qemu-iotests/common.rc | 105 ++++++++++++++++++++++++----- | ||
130 | tests/qemu-iotests/group | 2 + | ||
131 | tests/qemu-iotests/iotests.py | 4 +- | ||
132 | 67 files changed, 590 insertions(+), 292 deletions(-) | ||
133 | create mode 100755 tests/qemu-iotests/265 | ||
134 | create mode 100644 tests/qemu-iotests/265.out | ||
135 | create mode 100755 tests/qemu-iotests/266 | ||
136 | create mode 100644 tests/qemu-iotests/266.out | ||
76 | 137 | ||
77 | Thomas Huth (1): | ||
78 | block/vvfat: Fix crash when reporting error about too many files in directory | ||
79 | |||
80 | qapi/block-core.json | 7 + | ||
81 | block/vhdx.h | 12 +- | ||
82 | include/block/block.h | 5 +- | ||
83 | include/qemu/option.h | 2 +- | ||
84 | include/qemu/units.h | 18 + | ||
85 | include/sysemu/block-backend.h | 6 +- | ||
86 | block.c | 60 ++- | ||
87 | block/block-backend.c | 8 +- | ||
88 | block/bochs.c | 17 +- | ||
89 | block/cloop.c | 16 +- | ||
90 | block/curl.c | 8 +- | ||
91 | block/dmg.c | 16 +- | ||
92 | block/file-posix.c | 19 +- | ||
93 | block/gluster.c | 12 +- | ||
94 | block/iscsi.c | 8 +- | ||
95 | block/nbd-client.c | 10 +- | ||
96 | block/qcow.c | 18 +- | ||
97 | block/qcow2-bitmap.c | 24 +- | ||
98 | block/qcow2.c | 66 +-- | ||
99 | block/quorum.c | 45 +- | ||
100 | block/rbd.c | 14 +- | ||
101 | block/vdi.c | 68 +-- | ||
102 | block/vhdx-endian.c | 118 ++--- | ||
103 | block/vhdx-log.c | 4 +- | ||
104 | block/vhdx.c | 18 +- | ||
105 | block/vpc.c | 2 + | ||
106 | block/vvfat.c | 15 +- | ||
107 | blockdev.c | 3 +- | ||
108 | chardev/char.c | 2 +- | ||
109 | crypto/block-qcow.c | 2 + | ||
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 |
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 | block.c | 6 +++--- | ||
7 | 1 file changed, 3 insertions(+), 3 deletions(-) | ||
8 | |||
9 | diff --git a/block.c b/block.c | ||
10 | index XXXXXXX..XXXXXXX 100644 | ||
11 | --- a/block.c | ||
12 | +++ b/block.c | ||
13 | @@ -XXX,XX +XXX,XX @@ QemuOptsList bdrv_runtime_opts = { | ||
14 | .help = "try to optimize zero writes (off, on, unmap)", | ||
15 | }, | ||
16 | { | ||
17 | - .name = "discard", | ||
18 | + .name = BDRV_OPT_DISCARD, | ||
19 | .type = QEMU_OPT_STRING, | ||
20 | .help = "discard operation (ignore/off, unmap/on)", | ||
21 | }, | ||
22 | @@ -XXX,XX +XXX,XX @@ static int bdrv_open_common(BlockDriverState *bs, BlockBackend *file, | ||
23 | } | ||
24 | } | ||
25 | |||
26 | - discard = qemu_opt_get(opts, "discard"); | ||
27 | + discard = qemu_opt_get(opts, BDRV_OPT_DISCARD); | ||
28 | if (discard != NULL) { | ||
29 | if (bdrv_parse_discard_flags(discard, &bs->open_flags) != 0) { | ||
30 | error_setg(errp, "Invalid discard option"); | ||
31 | @@ -XXX,XX +XXX,XX @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue, | ||
32 | |||
33 | update_flags_from_options(&reopen_state->flags, opts); | ||
34 | |||
35 | - discard = qemu_opt_get_del(opts, "discard"); | ||
36 | + discard = qemu_opt_get_del(opts, BDRV_OPT_DISCARD); | ||
37 | if (discard != NULL) { | ||
38 | if (bdrv_parse_discard_flags(discard, &reopen_state->flags) != 0) { | ||
39 | error_setg(errp, "Invalid discard option"); | ||
40 | -- | ||
41 | 2.19.1 | ||
42 | |||
43 | diff view generated by jsdifflib |
1 | From: Alberto Garcia <berto@igalia.com> | 1 | From: Alberto Garcia <berto@igalia.com> |
---|---|---|---|
2 | 2 | ||
3 | This doesn't have any practical effect at the moment because the | 3 | The size of the qcow2 L2 cache defaults to 32 MB, which can be easily |
4 | values of BDRV_SECTOR_SIZE, QCRYPTO_BLOCK_LUKS_SECTOR_SIZE and | 4 | larger than the maximum amount of L2 metadata that the image can have. |
5 | QCRYPTO_BLOCK_QCOW_SECTOR_SIZE are all the same (512 bytes), but | 5 | For example: with 64 KB clusters the user would need a qcow2 image |
6 | future encryption methods could have different requirements. | 6 | with a virtual size of 256 GB in order to have 32 MB of L2 metadata. |
7 | 7 | ||
8 | Because of that, since commit b749562d9822d14ef69c9eaa5f85903010b86c30 | ||
9 | we forbid the L2 cache to become larger than the maximum amount of L2 | ||
10 | metadata for the image, calculated using this formula: | ||
11 | |||
12 | uint64_t max_l2_cache = virtual_disk_size / (s->cluster_size / 8); | ||
13 | |||
14 | The problem with this formula is that the result should be rounded up | ||
15 | to the cluster size because an L2 table on disk always takes one full | ||
16 | cluster. | ||
17 | |||
18 | For example, a 1280 MB qcow2 image with 64 KB clusters needs exactly | ||
19 | 160 KB of L2 metadata, but we need 192 KB on disk (3 clusters) even if | ||
20 | the last 32 KB of those are not going to be used. | ||
21 | |||
22 | However QEMU rounds the numbers down and only creates 2 cache tables | ||
23 | (128 KB), which is not enough for the image. | ||
24 | |||
25 | A quick test doing 4KB random writes on a 1280 MB image gives me | ||
26 | around 500 IOPS, while with the correct cache size I get 16K IOPS. | ||
27 | |||
28 | Cc: qemu-stable@nongnu.org | ||
8 | Signed-off-by: Alberto Garcia <berto@igalia.com> | 29 | 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> | 30 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
11 | --- | 31 | --- |
12 | block/qcow2.c | 2 +- | 32 | block/qcow2.c | 6 +++++- |
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | 33 | 1 file changed, 5 insertions(+), 1 deletion(-) |
14 | 34 | ||
15 | diff --git a/block/qcow2.c b/block/qcow2.c | 35 | diff --git a/block/qcow2.c b/block/qcow2.c |
16 | index XXXXXXX..XXXXXXX 100644 | 36 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/block/qcow2.c | 37 | --- a/block/qcow2.c |
18 | +++ b/block/qcow2.c | 38 | +++ b/block/qcow2.c |
19 | @@ -XXX,XX +XXX,XX @@ static void qcow2_refresh_limits(BlockDriverState *bs, Error **errp) | 39 | @@ -XXX,XX +XXX,XX @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, |
20 | 40 | bool l2_cache_entry_size_set; | |
21 | if (bs->encrypted) { | 41 | int min_refcount_cache = MIN_REFCOUNT_CACHE_SIZE * s->cluster_size; |
22 | /* Encryption works on a sector granularity */ | 42 | uint64_t virtual_disk_size = bs->total_sectors * BDRV_SECTOR_SIZE; |
23 | - bs->bl.request_alignment = BDRV_SECTOR_SIZE; | 43 | - uint64_t max_l2_cache = virtual_disk_size / (s->cluster_size / 8); |
24 | + bs->bl.request_alignment = qcrypto_block_get_sector_size(s->crypto); | 44 | + uint64_t max_l2_entries = DIV_ROUND_UP(virtual_disk_size, s->cluster_size); |
25 | } | 45 | + /* An L2 table is always one cluster in size so the max cache size |
26 | bs->bl.pwrite_zeroes_alignment = s->cluster_size; | 46 | + * should be a multiple of the cluster size. */ |
27 | bs->bl.pdiscard_alignment = s->cluster_size; | 47 | + uint64_t max_l2_cache = ROUND_UP(max_l2_entries * sizeof(uint64_t), |
48 | + s->cluster_size); | ||
49 | |||
50 | combined_cache_size_set = qemu_opt_get(opts, QCOW2_OPT_CACHE_SIZE); | ||
51 | l2_cache_size_set = qemu_opt_get(opts, QCOW2_OPT_L2_CACHE_SIZE); | ||
28 | -- | 52 | -- |
29 | 2.19.1 | 53 | 2.20.1 |
30 | 54 | ||
31 | 55 | diff view generated by jsdifflib |
1 | From: Peter Maydell <peter.maydell@linaro.org> | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | Taking the address of a field in a packed struct is a bad idea, because | 3 | In job_finish_sync job_enter should be enough for a job to make some |
4 | it might not be actually aligned enough for that pointer type (and | 4 | progress and draining is a wrong tool for it. So use job_enter directly |
5 | thus cause a crash on dereference on some host architectures). Newer | 5 | here and drop job_drain with all related staff not used more. |
6 | versions of clang warn about this. Avoid the bug by not using the | 6 | |
7 | "modify in place" byte swapping functions. | 7 | Suggested-by: Kevin Wolf <kwolf@redhat.com> |
8 | 8 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | |
9 | There are a few places where the in-place swap function is | 9 | Tested-by: John Snow <jsnow@redhat.com> |
10 | used on something other than a packed struct field; we convert | 10 | Reviewed-by: John Snow <jsnow@redhat.com> |
11 | those anyway, for consistency. | ||
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> | ||
17 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 11 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
18 | --- | 12 | --- |
19 | block/vhdx.h | 12 ++--- | 13 | include/block/blockjob_int.h | 19 ------------------- |
20 | block/vhdx-endian.c | 118 ++++++++++++++++++++++---------------------- | 14 | include/qemu/job.h | 13 ------------- |
21 | block/vhdx-log.c | 4 +- | 15 | block/backup.c | 19 +------------------ |
22 | block/vhdx.c | 18 +++---- | 16 | block/commit.c | 1 - |
23 | 4 files changed, 76 insertions(+), 76 deletions(-) | 17 | block/mirror.c | 28 +++------------------------- |
24 | 18 | block/stream.c | 1 - | |
25 | diff --git a/block/vhdx.h b/block/vhdx.h | 19 | blockjob.c | 13 ------------- |
26 | index XXXXXXX..XXXXXXX 100644 | 20 | job.c | 12 +----------- |
27 | --- a/block/vhdx.h | 21 | tests/test-bdrv-drain.c | 3 --- |
28 | +++ b/block/vhdx.h | 22 | tests/test-block-iothread.c | 1 - |
29 | @@ -XXX,XX +XXX,XX @@ int vhdx_log_write_and_flush(BlockDriverState *bs, BDRVVHDXState *s, | 23 | tests/test-blockjob-txn.c | 1 - |
30 | 24 | tests/test-blockjob.c | 2 -- | |
31 | static inline void leguid_to_cpus(MSGUID *guid) | 25 | 12 files changed, 5 insertions(+), 108 deletions(-) |
26 | |||
27 | diff --git a/include/block/blockjob_int.h b/include/block/blockjob_int.h | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/include/block/blockjob_int.h | ||
30 | +++ b/include/block/blockjob_int.h | ||
31 | @@ -XXX,XX +XXX,XX @@ struct BlockJobDriver { | ||
32 | * besides job->blk to the new AioContext. | ||
33 | */ | ||
34 | void (*attached_aio_context)(BlockJob *job, AioContext *new_context); | ||
35 | - | ||
36 | - /* | ||
37 | - * If the callback is not NULL, it will be invoked when the job has to be | ||
38 | - * synchronously cancelled or completed; it should drain BlockDriverStates | ||
39 | - * as required to ensure progress. | ||
40 | - * | ||
41 | - * Block jobs must use the default implementation for job_driver.drain, | ||
42 | - * which will in turn call this callback after doing generic block job | ||
43 | - * stuff. | ||
44 | - */ | ||
45 | - void (*drain)(BlockJob *job); | ||
46 | }; | ||
47 | |||
48 | /** | ||
49 | @@ -XXX,XX +XXX,XX @@ void block_job_free(Job *job); | ||
50 | */ | ||
51 | void block_job_user_resume(Job *job); | ||
52 | |||
53 | -/** | ||
54 | - * block_job_drain: | ||
55 | - * Callback to be used for JobDriver.drain in all block jobs. Drains the main | ||
56 | - * block node associated with the block jobs and calls BlockJobDriver.drain for | ||
57 | - * job-specific actions. | ||
58 | - */ | ||
59 | -void block_job_drain(Job *job); | ||
60 | - | ||
61 | /** | ||
62 | * block_job_ratelimit_get_delay: | ||
63 | * | ||
64 | diff --git a/include/qemu/job.h b/include/qemu/job.h | ||
65 | index XXXXXXX..XXXXXXX 100644 | ||
66 | --- a/include/qemu/job.h | ||
67 | +++ b/include/qemu/job.h | ||
68 | @@ -XXX,XX +XXX,XX @@ struct JobDriver { | ||
69 | */ | ||
70 | void (*complete)(Job *job, Error **errp); | ||
71 | |||
72 | - /* | ||
73 | - * If the callback is not NULL, it will be invoked when the job has to be | ||
74 | - * synchronously cancelled or completed; it should drain any activities | ||
75 | - * as required to ensure progress. | ||
76 | - */ | ||
77 | - void (*drain)(Job *job); | ||
78 | - | ||
79 | /** | ||
80 | * If the callback is not NULL, prepare will be invoked when all the jobs | ||
81 | * belonging to the same transaction complete; or upon this job's completion | ||
82 | @@ -XXX,XX +XXX,XX @@ bool job_user_paused(Job *job); | ||
83 | */ | ||
84 | void job_user_resume(Job *job, Error **errp); | ||
85 | |||
86 | -/* | ||
87 | - * Drain any activities as required to ensure progress. This can be called in a | ||
88 | - * loop to synchronously complete a job. | ||
89 | - */ | ||
90 | -void job_drain(Job *job); | ||
91 | - | ||
92 | /** | ||
93 | * Get the next element from the list of block jobs after @job, or the | ||
94 | * first one if @job is %NULL. | ||
95 | diff --git a/block/backup.c b/block/backup.c | ||
96 | index XXXXXXX..XXXXXXX 100644 | ||
97 | --- a/block/backup.c | ||
98 | +++ b/block/backup.c | ||
99 | @@ -XXX,XX +XXX,XX @@ void backup_do_checkpoint(BlockJob *job, Error **errp) | ||
100 | bdrv_set_dirty_bitmap(backup_job->copy_bitmap, 0, backup_job->len); | ||
101 | } | ||
102 | |||
103 | -static void backup_drain(BlockJob *job) | ||
104 | -{ | ||
105 | - BackupBlockJob *s = container_of(job, BackupBlockJob, common); | ||
106 | - | ||
107 | - /* Need to keep a reference in case blk_drain triggers execution | ||
108 | - * of backup_complete... | ||
109 | - */ | ||
110 | - if (s->target) { | ||
111 | - BlockBackend *target = s->target; | ||
112 | - blk_ref(target); | ||
113 | - blk_drain(target); | ||
114 | - blk_unref(target); | ||
115 | - } | ||
116 | -} | ||
117 | - | ||
118 | static BlockErrorAction backup_error_action(BackupBlockJob *job, | ||
119 | bool read, int error) | ||
32 | { | 120 | { |
33 | - le32_to_cpus(&guid->data1); | 121 | @@ -XXX,XX +XXX,XX @@ static const BlockJobDriver backup_job_driver = { |
34 | - le16_to_cpus(&guid->data2); | 122 | .job_type = JOB_TYPE_BACKUP, |
35 | - le16_to_cpus(&guid->data3); | 123 | .free = block_job_free, |
36 | + guid->data1 = le32_to_cpu(guid->data1); | 124 | .user_resume = block_job_user_resume, |
37 | + guid->data2 = le16_to_cpu(guid->data2); | 125 | - .drain = block_job_drain, |
38 | + guid->data3 = le16_to_cpu(guid->data3); | 126 | .run = backup_run, |
127 | .commit = backup_commit, | ||
128 | .abort = backup_abort, | ||
129 | .clean = backup_clean, | ||
130 | - }, | ||
131 | - .drain = backup_drain, | ||
132 | + } | ||
133 | }; | ||
134 | |||
135 | static int64_t backup_calculate_cluster_size(BlockDriverState *target, | ||
136 | diff --git a/block/commit.c b/block/commit.c | ||
137 | index XXXXXXX..XXXXXXX 100644 | ||
138 | --- a/block/commit.c | ||
139 | +++ b/block/commit.c | ||
140 | @@ -XXX,XX +XXX,XX @@ static const BlockJobDriver commit_job_driver = { | ||
141 | .job_type = JOB_TYPE_COMMIT, | ||
142 | .free = block_job_free, | ||
143 | .user_resume = block_job_user_resume, | ||
144 | - .drain = block_job_drain, | ||
145 | .run = commit_run, | ||
146 | .prepare = commit_prepare, | ||
147 | .abort = commit_abort, | ||
148 | diff --git a/block/mirror.c b/block/mirror.c | ||
149 | index XXXXXXX..XXXXXXX 100644 | ||
150 | --- a/block/mirror.c | ||
151 | +++ b/block/mirror.c | ||
152 | @@ -XXX,XX +XXX,XX @@ static int mirror_exit_common(Job *job) | ||
153 | bdrv_ref(mirror_top_bs); | ||
154 | bdrv_ref(target_bs); | ||
155 | |||
156 | - /* Remove target parent that still uses BLK_PERM_WRITE/RESIZE before | ||
157 | + /* | ||
158 | + * Remove target parent that still uses BLK_PERM_WRITE/RESIZE before | ||
159 | * inserting target_bs at s->to_replace, where we might not be able to get | ||
160 | * these permissions. | ||
161 | - * | ||
162 | - * Note that blk_unref() alone doesn't necessarily drop permissions because | ||
163 | - * we might be running nested inside mirror_drain(), which takes an extra | ||
164 | - * reference, so use an explicit blk_set_perm() first. */ | ||
165 | - blk_set_perm(s->target, 0, BLK_PERM_ALL, &error_abort); | ||
166 | + */ | ||
167 | blk_unref(s->target); | ||
168 | s->target = NULL; | ||
169 | |||
170 | @@ -XXX,XX +XXX,XX @@ static bool mirror_drained_poll(BlockJob *job) | ||
171 | return !!s->in_flight; | ||
39 | } | 172 | } |
40 | 173 | ||
41 | static inline void cpu_to_leguids(MSGUID *guid) | 174 | -static void mirror_drain(BlockJob *job) |
175 | -{ | ||
176 | - MirrorBlockJob *s = container_of(job, MirrorBlockJob, common); | ||
177 | - | ||
178 | - /* Need to keep a reference in case blk_drain triggers execution | ||
179 | - * of mirror_complete... | ||
180 | - */ | ||
181 | - if (s->target) { | ||
182 | - BlockBackend *target = s->target; | ||
183 | - blk_ref(target); | ||
184 | - blk_drain(target); | ||
185 | - blk_unref(target); | ||
186 | - } | ||
187 | -} | ||
188 | - | ||
189 | static const BlockJobDriver mirror_job_driver = { | ||
190 | .job_driver = { | ||
191 | .instance_size = sizeof(MirrorBlockJob), | ||
192 | .job_type = JOB_TYPE_MIRROR, | ||
193 | .free = block_job_free, | ||
194 | .user_resume = block_job_user_resume, | ||
195 | - .drain = block_job_drain, | ||
196 | .run = mirror_run, | ||
197 | .prepare = mirror_prepare, | ||
198 | .abort = mirror_abort, | ||
199 | @@ -XXX,XX +XXX,XX @@ static const BlockJobDriver mirror_job_driver = { | ||
200 | .complete = mirror_complete, | ||
201 | }, | ||
202 | .drained_poll = mirror_drained_poll, | ||
203 | - .drain = mirror_drain, | ||
204 | }; | ||
205 | |||
206 | static const BlockJobDriver commit_active_job_driver = { | ||
207 | @@ -XXX,XX +XXX,XX @@ static const BlockJobDriver commit_active_job_driver = { | ||
208 | .job_type = JOB_TYPE_COMMIT, | ||
209 | .free = block_job_free, | ||
210 | .user_resume = block_job_user_resume, | ||
211 | - .drain = block_job_drain, | ||
212 | .run = mirror_run, | ||
213 | .prepare = mirror_prepare, | ||
214 | .abort = mirror_abort, | ||
215 | @@ -XXX,XX +XXX,XX @@ static const BlockJobDriver commit_active_job_driver = { | ||
216 | .complete = mirror_complete, | ||
217 | }, | ||
218 | .drained_poll = mirror_drained_poll, | ||
219 | - .drain = mirror_drain, | ||
220 | }; | ||
221 | |||
222 | static void coroutine_fn | ||
223 | diff --git a/block/stream.c b/block/stream.c | ||
224 | index XXXXXXX..XXXXXXX 100644 | ||
225 | --- a/block/stream.c | ||
226 | +++ b/block/stream.c | ||
227 | @@ -XXX,XX +XXX,XX @@ static const BlockJobDriver stream_job_driver = { | ||
228 | .abort = stream_abort, | ||
229 | .clean = stream_clean, | ||
230 | .user_resume = block_job_user_resume, | ||
231 | - .drain = block_job_drain, | ||
232 | }, | ||
233 | }; | ||
234 | |||
235 | diff --git a/blockjob.c b/blockjob.c | ||
236 | index XXXXXXX..XXXXXXX 100644 | ||
237 | --- a/blockjob.c | ||
238 | +++ b/blockjob.c | ||
239 | @@ -XXX,XX +XXX,XX @@ void block_job_free(Job *job) | ||
240 | error_free(bjob->blocker); | ||
241 | } | ||
242 | |||
243 | -void block_job_drain(Job *job) | ||
244 | -{ | ||
245 | - BlockJob *bjob = container_of(job, BlockJob, job); | ||
246 | - const JobDriver *drv = job->driver; | ||
247 | - BlockJobDriver *bjdrv = container_of(drv, BlockJobDriver, job_driver); | ||
248 | - | ||
249 | - blk_drain(bjob->blk); | ||
250 | - if (bjdrv->drain) { | ||
251 | - bjdrv->drain(bjob); | ||
252 | - } | ||
253 | -} | ||
254 | - | ||
255 | static char *child_job_get_parent_desc(BdrvChild *c) | ||
42 | { | 256 | { |
43 | - cpu_to_le32s(&guid->data1); | 257 | BlockJob *job = c->opaque; |
44 | - cpu_to_le16s(&guid->data2); | 258 | @@ -XXX,XX +XXX,XX @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver, |
45 | - cpu_to_le16s(&guid->data3); | 259 | assert(is_block_job(&job->job)); |
46 | + guid->data1 = cpu_to_le32(guid->data1); | 260 | assert(job->job.driver->free == &block_job_free); |
47 | + guid->data2 = cpu_to_le16(guid->data2); | 261 | assert(job->job.driver->user_resume == &block_job_user_resume); |
48 | + guid->data3 = cpu_to_le16(guid->data3); | 262 | - assert(job->job.driver->drain == &block_job_drain); |
263 | |||
264 | job->blk = blk; | ||
265 | |||
266 | diff --git a/job.c b/job.c | ||
267 | index XXXXXXX..XXXXXXX 100644 | ||
268 | --- a/job.c | ||
269 | +++ b/job.c | ||
270 | @@ -XXX,XX +XXX,XX @@ void coroutine_fn job_sleep_ns(Job *job, int64_t ns) | ||
271 | job_pause_point(job); | ||
49 | } | 272 | } |
50 | 273 | ||
51 | void vhdx_header_le_import(VHDXHeader *h); | 274 | -void job_drain(Job *job) |
52 | diff --git a/block/vhdx-endian.c b/block/vhdx-endian.c | 275 | -{ |
53 | index XXXXXXX..XXXXXXX 100644 | 276 | - /* If job is !busy this kicks it into the next pause point. */ |
54 | --- a/block/vhdx-endian.c | 277 | - job_enter(job); |
55 | +++ b/block/vhdx-endian.c | 278 | - |
56 | @@ -XXX,XX +XXX,XX @@ void vhdx_header_le_import(VHDXHeader *h) | 279 | - if (job->driver->drain) { |
280 | - job->driver->drain(job); | ||
281 | - } | ||
282 | -} | ||
283 | - | ||
284 | /* Assumes the block_job_mutex is held */ | ||
285 | static bool job_timer_not_pending(Job *job) | ||
57 | { | 286 | { |
58 | assert(h != NULL); | 287 | @@ -XXX,XX +XXX,XX @@ int job_finish_sync(Job *job, void (*finish)(Job *, Error **errp), Error **errp) |
59 | |||
60 | - le32_to_cpus(&h->signature); | ||
61 | - le32_to_cpus(&h->checksum); | ||
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 | } | ||
80 | |||
81 | void vhdx_header_le_export(VHDXHeader *orig_h, VHDXHeader *new_h) | ||
82 | @@ -XXX,XX +XXX,XX @@ void vhdx_log_desc_le_import(VHDXLogDescriptor *d) | ||
83 | { | ||
84 | assert(d != NULL); | ||
85 | |||
86 | - le32_to_cpus(&d->signature); | ||
87 | - le64_to_cpus(&d->file_offset); | ||
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 | } | ||
93 | |||
94 | void vhdx_log_desc_le_export(VHDXLogDescriptor *d) | ||
95 | { | ||
96 | assert(d != NULL); | ||
97 | |||
98 | - cpu_to_le32s(&d->signature); | ||
99 | - cpu_to_le32s(&d->trailing_bytes); | ||
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 | } | ||
109 | |||
110 | void vhdx_log_data_le_import(VHDXLogDataSector *d) | ||
111 | { | ||
112 | assert(d != NULL); | ||
113 | |||
114 | - le32_to_cpus(&d->data_signature); | ||
115 | - le32_to_cpus(&d->sequence_high); | ||
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 | } | ||
121 | |||
122 | void vhdx_log_data_le_export(VHDXLogDataSector *d) | ||
123 | { | ||
124 | assert(d != NULL); | ||
125 | |||
126 | - cpu_to_le32s(&d->data_signature); | ||
127 | - cpu_to_le32s(&d->sequence_high); | ||
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 | } | ||
133 | |||
134 | void vhdx_log_entry_hdr_le_import(VHDXLogEntryHeader *hdr) | ||
135 | { | ||
136 | assert(hdr != NULL); | ||
137 | |||
138 | - le32_to_cpus(&hdr->signature); | ||
139 | - le32_to_cpus(&hdr->checksum); | ||
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 | } | ||
156 | |||
157 | void vhdx_log_entry_hdr_le_export(VHDXLogEntryHeader *hdr) | ||
158 | { | ||
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 | } | 288 | } |
310 | 289 | ||
311 | - le32_to_cpus(&s->params.block_size); | 290 | AIO_WAIT_WHILE(job->aio_context, |
312 | - le32_to_cpus(&s->params.data_bits); | 291 | - (job_drain(job), !job_is_completed(job))); |
313 | + s->params.block_size = le32_to_cpu(s->params.block_size); | 292 | + (job_enter(job), !job_is_completed(job))); |
314 | + s->params.data_bits = le32_to_cpu(s->params.data_bits); | 293 | |
315 | 294 | ret = (job_is_cancelled(job) && job->ret == 0) ? -ECANCELED : job->ret; | |
316 | 295 | job_unref(job); | |
317 | /* We now have the file parameters, so we can tell if this is a | 296 | diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c |
318 | @@ -XXX,XX +XXX,XX @@ static int vhdx_parse_metadata(BlockDriverState *bs, BDRVVHDXState *s) | 297 | index XXXXXXX..XXXXXXX 100644 |
319 | goto exit; | 298 | --- a/tests/test-bdrv-drain.c |
299 | +++ b/tests/test-bdrv-drain.c | ||
300 | @@ -XXX,XX +XXX,XX @@ BlockJobDriver test_job_driver = { | ||
301 | .instance_size = sizeof(TestBlockJob), | ||
302 | .free = block_job_free, | ||
303 | .user_resume = block_job_user_resume, | ||
304 | - .drain = block_job_drain, | ||
305 | .run = test_job_run, | ||
306 | .complete = test_job_complete, | ||
307 | .prepare = test_job_prepare, | ||
308 | @@ -XXX,XX +XXX,XX @@ static const BlockJobDriver test_drop_backing_job_driver = { | ||
309 | .instance_size = sizeof(TestDropBackingBlockJob), | ||
310 | .free = block_job_free, | ||
311 | .user_resume = block_job_user_resume, | ||
312 | - .drain = block_job_drain, | ||
313 | .run = test_drop_backing_job_run, | ||
314 | .commit = test_drop_backing_job_commit, | ||
320 | } | 315 | } |
321 | 316 | @@ -XXX,XX +XXX,XX @@ static const BlockJobDriver test_simple_job_driver = { | |
322 | - le64_to_cpus(&s->virtual_disk_size); | 317 | .instance_size = sizeof(TestSimpleBlockJob), |
323 | - le32_to_cpus(&s->logical_sector_size); | 318 | .free = block_job_free, |
324 | - le32_to_cpus(&s->physical_sector_size); | 319 | .user_resume = block_job_user_resume, |
325 | + s->virtual_disk_size = le64_to_cpu(s->virtual_disk_size); | 320 | - .drain = block_job_drain, |
326 | + s->logical_sector_size = le32_to_cpu(s->logical_sector_size); | 321 | .run = test_simple_job_run, |
327 | + s->physical_sector_size = le32_to_cpu(s->physical_sector_size); | 322 | .clean = test_simple_job_clean, |
328 | 323 | }, | |
329 | if (s->params.block_size < VHDX_BLOCK_SIZE_MIN || | 324 | diff --git a/tests/test-block-iothread.c b/tests/test-block-iothread.c |
330 | s->params.block_size > VHDX_BLOCK_SIZE_MAX) { | 325 | index XXXXXXX..XXXXXXX 100644 |
331 | @@ -XXX,XX +XXX,XX @@ static int vhdx_open(BlockDriverState *bs, QDict *options, int flags, | 326 | --- a/tests/test-block-iothread.c |
332 | /* endian convert, and verify populated BAT field file offsets against | 327 | +++ b/tests/test-block-iothread.c |
333 | * region table and log entries */ | 328 | @@ -XXX,XX +XXX,XX @@ BlockJobDriver test_job_driver = { |
334 | for (i = 0; i < s->bat_entries; i++) { | 329 | .instance_size = sizeof(TestBlockJob), |
335 | - le64_to_cpus(&s->bat[i]); | 330 | .free = block_job_free, |
336 | + s->bat[i] = le64_to_cpu(s->bat[i]); | 331 | .user_resume = block_job_user_resume, |
337 | if (payblocks--) { | 332 | - .drain = block_job_drain, |
338 | /* payload bat entries */ | 333 | .run = test_job_run, |
339 | if ((s->bat[i] & VHDX_BAT_STATE_BIT_MASK) == | 334 | .complete = test_job_complete, |
340 | @@ -XXX,XX +XXX,XX @@ static int vhdx_create_new_metadata(BlockBackend *blk, | 335 | .prepare = test_job_prepare, |
341 | mt_file_params->block_size = cpu_to_le32(block_size); | 336 | diff --git a/tests/test-blockjob-txn.c b/tests/test-blockjob-txn.c |
342 | if (type == VHDX_TYPE_FIXED) { | 337 | index XXXXXXX..XXXXXXX 100644 |
343 | mt_file_params->data_bits |= VHDX_PARAMS_LEAVE_BLOCKS_ALLOCED; | 338 | --- a/tests/test-blockjob-txn.c |
344 | - cpu_to_le32s(&mt_file_params->data_bits); | 339 | +++ b/tests/test-blockjob-txn.c |
345 | + mt_file_params->data_bits = cpu_to_le32(mt_file_params->data_bits); | 340 | @@ -XXX,XX +XXX,XX @@ static const BlockJobDriver test_block_job_driver = { |
346 | } | 341 | .instance_size = sizeof(TestBlockJob), |
347 | 342 | .free = block_job_free, | |
348 | vhdx_guid_generate(&mt_page83->page_83_data); | 343 | .user_resume = block_job_user_resume, |
349 | @@ -XXX,XX +XXX,XX @@ static int vhdx_create_bat(BlockBackend *blk, BDRVVHDXState *s, | 344 | - .drain = block_job_drain, |
350 | sinfo.file_offset = ROUND_UP(sinfo.file_offset, MiB); | 345 | .run = test_block_job_run, |
351 | vhdx_update_bat_table_entry(blk_bs(blk), s, &sinfo, &unused, &unused, | 346 | .clean = test_block_job_clean, |
352 | block_state); | 347 | }, |
353 | - cpu_to_le64s(&s->bat[sinfo.bat_idx]); | 348 | diff --git a/tests/test-blockjob.c b/tests/test-blockjob.c |
354 | + s->bat[sinfo.bat_idx] = cpu_to_le64(s->bat[sinfo.bat_idx]); | 349 | index XXXXXXX..XXXXXXX 100644 |
355 | sector_num += s->sectors_per_block; | 350 | --- a/tests/test-blockjob.c |
356 | } | 351 | +++ b/tests/test-blockjob.c |
357 | ret = blk_pwrite(blk, file_offset, s->bat, length, 0); | 352 | @@ -XXX,XX +XXX,XX @@ static const BlockJobDriver test_block_job_driver = { |
353 | .instance_size = sizeof(BlockJob), | ||
354 | .free = block_job_free, | ||
355 | .user_resume = block_job_user_resume, | ||
356 | - .drain = block_job_drain, | ||
357 | }, | ||
358 | }; | ||
359 | |||
360 | @@ -XXX,XX +XXX,XX @@ static const BlockJobDriver test_cancel_driver = { | ||
361 | .instance_size = sizeof(CancelJob), | ||
362 | .free = block_job_free, | ||
363 | .user_resume = block_job_user_resume, | ||
364 | - .drain = block_job_drain, | ||
365 | .run = cancel_job_run, | ||
366 | .complete = cancel_job_complete, | ||
367 | }, | ||
358 | -- | 368 | -- |
359 | 2.19.1 | 369 | 2.20.1 |
360 | 370 | ||
361 | 371 | diff view generated by jsdifflib |
1 | Some block drivers have traditionally changed their node to read-only | 1 | From: Max Reitz <mreitz@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 patch removes xfs_write_zeroes() and xfs_discard(). Both functions |
6 | the option. | 4 | have been added just before the same feature was present through |
5 | fallocate(): | ||
7 | 6 | ||
8 | This is the only use of bdrv_set_read_only(), so we can make it a bit | 7 | - fallocate() has supported PUNCH_HOLE for XFS since Linux 2.6.38 (March |
9 | more specific and turn it into a bdrv_apply_auto_read_only() that is | 8 | 2011); xfs_discard() was added in December 2010. |
10 | more convenient for drivers to use. | ||
11 | 9 | ||
10 | - fallocate() has supported ZERO_RANGE for XFS since Linux 3.15 (June | ||
11 | 2014); xfs_write_zeroes() was added in November 2013. | ||
12 | |||
13 | Nowadays, all systems that qemu runs on should support both fallocate() | ||
14 | features (RHEL 7's kernel does). | ||
15 | |||
16 | xfsctl() is still useful for getting the request alignment for O_DIRECT, | ||
17 | so this patch does not remove our dependency on it completely. | ||
18 | |||
19 | Note that xfs_write_zeroes() had a bug: It calls ftruncate() when the | ||
20 | file is shorter than the specified range (because ZERO_RANGE does not | ||
21 | increase the file length). ftruncate() may yield and then discard data | ||
22 | that parallel write requests have written past the EOF in the meantime. | ||
23 | Dropping the function altogether fixes the bug. | ||
24 | |||
25 | Suggested-by: Paolo Bonzini <pbonzini@redhat.com> | ||
26 | Fixes: 50ba5b2d994853b38fed10e0841b119da0f8b8e5 | ||
27 | Reported-by: Lukáš Doktor <ldoktor@redhat.com> | ||
28 | Cc: qemu-stable@nongnu.org | ||
29 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
30 | Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> | ||
31 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
32 | Tested-by: Stefano Garzarella <sgarzare@redhat.com> | ||
33 | Tested-by: John Snow <jsnow@redhat.com> | ||
12 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 34 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
13 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
14 | --- | 35 | --- |
15 | include/block/block.h | 3 ++- | 36 | block/file-posix.c | 77 +--------------------------------------------- |
16 | block.c | 42 +++++++++++++++++++++++++++--------------- | 37 | 1 file changed, 1 insertion(+), 76 deletions(-) |
17 | block/bochs.c | 17 ++++++----------- | ||
18 | block/cloop.c | 16 +++++----------- | ||
19 | block/dmg.c | 16 +++++----------- | ||
20 | block/rbd.c | 15 ++++----------- | ||
21 | block/vvfat.c | 10 ++-------- | ||
22 | 7 files changed, 51 insertions(+), 68 deletions(-) | ||
23 | 38 | ||
24 | diff --git a/include/block/block.h b/include/block/block.h | 39 | diff --git a/block/file-posix.c b/block/file-posix.c |
25 | index XXXXXXX..XXXXXXX 100644 | 40 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/block/block.h | 41 | --- a/block/file-posix.c |
27 | +++ b/include/block/block.h | 42 | +++ b/block/file-posix.c |
28 | @@ -XXX,XX +XXX,XX @@ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base, | 43 | @@ -XXX,XX +XXX,XX @@ out: |
29 | bool bdrv_is_read_only(BlockDriverState *bs); | 44 | } |
30 | int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, | ||
31 | bool ignore_allow_rdw, Error **errp); | ||
32 | -int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp); | ||
33 | +int bdrv_apply_auto_read_only(BlockDriverState *bs, const char *errmsg, | ||
34 | + Error **errp); | ||
35 | bool bdrv_is_writable(BlockDriverState *bs); | ||
36 | bool bdrv_is_sg(BlockDriverState *bs); | ||
37 | bool bdrv_is_inserted(BlockDriverState *bs); | ||
38 | diff --git a/block.c b/block.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/block.c | ||
41 | +++ b/block.c | ||
42 | @@ -XXX,XX +XXX,XX @@ int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, | ||
43 | return 0; | ||
44 | } | 45 | } |
45 | 46 | ||
46 | -/* TODO Remove (deprecated since 2.11) | 47 | -#ifdef CONFIG_XFS |
47 | - * Block drivers are not supposed to automatically change bs->read_only. | 48 | -static int xfs_write_zeroes(BDRVRawState *s, int64_t offset, uint64_t bytes) |
48 | - * Instead, they should just check whether they can provide what the user | 49 | -{ |
49 | - * explicitly requested and error out if read-write is requested, but they can | 50 | - int64_t len; |
50 | - * only provide read-only access. */ | 51 | - struct xfs_flock64 fl; |
51 | -int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp) | 52 | - int err; |
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 | { | ||
65 | int ret = 0; | ||
66 | |||
67 | - ret = bdrv_can_set_read_only(bs, read_only, false, errp); | ||
68 | - if (ret < 0) { | ||
69 | - return ret; | ||
70 | + if (!(bs->open_flags & BDRV_O_RDWR)) { | ||
71 | + return 0; | ||
72 | + } | ||
73 | + if (!(bs->open_flags & BDRV_O_AUTO_RDONLY)) { | ||
74 | + goto fail; | ||
75 | } | ||
76 | |||
77 | - bs->read_only = read_only; | ||
78 | - | 53 | - |
79 | - if (read_only) { | 54 | - len = lseek(s->fd, 0, SEEK_END); |
80 | - bs->open_flags &= ~BDRV_O_RDWR; | 55 | - if (len < 0) { |
81 | - } else { | 56 | - return -errno; |
82 | - bs->open_flags |= BDRV_O_RDWR; | 57 | - } |
83 | + ret = bdrv_can_set_read_only(bs, true, false, NULL); | 58 | - |
84 | + if (ret < 0) { | 59 | - if (offset + bytes > len) { |
85 | + goto fail; | 60 | - /* XFS_IOC_ZERO_RANGE does not increase the file length */ |
86 | } | 61 | - if (ftruncate(s->fd, offset + bytes) < 0) { |
87 | 62 | - return -errno; | |
88 | + bs->read_only = true; | ||
89 | + bs->open_flags &= ~BDRV_O_RDWR; | ||
90 | + | ||
91 | return 0; | ||
92 | + | ||
93 | +fail: | ||
94 | + error_setg(errp, "%s", errmsg ?: "Image is read-only"); | ||
95 | + return -EACCES; | ||
96 | } | ||
97 | |||
98 | void bdrv_get_full_backing_filename_from_filename(const char *backed, | ||
99 | diff --git a/block/bochs.c b/block/bochs.c | ||
100 | index XXXXXXX..XXXXXXX 100644 | ||
101 | --- a/block/bochs.c | ||
102 | +++ b/block/bochs.c | ||
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 | - } | 63 | - } |
128 | - } | 64 | - } |
129 | - | 65 | - |
130 | ret = bdrv_pread(bs->file, 0, &bochs, sizeof(bochs)); | 66 | - memset(&fl, 0, sizeof(fl)); |
131 | if (ret < 0) { | 67 | - fl.l_whence = SEEK_SET; |
132 | return ret; | 68 | - fl.l_start = offset; |
133 | diff --git a/block/cloop.c b/block/cloop.c | 69 | - fl.l_len = bytes; |
134 | index XXXXXXX..XXXXXXX 100644 | 70 | - |
135 | --- a/block/cloop.c | 71 | - if (xfsctl(NULL, s->fd, XFS_IOC_ZERO_RANGE, &fl) < 0) { |
136 | +++ b/block/cloop.c | 72 | - err = errno; |
137 | @@ -XXX,XX +XXX,XX @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags, | 73 | - trace_file_xfs_write_zeroes(strerror(errno)); |
138 | uint32_t offsets_size, max_compressed_block_size = 1, i; | 74 | - return -err; |
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 | - } | 75 | - } |
162 | - | 76 | - |
163 | /* read header */ | 77 | - return 0; |
164 | ret = bdrv_pread(bs->file, 128, &s->block_size, 4); | 78 | -} |
165 | if (ret < 0) { | 79 | - |
166 | diff --git a/block/dmg.c b/block/dmg.c | 80 | -static int xfs_discard(BDRVRawState *s, int64_t offset, uint64_t bytes) |
167 | index XXXXXXX..XXXXXXX 100644 | 81 | -{ |
168 | --- a/block/dmg.c | 82 | - struct xfs_flock64 fl; |
169 | +++ b/block/dmg.c | 83 | - int err; |
170 | @@ -XXX,XX +XXX,XX @@ static int dmg_open(BlockDriverState *bs, QDict *options, int flags, | 84 | - |
171 | int64_t offset; | 85 | - memset(&fl, 0, sizeof(fl)); |
172 | int ret; | 86 | - fl.l_whence = SEEK_SET; |
173 | 87 | - fl.l_start = offset; | |
174 | + ret = bdrv_apply_auto_read_only(bs, NULL, errp); | 88 | - fl.l_len = bytes; |
175 | + if (ret < 0) { | 89 | - |
176 | + return ret; | 90 | - if (xfsctl(NULL, s->fd, XFS_IOC_UNRESVSP64, &fl) < 0) { |
177 | + } | 91 | - err = errno; |
178 | + | 92 | - trace_file_xfs_discard(strerror(errno)); |
179 | bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, | 93 | - return -err; |
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 | - } | 94 | - } |
195 | - | 95 | - |
196 | block_module_load_one("dmg-bz2"); | 96 | - return 0; |
197 | 97 | -} | |
198 | s->n_chunks = 0; | 98 | -#endif |
199 | diff --git a/block/rbd.c b/block/rbd.c | 99 | - |
200 | index XXXXXXX..XXXXXXX 100644 | 100 | static int translate_err(int err) |
201 | --- a/block/rbd.c | 101 | { |
202 | +++ b/block/rbd.c | 102 | if (err == -ENODEV || err == -ENOSYS || err == -EOPNOTSUPP || |
203 | @@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags, | 103 | @@ -XXX,XX +XXX,XX @@ static ssize_t handle_aiocb_write_zeroes_block(RawPosixAIOData *aiocb) |
204 | /* If we are using an rbd snapshot, we must be r/o, otherwise | 104 | static int handle_aiocb_write_zeroes(void *opaque) |
205 | * leave as-is */ | 105 | { |
206 | if (s->snap != NULL) { | 106 | RawPosixAIOData *aiocb = opaque; |
207 | - if (!bdrv_is_read_only(bs)) { | 107 | -#if defined(CONFIG_FALLOCATE) || defined(CONFIG_XFS) |
208 | - error_report("Opening rbd snapshots without an explicit " | 108 | - BDRVRawState *s = aiocb->bs->opaque; |
209 | - "read-only=on option is deprecated. Future versions " | 109 | -#endif |
210 | - "will refuse to open the image instead of " | 110 | #ifdef CONFIG_FALLOCATE |
211 | - "automatically marking the image read-only."); | 111 | + BDRVRawState *s = aiocb->bs->opaque; |
212 | - r = bdrv_set_read_only(bs, true, &local_err); | 112 | int64_t len; |
213 | - if (r < 0) { | 113 | #endif |
214 | - rbd_close(s->image); | 114 | |
215 | - error_propagate(errp, local_err); | 115 | @@ -XXX,XX +XXX,XX @@ static int handle_aiocb_write_zeroes(void *opaque) |
216 | - goto failed_open; | 116 | return handle_aiocb_write_zeroes_block(aiocb); |
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 | } | 117 | } |
224 | 118 | ||
225 | diff --git a/block/vvfat.c b/block/vvfat.c | 119 | -#ifdef CONFIG_XFS |
226 | index XXXXXXX..XXXXXXX 100644 | 120 | - if (s->is_xfs) { |
227 | --- a/block/vvfat.c | 121 | - return xfs_write_zeroes(s, aiocb->aio_offset, aiocb->aio_nbytes); |
228 | +++ b/block/vvfat.c | 122 | - } |
229 | @@ -XXX,XX +XXX,XX @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags, | 123 | -#endif |
230 | "Unable to set VVFAT to 'rw' when drive is read-only"); | 124 | - |
231 | goto fail; | 125 | #ifdef CONFIG_FALLOCATE_ZERO_RANGE |
232 | } | 126 | if (s->has_write_zeroes) { |
233 | - } else if (!bdrv_is_read_only(bs)) { | 127 | int ret = do_fallocate(s->fd, FALLOC_FL_ZERO_RANGE, |
234 | - error_report("Opening non-rw vvfat images without an explicit " | 128 | @@ -XXX,XX +XXX,XX @@ static int handle_aiocb_write_zeroes_unmap(void *opaque) |
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 | } | 129 | } |
130 | #endif | ||
131 | |||
132 | -#ifdef CONFIG_XFS | ||
133 | - if (s->is_xfs) { | ||
134 | - /* xfs_discard() guarantees that the discarded area reads as all-zero | ||
135 | - * afterwards, so we can use it here. */ | ||
136 | - return xfs_discard(s, aiocb->aio_offset, aiocb->aio_nbytes); | ||
137 | - } | ||
138 | -#endif | ||
139 | - | ||
140 | /* If we couldn't manage to unmap while guaranteed that the area reads as | ||
141 | * all-zero afterwards, just write zeroes without unmapping */ | ||
142 | ret = handle_aiocb_write_zeroes(aiocb); | ||
143 | @@ -XXX,XX +XXX,XX @@ static int handle_aiocb_discard(void *opaque) | ||
144 | ret = -errno; | ||
145 | #endif | ||
146 | } else { | ||
147 | -#ifdef CONFIG_XFS | ||
148 | - if (s->is_xfs) { | ||
149 | - return xfs_discard(s, aiocb->aio_offset, aiocb->aio_nbytes); | ||
150 | - } | ||
151 | -#endif | ||
152 | - | ||
153 | #ifdef CONFIG_FALLOCATE_PUNCH_HOLE | ||
154 | ret = do_fallocate(s->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, | ||
155 | aiocb->aio_offset, aiocb->aio_nbytes); | ||
247 | -- | 156 | -- |
248 | 2.19.1 | 157 | 2.20.1 |
249 | 158 | ||
250 | 159 | diff view generated by jsdifflib |
1 | From: Max Reitz <mreitz@redhat.com> | ||
---|---|---|---|
2 | |||
3 | This exercises the regression introduced in commit | ||
4 | 50ba5b2d994853b38fed10e0841b119da0f8b8e5. On my machine, it has close | ||
5 | to a 50 % false-negative rate, but that should still be sufficient to | ||
6 | test the fix. | ||
7 | |||
8 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
9 | Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> | ||
10 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
11 | Tested-by: Stefano Garzarella <sgarzare@redhat.com> | ||
12 | Tested-by: John Snow <jsnow@redhat.com> | ||
1 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 13 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
2 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
3 | --- | 14 | --- |
4 | tests/qemu-iotests/232 | 147 +++++++++++++++++++++++++++++++++++++ | 15 | tests/qemu-iotests/265 | 67 ++++++++++++++++++++++++++++++++++++++ |
5 | tests/qemu-iotests/232.out | 59 +++++++++++++++ | 16 | tests/qemu-iotests/265.out | 6 ++++ |
6 | tests/qemu-iotests/group | 1 + | 17 | tests/qemu-iotests/group | 1 + |
7 | 3 files changed, 207 insertions(+) | 18 | 3 files changed, 74 insertions(+) |
8 | create mode 100755 tests/qemu-iotests/232 | 19 | create mode 100755 tests/qemu-iotests/265 |
9 | create mode 100644 tests/qemu-iotests/232.out | 20 | create mode 100644 tests/qemu-iotests/265.out |
10 | 21 | ||
11 | diff --git a/tests/qemu-iotests/232 b/tests/qemu-iotests/232 | 22 | diff --git a/tests/qemu-iotests/265 b/tests/qemu-iotests/265 |
12 | new file mode 100755 | 23 | new file mode 100755 |
13 | index XXXXXXX..XXXXXXX | 24 | index XXXXXXX..XXXXXXX |
14 | --- /dev/null | 25 | --- /dev/null |
15 | +++ b/tests/qemu-iotests/232 | 26 | +++ b/tests/qemu-iotests/265 |
16 | @@ -XXX,XX +XXX,XX @@ | 27 | @@ -XXX,XX +XXX,XX @@ |
17 | +#!/bin/bash | 28 | +#!/usr/bin/env bash |
18 | +# | 29 | +# |
19 | +# Test for auto-read-only | 30 | +# Test reverse-ordered qcow2 writes on a sub-cluster level |
20 | +# | 31 | +# |
21 | +# Copyright (C) 2018 Red Hat, Inc. | 32 | +# Copyright (C) 2019 Red Hat, Inc. |
22 | +# | 33 | +# |
23 | +# This program is free software; you can redistribute it and/or modify | 34 | +# 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 | 35 | +# 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 | 36 | +# the Free Software Foundation; either version 2 of the License, or |
26 | +# (at your option) any later version. | 37 | +# (at your option) any later version. |
... | ... | ||
32 | +# | 43 | +# |
33 | +# You should have received a copy of the GNU General Public License | 44 | +# You should have received a copy of the GNU General Public License |
34 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | 45 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
35 | +# | 46 | +# |
36 | + | 47 | + |
37 | +# creator | 48 | +seq=$(basename $0) |
38 | +owner=kwolf@redhat.com | ||
39 | + | ||
40 | +seq=`basename $0` | ||
41 | +echo "QA output created by $seq" | 49 | +echo "QA output created by $seq" |
42 | + | 50 | + |
43 | +here=`pwd` | ||
44 | +status=1 # failure is the default! | 51 | +status=1 # failure is the default! |
45 | + | 52 | + |
46 | +_cleanup() | 53 | +_cleanup() |
47 | +{ | 54 | +{ |
48 | + _cleanup_test_img | 55 | + _cleanup_test_img |
49 | + rm -f $TEST_IMG.snap | ||
50 | +} | 56 | +} |
51 | +trap "_cleanup; exit \$status" 0 1 2 3 15 | 57 | +trap "_cleanup; exit \$status" 0 1 2 3 15 |
52 | + | 58 | + |
53 | +# get standard environment, filters and checks | 59 | +# get standard environment, filters and checks |
54 | +. ./common.rc | 60 | +. ./common.rc |
55 | +. ./common.filter | 61 | +. ./common.filter |
56 | + | 62 | + |
57 | +_supported_fmt generic | 63 | +# qcow2-specific test |
64 | +_supported_fmt qcow2 | ||
58 | +_supported_proto file | 65 | +_supported_proto file |
59 | +_supported_os Linux | 66 | +_supported_os Linux |
60 | + | 67 | + |
61 | +function do_run_qemu() | 68 | +echo '--- Writing to the image ---' |
62 | +{ | ||
63 | + echo Testing: "$@" | ||
64 | + ( | ||
65 | + if ! test -t 0; then | ||
66 | + while read cmd; do | ||
67 | + echo $cmd | ||
68 | + done | ||
69 | + fi | ||
70 | + echo quit | ||
71 | + ) | $QEMU -nographic -monitor stdio -nodefaults "$@" | ||
72 | + echo | ||
73 | +} | ||
74 | + | 69 | + |
75 | +function run_qemu() | 70 | +# Reduce cluster size so we get more and quicker I/O |
76 | +{ | 71 | +IMGOPTS='cluster_size=4096' _make_test_img 1M |
77 | + do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_hmp | | 72 | +(for ((kb = 1024 - 4; kb >= 0; kb -= 4)); do \ |
78 | + _filter_generated_node_ids | _filter_imgfmt | 73 | + echo "aio_write -P 42 $((kb + 1))k 2k"; \ |
79 | +} | 74 | + done) \ |
75 | + | $QEMU_IO "$TEST_IMG" > /dev/null | ||
80 | + | 76 | + |
81 | +function run_qemu_info_block() | 77 | +echo '--- Verifying its content ---' |
82 | +{ | ||
83 | + echo "info block -n" | run_qemu "$@" | grep -e "(file" -e "QEMU_PROG" | ||
84 | +} | ||
85 | + | 78 | + |
86 | +size=128M | 79 | +(for ((kb = 0; kb < 1024; kb += 4)); do \ |
80 | + echo "read -P 0 ${kb}k 1k"; \ | ||
81 | + echo "read -P 42 $((kb + 1))k 2k"; \ | ||
82 | + echo "read -P 0 $((kb + 3))k 1k"; \ | ||
83 | + done) \ | ||
84 | + | $QEMU_IO "$TEST_IMG" | _filter_qemu_io | grep 'verification' | ||
87 | + | 85 | + |
88 | +_make_test_img $size | 86 | +# Status of qemu-io |
89 | + | 87 | +if [ ${PIPESTATUS[1]} = 0 ]; then |
90 | +echo | 88 | + echo 'Content verified.' |
91 | +echo "=== -drive with read-write image: read-only/auto-read-only combinations ===" | 89 | +fi |
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 | + | 90 | + |
160 | +# success, all done | 91 | +# success, all done |
161 | +echo "*** done" | 92 | +echo "*** done" |
162 | +rm -f $seq.full | 93 | +rm -f $seq.full |
163 | +status=0 | 94 | +status=0 |
164 | diff --git a/tests/qemu-iotests/232.out b/tests/qemu-iotests/232.out | 95 | diff --git a/tests/qemu-iotests/265.out b/tests/qemu-iotests/265.out |
165 | new file mode 100644 | 96 | new file mode 100644 |
166 | index XXXXXXX..XXXXXXX | 97 | index XXXXXXX..XXXXXXX |
167 | --- /dev/null | 98 | --- /dev/null |
168 | +++ b/tests/qemu-iotests/232.out | 99 | +++ b/tests/qemu-iotests/265.out |
169 | @@ -XXX,XX +XXX,XX @@ | 100 | @@ -XXX,XX +XXX,XX @@ |
170 | +QA output created by 232 | 101 | +QA output created by 265 |
171 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | 102 | +--- Writing to the image --- |
172 | + | 103 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 |
173 | +=== -drive with read-write image: read-only/auto-read-only combinations === | 104 | +--- Verifying its content --- |
174 | + | 105 | +Content verified. |
175 | +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) | ||
176 | +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) | ||
177 | +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) | ||
178 | + | ||
179 | +NODE_NAME: TEST_DIR/t.IMGFMT (file) | ||
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 | 106 | +*** done |
229 | diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group | 107 | diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group |
230 | index XXXXXXX..XXXXXXX 100644 | 108 | index XXXXXXX..XXXXXXX 100644 |
231 | --- a/tests/qemu-iotests/group | 109 | --- a/tests/qemu-iotests/group |
232 | +++ b/tests/qemu-iotests/group | 110 | +++ b/tests/qemu-iotests/group |
233 | @@ -XXX,XX +XXX,XX @@ | 111 | @@ -XXX,XX +XXX,XX @@ |
234 | 227 auto quick | 112 | 257 rw |
235 | 229 auto quick | 113 | 258 rw quick |
236 | 231 auto quick | 114 | 262 rw quick migration |
237 | +232 auto quick | 115 | +265 rw auto quick |
238 | -- | 116 | -- |
239 | 2.19.1 | 117 | 2.20.1 |
240 | 118 | ||
241 | 119 | diff view generated by jsdifflib |
1 | From: Leonid Bloch <lbloch@janustech.com> | 1 | From: Markus Armbruster <armbru@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | The lookup table for power-of-two sizes was added in commit 540b8492618eb | 3 | pr_manager_worker() passes its @opaque argument to g_free(). Wrong; |
4 | for the purpose of having convenient shortcuts for these sizes in cases | 4 | it points to pr_manager_worker()'s automatic @data. Broken when |
5 | when the literal number has to be present at compile time, and | 5 | commit 2f3a7ab39be converted @data from heap- to stack-allocated. Fix |
6 | expressions as '(1 * KiB)' can not be used. One such case is the | 6 | by deleting the g_free(). |
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 | 7 | ||
11 | Despite its convenience, this table introduced 55 lines of "dumb" code, | 8 | Fixes: 2f3a7ab39bec4ba8022dc4d42ea641165b004e3e |
12 | the purpose and origin of which are obscure without reading the message | 9 | Cc: qemu-stable@nongnu.org |
13 | of the commit which introduced it. This patch fixes that by adding a | 10 | Signed-off-by: Markus Armbruster <armbru@redhat.com> |
14 | comment to the code itself with a brief explanation for the reasoning | 11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
15 | behind this table. This comment includes the short AWK script that | 12 | Acked-by: Paolo Bonzini <pbonzini@redhat.com> |
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> | 13 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
22 | --- | 14 | --- |
23 | include/qemu/units.h | 18 ++++++++++++++++++ | 15 | scsi/pr-manager.c | 1 - |
24 | 1 file changed, 18 insertions(+) | 16 | 1 file changed, 1 deletion(-) |
25 | 17 | ||
26 | diff --git a/include/qemu/units.h b/include/qemu/units.h | 18 | diff --git a/scsi/pr-manager.c b/scsi/pr-manager.c |
27 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/include/qemu/units.h | 20 | --- a/scsi/pr-manager.c |
29 | +++ b/include/qemu/units.h | 21 | +++ b/scsi/pr-manager.c |
30 | @@ -XXX,XX +XXX,XX @@ | 22 | @@ -XXX,XX +XXX,XX @@ static int pr_manager_worker(void *opaque) |
31 | #define PiB (INT64_C(1) << 50) | 23 | int fd = data->fd; |
32 | #define EiB (INT64_C(1) << 60) | 24 | int r; |
33 | 25 | ||
34 | +/* | 26 | - g_free(data); |
35 | + * The following lookup table is intended to be used when a literal string of | 27 | trace_pr_manager_run(fd, hdr->cmdp[0], hdr->cmdp[1]); |
36 | + * the number of bytes is required (for example if it needs to be stringified). | 28 | |
37 | + * It can also be used for generic shortcuts of power-of-two sizes. | 29 | /* The reference was taken in pr_manager_execute. */ |
38 | + * This table is generated using the AWK script below: | ||
39 | + * | ||
40 | + * BEGIN { | ||
41 | + * suffix="KMGTPE"; | ||
42 | + * for(i=10; i<64; i++) { | ||
43 | + * val=2**i; | ||
44 | + * s=substr(suffix, int(i/10), 1); | ||
45 | + * n=2**(i%10); | ||
46 | + * pad=21-int(log(n)/log(10)); | ||
47 | + * printf("#define S_%d%siB %*d\n", n, s, pad, val); | ||
48 | + * } | ||
49 | + * } | ||
50 | + */ | ||
51 | + | ||
52 | #define S_1KiB 1024 | ||
53 | #define S_2KiB 2048 | ||
54 | #define S_4KiB 4096 | ||
55 | -- | 30 | -- |
56 | 2.19.1 | 31 | 2.20.1 |
57 | 32 | ||
58 | 33 | diff view generated by jsdifflib |
1 | If read-only=off, but auto-read-only=on is given, open the file | 1 | If QEMU_AIO_NO_FALLBACK is given, we always return failure and don't |
---|---|---|---|
2 | read-write if we have the permissions, but instead of erroring out for | 2 | even try to use the BLKZEROOUT ioctl. In this failure case, we shouldn't |
3 | read-only files, just degrade to read-only. | 3 | disable has_write_zeroes because we didn't learn anything about the |
4 | ioctl. The next request might not set QEMU_AIO_NO_FALLBACK and we can | ||
5 | still use the ioctl then. | ||
4 | 6 | ||
7 | Fixes: 738301e1175 | ||
8 | Reported-by: Eric Blake <eblake@redhat.com> | ||
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> |
7 | --- | 11 | --- |
8 | block/file-posix.c | 19 ++++++++++++++++--- | 12 | block/file-posix.c | 6 +++--- |
9 | 1 file changed, 16 insertions(+), 3 deletions(-) | 13 | 1 file changed, 3 insertions(+), 3 deletions(-) |
10 | 14 | ||
11 | diff --git a/block/file-posix.c b/block/file-posix.c | 15 | diff --git a/block/file-posix.c b/block/file-posix.c |
12 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/block/file-posix.c | 17 | --- a/block/file-posix.c |
14 | +++ b/block/file-posix.c | 18 | +++ b/block/file-posix.c |
15 | @@ -XXX,XX +XXX,XX @@ static int raw_open_common(BlockDriverState *bs, QDict *options, | 19 | @@ -XXX,XX +XXX,XX @@ static ssize_t handle_aiocb_write_zeroes_block(RawPosixAIOData *aiocb) |
16 | 20 | } while (errno == EINTR); | |
17 | s->fd = -1; | 21 | |
18 | fd = qemu_open(filename, s->open_flags, 0644); | 22 | ret = translate_err(-errno); |
19 | - if (fd < 0) { | 23 | + if (ret == -ENOTSUP) { |
20 | - ret = -errno; | 24 | + s->has_write_zeroes = false; |
21 | - error_setg_errno(errp, errno, "Could not open '%s'", filename); | ||
22 | + ret = fd < 0 ? -errno : 0; | ||
23 | + | ||
24 | + if (ret == -EACCES || ret == -EROFS) { | ||
25 | + /* Try to degrade to read-only, but if it doesn't work, still use the | ||
26 | + * normal error message. */ | ||
27 | + if (bdrv_apply_auto_read_only(bs, NULL, NULL) == 0) { | ||
28 | + bdrv_flags &= ~BDRV_O_RDWR; | ||
29 | + raw_parse_flags(bdrv_flags, &s->open_flags); | ||
30 | + assert(!(s->open_flags & O_CREAT)); | ||
31 | + fd = qemu_open(filename, s->open_flags); | ||
32 | + ret = fd < 0 ? -errno : 0; | ||
33 | + } | 25 | + } |
34 | + } | 26 | } |
35 | + | 27 | #endif |
36 | + if (ret < 0) { | 28 | |
37 | + error_setg_errno(errp, -ret, "Could not open '%s'", filename); | 29 | - if (ret == -ENOTSUP) { |
38 | if (ret == -EROFS) { | 30 | - s->has_write_zeroes = false; |
39 | ret = -EACCES; | 31 | - } |
40 | } | 32 | return ret; |
33 | } | ||
34 | |||
41 | -- | 35 | -- |
42 | 2.19.1 | 36 | 2.20.1 |
43 | 37 | ||
44 | 38 | diff view generated by jsdifflib |
1 | From: Max Reitz <mreitz@redhat.com> | ||
---|---|---|---|
2 | |||
3 | blockdev_create_run() directly uses .bdrv_co_create()'s return value as | ||
4 | the job's return value. Jobs must return 0 on success, not just any | ||
5 | nonnegative value. Therefore, using blockdev-create for VPC images may | ||
6 | currently fail as the vpc driver may return a positive integer. | ||
7 | |||
8 | Because there is no point in returning a positive integer anywhere in | ||
9 | the block layer (all non-negative integers are generally treated as | ||
10 | complete success), we probably do not want to add more such cases. | ||
11 | Therefore, fix this problem by making the vpc driver always return 0 in | ||
12 | case of success. | ||
13 | |||
14 | Suggested-by: Kevin Wolf <kwolf@redhat.com> | ||
15 | Cc: qemu-stable@nongnu.org | ||
16 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
1 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 17 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
2 | Reviewed-by: Alberto Garcia <berto@igalia.com> | ||
3 | --- | 18 | --- |
4 | block/vpc.c | 2 ++ | 19 | block/vpc.c | 3 ++- |
5 | 1 file changed, 2 insertions(+) | 20 | 1 file changed, 2 insertions(+), 1 deletion(-) |
6 | 21 | ||
7 | diff --git a/block/vpc.c b/block/vpc.c | 22 | diff --git a/block/vpc.c b/block/vpc.c |
8 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
9 | --- a/block/vpc.c | 24 | --- a/block/vpc.c |
10 | +++ b/block/vpc.c | 25 | +++ b/block/vpc.c |
11 | @@ -XXX,XX +XXX,XX @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, | 26 | @@ -XXX,XX +XXX,XX @@ static int create_dynamic_disk(BlockBackend *blk, uint8_t *buf, |
27 | goto fail; | ||
12 | } | 28 | } |
13 | 29 | ||
14 | qemu_co_mutex_init(&s->lock); | 30 | + ret = 0; |
15 | + qemu_opts_del(opts); | 31 | fail: |
16 | 32 | return ret; | |
17 | return 0; | 33 | } |
18 | 34 | @@ -XXX,XX +XXX,XX @@ static int create_fixed_disk(BlockBackend *blk, uint8_t *buf, | |
19 | fail: | 35 | return ret; |
20 | + qemu_opts_del(opts); | 36 | } |
21 | qemu_vfree(s->pagetable); | 37 | |
22 | #ifdef CACHE | 38 | - return ret; |
23 | g_free(s->pageentry_u8); | 39 | + return 0; |
40 | } | ||
41 | |||
42 | static int calculate_rounded_image_size(BlockdevCreateOptionsVpc *vpc_opts, | ||
24 | -- | 43 | -- |
25 | 2.19.1 | 44 | 2.20.1 |
26 | 45 | ||
27 | 46 | diff view generated by jsdifflib |
1 | From: Max Reitz <mreitz@redhat.com> | 1 | From: Max Reitz <mreitz@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | There is no good reason why there should be a newline in this | ||
4 | description, so remove it. | ||
5 | |||
6 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 3 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | ||
9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
10 | --- | 5 | --- |
11 | vl.c | 2 +- | 6 | tests/qemu-iotests/iotests.py | 4 +++- |
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | 7 | 1 file changed, 3 insertions(+), 1 deletion(-) |
13 | 8 | ||
14 | diff --git a/vl.c b/vl.c | 9 | diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py |
15 | index XXXXXXX..XXXXXXX 100644 | 10 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/vl.c | 11 | --- a/tests/qemu-iotests/iotests.py |
17 | +++ b/vl.c | 12 | +++ b/tests/qemu-iotests/iotests.py |
18 | @@ -XXX,XX +XXX,XX @@ static QemuOptsList qemu_fw_cfg_opts = { | 13 | @@ -XXX,XX +XXX,XX @@ def execute_unittest(output, verbosity, debug): |
19 | }, { | 14 | |
20 | .name = "file", | 15 | def execute_test(test_function=None, |
21 | .type = QEMU_OPT_STRING, | 16 | supported_fmts=[], supported_oses=['linux'], |
22 | - .help = "Sets the name of the file from which\n" | 17 | - supported_cache_modes=[], unsupported_fmts=[]): |
23 | + .help = "Sets the name of the file from which " | 18 | + supported_cache_modes=[], unsupported_fmts=[], |
24 | "the fw_cfg blob will be loaded", | 19 | + supported_protocols=[], unsupported_protocols=[]): |
25 | }, { | 20 | """Run either unittest or script-style tests.""" |
26 | .name = "string", | 21 | |
22 | # We are using TEST_DIR and QEMU_DEFAULT_MACHINE as proxies to | ||
23 | @@ -XXX,XX +XXX,XX @@ def execute_test(test_function=None, | ||
24 | debug = '-d' in sys.argv | ||
25 | verbosity = 1 | ||
26 | verify_image_format(supported_fmts, unsupported_fmts) | ||
27 | + verify_protocol(supported_protocols, unsupported_protocols) | ||
28 | verify_platform(supported_oses) | ||
29 | verify_cache_mode(supported_cache_modes) | ||
30 | |||
27 | -- | 31 | -- |
28 | 2.19.1 | 32 | 2.20.1 |
29 | 33 | ||
30 | 34 | diff view generated by jsdifflib |
1 | From: Max Reitz <mreitz@redhat.com> | 1 | From: Max Reitz <mreitz@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Just like in qemu_opts_print_help(), print the object name as a caption | 3 | Most of our Python unittest-style tests only support the file protocol. |
4 | instead of on every single line, indent all options, add angle brackets | 4 | You can run them with any other protocol, but the test will simply |
5 | around types, and align the descriptions after 24 characters. | 5 | ignore your choice and use file anyway. |
6 | 6 | ||
7 | Also, indent every object name in the list of available objects. | 7 | We should let them signal that they require the file protocol so they |
8 | are skipped when you want to test some other protocol. | ||
8 | 9 | ||
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 10 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
10 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | ||
11 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 11 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
12 | --- | 12 | --- |
13 | vl.c | 13 ++++++++++--- | 13 | tests/qemu-iotests/030 | 3 ++- |
14 | 1 file changed, 10 insertions(+), 3 deletions(-) | 14 | tests/qemu-iotests/040 | 3 ++- |
15 | 15 | tests/qemu-iotests/041 | 3 ++- | |
16 | diff --git a/vl.c b/vl.c | 16 | tests/qemu-iotests/044 | 3 ++- |
17 | tests/qemu-iotests/045 | 3 ++- | ||
18 | tests/qemu-iotests/055 | 3 ++- | ||
19 | tests/qemu-iotests/056 | 3 ++- | ||
20 | tests/qemu-iotests/057 | 3 ++- | ||
21 | tests/qemu-iotests/065 | 3 ++- | ||
22 | tests/qemu-iotests/096 | 3 ++- | ||
23 | tests/qemu-iotests/118 | 3 ++- | ||
24 | tests/qemu-iotests/124 | 3 ++- | ||
25 | tests/qemu-iotests/129 | 3 ++- | ||
26 | tests/qemu-iotests/132 | 3 ++- | ||
27 | tests/qemu-iotests/139 | 3 ++- | ||
28 | tests/qemu-iotests/148 | 3 ++- | ||
29 | tests/qemu-iotests/151 | 3 ++- | ||
30 | tests/qemu-iotests/152 | 3 ++- | ||
31 | tests/qemu-iotests/155 | 3 ++- | ||
32 | tests/qemu-iotests/163 | 3 ++- | ||
33 | tests/qemu-iotests/165 | 3 ++- | ||
34 | tests/qemu-iotests/169 | 3 ++- | ||
35 | tests/qemu-iotests/196 | 3 ++- | ||
36 | tests/qemu-iotests/199 | 3 ++- | ||
37 | tests/qemu-iotests/245 | 3 ++- | ||
38 | tests/qemu-iotests/257 | 3 ++- | ||
39 | 26 files changed, 52 insertions(+), 26 deletions(-) | ||
40 | |||
41 | diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030 | ||
42 | index XXXXXXX..XXXXXXX 100755 | ||
43 | --- a/tests/qemu-iotests/030 | ||
44 | +++ b/tests/qemu-iotests/030 | ||
45 | @@ -XXX,XX +XXX,XX @@ class TestSetSpeed(iotests.QMPTestCase): | ||
46 | self.cancel_and_wait(resume=True) | ||
47 | |||
48 | if __name__ == '__main__': | ||
49 | - iotests.main(supported_fmts=['qcow2', 'qed']) | ||
50 | + iotests.main(supported_fmts=['qcow2', 'qed'], | ||
51 | + supported_protocols=['file']) | ||
52 | diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040 | ||
53 | index XXXXXXX..XXXXXXX 100755 | ||
54 | --- a/tests/qemu-iotests/040 | ||
55 | +++ b/tests/qemu-iotests/040 | ||
56 | @@ -XXX,XX +XXX,XX @@ class TestReopenOverlay(ImageCommitTestCase): | ||
57 | self.run_commit_test(self.img1, self.img0) | ||
58 | |||
59 | if __name__ == '__main__': | ||
60 | - iotests.main(supported_fmts=['qcow2', 'qed']) | ||
61 | + iotests.main(supported_fmts=['qcow2', 'qed'], | ||
62 | + supported_protocols=['file']) | ||
63 | diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041 | ||
64 | index XXXXXXX..XXXXXXX 100755 | ||
65 | --- a/tests/qemu-iotests/041 | ||
66 | +++ b/tests/qemu-iotests/041 | ||
67 | @@ -XXX,XX +XXX,XX @@ class TestOrphanedSource(iotests.QMPTestCase): | ||
68 | self.assert_qmp(result, 'error/class', 'GenericError') | ||
69 | |||
70 | if __name__ == '__main__': | ||
71 | - iotests.main(supported_fmts=['qcow2', 'qed']) | ||
72 | + iotests.main(supported_fmts=['qcow2', 'qed'], | ||
73 | + supported_protocols=['file']) | ||
74 | diff --git a/tests/qemu-iotests/044 b/tests/qemu-iotests/044 | ||
75 | index XXXXXXX..XXXXXXX 100755 | ||
76 | --- a/tests/qemu-iotests/044 | ||
77 | +++ b/tests/qemu-iotests/044 | ||
78 | @@ -XXX,XX +XXX,XX @@ class TestRefcountTableGrowth(iotests.QMPTestCase): | ||
79 | pass | ||
80 | |||
81 | if __name__ == '__main__': | ||
82 | - iotests.main(supported_fmts=['qcow2']) | ||
83 | + iotests.main(supported_fmts=['qcow2'], | ||
84 | + supported_protocols=['file']) | ||
85 | diff --git a/tests/qemu-iotests/045 b/tests/qemu-iotests/045 | ||
86 | index XXXXXXX..XXXXXXX 100755 | ||
87 | --- a/tests/qemu-iotests/045 | ||
88 | +++ b/tests/qemu-iotests/045 | ||
89 | @@ -XXX,XX +XXX,XX @@ class TestSCMFd(iotests.QMPTestCase): | ||
90 | "File descriptor named '%s' not found" % fdname) | ||
91 | |||
92 | if __name__ == '__main__': | ||
93 | - iotests.main(supported_fmts=['raw']) | ||
94 | + iotests.main(supported_fmts=['raw'], | ||
95 | + supported_protocols=['file']) | ||
96 | diff --git a/tests/qemu-iotests/055 b/tests/qemu-iotests/055 | ||
97 | index XXXXXXX..XXXXXXX 100755 | ||
98 | --- a/tests/qemu-iotests/055 | ||
99 | +++ b/tests/qemu-iotests/055 | ||
100 | @@ -XXX,XX +XXX,XX @@ class TestDriveCompression(iotests.QMPTestCase): | ||
101 | target='drive1') | ||
102 | |||
103 | if __name__ == '__main__': | ||
104 | - iotests.main(supported_fmts=['raw', 'qcow2']) | ||
105 | + iotests.main(supported_fmts=['raw', 'qcow2'], | ||
106 | + supported_protocols=['file']) | ||
107 | diff --git a/tests/qemu-iotests/056 b/tests/qemu-iotests/056 | ||
108 | index XXXXXXX..XXXXXXX 100755 | ||
109 | --- a/tests/qemu-iotests/056 | ||
110 | +++ b/tests/qemu-iotests/056 | ||
111 | @@ -XXX,XX +XXX,XX @@ class BackupTest(iotests.QMPTestCase): | ||
112 | self.dismissal_failure(True) | ||
113 | |||
114 | if __name__ == '__main__': | ||
115 | - iotests.main(supported_fmts=['qcow2', 'qed']) | ||
116 | + iotests.main(supported_fmts=['qcow2', 'qed'], | ||
117 | + supported_protocols=['file']) | ||
118 | diff --git a/tests/qemu-iotests/057 b/tests/qemu-iotests/057 | ||
119 | index XXXXXXX..XXXXXXX 100755 | ||
120 | --- a/tests/qemu-iotests/057 | ||
121 | +++ b/tests/qemu-iotests/057 | ||
122 | @@ -XXX,XX +XXX,XX @@ class TestSnapshotDelete(ImageSnapshotTestCase): | ||
123 | self.assert_qmp(result, 'error/class', 'GenericError') | ||
124 | |||
125 | if __name__ == '__main__': | ||
126 | - iotests.main(supported_fmts=['qcow2']) | ||
127 | + iotests.main(supported_fmts=['qcow2'], | ||
128 | + supported_protocols=['file']) | ||
129 | diff --git a/tests/qemu-iotests/065 b/tests/qemu-iotests/065 | ||
130 | index XXXXXXX..XXXXXXX 100755 | ||
131 | --- a/tests/qemu-iotests/065 | ||
132 | +++ b/tests/qemu-iotests/065 | ||
133 | @@ -XXX,XX +XXX,XX @@ TestQemuImgInfo = None | ||
134 | TestQMP = None | ||
135 | |||
136 | if __name__ == '__main__': | ||
137 | - iotests.main(supported_fmts=['qcow2']) | ||
138 | + iotests.main(supported_fmts=['qcow2'], | ||
139 | + supported_protocols=['file']) | ||
140 | diff --git a/tests/qemu-iotests/096 b/tests/qemu-iotests/096 | ||
141 | index XXXXXXX..XXXXXXX 100755 | ||
142 | --- a/tests/qemu-iotests/096 | ||
143 | +++ b/tests/qemu-iotests/096 | ||
144 | @@ -XXX,XX +XXX,XX @@ class TestLiveSnapshot(iotests.QMPTestCase): | ||
145 | self.checkConfig('target') | ||
146 | |||
147 | if __name__ == '__main__': | ||
148 | - iotests.main(supported_fmts=['qcow2']) | ||
149 | + iotests.main(supported_fmts=['qcow2'], | ||
150 | + supported_protocols=['file']) | ||
151 | diff --git a/tests/qemu-iotests/118 b/tests/qemu-iotests/118 | ||
152 | index XXXXXXX..XXXXXXX 100755 | ||
153 | --- a/tests/qemu-iotests/118 | ||
154 | +++ b/tests/qemu-iotests/118 | ||
155 | @@ -XXX,XX +XXX,XX @@ if __name__ == '__main__': | ||
156 | iotests.qemu_default_machine) | ||
157 | # Need to support image creation | ||
158 | iotests.main(supported_fmts=['vpc', 'parallels', 'qcow', 'vdi', 'qcow2', | ||
159 | - 'vmdk', 'raw', 'vhdx', 'qed']) | ||
160 | + 'vmdk', 'raw', 'vhdx', 'qed'], | ||
161 | + supported_protocols=['file']) | ||
162 | diff --git a/tests/qemu-iotests/124 b/tests/qemu-iotests/124 | ||
163 | index XXXXXXX..XXXXXXX 100755 | ||
164 | --- a/tests/qemu-iotests/124 | ||
165 | +++ b/tests/qemu-iotests/124 | ||
166 | @@ -XXX,XX +XXX,XX @@ class TestIncrementalBackupBlkdebug(TestIncrementalBackupBase): | ||
167 | |||
168 | |||
169 | if __name__ == '__main__': | ||
170 | - iotests.main(supported_fmts=['qcow2']) | ||
171 | + iotests.main(supported_fmts=['qcow2'], | ||
172 | + supported_protocols=['file']) | ||
173 | diff --git a/tests/qemu-iotests/129 b/tests/qemu-iotests/129 | ||
174 | index XXXXXXX..XXXXXXX 100755 | ||
175 | --- a/tests/qemu-iotests/129 | ||
176 | +++ b/tests/qemu-iotests/129 | ||
177 | @@ -XXX,XX +XXX,XX @@ class TestStopWithBlockJob(iotests.QMPTestCase): | ||
178 | self.do_test_stop("block-commit", device="drive0") | ||
179 | |||
180 | if __name__ == '__main__': | ||
181 | - iotests.main(supported_fmts=["qcow2"]) | ||
182 | + iotests.main(supported_fmts=["qcow2"], | ||
183 | + supported_protocols=["file"]) | ||
184 | diff --git a/tests/qemu-iotests/132 b/tests/qemu-iotests/132 | ||
185 | index XXXXXXX..XXXXXXX 100755 | ||
186 | --- a/tests/qemu-iotests/132 | ||
187 | +++ b/tests/qemu-iotests/132 | ||
188 | @@ -XXX,XX +XXX,XX @@ class TestSingleDrive(iotests.QMPTestCase): | ||
189 | 'target image does not match source after mirroring') | ||
190 | |||
191 | if __name__ == '__main__': | ||
192 | - iotests.main(supported_fmts=['raw', 'qcow2']) | ||
193 | + iotests.main(supported_fmts=['raw', 'qcow2'], | ||
194 | + supported_protocols=['file']) | ||
195 | diff --git a/tests/qemu-iotests/139 b/tests/qemu-iotests/139 | ||
196 | index XXXXXXX..XXXXXXX 100755 | ||
197 | --- a/tests/qemu-iotests/139 | ||
198 | +++ b/tests/qemu-iotests/139 | ||
199 | @@ -XXX,XX +XXX,XX @@ class TestBlockdevDel(iotests.QMPTestCase): | ||
200 | |||
201 | |||
202 | if __name__ == '__main__': | ||
203 | - iotests.main(supported_fmts=["qcow2"]) | ||
204 | + iotests.main(supported_fmts=["qcow2"], | ||
205 | + supported_protocols=["file"]) | ||
206 | diff --git a/tests/qemu-iotests/148 b/tests/qemu-iotests/148 | ||
207 | index XXXXXXX..XXXXXXX 100755 | ||
208 | --- a/tests/qemu-iotests/148 | ||
209 | +++ b/tests/qemu-iotests/148 | ||
210 | @@ -XXX,XX +XXX,XX @@ class TestFifoQuorumEvents(TestQuorumEvents): | ||
211 | |||
212 | if __name__ == '__main__': | ||
213 | iotests.verify_quorum() | ||
214 | - iotests.main(supported_fmts=["raw"]) | ||
215 | + iotests.main(supported_fmts=["raw"], | ||
216 | + supported_protocols=["file"]) | ||
217 | diff --git a/tests/qemu-iotests/151 b/tests/qemu-iotests/151 | ||
218 | index XXXXXXX..XXXXXXX 100755 | ||
219 | --- a/tests/qemu-iotests/151 | ||
220 | +++ b/tests/qemu-iotests/151 | ||
221 | @@ -XXX,XX +XXX,XX @@ class TestActiveMirror(iotests.QMPTestCase): | ||
222 | |||
223 | |||
224 | if __name__ == '__main__': | ||
225 | - iotests.main(supported_fmts=['qcow2', 'raw']) | ||
226 | + iotests.main(supported_fmts=['qcow2', 'raw'], | ||
227 | + supported_protocols=['file']) | ||
228 | diff --git a/tests/qemu-iotests/152 b/tests/qemu-iotests/152 | ||
229 | index XXXXXXX..XXXXXXX 100755 | ||
230 | --- a/tests/qemu-iotests/152 | ||
231 | +++ b/tests/qemu-iotests/152 | ||
232 | @@ -XXX,XX +XXX,XX @@ class TestUnaligned(iotests.QMPTestCase): | ||
233 | |||
234 | |||
235 | if __name__ == '__main__': | ||
236 | - iotests.main(supported_fmts=['raw', 'qcow2']) | ||
237 | + iotests.main(supported_fmts=['raw', 'qcow2'], | ||
238 | + supported_protocols=['file']) | ||
239 | diff --git a/tests/qemu-iotests/155 b/tests/qemu-iotests/155 | ||
240 | index XXXXXXX..XXXXXXX 100755 | ||
241 | --- a/tests/qemu-iotests/155 | ||
242 | +++ b/tests/qemu-iotests/155 | ||
243 | @@ -XXX,XX +XXX,XX @@ BaseClass = None | ||
244 | MirrorBaseClass = None | ||
245 | |||
246 | if __name__ == '__main__': | ||
247 | - iotests.main(supported_fmts=['qcow2']) | ||
248 | + iotests.main(supported_fmts=['qcow2'], | ||
249 | + supported_protocols=['file']) | ||
250 | diff --git a/tests/qemu-iotests/163 b/tests/qemu-iotests/163 | ||
251 | index XXXXXXX..XXXXXXX 100755 | ||
252 | --- a/tests/qemu-iotests/163 | ||
253 | +++ b/tests/qemu-iotests/163 | ||
254 | @@ -XXX,XX +XXX,XX @@ class TestShrink1M(ShrinkBaseClass): | ||
255 | ShrinkBaseClass = None | ||
256 | |||
257 | if __name__ == '__main__': | ||
258 | - iotests.main(supported_fmts=['raw', 'qcow2']) | ||
259 | + iotests.main(supported_fmts=['raw', 'qcow2'], | ||
260 | + supported_protocols=['file']) | ||
261 | diff --git a/tests/qemu-iotests/165 b/tests/qemu-iotests/165 | ||
262 | index XXXXXXX..XXXXXXX 100755 | ||
263 | --- a/tests/qemu-iotests/165 | ||
264 | +++ b/tests/qemu-iotests/165 | ||
265 | @@ -XXX,XX +XXX,XX @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase): | ||
266 | self.vm.shutdown() | ||
267 | |||
268 | if __name__ == '__main__': | ||
269 | - iotests.main(supported_fmts=['qcow2']) | ||
270 | + iotests.main(supported_fmts=['qcow2'], | ||
271 | + supported_protocols=['file']) | ||
272 | diff --git a/tests/qemu-iotests/169 b/tests/qemu-iotests/169 | ||
273 | index XXXXXXX..XXXXXXX 100755 | ||
274 | --- a/tests/qemu-iotests/169 | ||
275 | +++ b/tests/qemu-iotests/169 | ||
276 | @@ -XXX,XX +XXX,XX @@ for cmb in list(itertools.product((True, False), repeat=2)): | ||
277 | 'do_test_migration_resume_source', *list(cmb)) | ||
278 | |||
279 | if __name__ == '__main__': | ||
280 | - iotests.main(supported_fmts=['qcow2']) | ||
281 | + iotests.main(supported_fmts=['qcow2'], | ||
282 | + supported_protocols=['file']) | ||
283 | diff --git a/tests/qemu-iotests/196 b/tests/qemu-iotests/196 | ||
284 | index XXXXXXX..XXXXXXX 100755 | ||
285 | --- a/tests/qemu-iotests/196 | ||
286 | +++ b/tests/qemu-iotests/196 | ||
287 | @@ -XXX,XX +XXX,XX @@ class TestInvalidateAutoclear(iotests.QMPTestCase): | ||
288 | self.assertEqual(f.read(1), b'\x00') | ||
289 | |||
290 | if __name__ == '__main__': | ||
291 | - iotests.main(supported_fmts=['qcow2']) | ||
292 | + iotests.main(supported_fmts=['qcow2'], | ||
293 | + supported_protocols=['file']) | ||
294 | diff --git a/tests/qemu-iotests/199 b/tests/qemu-iotests/199 | ||
295 | index XXXXXXX..XXXXXXX 100755 | ||
296 | --- a/tests/qemu-iotests/199 | ||
297 | +++ b/tests/qemu-iotests/199 | ||
298 | @@ -XXX,XX +XXX,XX @@ class TestDirtyBitmapPostcopyMigration(iotests.QMPTestCase): | ||
299 | self.assert_qmp(result, 'return/sha256', sha256); | ||
300 | |||
301 | if __name__ == '__main__': | ||
302 | - iotests.main(supported_fmts=['qcow2'], supported_cache_modes=['none']) | ||
303 | + iotests.main(supported_fmts=['qcow2'], supported_cache_modes=['none'], | ||
304 | + supported_protocols=['file']) | ||
305 | diff --git a/tests/qemu-iotests/245 b/tests/qemu-iotests/245 | ||
17 | index XXXXXXX..XXXXXXX 100644 | 306 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/vl.c | 307 | --- a/tests/qemu-iotests/245 |
19 | +++ b/vl.c | 308 | +++ b/tests/qemu-iotests/245 |
20 | @@ -XXX,XX +XXX,XX @@ static bool object_create_initial(const char *type, QemuOpts *opts) | 309 | @@ -XXX,XX +XXX,XX @@ class TestBlockdevReopen(iotests.QMPTestCase): |
21 | list = object_class_get_list_sorted(TYPE_USER_CREATABLE, false); | 310 | self.reopen(opts, {'backing': 'hd2'}) |
22 | for (l = list; l != NULL; l = l->next) { | 311 | |
23 | ObjectClass *oc = OBJECT_CLASS(l->data); | 312 | if __name__ == '__main__': |
24 | - printf("%s\n", object_class_get_name(oc)); | 313 | - iotests.main(supported_fmts=["qcow2"]) |
25 | + printf(" %s\n", object_class_get_name(oc)); | 314 | + iotests.main(supported_fmts=["qcow2"], |
26 | } | 315 | + supported_protocols=["file"]) |
27 | g_slist_free(list); | 316 | diff --git a/tests/qemu-iotests/257 b/tests/qemu-iotests/257 |
28 | exit(0); | 317 | index XXXXXXX..XXXXXXX 100755 |
29 | @@ -XXX,XX +XXX,XX @@ static bool object_create_initial(const char *type, QemuOpts *opts) | 318 | --- a/tests/qemu-iotests/257 |
30 | } | 319 | +++ b/tests/qemu-iotests/257 |
31 | 320 | @@ -XXX,XX +XXX,XX @@ def main(): | |
32 | str = g_string_new(NULL); | 321 | test_backup_api() |
33 | - g_string_append_printf(str, "%s.%s=%s", type, | 322 | |
34 | - prop->name, prop->type); | 323 | if __name__ == '__main__': |
35 | + g_string_append_printf(str, " %s=<%s>", prop->name, prop->type); | 324 | - iotests.script_main(main, supported_fmts=['qcow2']) |
36 | if (prop->description) { | 325 | + iotests.script_main(main, supported_fmts=['qcow2'], |
37 | + if (str->len < 24) { | 326 | + supported_protocols=['file']) |
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 | -- | 327 | -- |
54 | 2.19.1 | 328 | 2.20.1 |
55 | 329 | ||
56 | 330 | diff view generated by jsdifflib |
1 | From: Max Reitz <mreitz@redhat.com> | 1 | From: Max Reitz <mreitz@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Just like in qemu_opts_print_help(), print the device name as a caption | 3 | We have two Python unittest-style tests that test NBD. As such, they |
4 | instead of on every single line, indent all options, add angle brackets | 4 | should specify supported_protocols=['nbd'] so they are skipped when the |
5 | around types, and align the descriptions after 24 characters. Also, | 5 | user wants to test some other protocol. |
6 | separate the descriptions with " - " instead of putting them in | 6 | |
7 | parentheses, because that is what we do everywhere else. This does look | 7 | Furthermore, we should restrict their choice of formats to 'raw'. The |
8 | a bit funny here because basically all bits have the description | 8 | idea of a protocol/format combination is to use some format over some |
9 | "on/off", but funny does not mean it is less readable. | 9 | protocol; but we always use the raw format over NBD. It does not really |
10 | matter what the NBD server uses on its end, and it is not a useful test | ||
11 | of the respective format driver anyway. | ||
10 | 12 | ||
11 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 13 | 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 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
14 | --- | 15 | --- |
15 | qdev-monitor.c | 13 +++++++++++-- | 16 | tests/qemu-iotests/147 | 5 ++--- |
16 | 1 file changed, 11 insertions(+), 2 deletions(-) | 17 | tests/qemu-iotests/205 | 3 ++- |
18 | 2 files changed, 4 insertions(+), 4 deletions(-) | ||
17 | 19 | ||
18 | diff --git a/qdev-monitor.c b/qdev-monitor.c | 20 | diff --git a/tests/qemu-iotests/147 b/tests/qemu-iotests/147 |
19 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100755 |
20 | --- a/qdev-monitor.c | 22 | --- a/tests/qemu-iotests/147 |
21 | +++ b/qdev-monitor.c | 23 | +++ b/tests/qemu-iotests/147 |
22 | @@ -XXX,XX +XXX,XX @@ int qdev_device_help(QemuOpts *opts) | 24 | @@ -XXX,XX +XXX,XX @@ class BuiltinNBD(NBDBlockdevAddBase): |
23 | goto error; | 25 | |
24 | } | 26 | |
25 | 27 | if __name__ == '__main__': | |
26 | + if (prop_list) { | 28 | - # Need to support image creation |
27 | + out_printf("%s options:\n", driver); | 29 | - iotests.main(supported_fmts=['vpc', 'parallels', 'qcow', 'vdi', 'qcow2', |
28 | + } else { | 30 | - 'vmdk', 'raw', 'vhdx', 'qed']) |
29 | + out_printf("There are no options for %s.\n", driver); | 31 | + iotests.main(supported_fmts=['raw'], |
30 | + } | 32 | + supported_protocols=['nbd']) |
31 | for (prop = prop_list; prop; prop = prop->next) { | 33 | diff --git a/tests/qemu-iotests/205 b/tests/qemu-iotests/205 |
32 | - out_printf("%s.%s=%s", driver, prop->value->name, prop->value->type); | 34 | index XXXXXXX..XXXXXXX 100755 |
33 | + int len; | 35 | --- a/tests/qemu-iotests/205 |
34 | + out_printf(" %s=<%s>%n", prop->value->name, prop->value->type, &len); | 36 | +++ b/tests/qemu-iotests/205 |
35 | if (prop->value->has_description) { | 37 | @@ -XXX,XX +XXX,XX @@ class TestNbdServerRemove(iotests.QMPTestCase): |
36 | - out_printf(" (%s)\n", prop->value->description); | 38 | |
37 | + if (len < 24) { | 39 | |
38 | + out_printf("%*s", 24 - len, ""); | 40 | if __name__ == '__main__': |
39 | + } | 41 | - iotests.main(supported_fmts=['generic']) |
40 | + out_printf(" - %s\n", prop->value->description); | 42 | + iotests.main(supported_fmts=['raw'], |
41 | } else { | 43 | + supported_protocols=['nbd']) |
42 | out_printf("\n"); | ||
43 | } | ||
44 | -- | 44 | -- |
45 | 2.19.1 | 45 | 2.20.1 |
46 | 46 | ||
47 | 47 | diff view generated by jsdifflib |
1 | From: Max Reitz <mreitz@redhat.com> | 1 | From: Max Reitz <mreitz@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Following the example of qemu_opts_print_help(), indent all entries in | ||
4 | the list of character devices. | ||
5 | |||
6 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 3 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
7 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | ||
8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
9 | --- | 5 | --- |
10 | chardev/char.c | 2 +- | 6 | tests/qemu-iotests/266 | 153 +++++++++++++++++++++++++++++++++++++ |
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | 7 | tests/qemu-iotests/266.out | 137 +++++++++++++++++++++++++++++++++ |
8 | tests/qemu-iotests/group | 1 + | ||
9 | 3 files changed, 291 insertions(+) | ||
10 | create mode 100755 tests/qemu-iotests/266 | ||
11 | create mode 100644 tests/qemu-iotests/266.out | ||
12 | 12 | ||
13 | diff --git a/chardev/char.c b/chardev/char.c | 13 | diff --git a/tests/qemu-iotests/266 b/tests/qemu-iotests/266 |
14 | new file mode 100755 | ||
15 | index XXXXXXX..XXXXXXX | ||
16 | --- /dev/null | ||
17 | +++ b/tests/qemu-iotests/266 | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | +#!/usr/bin/env python | ||
20 | +# | ||
21 | +# Test VPC and file image creation | ||
22 | +# | ||
23 | +# Copyright (C) 2019 Red Hat, Inc. | ||
24 | +# | ||
25 | +# This program is free software; you can redistribute it and/or modify | ||
26 | +# it under the terms of the GNU General Public License as published by | ||
27 | +# the Free Software Foundation; either version 2 of the License, or | ||
28 | +# (at your option) any later version. | ||
29 | +# | ||
30 | +# This program is distributed in the hope that it will be useful, | ||
31 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
32 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
33 | +# GNU General Public License for more details. | ||
34 | +# | ||
35 | +# You should have received a copy of the GNU General Public License | ||
36 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
37 | +# | ||
38 | + | ||
39 | +import iotests | ||
40 | +from iotests import imgfmt | ||
41 | + | ||
42 | + | ||
43 | +def blockdev_create(vm, options): | ||
44 | + result = vm.qmp_log('blockdev-create', job_id='job0', options=options, | ||
45 | + filters=[iotests.filter_qmp_testfiles]) | ||
46 | + | ||
47 | + if 'return' in result: | ||
48 | + assert result['return'] == {} | ||
49 | + vm.run_job('job0') | ||
50 | + | ||
51 | + | ||
52 | +# Successful image creation (defaults) | ||
53 | +def implicit_defaults(vm, file_path): | ||
54 | + iotests.log("=== Successful image creation (defaults) ===") | ||
55 | + iotests.log("") | ||
56 | + | ||
57 | + # 8 heads, 964 cyls/head, 17 secs/cyl | ||
58 | + # (Close to 64 MB) | ||
59 | + size = 8 * 964 * 17 * 512 | ||
60 | + | ||
61 | + blockdev_create(vm, { 'driver': imgfmt, | ||
62 | + 'file': 'protocol-node', | ||
63 | + 'size': size }) | ||
64 | + | ||
65 | + | ||
66 | +# Successful image creation (explicit defaults) | ||
67 | +def explicit_defaults(vm, file_path): | ||
68 | + iotests.log("=== Successful image creation (explicit defaults) ===") | ||
69 | + iotests.log("") | ||
70 | + | ||
71 | + # 16 heads, 964 cyls/head, 17 secs/cyl | ||
72 | + # (Close to 128 MB) | ||
73 | + size = 16 * 964 * 17 * 512 | ||
74 | + | ||
75 | + blockdev_create(vm, { 'driver': imgfmt, | ||
76 | + 'file': 'protocol-node', | ||
77 | + 'size': size, | ||
78 | + 'subformat': 'dynamic', | ||
79 | + 'force-size': False }) | ||
80 | + | ||
81 | + | ||
82 | +# Successful image creation (non-default options) | ||
83 | +def non_defaults(vm, file_path): | ||
84 | + iotests.log("=== Successful image creation (non-default options) ===") | ||
85 | + iotests.log("") | ||
86 | + | ||
87 | + # Not representable in CHS (fine with force-size=True) | ||
88 | + size = 1048576 | ||
89 | + | ||
90 | + blockdev_create(vm, { 'driver': imgfmt, | ||
91 | + 'file': 'protocol-node', | ||
92 | + 'size': size, | ||
93 | + 'subformat': 'fixed', | ||
94 | + 'force-size': True }) | ||
95 | + | ||
96 | + | ||
97 | +# Size not representable in CHS with force-size=False | ||
98 | +def non_chs_size_without_force(vm, file_path): | ||
99 | + iotests.log("=== Size not representable in CHS ===") | ||
100 | + iotests.log("") | ||
101 | + | ||
102 | + # Not representable in CHS (will not work with force-size=False) | ||
103 | + size = 1048576 | ||
104 | + | ||
105 | + blockdev_create(vm, { 'driver': imgfmt, | ||
106 | + 'file': 'protocol-node', | ||
107 | + 'size': size, | ||
108 | + 'force-size': False }) | ||
109 | + | ||
110 | + | ||
111 | +# Zero size | ||
112 | +def zero_size(vm, file_path): | ||
113 | + iotests.log("=== Zero size===") | ||
114 | + iotests.log("") | ||
115 | + | ||
116 | + blockdev_create(vm, { 'driver': imgfmt, | ||
117 | + 'file': 'protocol-node', | ||
118 | + 'size': 0 }) | ||
119 | + | ||
120 | + | ||
121 | +# Maximum CHS size | ||
122 | +def maximum_chs_size(vm, file_path): | ||
123 | + iotests.log("=== Maximum CHS size===") | ||
124 | + iotests.log("") | ||
125 | + | ||
126 | + blockdev_create(vm, { 'driver': imgfmt, | ||
127 | + 'file': 'protocol-node', | ||
128 | + 'size': 16 * 65535 * 255 * 512 }) | ||
129 | + | ||
130 | + | ||
131 | +# Actual maximum size | ||
132 | +def maximum_size(vm, file_path): | ||
133 | + iotests.log("=== Actual maximum size===") | ||
134 | + iotests.log("") | ||
135 | + | ||
136 | + blockdev_create(vm, { 'driver': imgfmt, | ||
137 | + 'file': 'protocol-node', | ||
138 | + 'size': 0xff000000 * 512, | ||
139 | + 'force-size': True }) | ||
140 | + | ||
141 | + | ||
142 | +def main(): | ||
143 | + for test_func in [implicit_defaults, explicit_defaults, non_defaults, | ||
144 | + non_chs_size_without_force, zero_size, maximum_chs_size, | ||
145 | + maximum_size]: | ||
146 | + | ||
147 | + with iotests.FilePath('t.vpc') as file_path, \ | ||
148 | + iotests.VM() as vm: | ||
149 | + | ||
150 | + vm.launch() | ||
151 | + | ||
152 | + iotests.log('--- Creating empty file ---') | ||
153 | + blockdev_create(vm, { 'driver': 'file', | ||
154 | + 'filename': file_path, | ||
155 | + 'size': 0 }) | ||
156 | + | ||
157 | + vm.qmp_log('blockdev-add', driver='file', filename=file_path, | ||
158 | + node_name='protocol-node', | ||
159 | + filters=[iotests.filter_qmp_testfiles]) | ||
160 | + iotests.log('') | ||
161 | + | ||
162 | + print_info = test_func(vm, file_path) | ||
163 | + iotests.log('') | ||
164 | + | ||
165 | + vm.shutdown() | ||
166 | + iotests.img_info_log(file_path) | ||
167 | + | ||
168 | + | ||
169 | +iotests.script_main(main, | ||
170 | + supported_fmts=['vpc'], | ||
171 | + supported_protocols=['file']) | ||
172 | diff --git a/tests/qemu-iotests/266.out b/tests/qemu-iotests/266.out | ||
173 | new file mode 100644 | ||
174 | index XXXXXXX..XXXXXXX | ||
175 | --- /dev/null | ||
176 | +++ b/tests/qemu-iotests/266.out | ||
177 | @@ -XXX,XX +XXX,XX @@ | ||
178 | +--- Creating empty file --- | ||
179 | +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "size": 0}}} | ||
180 | +{"return": {}} | ||
181 | +{"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
182 | +{"return": {}} | ||
183 | +{"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}} | ||
184 | +{"return": {}} | ||
185 | + | ||
186 | +=== Successful image creation (defaults) === | ||
187 | + | ||
188 | +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "vpc", "file": "protocol-node", "size": 67125248}}} | ||
189 | +{"return": {}} | ||
190 | +{"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
191 | +{"return": {}} | ||
192 | + | ||
193 | +image: TEST_IMG | ||
194 | +file format: IMGFMT | ||
195 | +virtual size: 64 MiB (67125248 bytes) | ||
196 | +cluster_size: 2097152 | ||
197 | + | ||
198 | +--- Creating empty file --- | ||
199 | +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "size": 0}}} | ||
200 | +{"return": {}} | ||
201 | +{"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
202 | +{"return": {}} | ||
203 | +{"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}} | ||
204 | +{"return": {}} | ||
205 | + | ||
206 | +=== Successful image creation (explicit defaults) === | ||
207 | + | ||
208 | +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "vpc", "file": "protocol-node", "force-size": false, "size": 134250496, "subformat": "dynamic"}}} | ||
209 | +{"return": {}} | ||
210 | +{"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
211 | +{"return": {}} | ||
212 | + | ||
213 | +image: TEST_IMG | ||
214 | +file format: IMGFMT | ||
215 | +virtual size: 128 MiB (134250496 bytes) | ||
216 | +cluster_size: 2097152 | ||
217 | + | ||
218 | +--- Creating empty file --- | ||
219 | +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "size": 0}}} | ||
220 | +{"return": {}} | ||
221 | +{"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
222 | +{"return": {}} | ||
223 | +{"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}} | ||
224 | +{"return": {}} | ||
225 | + | ||
226 | +=== Successful image creation (non-default options) === | ||
227 | + | ||
228 | +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "vpc", "file": "protocol-node", "force-size": true, "size": 1048576, "subformat": "fixed"}}} | ||
229 | +{"return": {}} | ||
230 | +{"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
231 | +{"return": {}} | ||
232 | + | ||
233 | +image: TEST_IMG | ||
234 | +file format: IMGFMT | ||
235 | +virtual size: 1 MiB (1048576 bytes) | ||
236 | + | ||
237 | +--- Creating empty file --- | ||
238 | +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "size": 0}}} | ||
239 | +{"return": {}} | ||
240 | +{"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
241 | +{"return": {}} | ||
242 | +{"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}} | ||
243 | +{"return": {}} | ||
244 | + | ||
245 | +=== Size not representable in CHS === | ||
246 | + | ||
247 | +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "vpc", "file": "protocol-node", "force-size": false, "size": 1048576}}} | ||
248 | +{"return": {}} | ||
249 | +Job failed: The requested image size cannot be represented in CHS geometry | ||
250 | +{"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
251 | +{"return": {}} | ||
252 | + | ||
253 | +qemu-img: Could not open 'TEST_IMG': File too small for a VHD header | ||
254 | + | ||
255 | +--- Creating empty file --- | ||
256 | +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "size": 0}}} | ||
257 | +{"return": {}} | ||
258 | +{"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
259 | +{"return": {}} | ||
260 | +{"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}} | ||
261 | +{"return": {}} | ||
262 | + | ||
263 | +=== Zero size=== | ||
264 | + | ||
265 | +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "vpc", "file": "protocol-node", "size": 0}}} | ||
266 | +{"return": {}} | ||
267 | +{"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
268 | +{"return": {}} | ||
269 | + | ||
270 | +image: TEST_IMG | ||
271 | +file format: IMGFMT | ||
272 | +virtual size: 0 B (0 bytes) | ||
273 | +cluster_size: 2097152 | ||
274 | + | ||
275 | +--- Creating empty file --- | ||
276 | +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "size": 0}}} | ||
277 | +{"return": {}} | ||
278 | +{"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
279 | +{"return": {}} | ||
280 | +{"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}} | ||
281 | +{"return": {}} | ||
282 | + | ||
283 | +=== Maximum CHS size=== | ||
284 | + | ||
285 | +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "vpc", "file": "protocol-node", "size": 136899993600}}} | ||
286 | +{"return": {}} | ||
287 | +{"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
288 | +{"return": {}} | ||
289 | + | ||
290 | +image: TEST_IMG | ||
291 | +file format: IMGFMT | ||
292 | +virtual size: 127 GiB (136899993600 bytes) | ||
293 | +cluster_size: 2097152 | ||
294 | + | ||
295 | +--- Creating empty file --- | ||
296 | +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "size": 0}}} | ||
297 | +{"return": {}} | ||
298 | +{"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
299 | +{"return": {}} | ||
300 | +{"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}} | ||
301 | +{"return": {}} | ||
302 | + | ||
303 | +=== Actual maximum size=== | ||
304 | + | ||
305 | +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "vpc", "file": "protocol-node", "force-size": true, "size": 2190433320960}}} | ||
306 | +{"return": {}} | ||
307 | +{"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
308 | +{"return": {}} | ||
309 | + | ||
310 | +image: TEST_IMG | ||
311 | +file format: IMGFMT | ||
312 | +virtual size: 1.99 TiB (2190433320960 bytes) | ||
313 | +cluster_size: 2097152 | ||
314 | + | ||
315 | diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group | ||
14 | index XXXXXXX..XXXXXXX 100644 | 316 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/chardev/char.c | 317 | --- a/tests/qemu-iotests/group |
16 | +++ b/chardev/char.c | 318 | +++ b/tests/qemu-iotests/group |
17 | @@ -XXX,XX +XXX,XX @@ help_string_append(const char *name, void *opaque) | 319 | @@ -XXX,XX +XXX,XX @@ |
18 | { | 320 | 258 rw quick |
19 | GString *str = opaque; | 321 | 262 rw quick migration |
20 | 322 | 265 rw auto quick | |
21 | - g_string_append_printf(str, "\n%s", name); | 323 | +266 rw quick |
22 | + g_string_append_printf(str, "\n %s", name); | ||
23 | } | ||
24 | |||
25 | static const char *chardev_alias_translate(const char *name) | ||
26 | -- | 324 | -- |
27 | 2.19.1 | 325 | 2.20.1 |
28 | 326 | ||
29 | 327 | diff view generated by jsdifflib |
1 | From: Leonid Bloch <lbloch@janustech.com> | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | If an expression is used to define DEFAULT_CLUSTER_SIZE, when compiled, | 3 | chmod a-w don't help under root, so skip the test in such case. |
4 | it will be embedded as a literal expression in the binary (as the | ||
5 | default value) because it is stringified to mark the size of the default | ||
6 | value. Now this is fixed by using a defined number to define this value. | ||
7 | 4 | ||
8 | Signed-off-by: Leonid Bloch <lbloch@janustech.com> | 5 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
9 | Reviewed-by: Stefan Weil <sw@weilnetz.de> | ||
10 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 6 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
11 | --- | 7 | --- |
12 | block/vdi.c | 4 ++-- | 8 | tests/qemu-iotests/232 | 6 ++++++ |
13 | 1 file changed, 2 insertions(+), 2 deletions(-) | 9 | 1 file changed, 6 insertions(+) |
14 | 10 | ||
15 | diff --git a/block/vdi.c b/block/vdi.c | 11 | diff --git a/tests/qemu-iotests/232 b/tests/qemu-iotests/232 |
16 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100755 |
17 | --- a/block/vdi.c | 13 | --- a/tests/qemu-iotests/232 |
18 | +++ b/block/vdi.c | 14 | +++ b/tests/qemu-iotests/232 |
19 | @@ -XXX,XX +XXX,XX @@ | 15 | @@ -XXX,XX +XXX,XX @@ if [ -n "$TEST_IMG_FILE" ]; then |
20 | #define BLOCK_OPT_STATIC "static" | 16 | TEST_IMG=$TEST_IMG_FILE |
21 | 17 | fi | |
22 | #define SECTOR_SIZE 512 | 18 | |
23 | -#define DEFAULT_CLUSTER_SIZE (1 * MiB) | 19 | +chmod a-w $TEST_IMG |
24 | +#define DEFAULT_CLUSTER_SIZE S_1MiB | 20 | +(echo test > $TEST_IMG) 2>/dev/null && \ |
25 | 21 | + _notrun "Readonly attribute is ignored, probably you run this test as" \ | |
26 | #if defined(CONFIG_VDI_DEBUG) | 22 | + "root, which is unsupported." |
27 | #define VDI_DEBUG 1 | 23 | +chmod a+w $TEST_IMG |
28 | @@ -XXX,XX +XXX,XX @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags, | 24 | + |
29 | goto fail; | 25 | echo |
30 | } else if (header.block_size != DEFAULT_CLUSTER_SIZE) { | 26 | echo "=== -drive with read-write image: read-only/auto-read-only combinations ===" |
31 | error_setg(errp, "unsupported VDI image (block size %" PRIu32 | 27 | echo |
32 | - " is not %" PRIu64 ")", | ||
33 | + " is not %" PRIu32 ")", | ||
34 | header.block_size, DEFAULT_CLUSTER_SIZE); | ||
35 | ret = -ENOTSUP; | ||
36 | goto fail; | ||
37 | -- | 28 | -- |
38 | 2.19.1 | 29 | 2.20.1 |
39 | 30 | ||
40 | 31 | diff view generated by jsdifflib |
1 | From: Max Reitz <mreitz@redhat.com> | 1 | From: Peter Lieven <pl@kamp.de> |
---|---|---|---|
2 | 2 | ||
3 | This adds some whitespace into the option help (including indentation) | 3 | libnfs recently added support for unmounting. Add support |
4 | and puts angle brackets around the type names. Furthermore, the list | 4 | in Qemu too. |
5 | name is no longer printed as part of every line, but only once in | ||
6 | advance, and only if the caller did not print a caption already. | ||
7 | 5 | ||
8 | This patch also restores the description alignment we had before commit | 6 | Signed-off-by: Peter Lieven <pl@kamp.de> |
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> | 7 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
23 | --- | 8 | --- |
24 | include/qemu/option.h | 2 +- | 9 | block/nfs.c | 5 ++++- |
25 | qemu-img.c | 4 +- | 10 | 1 file changed, 4 insertions(+), 1 deletion(-) |
26 | util/qemu-option.c | 32 +- | ||
27 | tests/qemu-iotests/082.out | 956 ++++++++++++++++++------------------- | ||
28 | 4 files changed, 507 insertions(+), 487 deletions(-) | ||
29 | 11 | ||
30 | diff --git a/include/qemu/option.h b/include/qemu/option.h | 12 | diff --git a/block/nfs.c b/block/nfs.c |
31 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/include/qemu/option.h | 14 | --- a/block/nfs.c |
33 | +++ b/include/qemu/option.h | 15 | +++ b/block/nfs.c |
34 | @@ -XXX,XX +XXX,XX @@ typedef int (*qemu_opts_loopfunc)(void *opaque, QemuOpts *opts, Error **errp); | 16 | @@ -XXX,XX +XXX,XX @@ |
35 | int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, | 17 | /* |
36 | void *opaque, Error **errp); | 18 | * QEMU Block driver for native access to files on NFS shares |
37 | void qemu_opts_print(QemuOpts *opts, const char *sep); | 19 | * |
38 | -void qemu_opts_print_help(QemuOptsList *list); | 20 | - * Copyright (c) 2014-2017 Peter Lieven <pl@kamp.de> |
39 | +void qemu_opts_print_help(QemuOptsList *list, bool print_caption); | 21 | + * Copyright (c) 2014-2019 Peter Lieven <pl@kamp.de> |
40 | void qemu_opts_free(QemuOptsList *list); | 22 | * |
41 | QemuOptsList *qemu_opts_append(QemuOptsList *dst, QemuOptsList *list); | 23 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
42 | 24 | * of this software and associated documentation files (the "Software"), to deal | |
43 | diff --git a/qemu-img.c b/qemu-img.c | 25 | @@ -XXX,XX +XXX,XX @@ static void nfs_client_close(NFSClient *client) |
44 | index XXXXXXX..XXXXXXX 100644 | 26 | nfs_close(client->context, client->fh); |
45 | --- a/qemu-img.c | 27 | client->fh = NULL; |
46 | +++ b/qemu-img.c | ||
47 | @@ -XXX,XX +XXX,XX @@ static int print_block_option_help(const char *filename, const char *fmt) | ||
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 | } | 28 | } |
101 | g_ptr_array_add(array, g_string_free(str, false)); | 29 | +#ifdef LIBNFS_FEATURE_UMOUNT |
102 | @@ -XXX,XX +XXX,XX @@ void qemu_opts_print_help(QemuOptsList *list) | 30 | + nfs_umount(client->context); |
103 | } | 31 | +#endif |
104 | 32 | aio_set_fd_handler(client->aio_context, nfs_get_fd(client->context), | |
105 | g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0); | 33 | false, NULL, NULL, NULL, NULL); |
106 | + if (print_caption && array->len > 0) { | 34 | nfs_destroy_context(client->context); |
107 | + if (list->name) { | ||
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 | -- | 35 | -- |
1222 | 2.19.1 | 36 | 2.20.1 |
1223 | 37 | ||
1224 | 38 | diff view generated by jsdifflib |
1 | From: Alberto Garcia <berto@igalia.com> | 1 | From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | This patch tests that you can add and remove drives from a Quorum | 3 | With the '-valgrind' option, let all the QEMU processes be run under |
4 | using the x-blockdev-change command. | 4 | the Valgrind tool. The Valgrind own parameters may be set with its |
5 | 5 | environment variable VALGRIND_OPTS, e.g. | |
6 | Signed-off-by: Alberto Garcia <berto@igalia.com> | 6 | $ VALGRIND_OPTS="--leak-check=yes" ./check -valgrind <test#> |
7 | or they may be listed in the Valgrind checked file ./.valgrindrc or | ||
8 | ~/.valgrindrc like | ||
9 | --memcheck:leak-check=no | ||
10 | --memcheck:track-origins=yes | ||
11 | To exclude a specific process from running under the Valgrind, the | ||
12 | corresponding environment variable VALGRIND_QEMU_<name> is to be set | ||
13 | to the empty string: | ||
14 | $ VALGRIND_QEMU_IO= ./check -valgrind <test#> | ||
15 | When QEMU-IO process is being killed, the shell report refers to the | ||
16 | text of the command in _qemu_io_wrapper(), which was modified with this | ||
17 | patch. So, the benchmark output for the tests 039, 061 and 137 is to be | ||
18 | changed also. | ||
19 | |||
20 | Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> | ||
7 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 21 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
8 | --- | 22 | --- |
9 | tests/qemu-iotests/081 | 86 ++++++++++++++++++++++++++++++++++++++ | 23 | tests/qemu-iotests/039.out | 30 ++---------- |
10 | tests/qemu-iotests/081.out | 54 ++++++++++++++++++++++++ | 24 | tests/qemu-iotests/061.out | 12 +---- |
11 | 2 files changed, 140 insertions(+) | 25 | tests/qemu-iotests/137.out | 6 +-- |
12 | 26 | tests/qemu-iotests/common.rc | 88 ++++++++++++++++++++++++++++-------- | |
13 | diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081 | 27 | 4 files changed, 78 insertions(+), 58 deletions(-) |
14 | index XXXXXXX..XXXXXXX 100755 | 28 | |
15 | --- a/tests/qemu-iotests/081 | 29 | diff --git a/tests/qemu-iotests/039.out b/tests/qemu-iotests/039.out |
16 | +++ b/tests/qemu-iotests/081 | 30 | index XXXXXXX..XXXXXXX 100644 |
17 | @@ -XXX,XX +XXX,XX @@ quorum="$quorum,file.children.2.driver=raw" | 31 | --- a/tests/qemu-iotests/039.out |
18 | 32 | +++ b/tests/qemu-iotests/039.out | |
19 | $QEMU_IO -c "open -o $quorum" | _filter_qemu_io | 33 | @@ -XXX,XX +XXX,XX @@ No errors were found on the image. |
20 | 34 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | |
21 | +echo | 35 | wrote 512/512 bytes at offset 0 |
22 | +echo "== dynamically adding a child to a quorum ==" | 36 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) |
23 | + | 37 | -./common.rc: Killed ( if [ "${VALGRIND_QEMU}" == "y" ]; then |
24 | +for verify in false true; do | 38 | - exec valgrind --log-file="${VALGRIND_LOGFILE}" --error-exitcode=99 "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@"; |
25 | + run_qemu <<EOF | 39 | -else |
26 | + { "execute": "qmp_capabilities" } | 40 | - exec "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@"; |
27 | + { "execute": "blockdev-add", | 41 | -fi ) |
28 | + "arguments": { | 42 | +./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) |
29 | + "driver": "quorum", | 43 | incompatible_features 0x1 |
30 | + "node-name": "drive0-quorum", | 44 | ERROR cluster 5 refcount=0 reference=1 |
31 | + "vote-threshold": 2, | 45 | ERROR OFLAG_COPIED data cluster: l2_entry=8000000000050000 refcount=0 |
32 | + "blkverify": ${verify}, | 46 | @@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 0 |
33 | + "children": [ | 47 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 |
34 | + { | 48 | wrote 512/512 bytes at offset 0 |
35 | + "driver": "$IMGFMT", | 49 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) |
36 | + "file": { | 50 | -./common.rc: Killed ( if [ "${VALGRIND_QEMU}" == "y" ]; then |
37 | + "driver": "file", | 51 | - exec valgrind --log-file="${VALGRIND_LOGFILE}" --error-exitcode=99 "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@"; |
38 | + "filename": "$TEST_DIR/1.raw" | 52 | -else |
39 | + } | 53 | - exec "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@"; |
40 | + }, | 54 | -fi ) |
41 | + { | 55 | +./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) |
42 | + "driver": "$IMGFMT", | 56 | incompatible_features 0x1 |
43 | + "file": { | 57 | ERROR cluster 5 refcount=0 reference=1 |
44 | + "driver": "file", | 58 | Rebuilding refcount structure |
45 | + "filename": "$TEST_DIR/2.raw" | 59 | @@ -XXX,XX +XXX,XX @@ incompatible_features 0x0 |
46 | + } | 60 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 |
47 | + } | 61 | wrote 512/512 bytes at offset 0 |
48 | + ] | 62 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) |
49 | + } | 63 | -./common.rc: Killed ( if [ "${VALGRIND_QEMU}" == "y" ]; then |
50 | + } | 64 | - exec valgrind --log-file="${VALGRIND_LOGFILE}" --error-exitcode=99 "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@"; |
51 | + { "execute": "blockdev-add", | 65 | -else |
52 | + "arguments": { | 66 | - exec "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@"; |
53 | + "node-name": "drive3", | 67 | -fi ) |
54 | + "driver": "$IMGFMT", | 68 | +./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) |
55 | + "file": { | 69 | incompatible_features 0x0 |
56 | + "driver": "file", | 70 | No errors were found on the image. |
57 | + "filename": "$TEST_DIR/2.raw" | 71 | |
58 | + } | 72 | @@ -XXX,XX +XXX,XX @@ No errors were found on the image. |
59 | + } | 73 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 |
60 | + } | 74 | wrote 512/512 bytes at offset 0 |
61 | + { "execute": "x-blockdev-change", | 75 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) |
62 | + "arguments": { "parent": "drive0-quorum", | 76 | -./common.rc: Killed ( if [ "${VALGRIND_QEMU}" == "y" ]; then |
63 | + "node": "drive3" } } | 77 | - exec valgrind --log-file="${VALGRIND_LOGFILE}" --error-exitcode=99 "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@"; |
64 | + { "execute": "quit" } | 78 | -else |
65 | +EOF | 79 | - exec "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@"; |
66 | +done | 80 | -fi ) |
67 | + | 81 | +./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) |
68 | +echo | 82 | incompatible_features 0x1 |
69 | +echo "== dynamically removing a child from a quorum ==" | 83 | ERROR cluster 5 refcount=0 reference=1 |
70 | + | 84 | ERROR OFLAG_COPIED data cluster: l2_entry=8000000000050000 refcount=0 |
71 | +for verify in false true; do | 85 | @@ -XXX,XX +XXX,XX @@ Data may be corrupted, or further writes to the image may corrupt it. |
72 | + for vote_threshold in 1 2; do | 86 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 |
73 | + run_qemu <<EOF | 87 | wrote 512/512 bytes at offset 0 |
74 | + { "execute": "qmp_capabilities" } | 88 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) |
75 | + { "execute": "blockdev-add", | 89 | -./common.rc: Killed ( if [ "${VALGRIND_QEMU}" == "y" ]; then |
76 | + "arguments": { | 90 | - exec valgrind --log-file="${VALGRIND_LOGFILE}" --error-exitcode=99 "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@"; |
77 | + "driver": "quorum", | 91 | -else |
78 | + "node-name": "drive0-quorum", | 92 | - exec "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@"; |
79 | + "vote-threshold": ${vote_threshold}, | 93 | -fi ) |
80 | + "blkverify": ${verify}, | 94 | +./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) |
81 | + "children": [ | 95 | incompatible_features 0x0 |
82 | + { | 96 | No errors were found on the image. |
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 | 97 | *** done |
98 | diff --git a/tests/qemu-iotests/061.out b/tests/qemu-iotests/061.out | ||
99 | index XXXXXXX..XXXXXXX 100644 | ||
100 | --- a/tests/qemu-iotests/061.out | ||
101 | +++ b/tests/qemu-iotests/061.out | ||
102 | @@ -XXX,XX +XXX,XX @@ No errors were found on the image. | ||
103 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
104 | wrote 131072/131072 bytes at offset 0 | ||
105 | 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
106 | -./common.rc: Killed ( if [ "${VALGRIND_QEMU}" == "y" ]; then | ||
107 | - exec valgrind --log-file="${VALGRIND_LOGFILE}" --error-exitcode=99 "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@"; | ||
108 | -else | ||
109 | - exec "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@"; | ||
110 | -fi ) | ||
111 | +./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) | ||
112 | magic 0x514649fb | ||
113 | version 3 | ||
114 | backing_file_offset 0x0 | ||
115 | @@ -XXX,XX +XXX,XX @@ No errors were found on the image. | ||
116 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
117 | wrote 131072/131072 bytes at offset 0 | ||
118 | 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
119 | -./common.rc: Killed ( if [ "${VALGRIND_QEMU}" == "y" ]; then | ||
120 | - exec valgrind --log-file="${VALGRIND_LOGFILE}" --error-exitcode=99 "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@"; | ||
121 | -else | ||
122 | - exec "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@"; | ||
123 | -fi ) | ||
124 | +./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) | ||
125 | magic 0x514649fb | ||
126 | version 3 | ||
127 | backing_file_offset 0x0 | ||
128 | diff --git a/tests/qemu-iotests/137.out b/tests/qemu-iotests/137.out | ||
129 | index XXXXXXX..XXXXXXX 100644 | ||
130 | --- a/tests/qemu-iotests/137.out | ||
131 | +++ b/tests/qemu-iotests/137.out | ||
132 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
133 | qemu-io: Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are any of the following: none, constant, cached, all | ||
134 | wrote 512/512 bytes at offset 0 | ||
135 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
136 | -./common.rc: Killed ( if [ "${VALGRIND_QEMU}" == "y" ]; then | ||
137 | - exec valgrind --log-file="${VALGRIND_LOGFILE}" --error-exitcode=99 "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@"; | ||
138 | -else | ||
139 | - exec "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@"; | ||
140 | -fi ) | ||
141 | +./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) | ||
142 | incompatible_features 0x0 | ||
143 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
144 | wrote 65536/65536 bytes at offset 0 | ||
145 | diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc | ||
146 | index XXXXXXX..XXXXXXX 100644 | ||
147 | --- a/tests/qemu-iotests/common.rc | ||
148 | +++ b/tests/qemu-iotests/common.rc | ||
149 | @@ -XXX,XX +XXX,XX @@ if ! . ./common.config | ||
150 | exit 1 | ||
151 | fi | ||
152 | |||
153 | +# Set the variables to the empty string to turn Valgrind off | ||
154 | +# for specific processes, e.g. | ||
155 | +# $ VALGRIND_QEMU_IO= ./check -qcow2 -valgrind 015 | ||
156 | + | ||
157 | +: ${VALGRIND_QEMU_VM=$VALGRIND_QEMU} | ||
158 | +: ${VALGRIND_QEMU_IMG=$VALGRIND_QEMU} | ||
159 | +: ${VALGRIND_QEMU_IO=$VALGRIND_QEMU} | ||
160 | +: ${VALGRIND_QEMU_NBD=$VALGRIND_QEMU} | ||
161 | +: ${VALGRIND_QEMU_VXHS=$VALGRIND_QEMU} | ||
162 | + | ||
163 | +# The Valgrind own parameters may be set with | ||
164 | +# its environment variable VALGRIND_OPTS, e.g. | ||
165 | +# $ VALGRIND_OPTS="--leak-check=yes" ./check -qcow2 -valgrind 015 | ||
166 | + | ||
167 | +_qemu_proc_exec() | ||
168 | +{ | ||
169 | + local VALGRIND_LOGFILE="$1" | ||
170 | + shift | ||
171 | + if [ "${VALGRIND_QEMU}" == "y" ]; then | ||
172 | + exec valgrind --log-file="${VALGRIND_LOGFILE}" --error-exitcode=99 "$@" | ||
173 | + else | ||
174 | + exec "$@" | ||
175 | + fi | ||
176 | +} | ||
177 | + | ||
178 | +_qemu_proc_valgrind_log() | ||
179 | +{ | ||
180 | + local VALGRIND_LOGFILE="$1" | ||
181 | + local RETVAL="$2" | ||
182 | + if [ "${VALGRIND_QEMU}" == "y" ]; then | ||
183 | + if [ $RETVAL == 99 ]; then | ||
184 | + cat "${VALGRIND_LOGFILE}" | ||
185 | + fi | ||
186 | + rm -f "${VALGRIND_LOGFILE}" | ||
187 | + fi | ||
188 | +} | ||
189 | + | ||
190 | _qemu_wrapper() | ||
191 | { | ||
192 | + local VALGRIND_LOGFILE="${TEST_DIR}"/$$.valgrind | ||
193 | ( | ||
194 | if [ -n "${QEMU_NEED_PID}" ]; then | ||
195 | echo $BASHPID > "${QEMU_TEST_DIR}/qemu-${_QEMU_HANDLE}.pid" | ||
196 | fi | ||
197 | - exec "$QEMU_PROG" $QEMU_OPTIONS "$@" | ||
198 | + VALGRIND_QEMU="${VALGRIND_QEMU_VM}" _qemu_proc_exec "${VALGRIND_LOGFILE}" \ | ||
199 | + "$QEMU_PROG" $QEMU_OPTIONS "$@" | ||
200 | ) | ||
201 | + RETVAL=$? | ||
202 | + _qemu_proc_valgrind_log "${VALGRIND_LOGFILE}" $RETVAL | ||
203 | + return $RETVAL | ||
204 | } | ||
205 | |||
206 | _qemu_img_wrapper() | ||
207 | { | ||
208 | - (exec "$QEMU_IMG_PROG" $QEMU_IMG_OPTIONS "$@") | ||
209 | + local VALGRIND_LOGFILE="${TEST_DIR}"/$$.valgrind | ||
210 | + ( | ||
211 | + VALGRIND_QEMU="${VALGRIND_QEMU_IMG}" _qemu_proc_exec "${VALGRIND_LOGFILE}" \ | ||
212 | + "$QEMU_IMG_PROG" $QEMU_IMG_OPTIONS "$@" | ||
213 | + ) | ||
214 | + RETVAL=$? | ||
215 | + _qemu_proc_valgrind_log "${VALGRIND_LOGFILE}" $RETVAL | ||
216 | + return $RETVAL | ||
217 | } | ||
218 | |||
219 | _qemu_io_wrapper() | ||
220 | @@ -XXX,XX +XXX,XX @@ _qemu_io_wrapper() | ||
221 | QEMU_IO_ARGS="--object secret,id=keysec0,data=$IMGKEYSECRET $QEMU_IO_ARGS" | ||
222 | fi | ||
223 | fi | ||
224 | - local RETVAL | ||
225 | ( | ||
226 | - if [ "${VALGRIND_QEMU}" == "y" ]; then | ||
227 | - exec valgrind --log-file="${VALGRIND_LOGFILE}" --error-exitcode=99 "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" | ||
228 | - else | ||
229 | - exec "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" | ||
230 | - fi | ||
231 | + VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" \ | ||
232 | + "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" | ||
233 | ) | ||
234 | RETVAL=$? | ||
235 | - if [ "${VALGRIND_QEMU}" == "y" ]; then | ||
236 | - if [ $RETVAL == 99 ]; then | ||
237 | - cat "${VALGRIND_LOGFILE}" | ||
238 | - fi | ||
239 | - rm -f "${VALGRIND_LOGFILE}" | ||
240 | - fi | ||
241 | - (exit $RETVAL) | ||
242 | + _qemu_proc_valgrind_log "${VALGRIND_LOGFILE}" $RETVAL | ||
243 | + return $RETVAL | ||
244 | } | ||
245 | |||
246 | _qemu_nbd_wrapper() | ||
247 | { | ||
248 | - "$QEMU_NBD_PROG" --pid-file="${QEMU_TEST_DIR}/qemu-nbd.pid" \ | ||
249 | - $QEMU_NBD_OPTIONS "$@" | ||
250 | + local VALGRIND_LOGFILE="${TEST_DIR}"/$$.valgrind | ||
251 | + ( | ||
252 | + VALGRIND_QEMU="${VALGRIND_QEMU_NBD}" _qemu_proc_exec "${VALGRIND_LOGFILE}" \ | ||
253 | + "$QEMU_NBD_PROG" --pid-file="${QEMU_TEST_DIR}/qemu-nbd.pid" \ | ||
254 | + $QEMU_NBD_OPTIONS "$@" | ||
255 | + ) | ||
256 | + RETVAL=$? | ||
257 | + _qemu_proc_valgrind_log "${VALGRIND_LOGFILE}" $RETVAL | ||
258 | + return $RETVAL | ||
259 | } | ||
260 | |||
261 | _qemu_vxhs_wrapper() | ||
262 | { | ||
263 | + local VALGRIND_LOGFILE="${TEST_DIR}"/$$.valgrind | ||
264 | ( | ||
265 | echo $BASHPID > "${TEST_DIR}/qemu-vxhs.pid" | ||
266 | - exec "$QEMU_VXHS_PROG" $QEMU_VXHS_OPTIONS "$@" | ||
267 | + VALGRIND_QEMU="${VALGRIND_QEMU_VXHS}" _qemu_proc_exec "${VALGRIND_LOGFILE}" \ | ||
268 | + "$QEMU_VXHS_PROG" $QEMU_VXHS_OPTIONS "$@" | ||
269 | ) | ||
270 | + RETVAL=$? | ||
271 | + _qemu_proc_valgrind_log "${VALGRIND_LOGFILE}" $RETVAL | ||
272 | + return $RETVAL | ||
273 | } | ||
274 | |||
275 | export QEMU=_qemu_wrapper | ||
173 | -- | 276 | -- |
174 | 2.19.1 | 277 | 2.20.1 |
175 | 278 | ||
176 | 279 | diff view generated by jsdifflib |
1 | From: Peter Maydell <peter.maydell@linaro.org> | 1 | From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | Taking the address of a field in a packed struct is a bad idea, because | 3 | The Valgrind tool fails to manage its termination in multi-threaded |
4 | it might not be actually aligned enough for that pointer type (and | 4 | processes when they raise the signal SIGKILL. The bug has been reported |
5 | thus cause a crash on dereference on some host architectures). Newer | 5 | to the Valgrind maintainers and was registered as the bug #409141: |
6 | versions of clang warn about this. Avoid the bug by not using the | 6 | https://bugs.kde.org/show_bug.cgi?id=409141 |
7 | "modify in place" byte swapping functions. | 7 | Let's exclude such test cases from running under the Valgrind until a |
8 | new version with the bug fix is released because checking for the | ||
9 | memory issues is covered by other test cases. | ||
8 | 10 | ||
9 | There are a few places where the in-place swap function is | 11 | Suggested-by: John Snow <jsnow@redhat.com> |
10 | used on something other than a packed struct field; we convert | 12 | Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> |
11 | those anyway, for consistency. | ||
12 | |||
13 | This patch was produced with the following spatch script: | ||
14 | |||
15 | @@ | ||
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> | 13 | 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 | tests/qemu-iotests/039 | 5 +++++ |
53 | 1 file changed, 12 insertions(+), 12 deletions(-) | 17 | tests/qemu-iotests/061 | 2 ++ |
18 | tests/qemu-iotests/137 | 1 + | ||
19 | tests/qemu-iotests/common.rc | 12 ++++++++++-- | ||
20 | 4 files changed, 18 insertions(+), 2 deletions(-) | ||
54 | 21 | ||
55 | diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c | 22 | diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039 |
23 | index XXXXXXX..XXXXXXX 100755 | ||
24 | --- a/tests/qemu-iotests/039 | ||
25 | +++ b/tests/qemu-iotests/039 | ||
26 | @@ -XXX,XX +XXX,XX @@ echo "== Creating a dirty image file ==" | ||
27 | IMGOPTS="compat=1.1,lazy_refcounts=on" | ||
28 | _make_test_img $size | ||
29 | |||
30 | +_NO_VALGRIND \ | ||
31 | $QEMU_IO -c "write -P 0x5a 0 512" \ | ||
32 | -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ | ||
33 | | _filter_qemu_io | ||
34 | @@ -XXX,XX +XXX,XX @@ echo "== Opening a dirty image read/write should repair it ==" | ||
35 | IMGOPTS="compat=1.1,lazy_refcounts=on" | ||
36 | _make_test_img $size | ||
37 | |||
38 | +_NO_VALGRIND \ | ||
39 | $QEMU_IO -c "write -P 0x5a 0 512" \ | ||
40 | -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ | ||
41 | | _filter_qemu_io | ||
42 | @@ -XXX,XX +XXX,XX @@ echo "== Creating an image file with lazy_refcounts=off ==" | ||
43 | IMGOPTS="compat=1.1,lazy_refcounts=off" | ||
44 | _make_test_img $size | ||
45 | |||
46 | +_NO_VALGRIND \ | ||
47 | $QEMU_IO -c "write -P 0x5a 0 512" \ | ||
48 | -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ | ||
49 | | _filter_qemu_io | ||
50 | @@ -XXX,XX +XXX,XX @@ echo "== Changing lazy_refcounts setting at runtime ==" | ||
51 | IMGOPTS="compat=1.1,lazy_refcounts=off" | ||
52 | _make_test_img $size | ||
53 | |||
54 | +_NO_VALGRIND \ | ||
55 | $QEMU_IO -c "reopen -o lazy-refcounts=on" \ | ||
56 | -c "write -P 0x5a 0 512" \ | ||
57 | -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ | ||
58 | @@ -XXX,XX +XXX,XX @@ _check_test_img | ||
59 | IMGOPTS="compat=1.1,lazy_refcounts=on" | ||
60 | _make_test_img $size | ||
61 | |||
62 | +_NO_VALGRIND \ | ||
63 | $QEMU_IO -c "reopen -o lazy-refcounts=off" \ | ||
64 | -c "write -P 0x5a 0 512" \ | ||
65 | -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ | ||
66 | diff --git a/tests/qemu-iotests/061 b/tests/qemu-iotests/061 | ||
67 | index XXXXXXX..XXXXXXX 100755 | ||
68 | --- a/tests/qemu-iotests/061 | ||
69 | +++ b/tests/qemu-iotests/061 | ||
70 | @@ -XXX,XX +XXX,XX @@ echo | ||
71 | echo "=== Testing dirty version downgrade ===" | ||
72 | echo | ||
73 | IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img 64M | ||
74 | +_NO_VALGRIND \ | ||
75 | $QEMU_IO -c "write -P 0x2a 0 128k" -c flush \ | ||
76 | -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 | _filter_qemu_io | ||
77 | $PYTHON qcow2.py "$TEST_IMG" dump-header | ||
78 | @@ -XXX,XX +XXX,XX @@ echo | ||
79 | echo "=== Testing dirty lazy_refcounts=off ===" | ||
80 | echo | ||
81 | IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img 64M | ||
82 | +_NO_VALGRIND \ | ||
83 | $QEMU_IO -c "write -P 0x2a 0 128k" -c flush \ | ||
84 | -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 | _filter_qemu_io | ||
85 | $PYTHON qcow2.py "$TEST_IMG" dump-header | ||
86 | diff --git a/tests/qemu-iotests/137 b/tests/qemu-iotests/137 | ||
87 | index XXXXXXX..XXXXXXX 100755 | ||
88 | --- a/tests/qemu-iotests/137 | ||
89 | +++ b/tests/qemu-iotests/137 | ||
90 | @@ -XXX,XX +XXX,XX @@ echo | ||
91 | |||
92 | # Whether lazy-refcounts was actually enabled can easily be tested: Check if | ||
93 | # the dirty bit is set after a crash | ||
94 | +_NO_VALGRIND \ | ||
95 | $QEMU_IO \ | ||
96 | -c "reopen -o lazy-refcounts=on,overlap-check=blubb" \ | ||
97 | -c "write -P 0x5a 0 512" \ | ||
98 | diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc | ||
56 | index XXXXXXX..XXXXXXX 100644 | 99 | index XXXXXXX..XXXXXXX 100644 |
57 | --- a/block/qcow2-bitmap.c | 100 | --- a/tests/qemu-iotests/common.rc |
58 | +++ b/block/qcow2-bitmap.c | 101 | +++ b/tests/qemu-iotests/common.rc |
59 | @@ -XXX,XX +XXX,XX @@ static inline void bitmap_table_to_be(uint64_t *bitmap_table, size_t size) | 102 | @@ -XXX,XX +XXX,XX @@ _qemu_proc_exec() |
60 | size_t i; | 103 | { |
61 | 104 | local VALGRIND_LOGFILE="$1" | |
62 | for (i = 0; i < size; ++i) { | 105 | shift |
63 | - cpu_to_be64s(&bitmap_table[i]); | 106 | - if [ "${VALGRIND_QEMU}" == "y" ]; then |
64 | + bitmap_table[i] = cpu_to_be64(bitmap_table[i]); | 107 | + if [[ "${VALGRIND_QEMU}" == "y" && "${NO_VALGRIND}" != "y" ]]; then |
65 | } | 108 | exec valgrind --log-file="${VALGRIND_LOGFILE}" --error-exitcode=99 "$@" |
109 | else | ||
110 | exec "$@" | ||
111 | @@ -XXX,XX +XXX,XX @@ _qemu_proc_valgrind_log() | ||
112 | { | ||
113 | local VALGRIND_LOGFILE="$1" | ||
114 | local RETVAL="$2" | ||
115 | - if [ "${VALGRIND_QEMU}" == "y" ]; then | ||
116 | + if [[ "${VALGRIND_QEMU}" == "y" && "${NO_VALGRIND}" != "y" ]]; then | ||
117 | if [ $RETVAL == 99 ]; then | ||
118 | cat "${VALGRIND_LOGFILE}" | ||
119 | fi | ||
120 | @@ -XXX,XX +XXX,XX @@ _qemu_vxhs_wrapper() | ||
121 | return $RETVAL | ||
66 | } | 122 | } |
67 | 123 | ||
68 | @@ -XXX,XX +XXX,XX @@ static int bitmap_table_load(BlockDriverState *bs, Qcow2BitmapTable *tb, | 124 | +# Valgrind bug #409141 https://bugs.kde.org/show_bug.cgi?id=409141 |
69 | } | 125 | +# Until valgrind 3.16+ is ubiquitous, we must work around a hang in |
70 | 126 | +# valgrind when issuing sigkill. Disable valgrind for this invocation. | |
71 | for (i = 0; i < tb->size; ++i) { | 127 | +_NO_VALGRIND() |
72 | - be64_to_cpus(&table[i]); | 128 | +{ |
73 | + table[i] = be64_to_cpu(table[i]); | 129 | + NO_VALGRIND="y" "$@" |
74 | ret = check_table_entry(table[i], s->cluster_size); | 130 | +} |
75 | if (ret < 0) { | 131 | + |
76 | goto fail; | 132 | export QEMU=_qemu_wrapper |
77 | @@ -XXX,XX +XXX,XX @@ fail: | 133 | export QEMU_IMG=_qemu_img_wrapper |
78 | 134 | export QEMU_IO=_qemu_io_wrapper | |
79 | static inline void bitmap_dir_entry_to_cpu(Qcow2BitmapDirEntry *entry) | ||
80 | { | ||
81 | - be64_to_cpus(&entry->bitmap_table_offset); | ||
82 | - be32_to_cpus(&entry->bitmap_table_size); | ||
83 | - be32_to_cpus(&entry->flags); | ||
84 | - be16_to_cpus(&entry->name_size); | ||
85 | - be32_to_cpus(&entry->extra_data_size); | ||
86 | + entry->bitmap_table_offset = be64_to_cpu(entry->bitmap_table_offset); | ||
87 | + entry->bitmap_table_size = be32_to_cpu(entry->bitmap_table_size); | ||
88 | + entry->flags = be32_to_cpu(entry->flags); | ||
89 | + entry->name_size = be16_to_cpu(entry->name_size); | ||
90 | + entry->extra_data_size = be32_to_cpu(entry->extra_data_size); | ||
91 | } | ||
92 | |||
93 | static inline void bitmap_dir_entry_to_be(Qcow2BitmapDirEntry *entry) | ||
94 | { | ||
95 | - cpu_to_be64s(&entry->bitmap_table_offset); | ||
96 | - cpu_to_be32s(&entry->bitmap_table_size); | ||
97 | - cpu_to_be32s(&entry->flags); | ||
98 | - cpu_to_be16s(&entry->name_size); | ||
99 | - cpu_to_be32s(&entry->extra_data_size); | ||
100 | + entry->bitmap_table_offset = cpu_to_be64(entry->bitmap_table_offset); | ||
101 | + entry->bitmap_table_size = cpu_to_be32(entry->bitmap_table_size); | ||
102 | + entry->flags = cpu_to_be32(entry->flags); | ||
103 | + entry->name_size = cpu_to_be16(entry->name_size); | ||
104 | + entry->extra_data_size = cpu_to_be32(entry->extra_data_size); | ||
105 | } | ||
106 | |||
107 | static inline int calc_dir_entry_size(size_t name_size, size_t extra_data_size) | ||
108 | -- | 135 | -- |
109 | 2.19.1 | 136 | 2.20.1 |
110 | 137 | ||
111 | 138 | diff view generated by jsdifflib |
1 | From: Li Qiang <liq3ea@163.com> | 1 | From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Li Qiang <liq3ea@163.com> | 3 | The new function _casenotrun() is to be invoked if a test case cannot |
4 | Reviewed-by: Alberto Garcia <berto@igalia.com> | 4 | be run for some reason. The user will be notified by a message passed |
5 | to the function. It is the caller's responsibility to make skipped a | ||
6 | particular test. | ||
7 | |||
8 | Suggested-by: Kevin Wolf <kwolf@redhat.com> | ||
9 | Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> | ||
10 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
11 | Reviewed-by: Cleber Rosa <crosa@redhat.com> | ||
5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 12 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
6 | --- | 13 | --- |
7 | include/sysemu/block-backend.h | 6 +++--- | 14 | tests/qemu-iotests/common.rc | 9 +++++++++ |
8 | block/block-backend.c | 8 ++++---- | 15 | 1 file changed, 9 insertions(+) |
9 | 2 files changed, 7 insertions(+), 7 deletions(-) | ||
10 | 16 | ||
11 | diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h | 17 | diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc |
12 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/include/sysemu/block-backend.h | 19 | --- a/tests/qemu-iotests/common.rc |
14 | +++ b/include/sysemu/block-backend.h | 20 | +++ b/tests/qemu-iotests/common.rc |
15 | @@ -XXX,XX +XXX,XX @@ BlockErrorAction blk_get_error_action(BlockBackend *blk, bool is_read, | 21 | @@ -XXX,XX +XXX,XX @@ _notrun() |
16 | int error); | 22 | exit |
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 | } | ||
34 | } | 23 | } |
35 | 24 | ||
36 | -int blk_is_read_only(BlockBackend *blk) | 25 | +# bail out, setting up .casenotrun file |
37 | +bool blk_is_read_only(BlockBackend *blk) | 26 | +# The function _casenotrun() is used as a notifier. It is the |
38 | { | 27 | +# caller's responsibility to make skipped a particular test. |
39 | BlockDriverState *bs = blk_bs(blk); | 28 | +# |
40 | 29 | +_casenotrun() | |
41 | @@ -XXX,XX +XXX,XX @@ int blk_is_read_only(BlockBackend *blk) | 30 | +{ |
42 | } | 31 | + echo " [case not run] $*" >>"$OUTPUT_DIR/$seq.casenotrun" |
43 | } | 32 | +} |
44 | 33 | + | |
45 | -int blk_is_sg(BlockBackend *blk) | 34 | # just plain bail out |
46 | +bool blk_is_sg(BlockBackend *blk) | 35 | # |
47 | { | 36 | _fail() |
48 | BlockDriverState *bs = blk_bs(blk); | ||
49 | |||
50 | if (!bs) { | ||
51 | - return 0; | ||
52 | + return false; | ||
53 | } | ||
54 | |||
55 | return bdrv_is_sg(bs); | ||
56 | } | ||
57 | |||
58 | -int blk_enable_write_cache(BlockBackend *blk) | ||
59 | +bool blk_enable_write_cache(BlockBackend *blk) | ||
60 | { | ||
61 | return blk->enable_write_cache; | ||
62 | } | ||
63 | -- | 37 | -- |
64 | 2.19.1 | 38 | 2.20.1 |
65 | 39 | ||
66 | 40 | diff view generated by jsdifflib |
1 | From: Alberto Garcia <berto@igalia.com> | 1 | From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Alberto Garcia <berto@igalia.com> | 3 | The Valgrind uses the exported variable TMPDIR and fails if the |
4 | directory does not exist. Let us exclude such a test case from | ||
5 | being run under the Valgrind and notify the user of it. | ||
6 | |||
7 | Suggested-by: Kevin Wolf <kwolf@redhat.com> | ||
8 | Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> | ||
9 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 10 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
5 | --- | 11 | --- |
6 | tests/qemu-iotests/081 | 30 ++++++++++++++++++++++++++++++ | 12 | tests/qemu-iotests/051 | 4 ++++ |
7 | tests/qemu-iotests/081.out | 16 ++++++++++++++++ | 13 | 1 file changed, 4 insertions(+) |
8 | 2 files changed, 46 insertions(+) | ||
9 | 14 | ||
10 | diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081 | 15 | diff --git a/tests/qemu-iotests/051 b/tests/qemu-iotests/051 |
11 | index XXXXXXX..XXXXXXX 100755 | 16 | index XXXXXXX..XXXXXXX 100755 |
12 | --- a/tests/qemu-iotests/081 | 17 | --- a/tests/qemu-iotests/051 |
13 | +++ b/tests/qemu-iotests/081 | 18 | +++ b/tests/qemu-iotests/051 |
14 | @@ -XXX,XX +XXX,XX @@ echo "== checking that quorum is broken ==" | 19 | @@ -XXX,XX +XXX,XX @@ printf %b "qemu-io $device_id \"write -P 0x33 0 4k\"\ncommit $device_id\n" | |
15 | 20 | $QEMU_IO -c "read -P 0x33 0 4k" "$TEST_IMG" | _filter_qemu_io | |
16 | $QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io | 21 | |
17 | 22 | # Using snapshot=on with a non-existent TMPDIR | |
18 | +echo | 23 | +if [ "${VALGRIND_QEMU_VM}" == "y" ]; then |
19 | +echo "== checking the blkverify mode with broken content ==" | 24 | + _casenotrun "Valgrind needs a valid TMPDIR for itself" |
20 | + | 25 | +fi |
21 | +quorum="driver=raw,file.driver=quorum,file.vote-threshold=2,file.blkverify=on" | 26 | +VALGRIND_QEMU_VM= \ |
22 | +quorum="$quorum,file.children.0.file.filename=$TEST_DIR/1.raw" | 27 | TMPDIR=/nonexistent run_qemu -drive driver=null-co,snapshot=on |
23 | +quorum="$quorum,file.children.1.file.filename=$TEST_DIR/2.raw" | 28 | |
24 | +quorum="$quorum,file.children.0.driver=raw" | 29 | # Using snapshot=on together with read-only=on |
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 | -- | 30 | -- |
77 | 2.19.1 | 31 | 2.20.1 |
78 | 32 | ||
79 | 33 | diff view generated by jsdifflib |
1 | From: Peter Maydell <peter.maydell@linaro.org> | 1 | From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | Taking the address of a field in a packed struct is a bad idea, because | 3 | As the iotests run longer under the Valgrind, the QEMU_COMM_TIMEOUT is |
4 | it might not be actually aligned enough for that pointer type (and | 4 | to be increased in the test cases 028, 183 and 192 when running under |
5 | thus cause a crash on dereference on some host architectures). Newer | 5 | the Valgrind. |
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 | Suggested-by: Roman Kagan <rkagan@virtuozzo.com> |
10 | used on something other than a packed struct field; we convert | 8 | Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> |
11 | those anyway, for consistency. | 9 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
12 | |||
13 | This patch was produced with the following spatch script: | ||
14 | |||
15 | @@ | ||
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> | 10 | Reviewed-by: John Snow <jsnow@redhat.com> |
50 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 11 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
51 | --- | 12 | --- |
52 | block/qcow.c | 18 +++++++++--------- | 13 | tests/qemu-iotests/028 | 6 +++++- |
53 | 1 file changed, 9 insertions(+), 9 deletions(-) | 14 | tests/qemu-iotests/183 | 9 ++++++++- |
15 | tests/qemu-iotests/192 | 6 +++++- | ||
16 | 3 files changed, 18 insertions(+), 3 deletions(-) | ||
54 | 17 | ||
55 | diff --git a/block/qcow.c b/block/qcow.c | 18 | diff --git a/tests/qemu-iotests/028 b/tests/qemu-iotests/028 |
56 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100755 |
57 | --- a/block/qcow.c | 20 | --- a/tests/qemu-iotests/028 |
58 | +++ b/block/qcow.c | 21 | +++ b/tests/qemu-iotests/028 |
59 | @@ -XXX,XX +XXX,XX @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags, | 22 | @@ -XXX,XX +XXX,XX @@ echo |
60 | if (ret < 0) { | 23 | qemu_comm_method="monitor" |
61 | goto fail; | 24 | _launch_qemu -drive file="${TEST_IMG}",cache=${CACHEMODE},id=disk |
62 | } | 25 | h=$QEMU_HANDLE |
63 | - be32_to_cpus(&header.magic); | 26 | -QEMU_COMM_TIMEOUT=1 |
64 | - be32_to_cpus(&header.version); | 27 | +if [ "${VALGRIND_QEMU}" == "y" ]; then |
65 | - be64_to_cpus(&header.backing_file_offset); | 28 | + QEMU_COMM_TIMEOUT=7 |
66 | - be32_to_cpus(&header.backing_file_size); | 29 | +else |
67 | - be32_to_cpus(&header.mtime); | 30 | + QEMU_COMM_TIMEOUT=1 |
68 | - be64_to_cpus(&header.size); | 31 | +fi |
69 | - be32_to_cpus(&header.crypt_method); | 32 | |
70 | - be64_to_cpus(&header.l1_table_offset); | 33 | # Silence output since it contains the disk image path and QEMU's readline |
71 | + header.magic = be32_to_cpu(header.magic); | 34 | # character echoing makes it very hard to filter the output. Plus, there |
72 | + header.version = be32_to_cpu(header.version); | 35 | diff --git a/tests/qemu-iotests/183 b/tests/qemu-iotests/183 |
73 | + header.backing_file_offset = be64_to_cpu(header.backing_file_offset); | 36 | index XXXXXXX..XXXXXXX 100755 |
74 | + header.backing_file_size = be32_to_cpu(header.backing_file_size); | 37 | --- a/tests/qemu-iotests/183 |
75 | + header.mtime = be32_to_cpu(header.mtime); | 38 | +++ b/tests/qemu-iotests/183 |
76 | + header.size = be64_to_cpu(header.size); | 39 | @@ -XXX,XX +XXX,XX @@ if echo "$reply" | grep "compiled without old-style" > /dev/null; then |
77 | + header.crypt_method = be32_to_cpu(header.crypt_method); | 40 | _notrun "migrate -b support not compiled in" |
78 | + header.l1_table_offset = be64_to_cpu(header.l1_table_offset); | 41 | fi |
79 | 42 | ||
80 | if (header.magic != QCOW_MAGIC) { | 43 | -QEMU_COMM_TIMEOUT=0.1 qemu_cmd_repeat=50 silent=yes \ |
81 | error_setg(errp, "Image not in qcow format"); | 44 | +timeout_comm=$QEMU_COMM_TIMEOUT |
82 | @@ -XXX,XX +XXX,XX @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags, | 45 | +if [ "${VALGRIND_QEMU}" == "y" ]; then |
83 | } | 46 | + QEMU_COMM_TIMEOUT=4 |
84 | 47 | +else | |
85 | for(i = 0;i < s->l1_size; i++) { | 48 | + QEMU_COMM_TIMEOUT=0.1 |
86 | - be64_to_cpus(&s->l1_table[i]); | 49 | +fi |
87 | + s->l1_table[i] = be64_to_cpu(s->l1_table[i]); | 50 | +qemu_cmd_repeat=50 silent=yes \ |
88 | } | 51 | _send_qemu_cmd $src "{ 'execute': 'query-migrate' }" '"status": "completed"' |
89 | 52 | +QEMU_COMM_TIMEOUT=$timeout_comm | |
90 | /* alloc L2 cache (max. 64k * 16 * 8 = 8 MB) */ | 53 | _send_qemu_cmd $src "{ 'execute': 'query-status' }" "return" |
54 | |||
55 | echo | ||
56 | diff --git a/tests/qemu-iotests/192 b/tests/qemu-iotests/192 | ||
57 | index XXXXXXX..XXXXXXX 100755 | ||
58 | --- a/tests/qemu-iotests/192 | ||
59 | +++ b/tests/qemu-iotests/192 | ||
60 | @@ -XXX,XX +XXX,XX @@ fi | ||
61 | qemu_comm_method="monitor" | ||
62 | _launch_qemu -drive $DRIVE_ARG -incoming defer | ||
63 | h=$QEMU_HANDLE | ||
64 | -QEMU_COMM_TIMEOUT=1 | ||
65 | +if [ "${VALGRIND_QEMU}" == "y" ]; then | ||
66 | + QEMU_COMM_TIMEOUT=7 | ||
67 | +else | ||
68 | + QEMU_COMM_TIMEOUT=1 | ||
69 | +fi | ||
70 | |||
71 | _send_qemu_cmd $h "nbd_server_start unix:$TEST_DIR/nbd" "(qemu)" | ||
72 | _send_qemu_cmd $h "nbd_server_add -w drive0" "(qemu)" | ||
91 | -- | 73 | -- |
92 | 2.19.1 | 74 | 2.20.1 |
93 | 75 | ||
94 | 76 | diff view generated by jsdifflib |
1 | From: Peter Maydell <peter.maydell@linaro.org> | 1 | From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | Taking the address of a field in a packed struct is a bad idea, because | 3 | To synchronize the time when QEMU is running longer under the Valgrind, |
4 | it might not be actually aligned enough for that pointer type (and | 4 | increase the sleeping time in the test 247. |
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 | 5 | ||
9 | There are a few places where the in-place swap function is | 6 | Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> |
10 | used on something other than a packed struct field; we convert | 7 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
11 | those anyway, for consistency. | ||
12 | |||
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> | 8 | Reviewed-by: John Snow <jsnow@redhat.com> |
51 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
52 | --- | 10 | --- |
53 | block/qcow2.c | 64 +++++++++++++++++++++++++++------------------------ | 11 | tests/qemu-iotests/247 | 6 +++++- |
54 | 1 file changed, 34 insertions(+), 30 deletions(-) | 12 | 1 file changed, 5 insertions(+), 1 deletion(-) |
55 | 13 | ||
56 | diff --git a/block/qcow2.c b/block/qcow2.c | 14 | diff --git a/tests/qemu-iotests/247 b/tests/qemu-iotests/247 |
57 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100755 |
58 | --- a/block/qcow2.c | 16 | --- a/tests/qemu-iotests/247 |
59 | +++ b/block/qcow2.c | 17 | +++ b/tests/qemu-iotests/247 |
60 | @@ -XXX,XX +XXX,XX @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, | 18 | @@ -XXX,XX +XXX,XX @@ TEST_IMG="$TEST_IMG.4" _make_test_img $size |
61 | "pread fail from offset %" PRIu64, offset); | 19 | {"execute":"block-commit", |
62 | return 1; | 20 | "arguments":{"device":"format-4", "top-node": "format-2", "base-node":"format-0", "job-id":"job0"}} |
63 | } | 21 | EOF |
64 | - be32_to_cpus(&ext.magic); | 22 | -sleep 1 |
65 | - be32_to_cpus(&ext.len); | 23 | +if [ "${VALGRIND_QEMU}" == "y" ]; then |
66 | + ext.magic = be32_to_cpu(ext.magic); | 24 | + sleep 10 |
67 | + ext.len = be32_to_cpu(ext.len); | 25 | +else |
68 | offset += sizeof(ext); | 26 | + sleep 1 |
69 | #ifdef DEBUG_EXT | 27 | +fi |
70 | printf("ext.magic = 0x%x\n", ext.magic); | 28 | echo '{"execute":"quit"}' |
71 | @@ -XXX,XX +XXX,XX @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, | 29 | ) | $QEMU -qmp stdio -nographic -nodefaults \ |
72 | "Unable to read CRYPTO header extension"); | 30 | -blockdev file,node-name=file-0,filename=$TEST_IMG.0,auto-read-only=on \ |
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 | } | ||
101 | - be32_to_cpus(&header.magic); | ||
102 | - be32_to_cpus(&header.version); | ||
103 | - be64_to_cpus(&header.backing_file_offset); | ||
104 | - be32_to_cpus(&header.backing_file_size); | ||
105 | - be64_to_cpus(&header.size); | ||
106 | - be32_to_cpus(&header.cluster_bits); | ||
107 | - be32_to_cpus(&header.crypt_method); | ||
108 | - be64_to_cpus(&header.l1_table_offset); | ||
109 | - be32_to_cpus(&header.l1_size); | ||
110 | - be64_to_cpus(&header.refcount_table_offset); | ||
111 | - be32_to_cpus(&header.refcount_table_clusters); | ||
112 | - be64_to_cpus(&header.snapshots_offset); | ||
113 | - be32_to_cpus(&header.nb_snapshots); | ||
114 | + header.magic = be32_to_cpu(header.magic); | ||
115 | + header.version = be32_to_cpu(header.version); | ||
116 | + header.backing_file_offset = be64_to_cpu(header.backing_file_offset); | ||
117 | + header.backing_file_size = be32_to_cpu(header.backing_file_size); | ||
118 | + header.size = be64_to_cpu(header.size); | ||
119 | + header.cluster_bits = be32_to_cpu(header.cluster_bits); | ||
120 | + header.crypt_method = be32_to_cpu(header.crypt_method); | ||
121 | + header.l1_table_offset = be64_to_cpu(header.l1_table_offset); | ||
122 | + header.l1_size = be32_to_cpu(header.l1_size); | ||
123 | + header.refcount_table_offset = be64_to_cpu(header.refcount_table_offset); | ||
124 | + header.refcount_table_clusters = | ||
125 | + be32_to_cpu(header.refcount_table_clusters); | ||
126 | + header.snapshots_offset = be64_to_cpu(header.snapshots_offset); | ||
127 | + header.nb_snapshots = be32_to_cpu(header.nb_snapshots); | ||
128 | |||
129 | if (header.magic != QCOW_MAGIC) { | ||
130 | error_setg(errp, "Image is not in qcow2 format"); | ||
131 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, | ||
132 | header.refcount_order = 4; | ||
133 | header.header_length = 72; | ||
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; | ||
151 | } | ||
152 | for(i = 0;i < s->l1_size; i++) { | ||
153 | - be64_to_cpus(&s->l1_table[i]); | ||
154 | + s->l1_table[i] = be64_to_cpu(s->l1_table[i]); | ||
155 | } | ||
156 | } | ||
157 | |||
158 | @@ -XXX,XX +XXX,XX @@ int qcow2_update_header(BlockDriverState *bs) | ||
159 | |||
160 | /* Full disk encryption header pointer extension */ | ||
161 | if (s->crypto_header.offset != 0) { | ||
162 | - cpu_to_be64s(&s->crypto_header.offset); | ||
163 | - cpu_to_be64s(&s->crypto_header.length); | ||
164 | + s->crypto_header.offset = cpu_to_be64(s->crypto_header.offset); | ||
165 | + s->crypto_header.length = cpu_to_be64(s->crypto_header.length); | ||
166 | ret = header_ext_add(buf, QCOW2_EXT_MAGIC_CRYPTO_HEADER, | ||
167 | &s->crypto_header, sizeof(s->crypto_header), | ||
168 | buflen); | ||
169 | - be64_to_cpus(&s->crypto_header.offset); | ||
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 | } | ||
176 | -- | 31 | -- |
177 | 2.19.1 | 32 | 2.20.1 |
178 | 33 | ||
179 | 34 | diff view generated by jsdifflib |
1 | From: Stefan Weil <sw@weilnetz.de> | 1 | qemu_io_alloc_from_file() needs to close the pattern file even if some |
---|---|---|---|
2 | error occurred. | ||
2 | 3 | ||
3 | Use %zu instead of %zd for unsigned numbers. | 4 | Setting f = NULL in the success path and checking it for NULL in the |
5 | error path isn't strictly necessary at this point, but let's do it | ||
6 | anyway in case someone later adds a 'goto error' after closing the file. | ||
4 | 7 | ||
5 | This fixes two error messages from the LSTM static code analyzer: | 8 | Coverity: CID 1405303 |
6 | 9 | Fixes: 4d731510d34f280ed45a6de621d016f67a49ea48 | |
7 | This argument should be of type 'ssize_t' but is of type 'unsigned long' | ||
8 | |||
9 | Signed-off-by: Stefan Weil <sw@weilnetz.de> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 10 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
11 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
12 | Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> | ||
12 | --- | 13 | --- |
13 | qemu-io-cmds.c | 4 ++-- | 14 | qemu-io-cmds.c | 4 ++++ |
14 | 1 file changed, 2 insertions(+), 2 deletions(-) | 15 | 1 file changed, 4 insertions(+) |
15 | 16 | ||
16 | diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c | 17 | diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c |
17 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/qemu-io-cmds.c | 19 | --- a/qemu-io-cmds.c |
19 | +++ b/qemu-io-cmds.c | 20 | +++ b/qemu-io-cmds.c |
20 | @@ -XXX,XX +XXX,XX @@ static int readv_f(BlockBackend *blk, int argc, char **argv) | 21 | @@ -XXX,XX +XXX,XX @@ static void *qemu_io_alloc_from_file(BlockBackend *blk, size_t len, |
21 | memset(cmp_buf, pattern, qiov.size); | ||
22 | if (memcmp(buf, cmp_buf, qiov.size)) { | ||
23 | printf("Pattern verification failed at offset %" | ||
24 | - PRId64 ", %zd bytes\n", offset, qiov.size); | ||
25 | + PRId64 ", %zu bytes\n", offset, qiov.size); | ||
26 | ret = -EINVAL; | ||
27 | } | ||
28 | g_free(cmp_buf); | ||
29 | @@ -XXX,XX +XXX,XX @@ static void aio_read_done(void *opaque, int ret) | ||
30 | memset(cmp_buf, ctx->pattern, ctx->qiov.size); | ||
31 | if (memcmp(ctx->buf, cmp_buf, ctx->qiov.size)) { | ||
32 | printf("Pattern verification failed at offset %" | ||
33 | - PRId64 ", %zd bytes\n", ctx->offset, ctx->qiov.size); | ||
34 | + PRId64 ", %zu bytes\n", ctx->offset, ctx->qiov.size); | ||
35 | } | ||
36 | g_free(cmp_buf); | ||
37 | } | 22 | } |
23 | |||
24 | fclose(f); | ||
25 | + f = NULL; | ||
26 | |||
27 | if (len > pattern_len) { | ||
28 | len -= pattern_len; | ||
29 | @@ -XXX,XX +XXX,XX @@ static void *qemu_io_alloc_from_file(BlockBackend *blk, size_t len, | ||
30 | |||
31 | error: | ||
32 | qemu_io_free(buf_origin); | ||
33 | + if (f) { | ||
34 | + fclose(f); | ||
35 | + } | ||
36 | return NULL; | ||
37 | } | ||
38 | |||
38 | -- | 39 | -- |
39 | 2.19.1 | 40 | 2.20.1 |
40 | 41 | ||
41 | 42 | 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 | From: Cleber Rosa <crosa@redhat.com> | ||
2 | 1 | ||
3 | While testing the Python 3 changes which touch the 083 test, I noticed | ||
4 | that it would fail with qcow2. Expanding the testing, I noticed it | ||
5 | had nothing to do with the Python 3 changes, and in fact, it would not | ||
6 | pass on anything but raw: | ||
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> | ||
41 | --- | ||
42 | tests/qemu-iotests/083 | 2 +- | ||
43 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
44 | |||
45 | diff --git a/tests/qemu-iotests/083 b/tests/qemu-iotests/083 | ||
46 | index XXXXXXX..XXXXXXX 100755 | ||
47 | --- a/tests/qemu-iotests/083 | ||
48 | +++ b/tests/qemu-iotests/083 | ||
49 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
50 | . ./common.rc | ||
51 | . ./common.filter | ||
52 | |||
53 | -_supported_fmt generic | ||
54 | +_supported_fmt raw | ||
55 | _supported_proto nbd | ||
56 | _supported_os Linux | ||
57 | |||
58 | -- | ||
59 | 2.19.1 | ||
60 | |||
61 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Peter Maydell <peter.maydell@linaro.org> | ||
2 | 1 | ||
3 | Taking the address of a field in a packed struct is a bad idea, because | ||
4 | it might not be actually aligned enough for that pointer type (and | ||
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 | |||
9 | There are a few places where the in-place swap function is | ||
10 | used on something other than a packed struct field; we convert | ||
11 | those anyway, for consistency. | ||
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> | ||
21 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
22 | --- | ||
23 | block/vdi.c | 64 ++++++++++++++++++++++++++--------------------------- | ||
24 | 1 file changed, 32 insertions(+), 32 deletions(-) | ||
25 | |||
26 | diff --git a/block/vdi.c b/block/vdi.c | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/block/vdi.c | ||
29 | +++ b/block/vdi.c | ||
30 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
31 | |||
32 | static void vdi_header_to_cpu(VdiHeader *header) | ||
33 | { | ||
34 | - le32_to_cpus(&header->signature); | ||
35 | - le32_to_cpus(&header->version); | ||
36 | - le32_to_cpus(&header->header_size); | ||
37 | - le32_to_cpus(&header->image_type); | ||
38 | - le32_to_cpus(&header->image_flags); | ||
39 | - le32_to_cpus(&header->offset_bmap); | ||
40 | - le32_to_cpus(&header->offset_data); | ||
41 | - le32_to_cpus(&header->cylinders); | ||
42 | - le32_to_cpus(&header->heads); | ||
43 | - le32_to_cpus(&header->sectors); | ||
44 | - le32_to_cpus(&header->sector_size); | ||
45 | - le64_to_cpus(&header->disk_size); | ||
46 | - le32_to_cpus(&header->block_size); | ||
47 | - le32_to_cpus(&header->block_extra); | ||
48 | - le32_to_cpus(&header->blocks_in_image); | ||
49 | - le32_to_cpus(&header->blocks_allocated); | ||
50 | + header->signature = le32_to_cpu(header->signature); | ||
51 | + header->version = le32_to_cpu(header->version); | ||
52 | + header->header_size = le32_to_cpu(header->header_size); | ||
53 | + header->image_type = le32_to_cpu(header->image_type); | ||
54 | + header->image_flags = le32_to_cpu(header->image_flags); | ||
55 | + header->offset_bmap = le32_to_cpu(header->offset_bmap); | ||
56 | + header->offset_data = le32_to_cpu(header->offset_data); | ||
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 | -- | ||
109 | 2.19.1 | ||
110 | |||
111 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alberto Garcia <berto@igalia.com> | ||
2 | 1 | ||
3 | This is a static function with only one caller, so there's no need to | ||
4 | keep it. Inlining the code in quorum_compare() makes it much simpler. | ||
5 | |||
6 | Signed-off-by: Alberto Garcia <berto@igalia.com> | ||
7 | Reported-by: Markus Armbruster <armbru@redhat.com> | ||
8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
9 | --- | ||
10 | block/quorum.c | 24 +++++------------------- | ||
11 | 1 file changed, 5 insertions(+), 19 deletions(-) | ||
12 | |||
13 | diff --git a/block/quorum.c b/block/quorum.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/block/quorum.c | ||
16 | +++ b/block/quorum.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static bool quorum_iovec_compare(QEMUIOVector *a, QEMUIOVector *b) | ||
18 | return true; | ||
19 | } | ||
20 | |||
21 | -static void GCC_FMT_ATTR(2, 3) quorum_err(QuorumAIOCB *acb, | ||
22 | - const char *fmt, ...) | ||
23 | -{ | ||
24 | - va_list ap; | ||
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 | { | ||
40 | BDRVQuorumState *s = acb->bs->opaque; | ||
41 | ssize_t offset; | ||
42 | @@ -XXX,XX +XXX,XX @@ static bool quorum_compare(QuorumAIOCB *acb, | ||
43 | if (s->is_blkverify) { | ||
44 | offset = qemu_iovec_compare(a, b); | ||
45 | if (offset != -1) { | ||
46 | - quorum_err(acb, "contents mismatch at offset %" PRIu64, | ||
47 | - acb->offset + offset); | ||
48 | + fprintf(stderr, "quorum: offset=%" PRIu64 " bytes=%" PRIu64 | ||
49 | + " contents mismatch at offset %" PRIu64 "\n", | ||
50 | + acb->offset, acb->bytes, acb->offset + offset); | ||
51 | + exit(1); | ||
52 | } | ||
53 | return true; | ||
54 | } | ||
55 | -- | ||
56 | 2.19.1 | ||
57 | |||
58 | diff view generated by jsdifflib |
1 | From: Alberto Garcia <berto@igalia.com> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | The blkverify mode of Quorum only works when the number of children is | 3 | The 'blockdev-create' QMP command was introduced as experimental |
4 | exactly two, so any attempt to add a new one must return an error. | 4 | feature in commit b0292b851b8, using the assert() debug call. |
5 | It got promoted to 'stable' command in 3fb588a0f2c, but the | ||
6 | assert call was not removed. | ||
5 | 7 | ||
6 | quorum_del_child() on the other hand doesn't need any additional check | 8 | Some block drivers are optional, and bdrv_find_format() might |
7 | because decreasing the number of children would make it go under the | 9 | return a NULL value, triggering the assertion. |
8 | vote threshold. | ||
9 | 10 | ||
10 | Signed-off-by: Alberto Garcia <berto@igalia.com> | 11 | Stable code is not expected to abort, so return an error instead. |
11 | Reported-by: Kevin Wolf <kwolf@redhat.com> | 12 | |
13 | This is easily reproducible when libnfs is not installed: | ||
14 | |||
15 | ./configure | ||
16 | [...] | ||
17 | module support no | ||
18 | Block whitelist (rw) | ||
19 | Block whitelist (ro) | ||
20 | libiscsi support yes | ||
21 | libnfs support no | ||
22 | [...] | ||
23 | |||
24 | Start QEMU: | ||
25 | |||
26 | $ qemu-system-x86_64 -S -qmp unix:/tmp/qemu.qmp,server,nowait | ||
27 | |||
28 | Send the 'blockdev-create' with the 'nfs' driver: | ||
29 | |||
30 | $ ( cat << 'EOF' | ||
31 | {'execute': 'qmp_capabilities'} | ||
32 | {'execute': 'blockdev-create', 'arguments': {'job-id': 'x', 'options': {'size': 0, 'driver': 'nfs', 'location': {'path': '/', 'server': {'host': '::1', 'type': 'inet'}}}}, 'id': 'x'} | ||
33 | EOF | ||
34 | ) | socat STDIO UNIX:/tmp/qemu.qmp | ||
35 | {"QMP": {"version": {"qemu": {"micro": 50, "minor": 1, "major": 4}, "package": "v4.1.0-733-g89ea03a7dc"}, "capabilities": ["oob"]}} | ||
36 | {"return": {}} | ||
37 | |||
38 | QEMU crashes: | ||
39 | |||
40 | $ gdb qemu-system-x86_64 core | ||
41 | Program received signal SIGSEGV, Segmentation fault. | ||
42 | (gdb) bt | ||
43 | #0 0x00007ffff510957f in raise () at /lib64/libc.so.6 | ||
44 | #1 0x00007ffff50f3895 in abort () at /lib64/libc.so.6 | ||
45 | #2 0x00007ffff50f3769 in _nl_load_domain.cold.0 () at /lib64/libc.so.6 | ||
46 | #3 0x00007ffff5101a26 in .annobin_assert.c_end () at /lib64/libc.so.6 | ||
47 | #4 0x0000555555d7e1f1 in qmp_blockdev_create (job_id=0x555556baee40 "x", options=0x555557666610, errp=0x7fffffffc770) at block/create.c:69 | ||
48 | #5 0x0000555555c96b52 in qmp_marshal_blockdev_create (args=0x7fffdc003830, ret=0x7fffffffc7f8, errp=0x7fffffffc7f0) at qapi/qapi-commands-block-core.c:1314 | ||
49 | #6 0x0000555555deb0a0 in do_qmp_dispatch (cmds=0x55555645de70 <qmp_commands>, request=0x7fffdc005c70, allow_oob=false, errp=0x7fffffffc898) at qapi/qmp-dispatch.c:131 | ||
50 | #7 0x0000555555deb2a1 in qmp_dispatch (cmds=0x55555645de70 <qmp_commands>, request=0x7fffdc005c70, allow_oob=false) at qapi/qmp-dispatch.c:174 | ||
51 | |||
52 | With this patch applied, QEMU returns a QMP error: | ||
53 | |||
54 | {'execute': 'blockdev-create', 'arguments': {'job-id': 'x', 'options': {'size': 0, 'driver': 'nfs', 'location': {'path': '/', 'server': {'host': '::1', 'type': 'inet'}}}}, 'id': 'x'} | ||
55 | {"id": "x", "error": {"class": "GenericError", "desc": "Block driver 'nfs' not found or not supported"}} | ||
56 | |||
57 | Cc: qemu-stable@nongnu.org | ||
58 | Reported-by: Xu Tian <xutian@redhat.com> | ||
59 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
60 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
61 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
12 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 62 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
13 | --- | 63 | --- |
14 | block/quorum.c | 8 ++++++++ | 64 | block/create.c | 6 +++++- |
15 | 1 file changed, 8 insertions(+) | 65 | 1 file changed, 5 insertions(+), 1 deletion(-) |
16 | 66 | ||
17 | diff --git a/block/quorum.c b/block/quorum.c | 67 | diff --git a/block/create.c b/block/create.c |
18 | index XXXXXXX..XXXXXXX 100644 | 68 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/block/quorum.c | 69 | --- a/block/create.c |
20 | +++ b/block/quorum.c | 70 | +++ b/block/create.c |
21 | @@ -XXX,XX +XXX,XX @@ static void quorum_add_child(BlockDriverState *bs, BlockDriverState *child_bs, | 71 | @@ -XXX,XX +XXX,XX @@ void qmp_blockdev_create(const char *job_id, BlockdevCreateOptions *options, |
22 | char indexstr[32]; | 72 | const char *fmt = BlockdevDriver_str(options->driver); |
23 | int ret; | 73 | BlockDriver *drv = bdrv_find_format(fmt); |
24 | 74 | ||
25 | + if (s->is_blkverify) { | 75 | + if (!drv) { |
26 | + error_setg(errp, "Cannot add a child to a quorum in blkverify mode"); | 76 | + error_setg(errp, "Block driver '%s' not found or not supported", fmt); |
27 | + return; | 77 | + return; |
28 | + } | 78 | + } |
29 | + | 79 | + |
30 | assert(s->num_children <= INT_MAX / sizeof(BdrvChild *)); | 80 | /* If the driver is in the schema, we know that it exists. But it may not |
31 | if (s->num_children == INT_MAX / sizeof(BdrvChild *) || | 81 | * be whitelisted. */ |
32 | s->next_child_index == UINT_MAX) { | 82 | - assert(drv); |
33 | @@ -XXX,XX +XXX,XX @@ static void quorum_del_child(BlockDriverState *bs, BdrvChild *child, | 83 | if (bdrv_uses_whitelist() && !bdrv_is_whitelisted(drv, false)) { |
84 | error_setg(errp, "Driver is not whitelisted"); | ||
34 | return; | 85 | return; |
35 | } | ||
36 | |||
37 | + /* We know now that num_children > threshold, so blkverify must be false */ | ||
38 | + assert(!s->is_blkverify); | ||
39 | + | ||
40 | bdrv_drained_begin(bs); | ||
41 | |||
42 | /* We can safely remove this child now */ | ||
43 | -- | 86 | -- |
44 | 2.19.1 | 87 | 2.20.1 |
45 | 88 | ||
46 | 89 | diff view generated by jsdifflib |
1 | From: Alberto Garcia <berto@igalia.com> | 1 | From: Alberto Garcia <berto@igalia.com> |
---|---|---|---|
2 | 2 | ||
3 | The blkverify mode of Quorum can only be enabled if the number of | 3 | handle_alloc() tries to find as many contiguous clusters that need |
4 | children is exactly two and the value of vote-threshold is also two. | 4 | copy-on-write as possible in order to allocate all of them at the same |
5 | time. | ||
5 | 6 | ||
6 | If the user tries to enable it but the other settings are incorrect | 7 | However, compressed clusters are only overwritten one by one, so let's |
7 | then QEMU simply prints an error message to stderr and carries on | 8 | say that we have an image with 1024 consecutive compressed clusters: |
8 | disabling the blkverify setting. | ||
9 | 9 | ||
10 | This patch makes quorum_open() fail and return an error in this case. | 10 | qemu-img create -f qcow2 hd.qcow2 64M |
11 | for f in `seq 0 64 65472`; do | ||
12 | qemu-io -c "write -c ${f}k 64k" hd.qcow2 | ||
13 | done | ||
14 | |||
15 | In this case trying to overwrite the whole image with one large write | ||
16 | request results in 1024 separate allocations: | ||
17 | |||
18 | qemu-io -c "write 0 64M" hd.qcow2 | ||
19 | |||
20 | This restriction comes from commit 095a9c58ce12afeeb90c2 from 2008. | ||
21 | Nowadays QEMU can overwrite multiple compressed clusters just fine, | ||
22 | and in fact it already does: as long as the first cluster that | ||
23 | handle_alloc() finds is not compressed, all other compressed clusters | ||
24 | in the same batch will be overwritten in one go: | ||
25 | |||
26 | qemu-img create -f qcow2 hd.qcow2 64M | ||
27 | qemu-io -c "write -z 0 64k" hd.qcow2 | ||
28 | for f in `seq 64 64 65472`; do | ||
29 | qemu-io -c "write -c ${f}k 64k" hd.qcow2 | ||
30 | done | ||
31 | |||
32 | Compared to the previous one, overwriting this image on my computer | ||
33 | goes from 8.35s down to 230ms. | ||
11 | 34 | ||
12 | Signed-off-by: Alberto Garcia <berto@igalia.com> | 35 | Signed-off-by: Alberto Garcia <berto@igalia.com> |
13 | Reported-by: Markus Armbruster <armbru@redhat.com> | 36 | Reviewed-by: John Snow <jsnow@redhat.com |
14 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 37 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
15 | --- | 38 | --- |
16 | block/quorum.c | 13 ++++++------- | 39 | block/qcow2-cluster.c | 8 +------- |
17 | 1 file changed, 6 insertions(+), 7 deletions(-) | 40 | 1 file changed, 1 insertion(+), 7 deletions(-) |
18 | 41 | ||
19 | diff --git a/block/quorum.c b/block/quorum.c | 42 | diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c |
20 | index XXXXXXX..XXXXXXX 100644 | 43 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/block/quorum.c | 44 | --- a/block/qcow2-cluster.c |
22 | +++ b/block/quorum.c | 45 | +++ b/block/qcow2-cluster.c |
23 | @@ -XXX,XX +XXX,XX @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, | 46 | @@ -XXX,XX +XXX,XX @@ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset, |
24 | s->read_pattern = ret; | 47 | } |
25 | 48 | ||
26 | if (s->read_pattern == QUORUM_READ_PATTERN_QUORUM) { | 49 | entry = be64_to_cpu(l2_slice[l2_index]); |
27 | - /* is the driver in blkverify mode */ | 50 | - |
28 | - if (qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false) && | 51 | - /* For the moment, overwrite compressed clusters one by one */ |
29 | - s->num_children == 2 && s->threshold == 2) { | 52 | - if (entry & QCOW_OFLAG_COMPRESSED) { |
30 | - s->is_blkverify = true; | 53 | - nb_clusters = 1; |
31 | - } else if (qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false)) { | 54 | - } else { |
32 | - fprintf(stderr, "blkverify mode is set by setting blkverify=on " | 55 | - nb_clusters = count_cow_clusters(bs, nb_clusters, l2_slice, l2_index); |
33 | - "and using two files with vote_threshold=2\n"); | 56 | - } |
34 | + s->is_blkverify = qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false); | 57 | + nb_clusters = count_cow_clusters(bs, nb_clusters, l2_slice, l2_index); |
35 | + if (s->is_blkverify && (s->num_children != 2 || s->threshold != 2)) { | 58 | |
36 | + error_setg(&local_err, "blkverify=on can only be set if there are " | 59 | /* This function is only called when there were no non-COW clusters, so if |
37 | + "exactly two files and vote-threshold is 2"); | 60 | * we can't find any unallocated or COW clusters either, something is |
38 | + ret = -EINVAL; | ||
39 | + goto exit; | ||
40 | } | ||
41 | |||
42 | s->rewrite_corrupted = qemu_opt_get_bool(opts, QUORUM_OPT_REWRITE, | ||
43 | -- | 61 | -- |
44 | 2.19.1 | 62 | 2.20.1 |
45 | 63 | ||
46 | 64 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | To fully change the read-only state of a node, we must not only change | ||
2 | bs->read_only, but also update bs->open_flags. | ||
3 | 1 | ||
4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
5 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
6 | Reviewed-by: Alberto Garcia <berto@igalia.com> | ||
7 | --- | ||
8 | block.c | 7 +++++++ | ||
9 | 1 file changed, 7 insertions(+) | ||
10 | |||
11 | diff --git a/block.c b/block.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/block.c | ||
14 | +++ b/block.c | ||
15 | @@ -XXX,XX +XXX,XX @@ int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp) | ||
16 | } | ||
17 | |||
18 | bs->read_only = read_only; | ||
19 | + | ||
20 | + if (read_only) { | ||
21 | + bs->open_flags &= ~BDRV_O_RDWR; | ||
22 | + } else { | ||
23 | + bs->open_flags |= BDRV_O_RDWR; | ||
24 | + } | ||
25 | + | ||
26 | return 0; | ||
27 | } | ||
28 | |||
29 | -- | ||
30 | 2.19.1 | ||
31 | |||
32 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | If a management application builds the block graph node by node, the | ||
2 | protocol layer doesn't inherit its read-only option from the format | ||
3 | layer any more, so it must be set explicitly. | ||
4 | 1 | ||
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 | |||
38 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
39 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
40 | --- | ||
41 | qapi/block-core.json | 7 +++++++ | ||
42 | include/block/block.h | 2 ++ | ||
43 | block.c | 17 +++++++++++++++++ | ||
44 | block/vvfat.c | 1 + | ||
45 | blockdev.c | 2 +- | ||
46 | 5 files changed, 28 insertions(+), 1 deletion(-) | ||
47 | |||
48 | diff --git a/qapi/block-core.json b/qapi/block-core.json | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/qapi/block-core.json | ||
51 | +++ b/qapi/block-core.json | ||
52 | @@ -XXX,XX +XXX,XX @@ | ||
53 | # either generally or in certain configurations. In this case, | ||
54 | # the default value does not work and the option must be | ||
55 | # specified explicitly. | ||
56 | +# @auto-read-only: if true and @read-only is false, QEMU may automatically | ||
57 | +# decide not to open the image read-write as requested, but | ||
58 | +# fall back to read-only instead (and switch between the modes | ||
59 | +# later), e.g. depending on whether the image file is writable | ||
60 | +# or whether a writing user is attached to the node | ||
61 | +# (default: false, since 3.1) | ||
62 | # @detect-zeroes: detect and optimize zero writes (Since 2.1) | ||
63 | # (default: off) | ||
64 | # @force-share: force share all permission on added nodes. | ||
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 | ||
75 | --- a/include/block/block.h | ||
76 | +++ b/include/block/block.h | ||
77 | @@ -XXX,XX +XXX,XX @@ typedef struct HDGeometry { | ||
78 | select an appropriate protocol driver, | ||
79 | ignoring the format layer */ | ||
80 | #define BDRV_O_NO_IO 0x10000 /* don't initialize for I/O */ | ||
81 | +#define BDRV_O_AUTO_RDONLY 0x20000 /* degrade to read-only if opening read-write fails */ | ||
82 | |||
83 | #define BDRV_O_CACHE_MASK (BDRV_O_NOCACHE | BDRV_O_NO_FLUSH) | ||
84 | |||
85 | @@ -XXX,XX +XXX,XX @@ typedef struct HDGeometry { | ||
86 | #define BDRV_OPT_CACHE_DIRECT "cache.direct" | ||
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 | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/block.c | ||
96 | +++ b/block.c | ||
97 | @@ -XXX,XX +XXX,XX @@ static void bdrv_inherited_options(int *child_flags, QDict *child_options, | ||
98 | |||
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 | } | ||
116 | |||
117 | + assert(qemu_opt_find(opts, BDRV_OPT_AUTO_READ_ONLY)); | ||
118 | + if (qemu_opt_get_bool_del(opts, BDRV_OPT_AUTO_READ_ONLY, false)) { | ||
119 | + *flags |= BDRV_O_AUTO_RDONLY; | ||
120 | + } | ||
121 | } | ||
122 | |||
123 | static void update_options_from_flags(QDict *options, int flags) | ||
124 | @@ -XXX,XX +XXX,XX @@ static void update_options_from_flags(QDict *options, int flags) | ||
125 | if (!qdict_haskey(options, BDRV_OPT_READ_ONLY)) { | ||
126 | qdict_put_bool(options, BDRV_OPT_READ_ONLY, !(flags & BDRV_O_RDWR)); | ||
127 | } | ||
128 | + if (!qdict_haskey(options, BDRV_OPT_AUTO_READ_ONLY)) { | ||
129 | + qdict_put_bool(options, BDRV_OPT_AUTO_READ_ONLY, | ||
130 | + flags & BDRV_O_AUTO_RDONLY); | ||
131 | + } | ||
132 | } | ||
133 | |||
134 | static void bdrv_assign_node_name(BlockDriverState *bs, | ||
135 | @@ -XXX,XX +XXX,XX @@ QemuOptsList bdrv_runtime_opts = { | ||
136 | .type = QEMU_OPT_BOOL, | ||
137 | .help = "Node is opened in read-only mode", | ||
138 | }, | ||
139 | + { | ||
140 | + .name = BDRV_OPT_AUTO_READ_ONLY, | ||
141 | + .type = QEMU_OPT_BOOL, | ||
142 | + .help = "Node can become read-only if opening read-write fails", | ||
143 | + }, | ||
144 | { | ||
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 | ||
158 | --- a/block/vvfat.c | ||
159 | +++ b/block/vvfat.c | ||
160 | @@ -XXX,XX +XXX,XX @@ static void vvfat_qcow_options(int *child_flags, QDict *child_options, | ||
161 | int parent_flags, QDict *parent_options) | ||
162 | { | ||
163 | qdict_set_default_str(child_options, BDRV_OPT_READ_ONLY, "off"); | ||
164 | + qdict_set_default_str(child_options, BDRV_OPT_AUTO_READ_ONLY, "off"); | ||
165 | qdict_set_default_str(child_options, BDRV_OPT_CACHE_NO_FLUSH, "on"); | ||
166 | } | ||
167 | |||
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 | -- | ||
182 | 2.19.1 | ||
183 | |||
184 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Commit e2b8247a322 introduced an error path in qemu_rbd_open() after | ||
2 | calling rbd_open(), but neglected to close the image again in this error | ||
3 | path. The error path should contain everything that the regular close | ||
4 | function qemu_rbd_close() contains. | ||
5 | 1 | ||
6 | This adds the missing rbd_close() call. | ||
7 | |||
8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
9 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
10 | --- | ||
11 | block/rbd.c | 1 + | ||
12 | 1 file changed, 1 insertion(+) | ||
13 | |||
14 | diff --git a/block/rbd.c b/block/rbd.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/block/rbd.c | ||
17 | +++ b/block/rbd.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags, | ||
19 | "automatically marking the image read-only."); | ||
20 | r = bdrv_set_read_only(bs, true, &local_err); | ||
21 | if (r < 0) { | ||
22 | + rbd_close(s->image); | ||
23 | error_propagate(errp, local_err); | ||
24 | goto failed_open; | ||
25 | } | ||
26 | -- | ||
27 | 2.19.1 | ||
28 | |||
29 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | If read-only=off, but auto-read-only=on is given, open a read-write NBD | ||
2 | connection if the server provides a read-write export, but instead of | ||
3 | erroring out for read-only exports, just degrade to read-only. | ||
4 | 1 | ||
5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
6 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
7 | --- | ||
8 | block/nbd-client.c | 10 +++++----- | ||
9 | 1 file changed, 5 insertions(+), 5 deletions(-) | ||
10 | |||
11 | diff --git a/block/nbd-client.c b/block/nbd-client.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/block/nbd-client.c | ||
14 | +++ b/block/nbd-client.c | ||
15 | @@ -XXX,XX +XXX,XX @@ int nbd_client_init(BlockDriverState *bs, | ||
16 | logout("Failed to negotiate with the NBD server\n"); | ||
17 | return ret; | ||
18 | } | ||
19 | - if (client->info.flags & NBD_FLAG_READ_ONLY && | ||
20 | - !bdrv_is_read_only(bs)) { | ||
21 | - error_setg(errp, | ||
22 | - "request for write access conflicts with read-only export"); | ||
23 | - return -EACCES; | ||
24 | + if (client->info.flags & NBD_FLAG_READ_ONLY) { | ||
25 | + ret = bdrv_apply_auto_read_only(bs, "NBD export is read-only", errp); | ||
26 | + if (ret < 0) { | ||
27 | + return ret; | ||
28 | + } | ||
29 | } | ||
30 | if (client->info.flags & NBD_FLAG_SEND_FUA) { | ||
31 | bs->supported_write_flags = BDRV_REQ_FUA; | ||
32 | -- | ||
33 | 2.19.1 | ||
34 | |||
35 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | If read-only=off, but auto-read-only=on is given, just degrade to | ||
2 | read-only. | ||
3 | 1 | ||
4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
5 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
6 | --- | ||
7 | block/curl.c | 8 ++++---- | ||
8 | 1 file changed, 4 insertions(+), 4 deletions(-) | ||
9 | |||
10 | diff --git a/block/curl.c b/block/curl.c | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/block/curl.c | ||
13 | +++ b/block/curl.c | ||
14 | @@ -XXX,XX +XXX,XX @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags, | ||
15 | const char *protocol_delimiter; | ||
16 | int ret; | ||
17 | |||
18 | - | ||
19 | - if (flags & BDRV_O_RDWR) { | ||
20 | - error_setg(errp, "curl block device does not support writes"); | ||
21 | - return -EROFS; | ||
22 | + ret = bdrv_apply_auto_read_only(bs, "curl driver does not support writes", | ||
23 | + errp); | ||
24 | + if (ret < 0) { | ||
25 | + return ret; | ||
26 | } | ||
27 | |||
28 | if (!libcurl_initialized) { | ||
29 | -- | ||
30 | 2.19.1 | ||
31 | |||
32 | 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 | If read-only=off, but auto-read-only=on is given, open the volume | ||
2 | read-write if we have the permissions, but instead of erroring out for | ||
3 | read-only volumes, just degrade to read-only. | ||
4 | 1 | ||
5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
6 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
7 | --- | ||
8 | block/iscsi.c | 8 +++++--- | ||
9 | 1 file changed, 5 insertions(+), 3 deletions(-) | ||
10 | |||
11 | diff --git a/block/iscsi.c b/block/iscsi.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/block/iscsi.c | ||
14 | +++ b/block/iscsi.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags, | ||
16 | /* Check the write protect flag of the LUN if we want to write */ | ||
17 | if (iscsilun->type == TYPE_DISK && (flags & BDRV_O_RDWR) && | ||
18 | iscsilun->write_protected) { | ||
19 | - error_setg(errp, "Cannot open a write protected LUN as read-write"); | ||
20 | - ret = -EACCES; | ||
21 | - goto out; | ||
22 | + ret = bdrv_apply_auto_read_only(bs, "LUN is write protected", errp); | ||
23 | + if (ret < 0) { | ||
24 | + goto out; | ||
25 | + } | ||
26 | + flags &= ~BDRV_O_RDWR; | ||
27 | } | ||
28 | |||
29 | iscsi_readcapacity_sync(iscsilun, &local_err); | ||
30 | -- | ||
31 | 2.19.1 | ||
32 | |||
33 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | While we want machine interfaces like -blockdev and QMP blockdev-add to | ||
2 | add as little auto-detection as possible so that management tools are | ||
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 | 1 | ||
9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
10 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
11 | --- | ||
12 | blockdev.c | 1 + | ||
13 | 1 file changed, 1 insertion(+) | ||
14 | |||
15 | diff --git a/blockdev.c b/blockdev.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/blockdev.c | ||
18 | +++ b/blockdev.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts, | ||
20 | qdict_set_default_str(bs_opts, BDRV_OPT_CACHE_NO_FLUSH, "off"); | ||
21 | qdict_set_default_str(bs_opts, BDRV_OPT_READ_ONLY, | ||
22 | read_only ? "on" : "off"); | ||
23 | + qdict_set_default_str(bs_opts, BDRV_OPT_AUTO_READ_ONLY, "on"); | ||
24 | assert((bdrv_flags & BDRV_O_CACHE_MASK) == 0); | ||
25 | |||
26 | if (runstate_check(RUN_STATE_INMIGRATE)) { | ||
27 | -- | ||
28 | 2.19.1 | ||
29 | |||
30 | diff view generated by jsdifflib |