1 | The following changes since commit 5ec2eca83dc478ddf24077e02a8b34dd26cd3ff9: | 1 | The following changes since commit 23919ddfd56135cad3cb468a8f54d5a595f024f4: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/awilliam/tags/vfio-updates-20190613.0' into staging (2019-06-14 09:33:55 +0100) | 3 | Merge remote-tracking branch 'remotes/aperard/tags/pull-xen-20190827' into staging (2019-08-27 15:52:36 +0100) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | https://github.com/XanClic/qemu.git tags/pull-block-2019-06-14 | 7 | https://github.com/XanClic/qemu.git tags/pull-block-2019-08-27 |
8 | 8 | ||
9 | for you to fetch changes up to 21c1ce592a144188dfe59b9e156a97da412a59a2: | 9 | for you to fetch changes up to bb043c056cffcc2f3ce88bfdaf2e76e455c09e2c: |
10 | 10 | ||
11 | iotests: Test qemu-img convert -C --salvage (2019-06-14 15:09:42 +0200) | 11 | iotests: Unify cache mode quoting (2019-08-27 19:48:44 +0200) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Block patches: | 14 | Block patches: |
15 | - Allow blockdev-backup from nodes that are not in qemu's main AIO | 15 | - qemu-io now accepts a file to read a write pattern from |
16 | context to newly added nodes | 16 | - Ensure that raw files have their first block allocated so we can probe |
17 | - Add salvaging mode to qemu-img convert | 17 | the O_DIRECT alignment if necessary |
18 | - Minor fixes to tests, documentation, and for less Valgrind annoyance | 18 | - Various fixes |
19 | 19 | ||
20 | ---------------------------------------------------------------- | 20 | ---------------------------------------------------------------- |
21 | Andrey Shinkevich (1): | 21 | Denis Plotnikov (1): |
22 | hw/block/fdc: floppy command FIFO memory initialization | 22 | qemu-io: add pattern file for write command |
23 | 23 | ||
24 | John Snow (6): | 24 | Max Reitz (7): |
25 | blockdev-backup: don't check aio_context too early | 25 | iotests: Fix _filter_img_create() |
26 | iotests.py: do not use infinite waits | 26 | vmdk: Use bdrv_dirname() for relative extent paths |
27 | QEMUMachine: add events_wait method | 27 | iotests: Keep testing broken relative extent paths |
28 | iotests.py: rewrite run_job to be pickier | 28 | vmdk: Reject invalid compressed writes |
29 | iotests: add iotest 256 for testing blockdev-backup across iothread | 29 | iotests: Disable broken streamOptimized tests |
30 | contexts | 30 | iotests: Disable 110 for vmdk.twoGbMaxExtentSparse |
31 | event_match: always match on None value | 31 | iotests: Disable 126 for flat vmdk subformats |
32 | 32 | ||
33 | Max Reitz (12): | 33 | Nir Soffer (3): |
34 | iotests: Filter 175's allocation information | 34 | block: posix: Always allocate the first block |
35 | iotests: Fix intermittent failure in 219 | 35 | iotests: Test allocate_first_block() with O_DIRECT |
36 | qemu-img: Fix options leakage in img_rebase() | 36 | iotests: Unify cache mode quoting |
37 | qapi/block-core: Overlays are not snapshots | 37 | |
38 | blockdev: Overlays are not snapshots | 38 | Stefan Hajnoczi (1): |
39 | qemu-img: Move quiet into ImgConvertState | 39 | file-posix: fix request_alignment typo |
40 | qemu-img: Add salvaging mode to convert | 40 | |
41 | blkdebug: Add @iotype error option | 41 | Thomas Huth (2): |
42 | blkdebug: Add "none" event | 42 | iotests: Check for enabled drivers before testing them |
43 | blkdebug: Inject errors on .bdrv_co_block_status() | 43 | tests/check-block: Skip iotests when sanitizers are enabled |
44 | iotests: Test qemu-img convert --salvage | ||
45 | iotests: Test qemu-img convert -C --salvage | ||
46 | 44 | ||
47 | Vladimir Sementsov-Ogievskiy (1): | 45 | Vladimir Sementsov-Ogievskiy (1): |
48 | iotests: restrict 254 to support only qcow2 | 46 | block: fix permission update in bdrv_replace_node |
49 | 47 | ||
50 | qapi/block-core.json | 53 ++++++++--- | 48 | block.c | 5 +- |
51 | block/blkdebug.c | 60 ++++++++++-- | 49 | block/file-posix.c | 53 +++++++++- |
52 | blockdev.c | 14 +-- | 50 | block/vmdk.c | 64 ++++++++---- |
53 | hw/block/fdc.c | 1 + | 51 | qemu-io-cmds.c | 99 +++++++++++++++++-- |
54 | qemu-img.c | 106 +++++++++++++++------ | 52 | tests/check-block.sh | 5 + |
55 | python/qemu/__init__.py | 67 ++++++++++---- | 53 | tests/qemu-iotests/002 | 1 + |
56 | qemu-img-cmds.hx | 4 +- | 54 | tests/qemu-iotests/003 | 1 + |
57 | qemu-img.texi | 4 + | 55 | tests/qemu-iotests/005 | 3 +- |
58 | tests/qemu-iotests/082 | 1 + | 56 | tests/qemu-iotests/009 | 1 + |
59 | tests/qemu-iotests/082.out | 3 + | 57 | tests/qemu-iotests/010 | 1 + |
60 | tests/qemu-iotests/085.out | 10 +- | 58 | tests/qemu-iotests/011 | 1 + |
61 | tests/qemu-iotests/175 | 26 +++++- | 59 | tests/qemu-iotests/017 | 3 +- |
62 | tests/qemu-iotests/175.out | 8 +- | 60 | tests/qemu-iotests/018 | 3 +- |
63 | tests/qemu-iotests/219 | 13 ++- | 61 | tests/qemu-iotests/019 | 3 +- |
64 | tests/qemu-iotests/251 | 170 ++++++++++++++++++++++++++++++++++ | 62 | tests/qemu-iotests/020 | 3 +- |
65 | tests/qemu-iotests/251.out | 43 +++++++++ | 63 | tests/qemu-iotests/026 | 4 +- |
66 | tests/qemu-iotests/254 | 2 + | 64 | tests/qemu-iotests/027 | 1 + |
67 | tests/qemu-iotests/256 | 122 ++++++++++++++++++++++++ | 65 | tests/qemu-iotests/032 | 1 + |
68 | tests/qemu-iotests/256.out | 119 ++++++++++++++++++++++++ | 66 | tests/qemu-iotests/033 | 1 + |
69 | tests/qemu-iotests/group | 2 + | 67 | tests/qemu-iotests/034 | 3 +- |
70 | tests/qemu-iotests/iotests.py | 60 +++++++----- | 68 | tests/qemu-iotests/037 | 3 +- |
71 | 21 files changed, 772 insertions(+), 116 deletions(-) | 69 | tests/qemu-iotests/039 | 4 +- |
72 | create mode 100755 tests/qemu-iotests/251 | 70 | tests/qemu-iotests/052 | 2 +- |
73 | create mode 100644 tests/qemu-iotests/251.out | 71 | tests/qemu-iotests/059 | 34 ++++++- |
74 | create mode 100755 tests/qemu-iotests/256 | 72 | tests/qemu-iotests/059.out | 26 +++-- |
75 | create mode 100644 tests/qemu-iotests/256.out | 73 | tests/qemu-iotests/063 | 3 +- |
74 | tests/qemu-iotests/071 | 1 + | ||
75 | tests/qemu-iotests/072 | 1 + | ||
76 | tests/qemu-iotests/081 | 4 +- | ||
77 | tests/qemu-iotests/091 | 4 +- | ||
78 | tests/qemu-iotests/099 | 1 + | ||
79 | tests/qemu-iotests/105 | 3 +- | ||
80 | tests/qemu-iotests/110 | 3 +- | ||
81 | tests/qemu-iotests/120 | 1 + | ||
82 | tests/qemu-iotests/126 | 2 + | ||
83 | tests/qemu-iotests/{150.out => 150.out.qcow2} | 0 | ||
84 | tests/qemu-iotests/150.out.raw | 12 +++ | ||
85 | tests/qemu-iotests/162 | 4 +- | ||
86 | tests/qemu-iotests/175 | 47 +++++++-- | ||
87 | tests/qemu-iotests/175.out | 16 ++- | ||
88 | tests/qemu-iotests/178.out.qcow2 | 4 +- | ||
89 | tests/qemu-iotests/184 | 1 + | ||
90 | tests/qemu-iotests/186 | 1 + | ||
91 | tests/qemu-iotests/197 | 1 + | ||
92 | tests/qemu-iotests/215 | 1 + | ||
93 | tests/qemu-iotests/221.out | 12 ++- | ||
94 | tests/qemu-iotests/251 | 1 + | ||
95 | tests/qemu-iotests/253.out | 12 ++- | ||
96 | tests/qemu-iotests/common.filter | 4 +- | ||
97 | tests/qemu-iotests/common.rc | 14 +++ | ||
98 | 50 files changed, 391 insertions(+), 87 deletions(-) | ||
99 | rename tests/qemu-iotests/{150.out => 150.out.qcow2} (100%) | ||
100 | create mode 100644 tests/qemu-iotests/150.out.raw | ||
76 | 101 | ||
77 | -- | 102 | -- |
78 | 2.21.0 | 103 | 2.21.0 |
79 | 104 | ||
80 | 105 | diff view generated by jsdifflib |
1 | There are error messages which refer to an overlay node as the snapshot. | 1 | From: Denis Plotnikov <dplotnikov@virtuozzo.com> |
---|---|---|---|
2 | That is wrong, those are two different things. | ||
3 | 2 | ||
4 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 3 | The patch allows to provide a pattern file for write |
4 | command. There was no similar ability before. | ||
5 | |||
6 | Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com> | ||
7 | Message-id: 20190820164616.4072-1-dplotnikov@virtuozzo.com | ||
5 | Reviewed-by: Eric Blake <eblake@redhat.com> | 8 | Reviewed-by: Eric Blake <eblake@redhat.com> |
6 | Message-id: 20190603202236.1342-3-mreitz@redhat.com | 9 | [mreitz: Keep optstring in alphabetical order] |
7 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
8 | Reviewed-by: Alberto Garcia <berto@igalia.com> | ||
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 10 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
10 | --- | 11 | --- |
11 | blockdev.c | 10 +++++----- | 12 | qemu-io-cmds.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++--- |
12 | tests/qemu-iotests/085.out | 10 +++++----- | 13 | 1 file changed, 93 insertions(+), 6 deletions(-) |
13 | 2 files changed, 10 insertions(+), 10 deletions(-) | ||
14 | 14 | ||
15 | diff --git a/blockdev.c b/blockdev.c | 15 | diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c |
16 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/blockdev.c | 17 | --- a/qemu-io-cmds.c |
18 | +++ b/blockdev.c | 18 | +++ b/qemu-io-cmds.c |
19 | @@ -XXX,XX +XXX,XX @@ static void external_snapshot_prepare(BlkActionState *common, | 19 | @@ -XXX,XX +XXX,XX @@ static void qemu_io_free(void *p) |
20 | s->has_snapshot_node_name ? s->snapshot_node_name : NULL; | 20 | qemu_vfree(p); |
21 | 21 | } | |
22 | if (node_name && !snapshot_node_name) { | 22 | |
23 | - error_setg(errp, "New snapshot node name missing"); | 23 | +/* |
24 | + error_setg(errp, "New overlay node name missing"); | 24 | + * qemu_io_alloc_from_file() |
25 | goto out; | 25 | + * |
26 | } | 26 | + * Allocates the buffer and populates it with the content of the given file |
27 | 27 | + * up to @len bytes. If the file length is less than @len, then the buffer | |
28 | if (snapshot_node_name && | 28 | + * is populated with the file content cyclically. |
29 | bdrv_lookup_bs(snapshot_node_name, snapshot_node_name, NULL)) { | 29 | + * |
30 | - error_setg(errp, "New snapshot node name already in use"); | 30 | + * @blk - the block backend where the buffer content is going to be written to |
31 | + error_setg(errp, "New overlay node name already in use"); | 31 | + * @len - the buffer length |
32 | goto out; | 32 | + * @file_name - the file to read the content from |
33 | } | 33 | + * |
34 | 34 | + * Returns: the buffer pointer on success | |
35 | @@ -XXX,XX +XXX,XX @@ static void external_snapshot_prepare(BlkActionState *common, | 35 | + * NULL on error |
36 | + */ | ||
37 | +static void *qemu_io_alloc_from_file(BlockBackend *blk, size_t len, | ||
38 | + const char *file_name) | ||
39 | +{ | ||
40 | + char *buf, *buf_origin; | ||
41 | + FILE *f = fopen(file_name, "r"); | ||
42 | + int pattern_len; | ||
43 | + | ||
44 | + if (!f) { | ||
45 | + perror(file_name); | ||
46 | + return NULL; | ||
47 | + } | ||
48 | + | ||
49 | + if (qemuio_misalign) { | ||
50 | + len += MISALIGN_OFFSET; | ||
51 | + } | ||
52 | + | ||
53 | + buf_origin = buf = blk_blockalign(blk, len); | ||
54 | + | ||
55 | + if (qemuio_misalign) { | ||
56 | + buf_origin += MISALIGN_OFFSET; | ||
57 | + buf += MISALIGN_OFFSET; | ||
58 | + len -= MISALIGN_OFFSET; | ||
59 | + } | ||
60 | + | ||
61 | + pattern_len = fread(buf_origin, 1, len, f); | ||
62 | + | ||
63 | + if (ferror(f)) { | ||
64 | + perror(file_name); | ||
65 | + goto error; | ||
66 | + } | ||
67 | + | ||
68 | + if (pattern_len == 0) { | ||
69 | + fprintf(stderr, "%s: file is empty\n", file_name); | ||
70 | + goto error; | ||
71 | + } | ||
72 | + | ||
73 | + fclose(f); | ||
74 | + | ||
75 | + if (len > pattern_len) { | ||
76 | + len -= pattern_len; | ||
77 | + buf += pattern_len; | ||
78 | + | ||
79 | + while (len > 0) { | ||
80 | + size_t len_to_copy = MIN(pattern_len, len); | ||
81 | + | ||
82 | + memcpy(buf, buf_origin, len_to_copy); | ||
83 | + | ||
84 | + len -= len_to_copy; | ||
85 | + buf += len_to_copy; | ||
86 | + } | ||
87 | + } | ||
88 | + | ||
89 | + return buf_origin; | ||
90 | + | ||
91 | +error: | ||
92 | + qemu_io_free(buf_origin); | ||
93 | + return NULL; | ||
94 | +} | ||
95 | + | ||
96 | static void dump_buffer(const void *buffer, int64_t offset, int64_t len) | ||
97 | { | ||
98 | uint64_t i; | ||
99 | @@ -XXX,XX +XXX,XX @@ static void write_help(void) | ||
100 | " -n, -- with -z, don't allow slow fallback\n" | ||
101 | " -p, -- ignored for backwards compatibility\n" | ||
102 | " -P, -- use different pattern to fill file\n" | ||
103 | +" -s, -- use a pattern file to fill the write buffer\n" | ||
104 | " -C, -- report statistics in a machine parsable format\n" | ||
105 | " -q, -- quiet mode, do not show I/O statistics\n" | ||
106 | " -u, -- with -z, allow unmapping\n" | ||
107 | @@ -XXX,XX +XXX,XX @@ static const cmdinfo_t write_cmd = { | ||
108 | .perm = BLK_PERM_WRITE, | ||
109 | .argmin = 2, | ||
110 | .argmax = -1, | ||
111 | - .args = "[-bcCfnquz] [-P pattern] off len", | ||
112 | + .args = "[-bcCfnquz] [-P pattern | -s source_file] off len", | ||
113 | .oneline = "writes a number of bytes at a specified offset", | ||
114 | .help = write_help, | ||
115 | }; | ||
116 | @@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv) | ||
117 | { | ||
118 | struct timespec t1, t2; | ||
119 | bool Cflag = false, qflag = false, bflag = false; | ||
120 | - bool Pflag = false, zflag = false, cflag = false; | ||
121 | + bool Pflag = false, zflag = false, cflag = false, sflag = false; | ||
122 | int flags = 0; | ||
123 | int c, cnt, ret; | ||
124 | char *buf = NULL; | ||
125 | @@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv) | ||
126 | /* Some compilers get confused and warn if this is not initialized. */ | ||
127 | int64_t total = 0; | ||
128 | int pattern = 0xcd; | ||
129 | + const char *file_name = NULL; | ||
130 | |||
131 | - while ((c = getopt(argc, argv, "bcCfnpP:quz")) != -1) { | ||
132 | + while ((c = getopt(argc, argv, "bcCfnpP:qs:uz")) != -1) { | ||
133 | switch (c) { | ||
134 | case 'b': | ||
135 | bflag = true; | ||
136 | @@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv) | ||
137 | case 'q': | ||
138 | qflag = true; | ||
139 | break; | ||
140 | + case 's': | ||
141 | + sflag = true; | ||
142 | + file_name = optarg; | ||
143 | + break; | ||
144 | case 'u': | ||
145 | flags |= BDRV_REQ_MAY_UNMAP; | ||
146 | break; | ||
147 | @@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv) | ||
148 | return -EINVAL; | ||
36 | } | 149 | } |
37 | 150 | ||
38 | if (bdrv_has_blk(state->new_bs)) { | 151 | - if (zflag && Pflag) { |
39 | - error_setg(errp, "The snapshot is already in use"); | 152 | - printf("-z and -P cannot be specified at the same time\n"); |
40 | + error_setg(errp, "The overlay is already in use"); | 153 | + if (zflag + Pflag + sflag > 1) { |
41 | goto out; | 154 | + printf("Only one of -z, -P, and -s " |
155 | + "can be specified at the same time\n"); | ||
156 | return -EINVAL; | ||
42 | } | 157 | } |
43 | 158 | ||
44 | @@ -XXX,XX +XXX,XX @@ static void external_snapshot_prepare(BlkActionState *common, | 159 | @@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv) |
45 | } | 160 | } |
46 | 161 | ||
47 | if (state->new_bs->backing != NULL) { | 162 | if (!zflag) { |
48 | - error_setg(errp, "The snapshot already has a backing image"); | 163 | - buf = qemu_io_alloc(blk, count, pattern); |
49 | + error_setg(errp, "The overlay already has a backing image"); | 164 | + if (sflag) { |
50 | goto out; | 165 | + buf = qemu_io_alloc_from_file(blk, count, file_name); |
166 | + if (!buf) { | ||
167 | + return -EINVAL; | ||
168 | + } | ||
169 | + } else { | ||
170 | + buf = qemu_io_alloc(blk, count, pattern); | ||
171 | + } | ||
51 | } | 172 | } |
52 | 173 | ||
53 | if (!state->new_bs->drv->supports_backing) { | 174 | clock_gettime(CLOCK_MONOTONIC, &t1); |
54 | - error_setg(errp, "The snapshot does not support backing images"); | ||
55 | + error_setg(errp, "The overlay does not support backing images"); | ||
56 | goto out; | ||
57 | } | ||
58 | |||
59 | diff --git a/tests/qemu-iotests/085.out b/tests/qemu-iotests/085.out | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/tests/qemu-iotests/085.out | ||
62 | +++ b/tests/qemu-iotests/085.out | ||
63 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/ | ||
64 | |||
65 | === Invalid command - cannot create a snapshot using a file BDS === | ||
66 | |||
67 | -{"error": {"class": "GenericError", "desc": "The snapshot does not support backing images"}} | ||
68 | +{"error": {"class": "GenericError", "desc": "The overlay does not support backing images"}} | ||
69 | |||
70 | === Invalid command - snapshot node used as active layer === | ||
71 | |||
72 | -{"error": {"class": "GenericError", "desc": "The snapshot is already in use"}} | ||
73 | -{"error": {"class": "GenericError", "desc": "The snapshot is already in use"}} | ||
74 | -{"error": {"class": "GenericError", "desc": "The snapshot is already in use"}} | ||
75 | +{"error": {"class": "GenericError", "desc": "The overlay is already in use"}} | ||
76 | +{"error": {"class": "GenericError", "desc": "The overlay is already in use"}} | ||
77 | +{"error": {"class": "GenericError", "desc": "The overlay is already in use"}} | ||
78 | |||
79 | === Invalid command - snapshot node used as backing hd === | ||
80 | |||
81 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/ | ||
82 | Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=134217728 | ||
83 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/t.IMGFMT.base | ||
84 | {"return": {}} | ||
85 | -{"error": {"class": "GenericError", "desc": "The snapshot already has a backing image"}} | ||
86 | +{"error": {"class": "GenericError", "desc": "The overlay already has a backing image"}} | ||
87 | |||
88 | === Invalid command - The node does not exist === | ||
89 | |||
90 | -- | 175 | -- |
91 | 2.21.0 | 176 | 2.21.0 |
92 | 177 | ||
93 | 178 | diff view generated by jsdifflib |
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | Test fails at least for qcow, because of different cluster sizes in | 3 | It's wrong to OR shared permissions. It may lead to crash on further |
4 | base and top (and therefore different granularities of bitmaps we are | 4 | permission updates. |
5 | trying to merge). | 5 | Also, no needs to consider previously calculated permissions, as at |
6 | this point we already bind all new parents and bdrv_get_cumulative_perm | ||
7 | result is enough. So fix the bug by just set permissions by | ||
8 | bdrv_get_cumulative_perm result. | ||
6 | 9 | ||
7 | The test aim is to check block-dirty-bitmap-merge between different | 10 | Bug was introduced in long ago 234ac1a9025, in 2.9. |
8 | nodes functionality, no needs to check all formats. So, let's just drop | ||
9 | support for anything except qcow2. | ||
10 | 11 | ||
11 | Reported-by: Max Reitz <mreitz@redhat.com> | ||
12 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 12 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
13 | Message-id: 20190605155405.104384-1-vsementsov@virtuozzo.com | 13 | Message-id: 20190824100740.61635-1-vsementsov@virtuozzo.com |
14 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 14 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
15 | --- | 15 | --- |
16 | tests/qemu-iotests/254 | 2 ++ | 16 | block.c | 5 ++--- |
17 | 1 file changed, 2 insertions(+) | 17 | 1 file changed, 2 insertions(+), 3 deletions(-) |
18 | 18 | ||
19 | diff --git a/tests/qemu-iotests/254 b/tests/qemu-iotests/254 | 19 | diff --git a/block.c b/block.c |
20 | index XXXXXXX..XXXXXXX 100755 | 20 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/tests/qemu-iotests/254 | 21 | --- a/block.c |
22 | +++ b/tests/qemu-iotests/254 | 22 | +++ b/block.c |
23 | @@ -XXX,XX +XXX,XX @@ | 23 | @@ -XXX,XX +XXX,XX @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to, |
24 | import iotests | 24 | { |
25 | from iotests import qemu_img_create, file_path, log | 25 | BdrvChild *c, *next; |
26 | 26 | GSList *list = NULL, *p; | |
27 | +iotests.verify_image_format(supported_fmts=['qcow2']) | 27 | - uint64_t old_perm, old_shared; |
28 | + | 28 | uint64_t perm = 0, shared = BLK_PERM_ALL; |
29 | disk, top = file_path('disk', 'top') | 29 | int ret; |
30 | size = 1024 * 1024 | 30 | |
31 | 31 | @@ -XXX,XX +XXX,XX @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to, | |
32 | bdrv_unref(from); | ||
33 | } | ||
34 | |||
35 | - bdrv_get_cumulative_perm(to, &old_perm, &old_shared); | ||
36 | - bdrv_set_perm(to, old_perm | perm, old_shared | shared); | ||
37 | + bdrv_get_cumulative_perm(to, &perm, &shared); | ||
38 | + bdrv_set_perm(to, perm, shared); | ||
39 | |||
40 | out: | ||
41 | g_slist_free(list); | ||
32 | -- | 42 | -- |
33 | 2.21.0 | 43 | 2.21.0 |
34 | 44 | ||
35 | 45 | diff view generated by jsdifflib |
1 | It is possible for an empty file to take up blocks on a filesystem, for | 1 | From: Nir Soffer <nirsof@gmail.com> |
---|---|---|---|
2 | example: | 2 | |
3 | 3 | When creating an image with preallocation "off" or "falloc", the first | |
4 | $ qemu-img create -f raw test.img 1G | 4 | block of the image is typically not allocated. When using Gluster |
5 | Formatting 'test.img', fmt=raw size=1073741824 | 5 | storage backed by XFS filesystem, reading this block using direct I/O |
6 | $ mkfs.ext4 -I 128 -q test.img | 6 | succeeds regardless of request length, fooling alignment detection. |
7 | $ mkdir test-mount | 7 | |
8 | $ sudo mount -o loop test.img test-mount | 8 | In this case we fallback to a safe value (4096) instead of the optimal |
9 | $ sudo touch test-mount/test-file | 9 | value (512), which may lead to unneeded data copying when aligning |
10 | $ stat -c 'blocks=%b' test-mount/test-file | 10 | requests. Allocating the first block avoids the fallback. |
11 | blocks=8 | 11 | |
12 | 12 | Since we allocate the first block even with preallocation=off, we no | |
13 | These extra blocks (one cluster) are apparently used for metadata, | 13 | longer create images with zero disk size: |
14 | because they are always there, on top of blocks used for data: | 14 | |
15 | 15 | $ ./qemu-img create -f raw test.raw 1g | |
16 | $ sudo dd if=/dev/zero of=test-mount/test-file bs=1M count=1 | 16 | Formatting 'test.raw', fmt=raw size=1073741824 |
17 | 1+0 records in | 17 | |
18 | 1+0 records out | 18 | $ ls -lhs test.raw |
19 | 1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.00135339 s, 775 MB/s | 19 | 4.0K -rw-r--r--. 1 nsoffer nsoffer 1.0G Aug 16 23:48 test.raw |
20 | $ stat -c 'blocks=%b' test-mount/test-file | 20 | |
21 | blocks=2056 | 21 | And converting the image requires additional cluster: |
22 | 22 | ||
23 | Make iotest 175 take this into account. | 23 | $ ./qemu-img measure -f raw -O qcow2 test.raw |
24 | 24 | required size: 458752 | |
25 | Reported-by: Thomas Huth <thuth@redhat.com> | 25 | fully allocated size: 1074135040 |
26 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 26 | |
27 | Reviewed-by: Eric Blake <eblake@redhat.com> | 27 | When using format like vmdk with multiple files per image, we allocate |
28 | Reviewed-by: Nir Soffer <nsoffer@redhat.com> | 28 | one block per file: |
29 | Message-id: 20190516144319.12570-1-mreitz@redhat.com | 29 | |
30 | $ ./qemu-img create -f vmdk -o subformat=twoGbMaxExtentFlat test.vmdk 4g | ||
31 | Formatting 'test.vmdk', fmt=vmdk size=4294967296 compat6=off hwversion=undefined subformat=twoGbMaxExtentFlat | ||
32 | |||
33 | $ ls -lhs test*.vmdk | ||
34 | 4.0K -rw-r--r--. 1 nsoffer nsoffer 2.0G Aug 27 03:23 test-f001.vmdk | ||
35 | 4.0K -rw-r--r--. 1 nsoffer nsoffer 2.0G Aug 27 03:23 test-f002.vmdk | ||
36 | 4.0K -rw-r--r--. 1 nsoffer nsoffer 353 Aug 27 03:23 test.vmdk | ||
37 | |||
38 | I did quick performance test for copying disks with qemu-img convert to | ||
39 | new raw target image to Gluster storage with sector size of 512 bytes: | ||
40 | |||
41 | for i in $(seq 10); do | ||
42 | rm -f dst.raw | ||
43 | sleep 10 | ||
44 | time ./qemu-img convert -f raw -O raw -t none -T none src.raw dst.raw | ||
45 | done | ||
46 | |||
47 | Here is a table comparing the total time spent: | ||
48 | |||
49 | Type Before(s) After(s) Diff(%) | ||
50 | --------------------------------------- | ||
51 | real 530.028 469.123 -11.4 | ||
52 | user 17.204 10.768 -37.4 | ||
53 | sys 17.881 7.011 -60.7 | ||
54 | |||
55 | We can see very clear improvement in CPU usage. | ||
56 | |||
57 | Signed-off-by: Nir Soffer <nsoffer@redhat.com> | ||
58 | Message-id: 20190827010528.8818-2-nsoffer@redhat.com | ||
59 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
30 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 60 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
31 | --- | 61 | --- |
32 | tests/qemu-iotests/175 | 26 ++++++++++++++++++++++---- | 62 | block/file-posix.c | 51 +++++++++++++++++++ |
33 | tests/qemu-iotests/175.out | 8 ++++---- | 63 | tests/qemu-iotests/059.out | 2 +- |
34 | 2 files changed, 26 insertions(+), 8 deletions(-) | 64 | tests/qemu-iotests/{150.out => 150.out.qcow2} | 0 |
35 | 65 | tests/qemu-iotests/150.out.raw | 12 +++++ | |
66 | tests/qemu-iotests/175 | 19 ++++--- | ||
67 | tests/qemu-iotests/175.out | 8 +-- | ||
68 | tests/qemu-iotests/178.out.qcow2 | 4 +- | ||
69 | tests/qemu-iotests/221.out | 12 +++-- | ||
70 | tests/qemu-iotests/253.out | 12 +++-- | ||
71 | 9 files changed, 99 insertions(+), 21 deletions(-) | ||
72 | rename tests/qemu-iotests/{150.out => 150.out.qcow2} (100%) | ||
73 | create mode 100644 tests/qemu-iotests/150.out.raw | ||
74 | |||
75 | diff --git a/block/file-posix.c b/block/file-posix.c | ||
76 | index XXXXXXX..XXXXXXX 100644 | ||
77 | --- a/block/file-posix.c | ||
78 | +++ b/block/file-posix.c | ||
79 | @@ -XXX,XX +XXX,XX @@ static int handle_aiocb_discard(void *opaque) | ||
80 | return ret; | ||
81 | } | ||
82 | |||
83 | +/* | ||
84 | + * Help alignment probing by allocating the first block. | ||
85 | + * | ||
86 | + * When reading with direct I/O from unallocated area on Gluster backed by XFS, | ||
87 | + * reading succeeds regardless of request length. In this case we fallback to | ||
88 | + * safe alignment which is not optimal. Allocating the first block avoids this | ||
89 | + * fallback. | ||
90 | + * | ||
91 | + * fd may be opened with O_DIRECT, but we don't know the buffer alignment or | ||
92 | + * request alignment, so we use safe values. | ||
93 | + * | ||
94 | + * Returns: 0 on success, -errno on failure. Since this is an optimization, | ||
95 | + * caller may ignore failures. | ||
96 | + */ | ||
97 | +static int allocate_first_block(int fd, size_t max_size) | ||
98 | +{ | ||
99 | + size_t write_size = (max_size < MAX_BLOCKSIZE) | ||
100 | + ? BDRV_SECTOR_SIZE | ||
101 | + : MAX_BLOCKSIZE; | ||
102 | + size_t max_align = MAX(MAX_BLOCKSIZE, getpagesize()); | ||
103 | + void *buf; | ||
104 | + ssize_t n; | ||
105 | + int ret; | ||
106 | + | ||
107 | + buf = qemu_memalign(max_align, write_size); | ||
108 | + memset(buf, 0, write_size); | ||
109 | + | ||
110 | + do { | ||
111 | + n = pwrite(fd, buf, write_size, 0); | ||
112 | + } while (n == -1 && errno == EINTR); | ||
113 | + | ||
114 | + ret = (n == -1) ? -errno : 0; | ||
115 | + | ||
116 | + qemu_vfree(buf); | ||
117 | + return ret; | ||
118 | +} | ||
119 | + | ||
120 | static int handle_aiocb_truncate(void *opaque) | ||
121 | { | ||
122 | RawPosixAIOData *aiocb = opaque; | ||
123 | @@ -XXX,XX +XXX,XX @@ static int handle_aiocb_truncate(void *opaque) | ||
124 | /* posix_fallocate() doesn't set errno. */ | ||
125 | error_setg_errno(errp, -result, | ||
126 | "Could not preallocate new data"); | ||
127 | + } else if (current_length == 0) { | ||
128 | + /* | ||
129 | + * posix_fallocate() uses fallocate() if the filesystem | ||
130 | + * supports it, or fallback to manually writing zeroes. If | ||
131 | + * fallocate() was used, unaligned reads from the fallocated | ||
132 | + * area in raw_probe_alignment() will succeed, hence we need to | ||
133 | + * allocate the first block. | ||
134 | + * | ||
135 | + * Optimize future alignment probing; ignore failures. | ||
136 | + */ | ||
137 | + allocate_first_block(fd, offset); | ||
138 | } | ||
139 | } else { | ||
140 | result = 0; | ||
141 | @@ -XXX,XX +XXX,XX @@ static int handle_aiocb_truncate(void *opaque) | ||
142 | if (ftruncate(fd, offset) != 0) { | ||
143 | result = -errno; | ||
144 | error_setg_errno(errp, -result, "Could not resize file"); | ||
145 | + } else if (current_length == 0 && offset > current_length) { | ||
146 | + /* Optimize future alignment probing; ignore failures. */ | ||
147 | + allocate_first_block(fd, offset); | ||
148 | } | ||
149 | return result; | ||
150 | default: | ||
151 | diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out | ||
152 | index XXXXXXX..XXXXXXX 100644 | ||
153 | --- a/tests/qemu-iotests/059.out | ||
154 | +++ b/tests/qemu-iotests/059.out | ||
155 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000 subformat=twoGbMax | ||
156 | image: TEST_DIR/t.vmdk | ||
157 | file format: vmdk | ||
158 | virtual size: 0.977 TiB (1073741824000 bytes) | ||
159 | -disk size: 16 KiB | ||
160 | +disk size: 1.97 MiB | ||
161 | Format specific information: | ||
162 | cid: XXXXXXXX | ||
163 | parent cid: XXXXXXXX | ||
164 | diff --git a/tests/qemu-iotests/150.out b/tests/qemu-iotests/150.out.qcow2 | ||
165 | similarity index 100% | ||
166 | rename from tests/qemu-iotests/150.out | ||
167 | rename to tests/qemu-iotests/150.out.qcow2 | ||
168 | diff --git a/tests/qemu-iotests/150.out.raw b/tests/qemu-iotests/150.out.raw | ||
169 | new file mode 100644 | ||
170 | index XXXXXXX..XXXXXXX | ||
171 | --- /dev/null | ||
172 | +++ b/tests/qemu-iotests/150.out.raw | ||
173 | @@ -XXX,XX +XXX,XX @@ | ||
174 | +QA output created by 150 | ||
175 | + | ||
176 | +=== Mapping sparse conversion === | ||
177 | + | ||
178 | +Offset Length File | ||
179 | +0 0x1000 TEST_DIR/t.IMGFMT | ||
180 | + | ||
181 | +=== Mapping non-sparse conversion === | ||
182 | + | ||
183 | +Offset Length File | ||
184 | +0 0x100000 TEST_DIR/t.IMGFMT | ||
185 | +*** done | ||
36 | diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175 | 186 | diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175 |
37 | index XXXXXXX..XXXXXXX 100755 | 187 | index XXXXXXX..XXXXXXX 100755 |
38 | --- a/tests/qemu-iotests/175 | 188 | --- a/tests/qemu-iotests/175 |
39 | +++ b/tests/qemu-iotests/175 | 189 | +++ b/tests/qemu-iotests/175 |
40 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | 190 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
41 | 191 | # the file size. This function hides the resulting difference in the | |
42 | _cleanup() | 192 | # stat -c '%b' output. |
193 | # Parameter 1: Number of blocks an empty file occupies | ||
194 | -# Parameter 2: Image size in bytes | ||
195 | +# Parameter 2: Minimal number of blocks in an image | ||
196 | +# Parameter 3: Image size in bytes | ||
197 | _filter_blocks() | ||
43 | { | 198 | { |
44 | - _cleanup_test_img | 199 | extra_blocks=$1 |
45 | + _cleanup_test_img | 200 | - img_size=$2 |
46 | + rm -f "$TEST_DIR/empty" | 201 | + min_blocks=$2 |
202 | + img_size=$3 | ||
203 | |||
204 | - sed -e "s/blocks=$extra_blocks\\(\$\\|[^0-9]\\)/nothing allocated/" \ | ||
205 | - -e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/everything allocated/" | ||
206 | + sed -e "s/blocks=$min_blocks\\(\$\\|[^0-9]\\)/min allocation/" \ | ||
207 | + -e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/max allocation/" | ||
47 | } | 208 | } |
48 | trap "_cleanup; exit \$status" 0 1 2 3 15 | 209 | |
49 | |||
50 | +# Some file systems sometimes allocate extra blocks independently of | ||
51 | +# the file size. This function hides the resulting difference in the | ||
52 | +# stat -c '%b' output. | ||
53 | +# Parameter 1: Number of blocks an empty file occupies | ||
54 | +# Parameter 2: Image size in bytes | ||
55 | +_filter_blocks() | ||
56 | +{ | ||
57 | + extra_blocks=$1 | ||
58 | + img_size=$2 | ||
59 | + | ||
60 | + sed -e "s/blocks=$extra_blocks\\(\$\\|[^0-9]\\)/nothing allocated/" \ | ||
61 | + -e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/everything allocated/" | ||
62 | +} | ||
63 | + | ||
64 | # get standard environment, filters and checks | 210 | # get standard environment, filters and checks |
65 | . ./common.rc | 211 | @@ -XXX,XX +XXX,XX @@ size=$((1 * 1024 * 1024)) |
66 | . ./common.filter | 212 | touch "$TEST_DIR/empty" |
67 | @@ -XXX,XX +XXX,XX @@ _supported_fmt raw | 213 | extra_blocks=$(stat -c '%b' "$TEST_DIR/empty") |
68 | _supported_proto file | 214 | |
69 | _supported_os Linux | 215 | +# We always write the first byte; check how many blocks this filesystem |
70 | 216 | +# allocates to match empty image alloation. | |
71 | -size=1m | 217 | +printf "\0" > "$TEST_DIR/empty" |
72 | +size=$((1 * 1024 * 1024)) | 218 | +min_blocks=$(stat -c '%b' "$TEST_DIR/empty") |
73 | + | 219 | + |
74 | +touch "$TEST_DIR/empty" | ||
75 | +extra_blocks=$(stat -c '%b' "$TEST_DIR/empty") | ||
76 | |||
77 | echo | 220 | echo |
78 | echo "== creating image with default preallocation ==" | 221 | echo "== creating image with default preallocation ==" |
79 | _make_test_img $size | _filter_imgfmt | 222 | _make_test_img $size | _filter_imgfmt |
80 | -stat -c "size=%s, blocks=%b" $TEST_IMG | 223 | -stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $size |
81 | +stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $size | 224 | +stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size |
82 | 225 | ||
83 | for mode in off full falloc; do | 226 | for mode in off full falloc; do |
84 | echo | 227 | echo |
85 | echo "== creating image with preallocation $mode ==" | 228 | echo "== creating image with preallocation $mode ==" |
86 | IMGOPTS=preallocation=$mode _make_test_img $size | _filter_imgfmt | 229 | IMGOPTS=preallocation=$mode _make_test_img $size | _filter_imgfmt |
87 | - stat -c "size=%s, blocks=%b" $TEST_IMG | 230 | - stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $size |
88 | + stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $size | 231 | + stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size |
89 | done | 232 | done |
90 | 233 | ||
91 | # success, all done | 234 | # success, all done |
92 | diff --git a/tests/qemu-iotests/175.out b/tests/qemu-iotests/175.out | 235 | diff --git a/tests/qemu-iotests/175.out b/tests/qemu-iotests/175.out |
93 | index XXXXXXX..XXXXXXX 100644 | 236 | index XXXXXXX..XXXXXXX 100644 |
94 | --- a/tests/qemu-iotests/175.out | 237 | --- a/tests/qemu-iotests/175.out |
95 | +++ b/tests/qemu-iotests/175.out | 238 | +++ b/tests/qemu-iotests/175.out |
96 | @@ -XXX,XX +XXX,XX @@ QA output created by 175 | 239 | @@ -XXX,XX +XXX,XX @@ QA output created by 175 |
97 | 240 | ||
98 | == creating image with default preallocation == | 241 | == creating image with default preallocation == |
99 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 | 242 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 |
100 | -size=1048576, blocks=0 | 243 | -size=1048576, nothing allocated |
101 | +size=1048576, nothing allocated | 244 | +size=1048576, min allocation |
102 | 245 | ||
103 | == creating image with preallocation off == | 246 | == creating image with preallocation off == |
104 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=off | 247 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=off |
105 | -size=1048576, blocks=0 | 248 | -size=1048576, nothing allocated |
106 | +size=1048576, nothing allocated | 249 | +size=1048576, min allocation |
107 | 250 | ||
108 | == creating image with preallocation full == | 251 | == creating image with preallocation full == |
109 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=full | 252 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=full |
110 | -size=1048576, blocks=2048 | 253 | -size=1048576, everything allocated |
111 | +size=1048576, everything allocated | 254 | +size=1048576, max allocation |
112 | 255 | ||
113 | == creating image with preallocation falloc == | 256 | == creating image with preallocation falloc == |
114 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=falloc | 257 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=falloc |
115 | -size=1048576, blocks=2048 | 258 | -size=1048576, everything allocated |
116 | +size=1048576, everything allocated | 259 | +size=1048576, max allocation |
117 | *** done | 260 | *** done |
261 | diff --git a/tests/qemu-iotests/178.out.qcow2 b/tests/qemu-iotests/178.out.qcow2 | ||
262 | index XXXXXXX..XXXXXXX 100644 | ||
263 | --- a/tests/qemu-iotests/178.out.qcow2 | ||
264 | +++ b/tests/qemu-iotests/178.out.qcow2 | ||
265 | @@ -XXX,XX +XXX,XX @@ converted image file size in bytes: 196608 | ||
266 | == raw input image with data (human) == | ||
267 | |||
268 | Formatting 'TEST_DIR/t.qcow2', fmt=IMGFMT size=1073741824 | ||
269 | -required size: 393216 | ||
270 | +required size: 458752 | ||
271 | fully allocated size: 1074135040 | ||
272 | wrote 512/512 bytes at offset 512 | ||
273 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
274 | @@ -XXX,XX +XXX,XX @@ converted image file size in bytes: 196608 | ||
275 | |||
276 | Formatting 'TEST_DIR/t.qcow2', fmt=IMGFMT size=1073741824 | ||
277 | { | ||
278 | - "required": 393216, | ||
279 | + "required": 458752, | ||
280 | "fully-allocated": 1074135040 | ||
281 | } | ||
282 | wrote 512/512 bytes at offset 512 | ||
283 | diff --git a/tests/qemu-iotests/221.out b/tests/qemu-iotests/221.out | ||
284 | index XXXXXXX..XXXXXXX 100644 | ||
285 | --- a/tests/qemu-iotests/221.out | ||
286 | +++ b/tests/qemu-iotests/221.out | ||
287 | @@ -XXX,XX +XXX,XX @@ QA output created by 221 | ||
288 | === Check mapping of unaligned raw image === | ||
289 | |||
290 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=65537 | ||
291 | -[{ "start": 0, "length": 66048, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] | ||
292 | -[{ "start": 0, "length": 66048, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] | ||
293 | +[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, | ||
294 | +{ "start": 4096, "length": 61952, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] | ||
295 | +[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, | ||
296 | +{ "start": 4096, "length": 61952, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] | ||
297 | wrote 1/1 bytes at offset 65536 | ||
298 | 1 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
299 | -[{ "start": 0, "length": 65536, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, | ||
300 | +[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, | ||
301 | +{ "start": 4096, "length": 61440, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, | ||
302 | { "start": 65536, "length": 1, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, | ||
303 | { "start": 65537, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] | ||
304 | -[{ "start": 0, "length": 65536, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, | ||
305 | +[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, | ||
306 | +{ "start": 4096, "length": 61440, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, | ||
307 | { "start": 65536, "length": 1, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, | ||
308 | { "start": 65537, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] | ||
309 | *** done | ||
310 | diff --git a/tests/qemu-iotests/253.out b/tests/qemu-iotests/253.out | ||
311 | index XXXXXXX..XXXXXXX 100644 | ||
312 | --- a/tests/qemu-iotests/253.out | ||
313 | +++ b/tests/qemu-iotests/253.out | ||
314 | @@ -XXX,XX +XXX,XX @@ QA output created by 253 | ||
315 | === Check mapping of unaligned raw image === | ||
316 | |||
317 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048575 | ||
318 | -[{ "start": 0, "length": 1048576, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] | ||
319 | -[{ "start": 0, "length": 1048576, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] | ||
320 | +[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, | ||
321 | +{ "start": 4096, "length": 1044480, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] | ||
322 | +[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, | ||
323 | +{ "start": 4096, "length": 1044480, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] | ||
324 | wrote 65535/65535 bytes at offset 983040 | ||
325 | 63.999 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
326 | -[{ "start": 0, "length": 983040, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, | ||
327 | +[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, | ||
328 | +{ "start": 4096, "length": 978944, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, | ||
329 | { "start": 983040, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": OFFSET}] | ||
330 | -[{ "start": 0, "length": 983040, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, | ||
331 | +[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, | ||
332 | +{ "start": 4096, "length": 978944, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, | ||
333 | { "start": 983040, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": OFFSET}] | ||
334 | *** done | ||
118 | -- | 335 | -- |
119 | 2.21.0 | 336 | 2.21.0 |
120 | 337 | ||
121 | 338 | diff view generated by jsdifflib |
1 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 1 | From: Nir Soffer <nirsof@gmail.com> |
---|---|---|---|
2 | Reviewed-by: Eric Blake <eblake@redhat.com> | 2 | |
3 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 3 | Using block_resize we can test allocate_first_block() with file |
4 | Message-id: 20190507203508.18026-6-mreitz@redhat.com | 4 | descriptor opened with O_DIRECT, ensuring that it works for any size |
5 | larger than 4096 bytes. | ||
6 | |||
7 | Testing smaller sizes is tricky as the result depends on the filesystem | ||
8 | used for testing. For example on NFS any size will work since O_DIRECT | ||
9 | does not require any alignment. | ||
10 | |||
11 | Signed-off-by: Nir Soffer <nsoffer@redhat.com> | ||
12 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
13 | Message-id: 20190827010528.8818-3-nsoffer@redhat.com | ||
5 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 14 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
6 | --- | 15 | --- |
7 | qapi/block-core.json | 5 ++++- | 16 | tests/qemu-iotests/175 | 28 ++++++++++++++++++++++++++++ |
8 | block/blkdebug.c | 8 ++++++++ | 17 | tests/qemu-iotests/175.out | 8 ++++++++ |
9 | 2 files changed, 12 insertions(+), 1 deletion(-) | 18 | 2 files changed, 36 insertions(+) |
10 | 19 | ||
11 | diff --git a/qapi/block-core.json b/qapi/block-core.json | 20 | diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175 |
21 | index XXXXXXX..XXXXXXX 100755 | ||
22 | --- a/tests/qemu-iotests/175 | ||
23 | +++ b/tests/qemu-iotests/175 | ||
24 | @@ -XXX,XX +XXX,XX @@ _filter_blocks() | ||
25 | -e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/max allocation/" | ||
26 | } | ||
27 | |||
28 | +# Resize image using block_resize. | ||
29 | +# Parameter 1: image path | ||
30 | +# Parameter 2: new size | ||
31 | +_block_resize() | ||
32 | +{ | ||
33 | + local path=$1 | ||
34 | + local size=$2 | ||
35 | + | ||
36 | + $QEMU -qmp stdio -nographic -nodefaults \ | ||
37 | + -blockdev file,node-name=file,filename=$path,cache.direct=on \ | ||
38 | + <<EOF | ||
39 | +{'execute': 'qmp_capabilities'} | ||
40 | +{'execute': 'block_resize', 'arguments': {'node-name': 'file', 'size': $size}} | ||
41 | +{'execute': 'quit'} | ||
42 | +EOF | ||
43 | +} | ||
44 | + | ||
45 | # get standard environment, filters and checks | ||
46 | . ./common.rc | ||
47 | . ./common.filter | ||
48 | @@ -XXX,XX +XXX,XX @@ _supported_fmt raw | ||
49 | _supported_proto file | ||
50 | _supported_os Linux | ||
51 | |||
52 | +_default_cache_mode none | ||
53 | +_supported_cache_modes none directsync | ||
54 | + | ||
55 | size=$((1 * 1024 * 1024)) | ||
56 | |||
57 | touch "$TEST_DIR/empty" | ||
58 | @@ -XXX,XX +XXX,XX @@ for mode in off full falloc; do | ||
59 | stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size | ||
60 | done | ||
61 | |||
62 | +for new_size in 4096 1048576; do | ||
63 | + echo | ||
64 | + echo "== resize empty image with block_resize ==" | ||
65 | + _make_test_img 0 | _filter_imgfmt | ||
66 | + _block_resize $TEST_IMG $new_size >/dev/null | ||
67 | + stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $new_size | ||
68 | +done | ||
69 | + | ||
70 | # success, all done | ||
71 | echo "*** done" | ||
72 | rm -f $seq.full | ||
73 | diff --git a/tests/qemu-iotests/175.out b/tests/qemu-iotests/175.out | ||
12 | index XXXXXXX..XXXXXXX 100644 | 74 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/qapi/block-core.json | 75 | --- a/tests/qemu-iotests/175.out |
14 | +++ b/qapi/block-core.json | 76 | +++ b/tests/qemu-iotests/175.out |
15 | @@ -XXX,XX +XXX,XX @@ | 77 | @@ -XXX,XX +XXX,XX @@ size=1048576, max allocation |
16 | # | 78 | == creating image with preallocation falloc == |
17 | # @flush: .bdrv_co_flush_to_disk() | 79 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=falloc |
18 | # | 80 | size=1048576, max allocation |
19 | +# @block-status: .bdrv_co_block_status() | ||
20 | +# | ||
21 | # Since: 4.1 | ||
22 | ## | ||
23 | { 'enum': 'BlkdebugIOType', 'prefix': 'BLKDEBUG_IO_TYPE', | ||
24 | - 'data': [ 'read', 'write', 'write-zeroes', 'discard', 'flush' ] } | ||
25 | + 'data': [ 'read', 'write', 'write-zeroes', 'discard', 'flush', | ||
26 | + 'block-status' ] } | ||
27 | |||
28 | ## | ||
29 | # @BlkdebugInjectErrorOptions: | ||
30 | diff --git a/block/blkdebug.c b/block/blkdebug.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/block/blkdebug.c | ||
33 | +++ b/block/blkdebug.c | ||
34 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn blkdebug_co_block_status(BlockDriverState *bs, | ||
35 | int64_t *map, | ||
36 | BlockDriverState **file) | ||
37 | { | ||
38 | + int err; | ||
39 | + | 81 | + |
40 | assert(QEMU_IS_ALIGNED(offset | bytes, bs->bl.request_alignment)); | 82 | +== resize empty image with block_resize == |
83 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=0 | ||
84 | +size=4096, min allocation | ||
41 | + | 85 | + |
42 | + err = rule_check(bs, offset, bytes, BLKDEBUG_IO_TYPE_BLOCK_STATUS); | 86 | +== resize empty image with block_resize == |
43 | + if (err) { | 87 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=0 |
44 | + return err; | 88 | +size=1048576, min allocation |
45 | + } | 89 | *** done |
46 | + | ||
47 | return bdrv_co_block_status_from_file(bs, want_zero, offset, bytes, | ||
48 | pnum, map, file); | ||
49 | } | ||
50 | -- | 90 | -- |
51 | 2.21.0 | 91 | 2.21.0 |
52 | 92 | ||
53 | 93 | diff view generated by jsdifflib |
1 | img_rebase() can leak a QDict in two occasions. Fix it. | 1 | fe646693acc changed qemu-img create's output so that it no longer prints |
---|---|---|---|
2 | single quotes around parameter values. The subformat and adapter_type | ||
3 | filters in _filter_img_create() have never been adapted to that change. | ||
2 | 4 | ||
3 | Coverity: CID 1401416 | 5 | Fixes: fe646693acc13ac48b98435d14149ab04dc597bc |
4 | Fixes: d16699b64671466b42079c45b89127aeea1ca565 | ||
5 | Fixes: 330c72957196e0ae382abcaa97ebf4eb9bc8574f | ||
6 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 6 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
7 | Message-id: 20190528195338.12376-1-mreitz@redhat.com | 7 | Reviewed-by: John Snow <jsnow@redhat.com> |
8 | Message-id: 20190815153638.4600-2-mreitz@redhat.com | ||
8 | Reviewed-by: John Snow <jsnow@redhat.com> | 9 | Reviewed-by: John Snow <jsnow@redhat.com> |
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 10 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
10 | --- | 11 | --- |
11 | qemu-img.c | 3 +++ | 12 | tests/qemu-iotests/059.out | 16 ++++++++-------- |
12 | 1 file changed, 3 insertions(+) | 13 | tests/qemu-iotests/common.filter | 4 ++-- |
14 | 2 files changed, 10 insertions(+), 10 deletions(-) | ||
13 | 15 | ||
14 | diff --git a/qemu-img.c b/qemu-img.c | 16 | diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/qemu-img.c | 18 | --- a/tests/qemu-iotests/059.out |
17 | +++ b/qemu-img.c | 19 | +++ b/tests/qemu-iotests/059.out |
18 | @@ -XXX,XX +XXX,XX @@ static int img_rebase(int argc, char **argv) | 20 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 |
19 | out_baseimg, | 21 | qemu-io: can't open device TEST_DIR/t.vmdk: L1 size too big |
20 | &local_err); | 22 | |
21 | if (local_err) { | 23 | === Testing monolithicFlat creation and opening === |
22 | + qobject_unref(options); | 24 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat |
23 | error_reportf_err(local_err, | 25 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 |
24 | "Could not resolve backing filename: "); | 26 | image: TEST_DIR/t.IMGFMT |
25 | ret = -1; | 27 | file format: IMGFMT |
26 | @@ -XXX,XX +XXX,XX @@ static int img_rebase(int argc, char **argv) | 28 | virtual size: 2 GiB (2147483648 bytes) |
27 | */ | 29 | |
28 | prefix_chain_bs = bdrv_find_backing_image(bs, out_real_path); | 30 | === Testing monolithicFlat with zeroed_grain === |
29 | if (prefix_chain_bs) { | 31 | qemu-img: TEST_DIR/t.IMGFMT: Flat image can't enable zeroed grain |
30 | + qobject_unref(options); | 32 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat |
31 | g_free(out_real_path); | 33 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 |
32 | + | 34 | |
33 | blk_new_backing = blk_new(qemu_get_aio_context(), | 35 | === Testing big twoGbMaxExtentFlat === |
34 | BLK_PERM_CONSISTENT_READ, | 36 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000 subformat=twoGbMaxExtentFlat |
35 | BLK_PERM_ALL); | 37 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000 |
38 | image: TEST_DIR/t.vmdk | ||
39 | file format: vmdk | ||
40 | virtual size: 0.977 TiB (1073741824000 bytes) | ||
41 | @@ -XXX,XX +XXX,XX @@ Format specific information: | ||
42 | qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Invalid extent line: RW 12582912 VMFS "dummy.IMGFMT" 1 | ||
43 | |||
44 | === Testing truncated sparse === | ||
45 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=107374182400 subformat=monolithicSparse | ||
46 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=107374182400 | ||
47 | qemu-img: Could not open 'TEST_DIR/t.IMGFMT': File truncated, expecting at least 13172736 bytes | ||
48 | |||
49 | === Converting to streamOptimized from image with small cluster size=== | ||
50 | @@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240 | ||
51 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
52 | |||
53 | === Testing monolithicFlat with internally generated JSON file name === | ||
54 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 subformat=monolithicFlat | ||
55 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
56 | qemu-io: can't open: Cannot use relative extent paths with VMDK descriptor file 'json:{"image": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "driver": "blkdebug", "inject-error.0.event": "read_aio"}' | ||
57 | |||
58 | === Testing version 3 === | ||
59 | @@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 64931328 | ||
60 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
61 | |||
62 | === Testing 4TB monolithicFlat creation and IO === | ||
63 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4398046511104 subformat=monolithicFlat | ||
64 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4398046511104 | ||
65 | image: TEST_DIR/t.IMGFMT | ||
66 | file format: IMGFMT | ||
67 | virtual size: 4 TiB (4398046511104 bytes) | ||
68 | @@ -XXX,XX +XXX,XX @@ read 1024/1024 bytes at offset 966367641600 | ||
69 | 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
70 | |||
71 | === Testing qemu-img map on extents === | ||
72 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544 subformat=monolithicSparse | ||
73 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544 | ||
74 | wrote 1024/1024 bytes at offset 65024 | ||
75 | 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
76 | wrote 1024/1024 bytes at offset 2147483136 | ||
77 | @@ -XXX,XX +XXX,XX @@ Offset Length Mapped to File | ||
78 | 0 0x20000 0x3f0000 TEST_DIR/t.vmdk | ||
79 | 0x7fff0000 0x20000 0x410000 TEST_DIR/t.vmdk | ||
80 | 0x140000000 0x10000 0x430000 TEST_DIR/t.vmdk | ||
81 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544 subformat=twoGbMaxExtentSparse | ||
82 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544 | ||
83 | wrote 1024/1024 bytes at offset 65024 | ||
84 | 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
85 | wrote 1024/1024 bytes at offset 2147483136 | ||
86 | diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter | ||
87 | index XXXXXXX..XXXXXXX 100644 | ||
88 | --- a/tests/qemu-iotests/common.filter | ||
89 | +++ b/tests/qemu-iotests/common.filter | ||
90 | @@ -XXX,XX +XXX,XX @@ _filter_img_create() | ||
91 | -e "s# compat6=\\(on\\|off\\)##g" \ | ||
92 | -e "s# static=\\(on\\|off\\)##g" \ | ||
93 | -e "s# zeroed_grain=\\(on\\|off\\)##g" \ | ||
94 | - -e "s# subformat='[^']*'##g" \ | ||
95 | - -e "s# adapter_type='[^']*'##g" \ | ||
96 | + -e "s# subformat=[^ ]*##g" \ | ||
97 | + -e "s# adapter_type=[^ ]*##g" \ | ||
98 | -e "s# hwversion=[^ ]*##g" \ | ||
99 | -e "s# lazy_refcounts=\\(on\\|off\\)##g" \ | ||
100 | -e "s# block_size=[0-9]\\+##g" \ | ||
36 | -- | 101 | -- |
37 | 2.21.0 | 102 | 2.21.0 |
38 | 103 | ||
39 | 104 | diff view generated by jsdifflib |
1 | This adds a salvaging mode (--salvage) to qemu-img convert which ignores | 1 | This makes iotest 033 pass with e.g. subformat=monolithicFlat. It also |
---|---|---|---|
2 | read errors and treats the respective areas as containing only zeroes. | 2 | turns a former error in 059 into success. |
3 | This can be used for instance to at least partially recover the data | ||
4 | from terminally corrupted qcow2 images. | ||
5 | 3 | ||
6 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 4 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
7 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 5 | Message-id: 20190815153638.4600-3-mreitz@redhat.com |
8 | Message-id: 20190507203508.18026-3-mreitz@redhat.com | 6 | Reviewed-by: John Snow <jsnow@redhat.com> |
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 7 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
10 | --- | 8 | --- |
11 | qemu-img.c | 90 +++++++++++++++++++++++++++++++++++++----------- | 9 | block/vmdk.c | 54 ++++++++++++++++++++++++-------------- |
12 | qemu-img-cmds.hx | 4 +-- | 10 | tests/qemu-iotests/059 | 7 +++-- |
13 | qemu-img.texi | 4 +++ | 11 | tests/qemu-iotests/059.out | 4 ++- |
14 | 3 files changed, 75 insertions(+), 23 deletions(-) | 12 | 3 files changed, 42 insertions(+), 23 deletions(-) |
15 | 13 | ||
16 | diff --git a/qemu-img.c b/qemu-img.c | 14 | diff --git a/block/vmdk.c b/block/vmdk.c |
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/qemu-img.c | 16 | --- a/block/vmdk.c |
19 | +++ b/qemu-img.c | 17 | +++ b/block/vmdk.c |
20 | @@ -XXX,XX +XXX,XX @@ enum { | 18 | @@ -XXX,XX +XXX,XX @@ static const char *next_line(const char *s) |
21 | OPTION_SIZE = 264, | 19 | } |
22 | OPTION_PREALLOCATION = 265, | 20 | |
23 | OPTION_SHRINK = 266, | 21 | static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, |
24 | + OPTION_SALVAGE = 267, | 22 | - const char *desc_file_path, QDict *options, |
25 | }; | 23 | - Error **errp) |
26 | 24 | + QDict *options, Error **errp) | |
27 | typedef enum OutputFormat { | 25 | { |
28 | @@ -XXX,XX +XXX,XX @@ typedef struct ImgConvertState { | 26 | int ret; |
29 | int64_t target_backing_sectors; /* negative if unknown */ | 27 | int matches; |
30 | bool wr_in_order; | 28 | @@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, |
31 | bool copy_range; | 29 | const char *p, *np; |
32 | + bool salvage; | 30 | int64_t sectors = 0; |
33 | bool quiet; | 31 | int64_t flat_offset; |
34 | int min_sparse; | 32 | + char *desc_file_dir = NULL; |
35 | int alignment; | 33 | char *extent_path; |
36 | @@ -XXX,XX +XXX,XX @@ static int convert_iteration_sectors(ImgConvertState *s, int64_t sector_num) | 34 | BdrvChild *extent_file; |
37 | } | 35 | BDRVVmdkState *s = bs->opaque; |
38 | 36 | @@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, | |
39 | if (s->sector_next_status <= sector_num) { | 37 | continue; |
40 | - int64_t count = n * BDRV_SECTOR_SIZE; | 38 | } |
41 | + uint64_t offset = (sector_num - src_cur_offset) * BDRV_SECTOR_SIZE; | 39 | |
42 | + int64_t count; | 40 | - if (!path_is_absolute(fname) && !path_has_protocol(fname) && |
43 | 41 | - !desc_file_path[0]) | |
44 | - if (s->target_has_backing) { | 42 | - { |
45 | + do { | 43 | - bdrv_refresh_filename(bs->file->bs); |
46 | + count = n * BDRV_SECTOR_SIZE; | 44 | - error_setg(errp, "Cannot use relative extent paths with VMDK " |
47 | + | 45 | - "descriptor file '%s'", bs->file->bs->filename); |
48 | + if (s->target_has_backing) { | 46 | - return -EINVAL; |
49 | + ret = bdrv_block_status(blk_bs(s->src[src_cur]), offset, | 47 | - } |
50 | + count, &count, NULL, NULL); | 48 | + if (path_is_absolute(fname)) { |
51 | + } else { | 49 | + extent_path = g_strdup(fname); |
52 | + ret = bdrv_block_status_above(blk_bs(s->src[src_cur]), NULL, | 50 | + } else { |
53 | + offset, count, &count, NULL, | 51 | + if (!desc_file_dir) { |
54 | + NULL); | 52 | + desc_file_dir = bdrv_dirname(bs->file->bs, errp); |
55 | + } | 53 | + if (!desc_file_dir) { |
56 | + | 54 | + bdrv_refresh_filename(bs->file->bs); |
57 | + if (ret < 0) { | 55 | + error_prepend(errp, "Cannot use relative paths with VMDK " |
58 | + if (s->salvage) { | 56 | + "descriptor file '%s': ", |
59 | + if (n == 1) { | 57 | + bs->file->bs->filename); |
60 | + if (!s->quiet) { | 58 | + ret = -EINVAL; |
61 | + warn_report("error while reading block status at " | 59 | + goto out; |
62 | + "offset %" PRIu64 ": %s", offset, | ||
63 | + strerror(-ret)); | ||
64 | + } | ||
65 | + /* Just try to read the data, then */ | ||
66 | + ret = BDRV_BLOCK_DATA; | ||
67 | + count = BDRV_SECTOR_SIZE; | ||
68 | + } else { | ||
69 | + /* Retry on a shorter range */ | ||
70 | + n = DIV_ROUND_UP(n, 4); | ||
71 | + } | ||
72 | + } else { | ||
73 | + error_report("error while reading block status at offset " | ||
74 | + "%" PRIu64 ": %s", offset, strerror(-ret)); | ||
75 | + return ret; | ||
76 | + } | 60 | + } |
77 | + } | 61 | + } |
78 | + } while (ret < 0); | 62 | |
79 | 63 | - extent_path = path_combine(desc_file_path, fname); | |
80 | - ret = bdrv_block_status(blk_bs(s->src[src_cur]), | 64 | + extent_path = g_strconcat(desc_file_dir, fname, NULL); |
81 | - (sector_num - src_cur_offset) * | 65 | + } |
82 | - BDRV_SECTOR_SIZE, | 66 | |
83 | - count, &count, NULL, NULL); | 67 | ret = snprintf(extent_opt_prefix, 32, "extents.%d", s->num_extents); |
84 | - } else { | 68 | assert(ret < 32); |
85 | - ret = bdrv_block_status_above(blk_bs(s->src[src_cur]), NULL, | 69 | @@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, |
86 | - (sector_num - src_cur_offset) * | 70 | g_free(extent_path); |
87 | - BDRV_SECTOR_SIZE, | 71 | if (local_err) { |
88 | - count, &count, NULL, NULL); | 72 | error_propagate(errp, local_err); |
89 | - } | 73 | - return -EINVAL; |
90 | - if (ret < 0) { | 74 | + ret = -EINVAL; |
91 | - error_report("error while reading block status of sector %" PRId64 | 75 | + goto out; |
92 | - ": %s", sector_num, strerror(-ret)); | 76 | } |
93 | - return ret; | 77 | |
94 | - } | 78 | /* save to extents array */ |
95 | n = DIV_ROUND_UP(count, BDRV_SECTOR_SIZE); | 79 | @@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, |
96 | 80 | 0, 0, 0, 0, 0, &extent, errp); | |
97 | if (ret & BDRV_BLOCK_ZERO) { | 81 | if (ret < 0) { |
98 | @@ -XXX,XX +XXX,XX @@ static int convert_iteration_sectors(ImgConvertState *s, int64_t sector_num) | 82 | bdrv_unref_child(bs, extent_file); |
99 | static int coroutine_fn convert_co_read(ImgConvertState *s, int64_t sector_num, | 83 | - return ret; |
100 | int nb_sectors, uint8_t *buf) | 84 | + goto out; |
101 | { | 85 | } |
102 | + uint64_t single_read_until = 0; | 86 | extent->flat_start_offset = flat_offset << 9; |
103 | int n, ret; | 87 | } else if (!strcmp(type, "SPARSE") || !strcmp(type, "VMFSSPARSE")) { |
104 | 88 | @@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, | |
105 | assert(nb_sectors <= s->buf_sectors); | 89 | g_free(buf); |
106 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn convert_co_read(ImgConvertState *s, int64_t sector_num, | 90 | if (ret) { |
107 | BlockBackend *blk; | 91 | bdrv_unref_child(bs, extent_file); |
108 | int src_cur; | 92 | - return ret; |
109 | int64_t bs_sectors, src_cur_offset; | 93 | + goto out; |
110 | + uint64_t offset; | 94 | } |
111 | 95 | extent = &s->extents[s->num_extents - 1]; | |
112 | /* In the case of compression with multiple source files, we can get a | 96 | } else if (!strcmp(type, "SESPARSE")) { |
113 | * nb_sectors that spreads into the next part. So we must be able to | 97 | ret = vmdk_open_se_sparse(bs, extent_file, bs->open_flags, errp); |
114 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn convert_co_read(ImgConvertState *s, int64_t sector_num, | 98 | if (ret) { |
115 | blk = s->src[src_cur]; | 99 | bdrv_unref_child(bs, extent_file); |
116 | bs_sectors = s->src_sectors[src_cur]; | 100 | - return ret; |
117 | 101 | + goto out; | |
118 | + offset = (sector_num - src_cur_offset) << BDRV_SECTOR_BITS; | 102 | } |
103 | extent = &s->extents[s->num_extents - 1]; | ||
104 | } else { | ||
105 | error_setg(errp, "Unsupported extent type '%s'", type); | ||
106 | bdrv_unref_child(bs, extent_file); | ||
107 | - return -ENOTSUP; | ||
108 | + ret = -ENOTSUP; | ||
109 | + goto out; | ||
110 | } | ||
111 | extent->type = g_strdup(type); | ||
112 | } | ||
113 | - return 0; | ||
119 | + | 114 | + |
120 | n = MIN(nb_sectors, bs_sectors - (sector_num - src_cur_offset)); | 115 | + ret = 0; |
121 | + if (single_read_until > offset) { | 116 | + goto out; |
122 | + n = 1; | 117 | |
123 | + } | 118 | invalid: |
124 | 119 | np = next_line(p); | |
125 | - ret = blk_co_pread( | 120 | @@ -XXX,XX +XXX,XX @@ invalid: |
126 | - blk, (sector_num - src_cur_offset) << BDRV_SECTOR_BITS, | 121 | np--; |
127 | - n << BDRV_SECTOR_BITS, buf, 0); | ||
128 | + ret = blk_co_pread(blk, offset, n << BDRV_SECTOR_BITS, buf, 0); | ||
129 | if (ret < 0) { | ||
130 | - return ret; | ||
131 | + if (s->salvage) { | ||
132 | + if (n > 1) { | ||
133 | + single_read_until = offset + (n << BDRV_SECTOR_BITS); | ||
134 | + continue; | ||
135 | + } else { | ||
136 | + if (!s->quiet) { | ||
137 | + warn_report("error while reading offset %" PRIu64 | ||
138 | + ": %s", offset, strerror(-ret)); | ||
139 | + } | ||
140 | + memset(buf, 0, BDRV_SECTOR_SIZE); | ||
141 | + } | ||
142 | + } else { | ||
143 | + return ret; | ||
144 | + } | ||
145 | } | ||
146 | |||
147 | sector_num += n; | ||
148 | @@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv) | ||
149 | {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, | ||
150 | {"force-share", no_argument, 0, 'U'}, | ||
151 | {"target-image-opts", no_argument, 0, OPTION_TARGET_IMAGE_OPTS}, | ||
152 | + {"salvage", no_argument, 0, OPTION_SALVAGE}, | ||
153 | {0, 0, 0, 0} | ||
154 | }; | ||
155 | c = getopt_long(argc, argv, ":hf:O:B:Cco:l:S:pt:T:qnm:WU", | ||
156 | @@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv) | ||
157 | case OPTION_IMAGE_OPTS: | ||
158 | image_opts = true; | ||
159 | break; | ||
160 | + case OPTION_SALVAGE: | ||
161 | + s.salvage = true; | ||
162 | + break; | ||
163 | case OPTION_TARGET_IMAGE_OPTS: | ||
164 | tgt_image_opts = true; | ||
165 | break; | ||
166 | @@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv) | ||
167 | goto fail_getopt; | ||
168 | } | 122 | } |
169 | 123 | error_setg(errp, "Invalid extent line: %.*s", (int)(np - p), p); | |
170 | + if (s.copy_range && s.salvage) { | 124 | - return -EINVAL; |
171 | + error_report("Cannot use copy offloading in salvaging mode"); | 125 | + ret = -EINVAL; |
172 | + goto fail_getopt; | ||
173 | + } | ||
174 | + | 126 | + |
175 | if (tgt_image_opts && !skip_create) { | 127 | +out: |
176 | error_report("--target-image-opts requires use of -n flag"); | 128 | + g_free(desc_file_dir); |
177 | goto fail_getopt; | 129 | + return ret; |
178 | diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx | 130 | } |
131 | |||
132 | static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf, | ||
133 | @@ -XXX,XX +XXX,XX @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf, | ||
134 | } | ||
135 | s->create_type = g_strdup(ct); | ||
136 | s->desc_offset = 0; | ||
137 | - ret = vmdk_parse_extents(buf, bs, bs->file->bs->exact_filename, options, | ||
138 | - errp); | ||
139 | + ret = vmdk_parse_extents(buf, bs, options, errp); | ||
140 | exit: | ||
141 | return ret; | ||
142 | } | ||
143 | diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059 | ||
144 | index XXXXXXX..XXXXXXX 100755 | ||
145 | --- a/tests/qemu-iotests/059 | ||
146 | +++ b/tests/qemu-iotests/059 | ||
147 | @@ -XXX,XX +XXX,XX @@ $QEMU_IMG convert -f qcow2 -O vmdk -o subformat=streamOptimized "$TEST_IMG.qcow2 | ||
148 | |||
149 | echo | ||
150 | echo "=== Testing monolithicFlat with internally generated JSON file name ===" | ||
151 | +# Should work, because bdrv_dirname() works fine with blkdebug | ||
152 | IMGOPTS="subformat=monolithicFlat" _make_test_img 64M | ||
153 | -$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" 2>&1 \ | ||
154 | - | _filter_testdir | _filter_imgfmt | ||
155 | +$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" \ | ||
156 | + -c info \ | ||
157 | + 2>&1 \ | ||
158 | + | _filter_testdir | _filter_imgfmt | _filter_img_info | ||
159 | _cleanup_test_img | ||
160 | |||
161 | echo | ||
162 | diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out | ||
179 | index XXXXXXX..XXXXXXX 100644 | 163 | index XXXXXXX..XXXXXXX 100644 |
180 | --- a/qemu-img-cmds.hx | 164 | --- a/tests/qemu-iotests/059.out |
181 | +++ b/qemu-img-cmds.hx | 165 | +++ b/tests/qemu-iotests/059.out |
182 | @@ -XXX,XX +XXX,XX @@ STEXI | 166 | @@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240 |
183 | ETEXI | 167 | |
184 | 168 | === Testing monolithicFlat with internally generated JSON file name === | |
185 | DEF("convert", img_convert, | 169 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 |
186 | - "convert [--object objectdef] [--image-opts] [--target-image-opts] [-U] [-C] [-c] [-p] [-q] [-n] [-f fmt] [-t cache] [-T src_cache] [-O output_fmt] [-B backing_file] [-o options] [-l snapshot_param] [-S sparse_size] [-m num_coroutines] [-W] filename [filename2 [...]] output_filename") | 170 | -qemu-io: can't open: Cannot use relative extent paths with VMDK descriptor file 'json:{"image": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "driver": "blkdebug", "inject-error.0.event": "read_aio"}' |
187 | + "convert [--object objectdef] [--image-opts] [--target-image-opts] [-U] [-C] [-c] [-p] [-q] [-n] [-f fmt] [-t cache] [-T src_cache] [-O output_fmt] [-B backing_file] [-o options] [-l snapshot_param] [-S sparse_size] [-m num_coroutines] [-W] [--salvage] filename [filename2 [...]] output_filename") | 171 | +format name: IMGFMT |
188 | STEXI | 172 | +cluster size: 0 bytes |
189 | -@item convert [--object @var{objectdef}] [--image-opts] [--target-image-opts] [-U] [-C] [-c] [-p] [-q] [-n] [-f @var{fmt}] [-t @var{cache}] [-T @var{src_cache}] [-O @var{output_fmt}] [-B @var{backing_file}] [-o @var{options}] [-l @var{snapshot_param}] [-S @var{sparse_size}] [-m @var{num_coroutines}] [-W] @var{filename} [@var{filename2} [...]] @var{output_filename} | 173 | +vm state offset: 0 bytes |
190 | +@item convert [--object @var{objectdef}] [--image-opts] [--target-image-opts] [-U] [-C] [-c] [-p] [-q] [-n] [-f @var{fmt}] [-t @var{cache}] [-T @var{src_cache}] [-O @var{output_fmt}] [-B @var{backing_file}] [-o @var{options}] [-l @var{snapshot_param}] [-S @var{sparse_size}] [-m @var{num_coroutines}] [-W] [--salvage] @var{filename} [@var{filename2} [...]] @var{output_filename} | 174 | |
191 | ETEXI | 175 | === Testing version 3 === |
192 | 176 | image: TEST_DIR/iotest-version3.IMGFMT | |
193 | DEF("create", img_create, | ||
194 | diff --git a/qemu-img.texi b/qemu-img.texi | ||
195 | index XXXXXXX..XXXXXXX 100644 | ||
196 | --- a/qemu-img.texi | ||
197 | +++ b/qemu-img.texi | ||
198 | @@ -XXX,XX +XXX,XX @@ improve performance if the data is remote, such as with NFS or iSCSI backends, | ||
199 | but will not automatically sparsify zero sectors, and may result in a fully | ||
200 | allocated target image depending on the host support for getting allocation | ||
201 | information. | ||
202 | +@item --salvage | ||
203 | +Try to ignore I/O errors when reading. Unless in quiet mode (@code{-q}), errors | ||
204 | +will still be printed. Areas that cannot be read from the source will be | ||
205 | +treated as containing only zeroes. | ||
206 | @end table | ||
207 | |||
208 | Parameters to dd subcommand: | ||
209 | -- | 177 | -- |
210 | 2.21.0 | 178 | 2.21.0 |
211 | 179 | ||
212 | 180 | diff view generated by jsdifflib |
1 | Together with @iotypes and @sector, this can be used to trap e.g. the | 1 | We had a test for a case where relative extent paths did not work, but |
---|---|---|---|
2 | first read or write access to a certain sector without having to know | 2 | unfortunately we just fixed the underlying problem, so it works now. |
3 | what happens internally in the block layer, i.e. which "real" events | 3 | This patch adds a new test case that still fails. |
4 | happen right before such an access. | ||
5 | 4 | ||
6 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 5 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
7 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 6 | Reviewed-by: John Snow <jsnow@redhat.com> |
8 | Message-id: 20190507203508.18026-5-mreitz@redhat.com | 7 | Message-id: 20190815153638.4600-4-mreitz@redhat.com |
8 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 9 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
10 | --- | 10 | --- |
11 | qapi/block-core.json | 4 +++- | 11 | tests/qemu-iotests/059 | 27 +++++++++++++++++++++++++++ |
12 | block/blkdebug.c | 2 ++ | 12 | tests/qemu-iotests/059.out | 4 ++++ |
13 | 2 files changed, 5 insertions(+), 1 deletion(-) | 13 | 2 files changed, 31 insertions(+) |
14 | 14 | ||
15 | diff --git a/qapi/block-core.json b/qapi/block-core.json | 15 | diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059 |
16 | index XXXXXXX..XXXXXXX 100755 | ||
17 | --- a/tests/qemu-iotests/059 | ||
18 | +++ b/tests/qemu-iotests/059 | ||
19 | @@ -XXX,XX +XXX,XX @@ $QEMU_IMG convert -f qcow2 -O vmdk -o subformat=streamOptimized "$TEST_IMG.qcow2 | ||
20 | |||
21 | echo | ||
22 | echo "=== Testing monolithicFlat with internally generated JSON file name ===" | ||
23 | + | ||
24 | +echo '--- blkdebug ---' | ||
25 | # Should work, because bdrv_dirname() works fine with blkdebug | ||
26 | IMGOPTS="subformat=monolithicFlat" _make_test_img 64M | ||
27 | $QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" \ | ||
28 | @@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TE | ||
29 | | _filter_testdir | _filter_imgfmt | _filter_img_info | ||
30 | _cleanup_test_img | ||
31 | |||
32 | +echo '--- quorum ---' | ||
33 | +# Should not work, because bdrv_dirname() does not work with quorum | ||
34 | +IMGOPTS="subformat=monolithicFlat" _make_test_img 64M | ||
35 | +cp "$TEST_IMG" "$TEST_IMG.orig" | ||
36 | + | ||
37 | +filename="json:{ | ||
38 | + \"driver\": \"$IMGFMT\", | ||
39 | + \"file\": { | ||
40 | + \"driver\": \"quorum\", | ||
41 | + \"children\": [ { | ||
42 | + \"driver\": \"file\", | ||
43 | + \"filename\": \"$TEST_IMG\" | ||
44 | + }, { | ||
45 | + \"driver\": \"file\", | ||
46 | + \"filename\": \"$TEST_IMG.orig\" | ||
47 | + } ], | ||
48 | + \"vote-threshold\": 1 | ||
49 | + } }" | ||
50 | + | ||
51 | +filename=$(echo "$filename" | tr '\n' ' ' | sed -e 's/\s\+/ /g') | ||
52 | +$QEMU_IMG info "$filename" 2>&1 \ | ||
53 | + | sed -e "s/'json:[^']*'/\$QUORUM_FILE/g" \ | ||
54 | + | _filter_testdir | _filter_imgfmt | _filter_img_info | ||
55 | + | ||
56 | + | ||
57 | echo | ||
58 | echo "=== Testing version 3 ===" | ||
59 | _use_sample_img iotest-version3.vmdk.bz2 | ||
60 | diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out | ||
16 | index XXXXXXX..XXXXXXX 100644 | 61 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/qapi/block-core.json | 62 | --- a/tests/qemu-iotests/059.out |
18 | +++ b/qapi/block-core.json | 63 | +++ b/tests/qemu-iotests/059.out |
19 | @@ -XXX,XX +XXX,XX @@ | 64 | @@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240 |
20 | # | 65 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) |
21 | # @cluster_alloc_space: an allocation of file space for a cluster (since 4.1) | 66 | |
22 | # | 67 | === Testing monolithicFlat with internally generated JSON file name === |
23 | +# @none: triggers once at creation of the blkdebug node (since 4.1) | 68 | +--- blkdebug --- |
24 | +# | 69 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 |
25 | # Since: 2.9 | 70 | format name: IMGFMT |
26 | ## | 71 | cluster size: 0 bytes |
27 | { 'enum': 'BlkdebugEvent', 'prefix': 'BLKDBG', | 72 | vm state offset: 0 bytes |
28 | @@ -XXX,XX +XXX,XX @@ | 73 | +--- quorum --- |
29 | 'pwritev_rmw_tail', 'pwritev_rmw_after_tail', 'pwritev', | 74 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 |
30 | 'pwritev_zero', 'pwritev_done', 'empty_image_prepare', | 75 | +qemu-img: Could not open $QUORUM_FILE: Cannot use relative paths with VMDK descriptor file $QUORUM_FILE: Cannot generate a base directory for quorum nodes |
31 | 'l1_shrink_write_table', 'l1_shrink_free_l2_clusters', | 76 | |
32 | - 'cor_write', 'cluster_alloc_space'] } | 77 | === Testing version 3 === |
33 | + 'cor_write', 'cluster_alloc_space', 'none'] } | 78 | image: TEST_DIR/iotest-version3.IMGFMT |
34 | |||
35 | ## | ||
36 | # @BlkdebugIOType: | ||
37 | diff --git a/block/blkdebug.c b/block/blkdebug.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/block/blkdebug.c | ||
40 | +++ b/block/blkdebug.c | ||
41 | @@ -XXX,XX +XXX,XX @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, | ||
42 | goto out; | ||
43 | } | ||
44 | |||
45 | + bdrv_debug_event(bs, BLKDBG_NONE); | ||
46 | + | ||
47 | ret = 0; | ||
48 | out: | ||
49 | if (ret < 0) { | ||
50 | -- | 79 | -- |
51 | 2.21.0 | 80 | 2.21.0 |
52 | 81 | ||
53 | 82 | diff view generated by jsdifflib |
1 | This new error option allows users of blkdebug to inject errors only on | 1 | Compressed writes generally have to write full clusters, not just in |
---|---|---|---|
2 | certain kinds of I/O operations. Users usually want to make a very | 2 | theory but also in practice when it comes to vmdk's streamOptimized |
3 | specific operation fail, not just any; but right now they simply hope | 3 | subformat. It currently is just silently broken for writes with |
4 | that the event that triggers the error injection is followed up with | 4 | non-zero in-cluster offsets: |
5 | that very operation. That may not be true, however, because the block | ||
6 | layer is changing (including blkdebug, which may increase the number of | ||
7 | types of I/O operations on which to inject errors). | ||
8 | 5 | ||
9 | The new option's default has been chosen to keep backwards | 6 | $ qemu-img create -f vmdk -o subformat=streamOptimized foo.vmdk 1M |
10 | compatibility. | 7 | $ qemu-io -c 'write 4k 4k' -c 'read 4k 4k' foo.vmdk |
8 | wrote 4096/4096 bytes at offset 4096 | ||
9 | 4 KiB, 1 ops; 00.01 sec (443.724 KiB/sec and 110.9309 ops/sec) | ||
10 | read failed: Invalid argument | ||
11 | 11 | ||
12 | Note that similar to the internal representation, we could choose to | 12 | (The technical reason is that vmdk_write_extent() just writes the |
13 | expose this option as a list of I/O types. But there is no practical | 13 | incomplete compressed data actually to offset 4k. When reading the |
14 | use for this, because as described above, users usually know exactly | 14 | data, vmdk_read_extent() looks at offset 0 and finds the compressed data |
15 | which kind of operation they want to make fail, so there is no need to | 15 | size to be 0, because that is what it reads from there. This yields an |
16 | specify multiple I/O types at once. In addition, exposing this option | 16 | error.) |
17 | as a list would require non-trivial changes to qemu_opts_absorb_qdict(). | 17 | |
18 | For incomplete writes with zero in-cluster offsets, the error path when | ||
19 | reading the rest of the cluster is a bit different, but the result is | ||
20 | the same: | ||
21 | |||
22 | $ qemu-img create -f vmdk -o subformat=streamOptimized foo.vmdk 1M | ||
23 | $ qemu-io -c 'write 0k 4k' -c 'read 4k 4k' foo.vmdk | ||
24 | wrote 4096/4096 bytes at offset 0 | ||
25 | 4 KiB, 1 ops; 00.01 sec (362.641 KiB/sec and 90.6603 ops/sec) | ||
26 | read failed: Invalid argument | ||
27 | |||
28 | (Here, vmdk_read_extent() finds the data and then sees that the | ||
29 | uncompressed data is short.) | ||
30 | |||
31 | It is better to reject invalid writes than to make the user believe they | ||
32 | might have succeeded and then fail when trying to read it back. | ||
18 | 33 | ||
19 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 34 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
20 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 35 | Reviewed-by: John Snow <jsnow@redhat.com> |
21 | Message-id: 20190507203508.18026-4-mreitz@redhat.com | 36 | Message-id: 20190815153638.4600-5-mreitz@redhat.com |
37 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
22 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 38 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
23 | --- | 39 | --- |
24 | qapi/block-core.json | 26 +++++++++++++++++++++++ | 40 | block/vmdk.c | 10 ++++++++++ |
25 | block/blkdebug.c | 50 ++++++++++++++++++++++++++++++++++++-------- | 41 | 1 file changed, 10 insertions(+) |
26 | 2 files changed, 67 insertions(+), 9 deletions(-) | ||
27 | 42 | ||
28 | diff --git a/qapi/block-core.json b/qapi/block-core.json | 43 | diff --git a/block/vmdk.c b/block/vmdk.c |
29 | index XXXXXXX..XXXXXXX 100644 | 44 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/qapi/block-core.json | 45 | --- a/block/vmdk.c |
31 | +++ b/qapi/block-core.json | 46 | +++ b/block/vmdk.c |
32 | @@ -XXX,XX +XXX,XX @@ | 47 | @@ -XXX,XX +XXX,XX @@ static int vmdk_write_extent(VmdkExtent *extent, int64_t cluster_offset, |
33 | 'l1_shrink_write_table', 'l1_shrink_free_l2_clusters', | 48 | if (extent->compressed) { |
34 | 'cor_write', 'cluster_alloc_space'] } | 49 | void *compressed_data; |
35 | 50 | ||
36 | +## | 51 | + /* Only whole clusters */ |
37 | +# @BlkdebugIOType: | 52 | + if (offset_in_cluster || |
38 | +# | 53 | + n_bytes > (extent->cluster_sectors * SECTOR_SIZE) || |
39 | +# Kinds of I/O that blkdebug can inject errors in. | 54 | + (n_bytes < (extent->cluster_sectors * SECTOR_SIZE) && |
40 | +# | 55 | + offset + n_bytes != extent->end_sector * SECTOR_SIZE)) |
41 | +# @read: .bdrv_co_preadv() | ||
42 | +# | ||
43 | +# @write: .bdrv_co_pwritev() | ||
44 | +# | ||
45 | +# @write-zeroes: .bdrv_co_pwrite_zeroes() | ||
46 | +# | ||
47 | +# @discard: .bdrv_co_pdiscard() | ||
48 | +# | ||
49 | +# @flush: .bdrv_co_flush_to_disk() | ||
50 | +# | ||
51 | +# Since: 4.1 | ||
52 | +## | ||
53 | +{ 'enum': 'BlkdebugIOType', 'prefix': 'BLKDEBUG_IO_TYPE', | ||
54 | + 'data': [ 'read', 'write', 'write-zeroes', 'discard', 'flush' ] } | ||
55 | + | ||
56 | ## | ||
57 | # @BlkdebugInjectErrorOptions: | ||
58 | # | ||
59 | @@ -XXX,XX +XXX,XX @@ | ||
60 | # @state: the state identifier blkdebug needs to be in to | ||
61 | # actually trigger the event; defaults to "any" | ||
62 | # | ||
63 | +# @iotype: the type of I/O operations on which this error should | ||
64 | +# be injected; defaults to "all read, write, | ||
65 | +# write-zeroes, discard, and flush operations" | ||
66 | +# (since: 4.1) | ||
67 | +# | ||
68 | # @errno: error identifier (errno) to be returned; defaults to | ||
69 | # EIO | ||
70 | # | ||
71 | @@ -XXX,XX +XXX,XX @@ | ||
72 | { 'struct': 'BlkdebugInjectErrorOptions', | ||
73 | 'data': { 'event': 'BlkdebugEvent', | ||
74 | '*state': 'int', | ||
75 | + '*iotype': 'BlkdebugIOType', | ||
76 | '*errno': 'int', | ||
77 | '*sector': 'int', | ||
78 | '*once': 'bool', | ||
79 | diff --git a/block/blkdebug.c b/block/blkdebug.c | ||
80 | index XXXXXXX..XXXXXXX 100644 | ||
81 | --- a/block/blkdebug.c | ||
82 | +++ b/block/blkdebug.c | ||
83 | @@ -XXX,XX +XXX,XX @@ typedef struct BlkdebugRule { | ||
84 | int state; | ||
85 | union { | ||
86 | struct { | ||
87 | + uint64_t iotype_mask; | ||
88 | int error; | ||
89 | int immediately; | ||
90 | int once; | ||
91 | @@ -XXX,XX +XXX,XX @@ typedef struct BlkdebugRule { | ||
92 | QSIMPLEQ_ENTRY(BlkdebugRule) active_next; | ||
93 | } BlkdebugRule; | ||
94 | |||
95 | +QEMU_BUILD_BUG_MSG(BLKDEBUG_IO_TYPE__MAX > 64, | ||
96 | + "BlkdebugIOType mask does not fit into an uint64_t"); | ||
97 | + | ||
98 | static QemuOptsList inject_error_opts = { | ||
99 | .name = "inject-error", | ||
100 | .head = QTAILQ_HEAD_INITIALIZER(inject_error_opts.head), | ||
101 | @@ -XXX,XX +XXX,XX @@ static QemuOptsList inject_error_opts = { | ||
102 | .name = "state", | ||
103 | .type = QEMU_OPT_NUMBER, | ||
104 | }, | ||
105 | + { | 56 | + { |
106 | + .name = "iotype", | 57 | + ret = -EINVAL; |
107 | + .type = QEMU_OPT_STRING, | 58 | + goto out; |
108 | + }, | ||
109 | { | ||
110 | .name = "errno", | ||
111 | .type = QEMU_OPT_NUMBER, | ||
112 | @@ -XXX,XX +XXX,XX @@ static int add_rule(void *opaque, QemuOpts *opts, Error **errp) | ||
113 | int event; | ||
114 | struct BlkdebugRule *rule; | ||
115 | int64_t sector; | ||
116 | + BlkdebugIOType iotype; | ||
117 | + Error *local_error = NULL; | ||
118 | |||
119 | /* Find the right event for the rule */ | ||
120 | event_name = qemu_opt_get(opts, "event"); | ||
121 | @@ -XXX,XX +XXX,XX @@ static int add_rule(void *opaque, QemuOpts *opts, Error **errp) | ||
122 | sector = qemu_opt_get_number(opts, "sector", -1); | ||
123 | rule->options.inject.offset = | ||
124 | sector == -1 ? -1 : sector * BDRV_SECTOR_SIZE; | ||
125 | + | ||
126 | + iotype = qapi_enum_parse(&BlkdebugIOType_lookup, | ||
127 | + qemu_opt_get(opts, "iotype"), | ||
128 | + BLKDEBUG_IO_TYPE__MAX, &local_error); | ||
129 | + if (local_error) { | ||
130 | + error_propagate(errp, local_error); | ||
131 | + return -1; | ||
132 | + } | ||
133 | + if (iotype != BLKDEBUG_IO_TYPE__MAX) { | ||
134 | + rule->options.inject.iotype_mask = (1ull << iotype); | ||
135 | + } else { | ||
136 | + /* Apply the default */ | ||
137 | + rule->options.inject.iotype_mask = | ||
138 | + (1ull << BLKDEBUG_IO_TYPE_READ) | ||
139 | + | (1ull << BLKDEBUG_IO_TYPE_WRITE) | ||
140 | + | (1ull << BLKDEBUG_IO_TYPE_WRITE_ZEROES) | ||
141 | + | (1ull << BLKDEBUG_IO_TYPE_DISCARD) | ||
142 | + | (1ull << BLKDEBUG_IO_TYPE_FLUSH); | ||
143 | + } | 59 | + } |
144 | + | 60 | + |
145 | break; | 61 | if (!extent->has_marker) { |
146 | 62 | ret = -EINVAL; | |
147 | case ACTION_SET_STATE: | 63 | goto out; |
148 | @@ -XXX,XX +XXX,XX @@ out: | ||
149 | return ret; | ||
150 | } | ||
151 | |||
152 | -static int rule_check(BlockDriverState *bs, uint64_t offset, uint64_t bytes) | ||
153 | +static int rule_check(BlockDriverState *bs, uint64_t offset, uint64_t bytes, | ||
154 | + BlkdebugIOType iotype) | ||
155 | { | ||
156 | BDRVBlkdebugState *s = bs->opaque; | ||
157 | BlkdebugRule *rule = NULL; | ||
158 | @@ -XXX,XX +XXX,XX @@ static int rule_check(BlockDriverState *bs, uint64_t offset, uint64_t bytes) | ||
159 | QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) { | ||
160 | uint64_t inject_offset = rule->options.inject.offset; | ||
161 | |||
162 | - if (inject_offset == -1 || | ||
163 | - (bytes && inject_offset >= offset && | ||
164 | - inject_offset < offset + bytes)) | ||
165 | + if ((inject_offset == -1 || | ||
166 | + (bytes && inject_offset >= offset && | ||
167 | + inject_offset < offset + bytes)) && | ||
168 | + (rule->options.inject.iotype_mask & (1ull << iotype))) | ||
169 | { | ||
170 | break; | ||
171 | } | ||
172 | @@ -XXX,XX +XXX,XX @@ blkdebug_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, | ||
173 | assert(bytes <= bs->bl.max_transfer); | ||
174 | } | ||
175 | |||
176 | - err = rule_check(bs, offset, bytes); | ||
177 | + err = rule_check(bs, offset, bytes, BLKDEBUG_IO_TYPE_READ); | ||
178 | if (err) { | ||
179 | return err; | ||
180 | } | ||
181 | @@ -XXX,XX +XXX,XX @@ blkdebug_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, | ||
182 | assert(bytes <= bs->bl.max_transfer); | ||
183 | } | ||
184 | |||
185 | - err = rule_check(bs, offset, bytes); | ||
186 | + err = rule_check(bs, offset, bytes, BLKDEBUG_IO_TYPE_WRITE); | ||
187 | if (err) { | ||
188 | return err; | ||
189 | } | ||
190 | @@ -XXX,XX +XXX,XX @@ blkdebug_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, | ||
191 | |||
192 | static int blkdebug_co_flush(BlockDriverState *bs) | ||
193 | { | ||
194 | - int err = rule_check(bs, 0, 0); | ||
195 | + int err = rule_check(bs, 0, 0, BLKDEBUG_IO_TYPE_FLUSH); | ||
196 | |||
197 | if (err) { | ||
198 | return err; | ||
199 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn blkdebug_co_pwrite_zeroes(BlockDriverState *bs, | ||
200 | assert(bytes <= bs->bl.max_pwrite_zeroes); | ||
201 | } | ||
202 | |||
203 | - err = rule_check(bs, offset, bytes); | ||
204 | + err = rule_check(bs, offset, bytes, BLKDEBUG_IO_TYPE_WRITE_ZEROES); | ||
205 | if (err) { | ||
206 | return err; | ||
207 | } | ||
208 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn blkdebug_co_pdiscard(BlockDriverState *bs, | ||
209 | assert(bytes <= bs->bl.max_pdiscard); | ||
210 | } | ||
211 | |||
212 | - err = rule_check(bs, offset, bytes); | ||
213 | + err = rule_check(bs, offset, bytes, BLKDEBUG_IO_TYPE_DISCARD); | ||
214 | if (err) { | ||
215 | return err; | ||
216 | } | ||
217 | -- | 64 | -- |
218 | 2.21.0 | 65 | 2.21.0 |
219 | 66 | ||
220 | 67 | diff view generated by jsdifflib |
1 | Move img_convert()'s quiet flag into the ImgConvertState so it is | 1 | streamOptimized does not support writes that do not span exactly one |
---|---|---|---|
2 | accessible by nested functions. -q dictates that it suppresses anything | 2 | cluster. Furthermore, it cannot rewrite already allocated clusters. |
3 | but errors, so if those functions want to emit warnings, they need to | 3 | As such, many iotests do not work with it. Disable them. |
4 | query this flag first. (There currently are no such warnings, but there | ||
5 | will be as of the next patch.) | ||
6 | 4 | ||
7 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 5 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
8 | Reviewed-by: Eric Blake <eblake@redhat.com> | 6 | Message-id: 20190815153638.4600-6-mreitz@redhat.com |
9 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 7 | Reviewed-by: John Snow <jsnow@redhat.com> |
10 | Message-id: 20190507203508.18026-2-mreitz@redhat.com | ||
11 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 8 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
12 | --- | 9 | --- |
13 | qemu-img.c | 13 +++++++------ | 10 | tests/qemu-iotests/002 | 1 + |
14 | 1 file changed, 7 insertions(+), 6 deletions(-) | 11 | tests/qemu-iotests/003 | 1 + |
12 | tests/qemu-iotests/005 | 3 ++- | ||
13 | tests/qemu-iotests/009 | 1 + | ||
14 | tests/qemu-iotests/010 | 1 + | ||
15 | tests/qemu-iotests/011 | 1 + | ||
16 | tests/qemu-iotests/017 | 3 ++- | ||
17 | tests/qemu-iotests/018 | 3 ++- | ||
18 | tests/qemu-iotests/019 | 3 ++- | ||
19 | tests/qemu-iotests/020 | 3 ++- | ||
20 | tests/qemu-iotests/027 | 1 + | ||
21 | tests/qemu-iotests/032 | 1 + | ||
22 | tests/qemu-iotests/033 | 1 + | ||
23 | tests/qemu-iotests/034 | 3 ++- | ||
24 | tests/qemu-iotests/037 | 3 ++- | ||
25 | tests/qemu-iotests/063 | 3 ++- | ||
26 | tests/qemu-iotests/072 | 1 + | ||
27 | tests/qemu-iotests/105 | 3 ++- | ||
28 | tests/qemu-iotests/197 | 1 + | ||
29 | tests/qemu-iotests/215 | 1 + | ||
30 | tests/qemu-iotests/251 | 1 + | ||
31 | 21 files changed, 30 insertions(+), 9 deletions(-) | ||
15 | 32 | ||
16 | diff --git a/qemu-img.c b/qemu-img.c | 33 | diff --git a/tests/qemu-iotests/002 b/tests/qemu-iotests/002 |
17 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100755 |
18 | --- a/qemu-img.c | 35 | --- a/tests/qemu-iotests/002 |
19 | +++ b/qemu-img.c | 36 | +++ b/tests/qemu-iotests/002 |
20 | @@ -XXX,XX +XXX,XX @@ typedef struct ImgConvertState { | 37 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
21 | int64_t target_backing_sectors; /* negative if unknown */ | 38 | |
22 | bool wr_in_order; | 39 | _supported_fmt generic |
23 | bool copy_range; | 40 | _supported_proto generic |
24 | + bool quiet; | 41 | +_unsupported_imgopts "subformat=streamOptimized" |
25 | int min_sparse; | 42 | |
26 | int alignment; | 43 | |
27 | size_t cluster_sectors; | 44 | size=128M |
28 | @@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv) | 45 | diff --git a/tests/qemu-iotests/003 b/tests/qemu-iotests/003 |
29 | QDict *open_opts = NULL; | 46 | index XXXXXXX..XXXXXXX 100755 |
30 | char *options = NULL; | 47 | --- a/tests/qemu-iotests/003 |
31 | Error *local_err = NULL; | 48 | +++ b/tests/qemu-iotests/003 |
32 | - bool writethrough, src_writethrough, quiet = false, image_opts = false, | 49 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
33 | + bool writethrough, src_writethrough, image_opts = false, | 50 | |
34 | skip_create = false, progress = false, tgt_image_opts = false; | 51 | _supported_fmt generic |
35 | int64_t ret = -EINVAL; | 52 | _supported_proto generic |
36 | bool force_share = false; | 53 | +_unsupported_imgopts "subformat=streamOptimized" |
37 | @@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv) | 54 | |
38 | src_cache = optarg; | 55 | size=128M |
39 | break; | 56 | offset=67M |
40 | case 'q': | 57 | diff --git a/tests/qemu-iotests/005 b/tests/qemu-iotests/005 |
41 | - quiet = true; | 58 | index XXXXXXX..XXXXXXX 100755 |
42 | + s.quiet = true; | 59 | --- a/tests/qemu-iotests/005 |
43 | break; | 60 | +++ b/tests/qemu-iotests/005 |
44 | case 'n': | 61 | @@ -XXX,XX +XXX,XX @@ _supported_fmt generic |
45 | skip_create = true; | 62 | _supported_proto generic |
46 | @@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv) | 63 | _supported_os Linux |
47 | } | 64 | _unsupported_imgopts "subformat=twoGbMaxExtentFlat" \ |
48 | 65 | - "subformat=twoGbMaxExtentSparse" | |
49 | /* Initialize before goto out */ | 66 | + "subformat=twoGbMaxExtentSparse" \ |
50 | - if (quiet) { | 67 | + "subformat=streamOptimized" |
51 | + if (s.quiet) { | 68 | |
52 | progress = false; | 69 | # vpc is limited to 127GB, so we can't test it here |
53 | } | 70 | if [ "$IMGFMT" = "vpc" ]; then |
54 | qemu_progress_init(progress, 1.0); | 71 | diff --git a/tests/qemu-iotests/009 b/tests/qemu-iotests/009 |
55 | @@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv) | 72 | index XXXXXXX..XXXXXXX 100755 |
56 | 73 | --- a/tests/qemu-iotests/009 | |
57 | for (bs_i = 0; bs_i < s.src_num; bs_i++) { | 74 | +++ b/tests/qemu-iotests/009 |
58 | s.src[bs_i] = img_open(image_opts, argv[optind + bs_i], | 75 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
59 | - fmt, src_flags, src_writethrough, quiet, | 76 | |
60 | + fmt, src_flags, src_writethrough, s.quiet, | 77 | _supported_fmt generic |
61 | force_share); | 78 | _supported_proto generic |
62 | if (!s.src[bs_i]) { | 79 | +_unsupported_imgopts "subformat=streamOptimized" |
63 | ret = -1; | 80 | |
64 | @@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv) | 81 | |
65 | 82 | size=6G | |
66 | if (skip_create) { | 83 | diff --git a/tests/qemu-iotests/010 b/tests/qemu-iotests/010 |
67 | s.target = img_open(tgt_image_opts, out_filename, out_fmt, | 84 | index XXXXXXX..XXXXXXX 100755 |
68 | - flags, writethrough, quiet, false); | 85 | --- a/tests/qemu-iotests/010 |
69 | + flags, writethrough, s.quiet, false); | 86 | +++ b/tests/qemu-iotests/010 |
70 | } else { | 87 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
71 | /* TODO ultimately we should allow --target-image-opts | 88 | |
72 | * to be used even when -n is not given. | 89 | _supported_fmt generic |
73 | @@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv) | 90 | _supported_proto generic |
74 | * to allow filenames in option syntax | 91 | +_unsupported_imgopts "subformat=streamOptimized" |
75 | */ | 92 | |
76 | s.target = img_open_file(out_filename, open_opts, out_fmt, | 93 | |
77 | - flags, writethrough, quiet, false); | 94 | size=6G |
78 | + flags, writethrough, s.quiet, false); | 95 | diff --git a/tests/qemu-iotests/011 b/tests/qemu-iotests/011 |
79 | open_opts = NULL; /* blk_new_open will have freed it */ | 96 | index XXXXXXX..XXXXXXX 100755 |
80 | } | 97 | --- a/tests/qemu-iotests/011 |
81 | if (!s.target) { | 98 | +++ b/tests/qemu-iotests/011 |
99 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
100 | |||
101 | _supported_fmt generic | ||
102 | _supported_proto generic | ||
103 | +_unsupported_imgopts "subformat=streamOptimized" | ||
104 | |||
105 | |||
106 | size=6G | ||
107 | diff --git a/tests/qemu-iotests/017 b/tests/qemu-iotests/017 | ||
108 | index XXXXXXX..XXXXXXX 100755 | ||
109 | --- a/tests/qemu-iotests/017 | ||
110 | +++ b/tests/qemu-iotests/017 | ||
111 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
112 | _supported_fmt qcow qcow2 vmdk qed | ||
113 | _supported_proto generic | ||
114 | _unsupported_proto vxhs | ||
115 | -_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" | ||
116 | +_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \ | ||
117 | + "subformat=streamOptimized" | ||
118 | |||
119 | TEST_OFFSETS="0 4294967296" | ||
120 | |||
121 | diff --git a/tests/qemu-iotests/018 b/tests/qemu-iotests/018 | ||
122 | index XXXXXXX..XXXXXXX 100755 | ||
123 | --- a/tests/qemu-iotests/018 | ||
124 | +++ b/tests/qemu-iotests/018 | ||
125 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
126 | _supported_fmt qcow qcow2 vmdk qed | ||
127 | _supported_proto file | ||
128 | _supported_os Linux | ||
129 | -_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" | ||
130 | +_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \ | ||
131 | + "streamOptimized" | ||
132 | |||
133 | TEST_OFFSETS="0 4294967296" | ||
134 | |||
135 | diff --git a/tests/qemu-iotests/019 b/tests/qemu-iotests/019 | ||
136 | index XXXXXXX..XXXXXXX 100755 | ||
137 | --- a/tests/qemu-iotests/019 | ||
138 | +++ b/tests/qemu-iotests/019 | ||
139 | @@ -XXX,XX +XXX,XX @@ _supported_proto file | ||
140 | _supported_os Linux | ||
141 | _unsupported_imgopts "subformat=monolithicFlat" \ | ||
142 | "subformat=twoGbMaxExtentFlat" \ | ||
143 | - "subformat=twoGbMaxExtentSparse" | ||
144 | + "subformat=twoGbMaxExtentSparse" \ | ||
145 | + "subformat=streamOptimized" | ||
146 | |||
147 | TEST_OFFSETS="0 4294967296" | ||
148 | CLUSTER_SIZE=65536 | ||
149 | diff --git a/tests/qemu-iotests/020 b/tests/qemu-iotests/020 | ||
150 | index XXXXXXX..XXXXXXX 100755 | ||
151 | --- a/tests/qemu-iotests/020 | ||
152 | +++ b/tests/qemu-iotests/020 | ||
153 | @@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed | ||
154 | _supported_proto file | ||
155 | _unsupported_imgopts "subformat=monolithicFlat" \ | ||
156 | "subformat=twoGbMaxExtentFlat" \ | ||
157 | - "subformat=twoGbMaxExtentSparse" | ||
158 | + "subformat=twoGbMaxExtentSparse" \ | ||
159 | + "subformat=streamOptimized" | ||
160 | |||
161 | TEST_OFFSETS="0 4294967296" | ||
162 | |||
163 | diff --git a/tests/qemu-iotests/027 b/tests/qemu-iotests/027 | ||
164 | index XXXXXXX..XXXXXXX 100755 | ||
165 | --- a/tests/qemu-iotests/027 | ||
166 | +++ b/tests/qemu-iotests/027 | ||
167 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
168 | |||
169 | _supported_fmt vmdk qcow qcow2 qed | ||
170 | _supported_proto generic | ||
171 | +_unsupported_imgopts "subformat=streamOptimized" | ||
172 | |||
173 | |||
174 | size=128M | ||
175 | diff --git a/tests/qemu-iotests/032 b/tests/qemu-iotests/032 | ||
176 | index XXXXXXX..XXXXXXX 100755 | ||
177 | --- a/tests/qemu-iotests/032 | ||
178 | +++ b/tests/qemu-iotests/032 | ||
179 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
180 | # This works for any image format (though unlikely to segfault for raw) | ||
181 | _supported_fmt generic | ||
182 | _supported_proto generic | ||
183 | +_unsupported_imgopts "subformat=streamOptimized" | ||
184 | |||
185 | echo | ||
186 | echo === Prepare image === | ||
187 | diff --git a/tests/qemu-iotests/033 b/tests/qemu-iotests/033 | ||
188 | index XXXXXXX..XXXXXXX 100755 | ||
189 | --- a/tests/qemu-iotests/033 | ||
190 | +++ b/tests/qemu-iotests/033 | ||
191 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
192 | |||
193 | _supported_fmt generic | ||
194 | _supported_proto generic | ||
195 | +_unsupported_imgopts "subformat=streamOptimized" | ||
196 | |||
197 | |||
198 | size=128M | ||
199 | diff --git a/tests/qemu-iotests/034 b/tests/qemu-iotests/034 | ||
200 | index XXXXXXX..XXXXXXX 100755 | ||
201 | --- a/tests/qemu-iotests/034 | ||
202 | +++ b/tests/qemu-iotests/034 | ||
203 | @@ -XXX,XX +XXX,XX @@ _supported_proto file | ||
204 | _supported_os Linux | ||
205 | _unsupported_imgopts "subformat=monolithicFlat" \ | ||
206 | "subformat=twoGbMaxExtentFlat" \ | ||
207 | - "subformat=twoGbMaxExtentSparse" | ||
208 | + "subformat=twoGbMaxExtentSparse" \ | ||
209 | + "subformat=streamOptimized" | ||
210 | |||
211 | CLUSTER_SIZE=4k | ||
212 | size=128M | ||
213 | diff --git a/tests/qemu-iotests/037 b/tests/qemu-iotests/037 | ||
214 | index XXXXXXX..XXXXXXX 100755 | ||
215 | --- a/tests/qemu-iotests/037 | ||
216 | +++ b/tests/qemu-iotests/037 | ||
217 | @@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed | ||
218 | _supported_proto file | ||
219 | _unsupported_imgopts "subformat=monolithicFlat" \ | ||
220 | "subformat=twoGbMaxExtentFlat" \ | ||
221 | - "subformat=twoGbMaxExtentSparse" | ||
222 | + "subformat=twoGbMaxExtentSparse" \ | ||
223 | + "subformat=streamOptimized" | ||
224 | |||
225 | CLUSTER_SIZE=4k | ||
226 | size=128M | ||
227 | diff --git a/tests/qemu-iotests/063 b/tests/qemu-iotests/063 | ||
228 | index XXXXXXX..XXXXXXX 100755 | ||
229 | --- a/tests/qemu-iotests/063 | ||
230 | +++ b/tests/qemu-iotests/063 | ||
231 | @@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed raw | ||
232 | _supported_proto file | ||
233 | _unsupported_imgopts "subformat=monolithicFlat" \ | ||
234 | "subformat=twoGbMaxExtentFlat" \ | ||
235 | - "subformat=twoGbMaxExtentSparse" | ||
236 | + "subformat=twoGbMaxExtentSparse" \ | ||
237 | + "subformat=streamOptimized" | ||
238 | |||
239 | _make_test_img 4M | ||
240 | |||
241 | diff --git a/tests/qemu-iotests/072 b/tests/qemu-iotests/072 | ||
242 | index XXXXXXX..XXXXXXX 100755 | ||
243 | --- a/tests/qemu-iotests/072 | ||
244 | +++ b/tests/qemu-iotests/072 | ||
245 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
246 | |||
247 | _supported_fmt vpc vmdk vhdx vdi qed qcow2 qcow | ||
248 | _supported_proto file | ||
249 | +_unsupported_imgopts "subformat=streamOptimized" | ||
250 | |||
251 | IMG_SIZE=64M | ||
252 | |||
253 | diff --git a/tests/qemu-iotests/105 b/tests/qemu-iotests/105 | ||
254 | index XXXXXXX..XXXXXXX 100755 | ||
255 | --- a/tests/qemu-iotests/105 | ||
256 | +++ b/tests/qemu-iotests/105 | ||
257 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
258 | _supported_fmt qcow2 vmdk vhdx qed | ||
259 | _supported_proto generic | ||
260 | _unsupported_imgopts "subformat=twoGbMaxExtentFlat" \ | ||
261 | - "subformat=twoGbMaxExtentSparse" | ||
262 | + "subformat=twoGbMaxExtentSparse" \ | ||
263 | + "subformat=streamOptimized" | ||
264 | |||
265 | echo | ||
266 | echo "creating large image" | ||
267 | diff --git a/tests/qemu-iotests/197 b/tests/qemu-iotests/197 | ||
268 | index XXXXXXX..XXXXXXX 100755 | ||
269 | --- a/tests/qemu-iotests/197 | ||
270 | +++ b/tests/qemu-iotests/197 | ||
271 | @@ -XXX,XX +XXX,XX @@ _supported_fmt generic | ||
272 | _supported_proto generic | ||
273 | # LUKS support may be possible, but it complicates things. | ||
274 | _unsupported_fmt luks | ||
275 | +_unsupported_imgopts "subformat=streamOptimized" | ||
276 | |||
277 | echo | ||
278 | echo '=== Copy-on-read ===' | ||
279 | diff --git a/tests/qemu-iotests/215 b/tests/qemu-iotests/215 | ||
280 | index XXXXXXX..XXXXXXX 100755 | ||
281 | --- a/tests/qemu-iotests/215 | ||
282 | +++ b/tests/qemu-iotests/215 | ||
283 | @@ -XXX,XX +XXX,XX @@ _supported_fmt generic | ||
284 | _supported_proto generic | ||
285 | # LUKS support may be possible, but it complicates things. | ||
286 | _unsupported_fmt luks | ||
287 | +_unsupported_imgopts "subformat=streamOptimized" | ||
288 | |||
289 | echo | ||
290 | echo '=== Copy-on-read ===' | ||
291 | diff --git a/tests/qemu-iotests/251 b/tests/qemu-iotests/251 | ||
292 | index XXXXXXX..XXXXXXX 100755 | ||
293 | --- a/tests/qemu-iotests/251 | ||
294 | +++ b/tests/qemu-iotests/251 | ||
295 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
296 | _supported_fmt generic | ||
297 | _supported_proto file | ||
298 | _supported_os Linux | ||
299 | +_unsupported_imgopts "subformat=streamOptimized" | ||
300 | |||
301 | if [ "$IMGOPTSSYNTAX" = "true" ]; then | ||
302 | # We use json:{} filenames here, so we cannot work with additional options. | ||
82 | -- | 303 | -- |
83 | 2.21.0 | 304 | 2.21.0 |
84 | 305 | ||
85 | 306 | diff view generated by jsdifflib |
1 | A snapshot is something that reflects the state of something at a | 1 | The error message for the test case where we have a quorum node for |
---|---|---|---|
2 | certain point in time. It does not change. | 2 | which no directory name can be generated is different: For |
3 | 3 | twoGbMaxExtentSparse, it complains that it cannot open the extent file. | |
4 | The file our snapshot commands create (or the node they install) is not | 4 | For other (sub)formats, it just notes that it cannot determine the |
5 | a snapshot, as it does change over time. It is an overlay. We cannot | 5 | backing file path. Both are fine, but just disable twoGbMaxExtentSparse |
6 | do anything about the parameter names, but we can at least adjust the | 6 | for simplicity's sake. |
7 | descriptions to reflect that fact. | ||
8 | 7 | ||
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 8 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
10 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
11 | Message-id: 20190603202236.1342-2-mreitz@redhat.com | ||
12 | Reviewed-by: John Snow <jsnow@redhat.com> | 9 | Reviewed-by: John Snow <jsnow@redhat.com> |
13 | Reviewed-by: Alberto Garcia <berto@igalia.com> | 10 | Message-id: 20190815153638.4600-7-mreitz@redhat.com |
11 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
14 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 12 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
15 | --- | 13 | --- |
16 | qapi/block-core.json | 20 ++++++++++---------- | 14 | tests/qemu-iotests/110 | 3 ++- |
17 | 1 file changed, 10 insertions(+), 10 deletions(-) | 15 | 1 file changed, 2 insertions(+), 1 deletion(-) |
18 | 16 | ||
19 | diff --git a/qapi/block-core.json b/qapi/block-core.json | 17 | diff --git a/tests/qemu-iotests/110 b/tests/qemu-iotests/110 |
20 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100755 |
21 | --- a/qapi/block-core.json | 19 | --- a/tests/qemu-iotests/110 |
22 | +++ b/qapi/block-core.json | 20 | +++ b/tests/qemu-iotests/110 |
23 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
24 | # | 22 | # Any format supporting backing files |
25 | # Either @device or @node-name must be set but not both. | 23 | _supported_fmt qed qcow qcow2 vmdk |
26 | # | 24 | _supported_proto file |
27 | -# @device: the name of the device to generate the snapshot from. | 25 | -_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" |
28 | +# @device: the name of the device to take a snapshot of. | 26 | +_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \ |
29 | # | 27 | + "subformat=twoGbMaxExtentSparse" |
30 | # @node-name: graph node name to generate the snapshot from (Since 2.0) | 28 | |
31 | # | 29 | TEST_IMG_REL=$(basename "$TEST_IMG") |
32 | -# @snapshot-file: the target of the new image. If the file exists, or | 30 | |
33 | -# if it is a device, the snapshot will be created in the existing | ||
34 | -# file/device. Otherwise, a new file will be created. | ||
35 | +# @snapshot-file: the target of the new overlay image. If the file | ||
36 | +# exists, or if it is a device, the overlay will be created in the | ||
37 | +# existing file/device. Otherwise, a new file will be created. | ||
38 | # | ||
39 | # @snapshot-node-name: the graph node name of the new image (Since 2.0) | ||
40 | # | ||
41 | -# @format: the format of the snapshot image, default is 'qcow2'. | ||
42 | +# @format: the format of the overlay image, default is 'qcow2'. | ||
43 | # | ||
44 | # @mode: whether and how QEMU should create a new image, default is | ||
45 | # 'absolute-paths'. | ||
46 | @@ -XXX,XX +XXX,XX @@ | ||
47 | ## | ||
48 | # @BlockdevSnapshot: | ||
49 | # | ||
50 | -# @node: device or node name that will have a snapshot created. | ||
51 | +# @node: device or node name that will have a snapshot taken. | ||
52 | # | ||
53 | # @overlay: reference to the existing block device that will become | ||
54 | -# the overlay of @node, as part of creating the snapshot. | ||
55 | +# the overlay of @node, as part of taking the snapshot. | ||
56 | # It must not have a current backing file (this can be | ||
57 | # achieved by passing "backing": null to blockdev-add). | ||
58 | # | ||
59 | @@ -XXX,XX +XXX,XX @@ | ||
60 | ## | ||
61 | # @blockdev-snapshot-sync: | ||
62 | # | ||
63 | -# Generates a synchronous snapshot of a block device. | ||
64 | +# Takes a synchronous snapshot of a block device. | ||
65 | # | ||
66 | # For the arguments, see the documentation of BlockdevSnapshotSync. | ||
67 | # | ||
68 | @@ -XXX,XX +XXX,XX @@ | ||
69 | ## | ||
70 | # @blockdev-snapshot: | ||
71 | # | ||
72 | -# Generates a snapshot of a block device. | ||
73 | +# Takes a snapshot of a block device. | ||
74 | # | ||
75 | -# Create a snapshot, by installing 'node' as the backing image of | ||
76 | +# Take a snapshot, by installing 'node' as the backing image of | ||
77 | # 'overlay'. Additionally, if 'node' is associated with a block | ||
78 | # device, the block device changes to using 'overlay' as its new active | ||
79 | # image. | ||
80 | -- | 31 | -- |
81 | 2.21.0 | 32 | 2.21.0 |
82 | 33 | ||
83 | 34 | diff view generated by jsdifflib |
1 | From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> | 1 | iotest 126 requires backing file support, which flat vmdks cannot offer. |
---|---|---|---|
2 | Skip this test for such subformats. | ||
2 | 3 | ||
3 | The uninitialized memory allocated for the command FIFO of the | 4 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
4 | floppy controller during the VM hardware initialization incurs | 5 | Message-id: 20190815153638.4600-8-mreitz@redhat.com |
5 | many unwanted reports by Valgrind when VM state is being saved. | ||
6 | That verbosity hardens a search for the real memory issues when | ||
7 | the iotests run. Particularly, the patch eliminates 20 unnecessary | ||
8 | reports of the Valgrind tool in the iotest #169. | ||
9 | |||
10 | Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> | ||
11 | Message-id: 1559154027-282547-1-git-send-email-andrey.shinkevich@virtuozzo.com | ||
12 | Reviewed-by: John Snow <jsnow@redhat.com> | 6 | Reviewed-by: John Snow <jsnow@redhat.com> |
13 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 7 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
14 | --- | 8 | --- |
15 | hw/block/fdc.c | 1 + | 9 | tests/qemu-iotests/126 | 2 ++ |
16 | 1 file changed, 1 insertion(+) | 10 | 1 file changed, 2 insertions(+) |
17 | 11 | ||
18 | diff --git a/hw/block/fdc.c b/hw/block/fdc.c | 12 | diff --git a/tests/qemu-iotests/126 b/tests/qemu-iotests/126 |
19 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100755 |
20 | --- a/hw/block/fdc.c | 14 | --- a/tests/qemu-iotests/126 |
21 | +++ b/hw/block/fdc.c | 15 | +++ b/tests/qemu-iotests/126 |
22 | @@ -XXX,XX +XXX,XX @@ static void fdctrl_realize_common(DeviceState *dev, FDCtrl *fdctrl, | 16 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! |
23 | 17 | ||
24 | FLOPPY_DPRINTF("init controller\n"); | 18 | # Needs backing file support |
25 | fdctrl->fifo = qemu_memalign(512, FD_SECTOR_LEN); | 19 | _supported_fmt qcow qcow2 qed vmdk |
26 | + memset(fdctrl->fifo, 0, FD_SECTOR_LEN); | 20 | +_unsupported_imgopts "subformat=monolithicFlat" \ |
27 | fdctrl->fifo_size = 512; | 21 | + "subformat=twoGbMaxExtentFlat" |
28 | fdctrl->result_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, | 22 | # This is the default protocol (and we want to test the difference between |
29 | fdctrl_result_timer, fdctrl); | 23 | # colons which separate a protocol prefix from the rest and colons which are |
24 | # just part of the filename, so we cannot test protocols which require a prefix) | ||
30 | -- | 25 | -- |
31 | 2.21.0 | 26 | 2.21.0 |
32 | 27 | ||
33 | 28 | diff view generated by jsdifflib |
1 | In 219, we wait for the job to make progress before we emit its status. | 1 | From: Stefan Hajnoczi <stefanha@redhat.com> |
---|---|---|---|
2 | This makes the output reliable. We do not wait for any more progress if | ||
3 | the job's current-progress already matches its total-progress. | ||
4 | 2 | ||
5 | Unfortunately, there is a bug: Right after the job has been started, | 3 | Fixes: a6b257a08e3d72219f03e461a52152672fec0612 |
6 | it's possible that total-progress is still 0. In that case, we may skip | 4 | ("file-posix: Handle undetectable alignment") |
7 | the first progress-making step and keep ending up 64 kB short. | 5 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
8 | 6 | Message-id: 20190827101328.4062-1-stefanha@redhat.com | |
9 | To fix that bug, we can simply wait for total-progress to reach 4 MB | 7 | Reviewed-by: Thomas Huth <thuth@redhat.com> |
10 | (the image size) after starting the job. | ||
11 | |||
12 | Reported-by: Karen Mezick <kmezick@redhat.com> | ||
13 | Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1686651 | ||
14 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
15 | Message-id: 20190516161114.27596-1-mreitz@redhat.com | ||
16 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
17 | [mreitz: Adjusted commit message as per John's proposal] | ||
18 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 8 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
19 | --- | 9 | --- |
20 | tests/qemu-iotests/219 | 13 ++++++++++--- | 10 | block/file-posix.c | 2 +- |
21 | 1 file changed, 10 insertions(+), 3 deletions(-) | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
22 | 12 | ||
23 | diff --git a/tests/qemu-iotests/219 b/tests/qemu-iotests/219 | 13 | diff --git a/block/file-posix.c b/block/file-posix.c |
24 | index XXXXXXX..XXXXXXX 100755 | 14 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/tests/qemu-iotests/219 | 15 | --- a/block/file-posix.c |
26 | +++ b/tests/qemu-iotests/219 | 16 | +++ b/block/file-posix.c |
27 | @@ -XXX,XX +XXX,XX @@ import iotests | 17 | @@ -XXX,XX +XXX,XX @@ static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp) |
28 | 18 | for (i = 0; i < ARRAY_SIZE(alignments); i++) { | |
29 | iotests.verify_image_format(supported_fmts=['qcow2']) | 19 | align = alignments[i]; |
30 | 20 | if (raw_is_io_aligned(fd, buf + align, max_align)) { | |
31 | +img_size = 4 * 1024 * 1024 | 21 | - /* Fallback to request_aligment. */ |
32 | + | 22 | + /* Fallback to request_alignment. */ |
33 | def pause_wait(vm, job_id): | 23 | s->buf_align = (align != 1) ? align : bs->bl.request_alignment; |
34 | with iotests.Timeout(3, "Timeout waiting for job to pause"): | 24 | break; |
35 | while True: | 25 | } |
36 | @@ -XXX,XX +XXX,XX @@ def test_pause_resume(vm): | ||
37 | iotests.log(vm.qmp('query-jobs')) | ||
38 | |||
39 | def test_job_lifecycle(vm, job, job_args, has_ready=False): | ||
40 | + global img_size | ||
41 | + | ||
42 | iotests.log('') | ||
43 | iotests.log('') | ||
44 | iotests.log('Starting block job: %s (auto-finalize: %s; auto-dismiss: %s)' % | ||
45 | @@ -XXX,XX +XXX,XX @@ def test_job_lifecycle(vm, job, job_args, has_ready=False): | ||
46 | iotests.log(iotests.filter_qmp_event(vm.event_wait('JOB_STATUS_CHANGE'))) | ||
47 | iotests.log(iotests.filter_qmp_event(vm.event_wait('JOB_STATUS_CHANGE'))) | ||
48 | |||
49 | + # Wait for total-progress to stabilize | ||
50 | + while vm.qmp('query-jobs')['return'][0]['total-progress'] < img_size: | ||
51 | + pass | ||
52 | + | ||
53 | # RUNNING state: | ||
54 | # pause/resume should work, complete/finalize/dismiss should error out | ||
55 | iotests.log('') | ||
56 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('disk.img') as disk_path, \ | ||
57 | iotests.FilePath('copy.img') as copy_path, \ | ||
58 | iotests.VM() as vm: | ||
59 | |||
60 | - img_size = '4M' | ||
61 | - iotests.qemu_img_create('-f', iotests.imgfmt, disk_path, img_size) | ||
62 | - iotests.qemu_io('-c', 'write 0 %s' % (img_size), | ||
63 | + iotests.qemu_img_create('-f', iotests.imgfmt, disk_path, str(img_size)) | ||
64 | + iotests.qemu_io('-c', 'write 0 %i' % (img_size), | ||
65 | '-f', iotests.imgfmt, disk_path) | ||
66 | |||
67 | iotests.log('Launching VM...') | ||
68 | -- | 26 | -- |
69 | 2.21.0 | 27 | 2.21.0 |
70 | 28 | ||
71 | 29 | diff view generated by jsdifflib |
1 | We do not support this combination (yet), so this should yield an error | 1 | From: Thomas Huth <thuth@redhat.com> |
---|---|---|---|
2 | message. | ||
3 | 2 | ||
4 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 3 | It is possible to enable only a subset of the block drivers with the |
5 | Tested-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 4 | "--block-drv-rw-whitelist" option of the "configure" script. All other |
6 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 5 | drivers are marked as unusable (or only included as read-only with the |
7 | Message-id: 20190507203508.18026-8-mreitz@redhat.com | 6 | "--block-drv-ro-whitelist" option). If an iotest is now using such a |
7 | disabled block driver, it is failing - which is bad, since at least the | ||
8 | tests in the "auto" group should be able to deal with this situation. | ||
9 | Thus let's introduce a "_require_drivers" function that can be used by | ||
10 | the shell tests to check for the availability of certain drivers first, | ||
11 | and marks the test as "not run" if one of the drivers is missing. | ||
12 | |||
13 | This patch mainly targets the test in the "auto" group which should | ||
14 | never fail in such a case, but also improves some of the other tests | ||
15 | along the way. Note that we also assume that the "qcow2" and "file" | ||
16 | drivers are always available - otherwise it does not make sense to | ||
17 | run "make check-block" at all (which only tests with qcow2 by default). | ||
18 | |||
19 | Signed-off-by: Thomas Huth <thuth@redhat.com> | ||
20 | Message-id: 20190823133552.11680-1-thuth@redhat.com | ||
8 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 21 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
9 | --- | 22 | --- |
10 | tests/qemu-iotests/082 | 1 + | 23 | tests/qemu-iotests/071 | 1 + |
11 | tests/qemu-iotests/082.out | 3 +++ | 24 | tests/qemu-iotests/081 | 4 +--- |
12 | 2 files changed, 4 insertions(+) | 25 | tests/qemu-iotests/099 | 1 + |
26 | tests/qemu-iotests/120 | 1 + | ||
27 | tests/qemu-iotests/162 | 4 +--- | ||
28 | tests/qemu-iotests/184 | 1 + | ||
29 | tests/qemu-iotests/186 | 1 + | ||
30 | tests/qemu-iotests/common.rc | 14 ++++++++++++++ | ||
31 | 8 files changed, 21 insertions(+), 6 deletions(-) | ||
13 | 32 | ||
14 | diff --git a/tests/qemu-iotests/082 b/tests/qemu-iotests/082 | 33 | diff --git a/tests/qemu-iotests/071 b/tests/qemu-iotests/071 |
15 | index XXXXXXX..XXXXXXX 100755 | 34 | index XXXXXXX..XXXXXXX 100755 |
16 | --- a/tests/qemu-iotests/082 | 35 | --- a/tests/qemu-iotests/071 |
17 | +++ b/tests/qemu-iotests/082 | 36 | +++ b/tests/qemu-iotests/071 |
18 | @@ -XXX,XX +XXX,XX @@ echo === convert: -C and other options === | 37 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
19 | run_qemu_img convert -C -S 4k -O $IMGFMT "$TEST_IMG" "$TEST_IMG".target | 38 | |
20 | run_qemu_img convert -C -S 8k -O $IMGFMT "$TEST_IMG" "$TEST_IMG".target | 39 | _supported_fmt qcow2 |
21 | run_qemu_img convert -C -c -O $IMGFMT "$TEST_IMG" "$TEST_IMG".target | 40 | _supported_proto file |
22 | +run_qemu_img convert -C --salvage -O $IMGFMT "$TEST_IMG" "$TEST_IMG".target | 41 | +_require_drivers blkdebug blkverify |
42 | |||
43 | do_run_qemu() | ||
44 | { | ||
45 | diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081 | ||
46 | index XXXXXXX..XXXXXXX 100755 | ||
47 | --- a/tests/qemu-iotests/081 | ||
48 | +++ b/tests/qemu-iotests/081 | ||
49 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
50 | _supported_fmt raw | ||
51 | _supported_proto file | ||
52 | _supported_os Linux | ||
53 | +_require_drivers quorum | ||
54 | |||
55 | do_run_qemu() | ||
56 | { | ||
57 | @@ -XXX,XX +XXX,XX @@ run_qemu() | ||
58 | | _filter_qemu_io | _filter_generated_node_ids | ||
59 | } | ||
60 | |||
61 | -test_quorum=$($QEMU_IMG --help|grep quorum) | ||
62 | -[ "$test_quorum" = "" ] && _supported_fmt quorum | ||
63 | - | ||
64 | quorum="driver=raw,file.driver=quorum,file.vote-threshold=2" | ||
65 | quorum="$quorum,file.children.0.file.filename=$TEST_DIR/1.raw" | ||
66 | quorum="$quorum,file.children.1.file.filename=$TEST_DIR/2.raw" | ||
67 | diff --git a/tests/qemu-iotests/099 b/tests/qemu-iotests/099 | ||
68 | index XXXXXXX..XXXXXXX 100755 | ||
69 | --- a/tests/qemu-iotests/099 | ||
70 | +++ b/tests/qemu-iotests/099 | ||
71 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
72 | _supported_fmt qcow qcow2 qed vdi vhdx vmdk vpc | ||
73 | _supported_proto file | ||
74 | _supported_os Linux | ||
75 | +_require_drivers blkdebug blkverify | ||
76 | _unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \ | ||
77 | "subformat=twoGbMaxExtentSparse" | ||
78 | |||
79 | diff --git a/tests/qemu-iotests/120 b/tests/qemu-iotests/120 | ||
80 | index XXXXXXX..XXXXXXX 100755 | ||
81 | --- a/tests/qemu-iotests/120 | ||
82 | +++ b/tests/qemu-iotests/120 | ||
83 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
84 | _supported_fmt generic | ||
85 | _supported_proto file | ||
86 | _unsupported_fmt luks | ||
87 | +_require_drivers raw | ||
88 | |||
89 | _make_test_img 64M | ||
90 | |||
91 | diff --git a/tests/qemu-iotests/162 b/tests/qemu-iotests/162 | ||
92 | index XXXXXXX..XXXXXXX 100755 | ||
93 | --- a/tests/qemu-iotests/162 | ||
94 | +++ b/tests/qemu-iotests/162 | ||
95 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
96 | . ./common.filter | ||
97 | |||
98 | _supported_fmt generic | ||
99 | - | ||
100 | -test_ssh=$($QEMU_IMG --help | grep '^Supported formats:.* ssh\( \|$\)') | ||
101 | -[ "$test_ssh" = "" ] && _notrun "ssh support required" | ||
102 | +_require_drivers ssh | ||
23 | 103 | ||
24 | echo | 104 | echo |
25 | echo === amend: Options specified more than once === | 105 | echo '=== NBD ===' |
26 | diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out | 106 | diff --git a/tests/qemu-iotests/184 b/tests/qemu-iotests/184 |
107 | index XXXXXXX..XXXXXXX 100755 | ||
108 | --- a/tests/qemu-iotests/184 | ||
109 | +++ b/tests/qemu-iotests/184 | ||
110 | @@ -XXX,XX +XXX,XX @@ trap "exit \$status" 0 1 2 3 15 | ||
111 | . ./common.filter | ||
112 | |||
113 | _supported_os Linux | ||
114 | +_require_drivers throttle | ||
115 | |||
116 | do_run_qemu() | ||
117 | { | ||
118 | diff --git a/tests/qemu-iotests/186 b/tests/qemu-iotests/186 | ||
119 | index XXXXXXX..XXXXXXX 100755 | ||
120 | --- a/tests/qemu-iotests/186 | ||
121 | +++ b/tests/qemu-iotests/186 | ||
122 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
123 | |||
124 | _supported_fmt qcow2 | ||
125 | _supported_proto file | ||
126 | +_require_drivers null-co | ||
127 | |||
128 | if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then | ||
129 | _notrun "Requires a PC machine" | ||
130 | diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc | ||
27 | index XXXXXXX..XXXXXXX 100644 | 131 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/tests/qemu-iotests/082.out | 132 | --- a/tests/qemu-iotests/common.rc |
29 | +++ b/tests/qemu-iotests/082.out | 133 | +++ b/tests/qemu-iotests/common.rc |
30 | @@ -XXX,XX +XXX,XX @@ qemu-img: Cannot enable copy offloading when -S is used | 134 | @@ -XXX,XX +XXX,XX @@ _require_command() |
31 | Testing: convert -C -c -O qcow2 TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.target | 135 | [ -x "$c" ] || _notrun "$1 utility required, skipped this test" |
32 | qemu-img: Cannot enable copy offloading when -c is used | 136 | } |
33 | 137 | ||
34 | +Testing: convert -C --salvage -O qcow2 TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.target | 138 | +# Check that a set of drivers has been whitelisted in the QEMU binary |
35 | +qemu-img: Cannot use copy offloading in salvaging mode | 139 | +# |
140 | +_require_drivers() | ||
141 | +{ | ||
142 | + available=$($QEMU -drive format=help | \ | ||
143 | + sed -e '/Supported formats:/!d' -e 's/Supported formats://') | ||
144 | + for driver | ||
145 | + do | ||
146 | + if ! echo "$available" | grep -q " $driver\( \|$\)"; then | ||
147 | + _notrun "$driver not available" | ||
148 | + fi | ||
149 | + done | ||
150 | +} | ||
36 | + | 151 | + |
37 | === amend: Options specified more than once === | 152 | # make sure this script returns success |
38 | 153 | true | |
39 | Testing: amend -f foo -f qcow2 -o lazy_refcounts=on TEST_DIR/t.qcow2 | ||
40 | -- | 154 | -- |
41 | 2.21.0 | 155 | 2.21.0 |
42 | 156 | ||
43 | 157 | diff view generated by jsdifflib |
1 | This test converts a simple image to another, but blkdebug injects | 1 | From: Thomas Huth <thuth@redhat.com> |
---|---|---|---|
2 | block_status and read faults at some offsets. The resulting image | ||
3 | should be the same as the input image, except that sectors that could | ||
4 | not be read have to be 0. | ||
5 | 2 | ||
6 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 3 | The sanitizers (especially the address sanitizer from Clang) are |
7 | Message-id: 20190507203508.18026-7-mreitz@redhat.com | 4 | sometimes printing out warnings or false positives - this spoils |
8 | Tested-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 5 | the output of the iotests, causing some of the tests to fail. |
9 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 6 | Thus let's skip the automatic iotests during "make check" when the |
10 | [mreitz: Dropped superfluous printf from _filter_offsets, as suggested | 7 | user configured QEMU with --enable-sanitizers. |
11 | by Vladimir; disable test for VDI and IMGOPTSSYNTAX] | 8 | |
9 | Signed-off-by: Thomas Huth <thuth@redhat.com> | ||
10 | Message-id: 20190823084203.29734-1-thuth@redhat.com | ||
12 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 11 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
13 | --- | 12 | --- |
14 | tests/qemu-iotests/251 | 170 +++++++++++++++++++++++++++++++++++++ | 13 | tests/check-block.sh | 5 +++++ |
15 | tests/qemu-iotests/251.out | 43 ++++++++++ | 14 | 1 file changed, 5 insertions(+) |
16 | tests/qemu-iotests/group | 1 + | ||
17 | 3 files changed, 214 insertions(+) | ||
18 | create mode 100755 tests/qemu-iotests/251 | ||
19 | create mode 100644 tests/qemu-iotests/251.out | ||
20 | 15 | ||
21 | diff --git a/tests/qemu-iotests/251 b/tests/qemu-iotests/251 | 16 | diff --git a/tests/check-block.sh b/tests/check-block.sh |
22 | new file mode 100755 | 17 | index XXXXXXX..XXXXXXX 100755 |
23 | index XXXXXXX..XXXXXXX | 18 | --- a/tests/check-block.sh |
24 | --- /dev/null | 19 | +++ b/tests/check-block.sh |
25 | +++ b/tests/qemu-iotests/251 | 20 | @@ -XXX,XX +XXX,XX @@ if grep -q "TARGET_GPROF=y" *-softmmu/config-target.mak 2>/dev/null ; then |
26 | @@ -XXX,XX +XXX,XX @@ | 21 | exit 0 |
27 | +#!/usr/bin/env bash | 22 | fi |
28 | +# | 23 | |
29 | +# Test qemu-img convert --salvage | 24 | +if grep -q "CFLAGS.*-fsanitize" config-host.mak 2>/dev/null ; then |
30 | +# | 25 | + echo "Sanitizers are enabled ==> Not running the qemu-iotests." |
31 | +# Copyright (C) 2019 Red Hat, Inc. | 26 | + exit 0 |
32 | +# | ||
33 | +# This program is free software; you can redistribute it and/or modify | ||
34 | +# it under the terms of the GNU General Public License as published by | ||
35 | +# the Free Software Foundation; either version 2 of the License, or | ||
36 | +# (at your option) any later version. | ||
37 | +# | ||
38 | +# This program is distributed in the hope that it will be useful, | ||
39 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
40 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
41 | +# GNU General Public License for more details. | ||
42 | +# | ||
43 | +# You should have received a copy of the GNU General Public License | ||
44 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
45 | +# | ||
46 | + | ||
47 | +# creator | ||
48 | +owner=mreitz@redhat.com | ||
49 | + | ||
50 | +seq=$(basename $0) | ||
51 | +echo "QA output created by $seq" | ||
52 | + | ||
53 | +status=1 # failure is the default! | ||
54 | + | ||
55 | +_cleanup() | ||
56 | +{ | ||
57 | + _cleanup_test_img | ||
58 | +} | ||
59 | +trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
60 | + | ||
61 | +# get standard environment, filters and checks | ||
62 | +. ./common.rc | ||
63 | +. ./common.filter | ||
64 | +. ./common.qemu | ||
65 | + | ||
66 | +_supported_fmt generic | ||
67 | +_supported_proto file | ||
68 | +_supported_os Linux | ||
69 | + | ||
70 | +if [ "$IMGOPTSSYNTAX" = "true" ]; then | ||
71 | + # We use json:{} filenames here, so we cannot work with additional options. | ||
72 | + _unsupported_fmt $IMGFMT | ||
73 | +else | ||
74 | + # With VDI, the output is ordered differently. Just disable it. | ||
75 | + _unsupported_fmt vdi | ||
76 | +fi | 27 | +fi |
77 | + | 28 | + |
78 | + | 29 | if [ -z "$(find . -name 'qemu-system-*' -print)" ]; then |
79 | +TEST_IMG="$TEST_IMG.orig" _make_test_img 64M | 30 | echo "No qemu-system binary available ==> Not running the qemu-iotests." |
80 | + | 31 | exit 0 |
81 | +$QEMU_IO -c 'write -P 42 0 64M' "$TEST_IMG.orig" | _filter_qemu_io | ||
82 | + | ||
83 | + | ||
84 | +sector_size=512 | ||
85 | + | ||
86 | +# Offsets on which to fail block-status. Keep in ascending order so | ||
87 | +# the indexing done by _filter_offsets will appear in ascending order | ||
88 | +# in the output as well. | ||
89 | +status_fail_offsets="$((16 * 1024 * 1024 + 8192)) | ||
90 | + $((33 * 1024 * 1024 + 512))" | ||
91 | + | ||
92 | +# Offsets on which to fail reads. Keep in ascending order for the | ||
93 | +# same reason. | ||
94 | +# The second element is shared with $status_fail_offsets on purpose. | ||
95 | +# Starting with the third element, we test what happens when a | ||
96 | +# continuous range of sectors is inaccessible. | ||
97 | +read_fail_offsets="$((32 * 1024 * 1024 - 65536)) | ||
98 | + $((33 * 1024 * 1024 + 512)) | ||
99 | + $(seq $((34 * 1024 * 1024)) $sector_size \ | ||
100 | + $((34 * 1024 * 1024 + 4096 - $sector_size)))" | ||
101 | + | ||
102 | + | ||
103 | +# blkdebug must be above the format layer so it can intercept all | ||
104 | +# block-status events | ||
105 | +source_img="json:{'driver': 'blkdebug', | ||
106 | + 'image': { | ||
107 | + 'driver': '$IMGFMT', | ||
108 | + 'file': { | ||
109 | + 'driver': 'file', | ||
110 | + 'filename': '$TEST_IMG.orig' | ||
111 | + } | ||
112 | + }, | ||
113 | + 'inject-error': [" | ||
114 | + | ||
115 | +for ofs in $status_fail_offsets | ||
116 | +do | ||
117 | + source_img+="{ 'event': 'none', | ||
118 | + 'iotype': 'block-status', | ||
119 | + 'errno': 5, | ||
120 | + 'sector': $((ofs / sector_size)) }," | ||
121 | +done | ||
122 | + | ||
123 | +for ofs in $read_fail_offsets | ||
124 | +do | ||
125 | + source_img+="{ 'event': 'none', | ||
126 | + 'iotype': 'read', | ||
127 | + 'errno': 5, | ||
128 | + 'sector': $((ofs / sector_size)) }," | ||
129 | +done | ||
130 | + | ||
131 | +# Remove the trailing comma and terminate @inject-error and json:{} | ||
132 | +source_img="${source_img%,} ] }" | ||
133 | + | ||
134 | + | ||
135 | +echo | ||
136 | + | ||
137 | + | ||
138 | +_filter_offsets() { | ||
139 | + filters= | ||
140 | + | ||
141 | + index=0 | ||
142 | + for ofs in $1 | ||
143 | + do | ||
144 | + filters+=" -e s/$ofs/status_fail_offset_$index/" | ||
145 | + index=$((index + 1)) | ||
146 | + done | ||
147 | + | ||
148 | + index=0 | ||
149 | + for ofs in $2 | ||
150 | + do | ||
151 | + filters+=" -e s/$ofs/read_fail_offset_$index/" | ||
152 | + index=$((index + 1)) | ||
153 | + done | ||
154 | + | ||
155 | + sed $filters | ||
156 | +} | ||
157 | + | ||
158 | +# While determining the number of allocated sectors in the input | ||
159 | +# image, we should see one block status warning per element of | ||
160 | +# $status_fail_offsets. | ||
161 | +# | ||
162 | +# Then, the image is read. Since the block status is queried in | ||
163 | +# basically the same way, the same warnings as in the previous step | ||
164 | +# should reappear. Interleaved with those we should see a read | ||
165 | +# warning per element of $read_fail_offsets. | ||
166 | +# Note that $read_fail_offsets and $status_fail_offsets share an | ||
167 | +# element (read_fail_offset_1 == status_fail_offset_1), so | ||
168 | +# "status_fail_offset_1" in the output is the same as | ||
169 | +# "read_fail_offset_1". | ||
170 | +$QEMU_IMG convert --salvage "$source_img" "$TEST_IMG" 2>&1 \ | ||
171 | + | _filter_offsets "$status_fail_offsets" "$read_fail_offsets" | ||
172 | + | ||
173 | +echo | ||
174 | + | ||
175 | +# The offsets where the block status could not be determined should | ||
176 | +# have been treated as containing data and thus should be correct in | ||
177 | +# the output image. | ||
178 | +# The offsets where reading failed altogether should be 0. Make them | ||
179 | +# 0 in the input image, too, so we can compare both images. | ||
180 | +for ofs in $read_fail_offsets | ||
181 | +do | ||
182 | + $QEMU_IO -c "write -z $ofs $sector_size" "$TEST_IMG.orig" \ | ||
183 | + | _filter_qemu_io \ | ||
184 | + | _filter_offsets '' "$read_fail_offsets" | ||
185 | +done | ||
186 | + | ||
187 | +echo | ||
188 | + | ||
189 | +# These should be equal now. | ||
190 | +$QEMU_IMG compare "$TEST_IMG.orig" "$TEST_IMG" | ||
191 | + | ||
192 | + | ||
193 | +# success, all done | ||
194 | +echo "*** done" | ||
195 | +rm -f $seq.full | ||
196 | +status=0 | ||
197 | diff --git a/tests/qemu-iotests/251.out b/tests/qemu-iotests/251.out | ||
198 | new file mode 100644 | ||
199 | index XXXXXXX..XXXXXXX | ||
200 | --- /dev/null | ||
201 | +++ b/tests/qemu-iotests/251.out | ||
202 | @@ -XXX,XX +XXX,XX @@ | ||
203 | +QA output created by 251 | ||
204 | +Formatting 'TEST_DIR/t.IMGFMT.orig', fmt=IMGFMT size=67108864 | ||
205 | +wrote 67108864/67108864 bytes at offset 0 | ||
206 | +64 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
207 | + | ||
208 | +qemu-img: warning: error while reading block status at offset status_fail_offset_0: Input/output error | ||
209 | +qemu-img: warning: error while reading block status at offset status_fail_offset_1: Input/output error | ||
210 | +qemu-img: warning: error while reading block status at offset status_fail_offset_0: Input/output error | ||
211 | +qemu-img: warning: error while reading offset read_fail_offset_0: Input/output error | ||
212 | +qemu-img: warning: error while reading block status at offset status_fail_offset_1: Input/output error | ||
213 | +qemu-img: warning: error while reading offset status_fail_offset_1: Input/output error | ||
214 | +qemu-img: warning: error while reading offset read_fail_offset_2: Input/output error | ||
215 | +qemu-img: warning: error while reading offset read_fail_offset_3: Input/output error | ||
216 | +qemu-img: warning: error while reading offset read_fail_offset_4: Input/output error | ||
217 | +qemu-img: warning: error while reading offset read_fail_offset_5: Input/output error | ||
218 | +qemu-img: warning: error while reading offset read_fail_offset_6: Input/output error | ||
219 | +qemu-img: warning: error while reading offset read_fail_offset_7: Input/output error | ||
220 | +qemu-img: warning: error while reading offset read_fail_offset_8: Input/output error | ||
221 | +qemu-img: warning: error while reading offset read_fail_offset_9: Input/output error | ||
222 | + | ||
223 | +wrote 512/512 bytes at offset read_fail_offset_0 | ||
224 | +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
225 | +wrote 512/512 bytes at offset read_fail_offset_1 | ||
226 | +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
227 | +wrote 512/512 bytes at offset read_fail_offset_2 | ||
228 | +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
229 | +wrote 512/512 bytes at offset read_fail_offset_3 | ||
230 | +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
231 | +wrote 512/512 bytes at offset read_fail_offset_4 | ||
232 | +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
233 | +wrote 512/512 bytes at offset read_fail_offset_5 | ||
234 | +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
235 | +wrote 512/512 bytes at offset read_fail_offset_6 | ||
236 | +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
237 | +wrote 512/512 bytes at offset read_fail_offset_7 | ||
238 | +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
239 | +wrote 512/512 bytes at offset read_fail_offset_8 | ||
240 | +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
241 | +wrote 512/512 bytes at offset read_fail_offset_9 | ||
242 | +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
243 | + | ||
244 | +Images are identical. | ||
245 | +*** done | ||
246 | diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group | ||
247 | index XXXXXXX..XXXXXXX 100644 | ||
248 | --- a/tests/qemu-iotests/group | ||
249 | +++ b/tests/qemu-iotests/group | ||
250 | @@ -XXX,XX +XXX,XX @@ | ||
251 | 248 rw quick | ||
252 | 249 rw auto quick | ||
253 | 250 rw auto quick | ||
254 | +251 rw auto quick | ||
255 | 252 rw auto backing quick | ||
256 | 253 rw auto quick | ||
257 | 254 rw auto backing quick | ||
258 | -- | 32 | -- |
259 | 2.21.0 | 33 | 2.21.0 |
260 | 34 | ||
261 | 35 | diff view generated by jsdifflib |
1 | From: John Snow <jsnow@redhat.com> | 1 | From: Nir Soffer <nirsof@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | in blockdev_backup_prepare, we check to make sure that the target is | 3 | Quoting cache mode is not needed, and most tests use unquoted values. |
4 | associated with a compatible aio context. However, do_blockdev_backup is | 4 | Unify all test to use the same style. |
5 | called later and has some logic to move the target to a compatible | ||
6 | aio_context. The transaction version will fail certain commands | ||
7 | needlessly early as a result. | ||
8 | 5 | ||
9 | Allow blockdev_backup_prepare to simply call do_blockdev_backup, which | 6 | Message-id: 20190827173432.7656-1-nsoffer@redhat.com |
10 | will ultimately decide if the contexts are compatible or not. | 7 | Signed-off-by: Nir Soffer <nsoffer@redhat.com> |
11 | |||
12 | Note: the transaction version has always disallowed this operation since | ||
13 | its initial commit bd8baecd (2014), whereas the version of | ||
14 | qmp_blockdev_backup at the time, from commit c29c1dd312f, tried to | ||
15 | enforce the aio_context switch instead. It's not clear, and I can't see | ||
16 | from the mailing list archives at the time, why the two functions take a | ||
17 | different approach. It wasn't until later in efd7556708b (2016) that the | ||
18 | standalone version tried to determine if it could set the context or | ||
19 | not. | ||
20 | |||
21 | Reported-by: aihua liang <aliang@redhat.com> | ||
22 | Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1683498 | ||
23 | Signed-off-by: John Snow <jsnow@redhat.com> | ||
24 | Message-id: 20190523170643.20794-2-jsnow@redhat.com | ||
25 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
26 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 8 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
27 | --- | 9 | --- |
28 | blockdev.c | 4 ---- | 10 | tests/qemu-iotests/026 | 4 ++-- |
29 | 1 file changed, 4 deletions(-) | 11 | tests/qemu-iotests/039 | 4 ++-- |
12 | tests/qemu-iotests/052 | 2 +- | ||
13 | tests/qemu-iotests/091 | 4 ++-- | ||
14 | 4 files changed, 7 insertions(+), 7 deletions(-) | ||
30 | 15 | ||
31 | diff --git a/blockdev.c b/blockdev.c | 16 | diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026 |
32 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100755 |
33 | --- a/blockdev.c | 18 | --- a/tests/qemu-iotests/026 |
34 | +++ b/blockdev.c | 19 | +++ b/tests/qemu-iotests/026 |
35 | @@ -XXX,XX +XXX,XX @@ static void blockdev_backup_prepare(BlkActionState *common, Error **errp) | 20 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
36 | } | 21 | # Currently only qcow2 supports rebasing |
37 | 22 | _supported_fmt qcow2 | |
38 | aio_context = bdrv_get_aio_context(bs); | 23 | _supported_proto file |
39 | - if (aio_context != bdrv_get_aio_context(target)) { | 24 | -_default_cache_mode "writethrough" |
40 | - error_setg(errp, "Backup between two IO threads is not implemented"); | 25 | -_supported_cache_modes "writethrough" "none" |
41 | - return; | 26 | +_default_cache_mode writethrough |
42 | - } | 27 | +_supported_cache_modes writethrough none |
43 | aio_context_acquire(aio_context); | 28 | # The refcount table tests expect a certain minimum width for refcount entries |
44 | state->bs = bs; | 29 | # (so that the refcount table actually needs to grow); that minimum is 16 bits, |
30 | # being the default refcount entry width. | ||
31 | diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039 | ||
32 | index XXXXXXX..XXXXXXX 100755 | ||
33 | --- a/tests/qemu-iotests/039 | ||
34 | +++ b/tests/qemu-iotests/039 | ||
35 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
36 | _supported_fmt qcow2 | ||
37 | _supported_proto file | ||
38 | _supported_os Linux | ||
39 | -_default_cache_mode "writethrough" | ||
40 | -_supported_cache_modes "writethrough" | ||
41 | +_default_cache_mode writethrough | ||
42 | +_supported_cache_modes writethrough | ||
43 | |||
44 | size=128M | ||
45 | |||
46 | diff --git a/tests/qemu-iotests/052 b/tests/qemu-iotests/052 | ||
47 | index XXXXXXX..XXXXXXX 100755 | ||
48 | --- a/tests/qemu-iotests/052 | ||
49 | +++ b/tests/qemu-iotests/052 | ||
50 | @@ -XXX,XX +XXX,XX @@ _supported_fmt generic | ||
51 | _supported_proto file | ||
52 | |||
53 | # Don't do O_DIRECT on tmpfs | ||
54 | -_supported_cache_modes "writeback" "writethrough" "unsafe" | ||
55 | +_supported_cache_modes writeback writethrough unsafe | ||
56 | |||
57 | size=128M | ||
58 | _make_test_img $size | ||
59 | diff --git a/tests/qemu-iotests/091 b/tests/qemu-iotests/091 | ||
60 | index XXXXXXX..XXXXXXX 100755 | ||
61 | --- a/tests/qemu-iotests/091 | ||
62 | +++ b/tests/qemu-iotests/091 | ||
63 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
64 | _supported_fmt qcow2 | ||
65 | _supported_proto file | ||
66 | _supported_os Linux | ||
67 | -_default_cache_mode "none" | ||
68 | -_supported_cache_modes "writethrough" "none" "writeback" | ||
69 | +_default_cache_mode none | ||
70 | +_supported_cache_modes writethrough none writeback | ||
71 | |||
72 | size=1G | ||
45 | 73 | ||
46 | -- | 74 | -- |
47 | 2.21.0 | 75 | 2.21.0 |
48 | 76 | ||
49 | 77 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: John Snow <jsnow@redhat.com> | ||
2 | 1 | ||
3 | Cap waits to 60 seconds so that iotests can fail gracefully if something | ||
4 | goes wrong. | ||
5 | |||
6 | Signed-off-by: John Snow <jsnow@redhat.com> | ||
7 | Message-id: 20190523170643.20794-3-jsnow@redhat.com | ||
8 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
10 | --- | ||
11 | tests/qemu-iotests/iotests.py | 14 +++++++------- | ||
12 | 1 file changed, 7 insertions(+), 7 deletions(-) | ||
13 | |||
14 | diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/tests/qemu-iotests/iotests.py | ||
17 | +++ b/tests/qemu-iotests/iotests.py | ||
18 | @@ -XXX,XX +XXX,XX @@ class VM(qtest.QEMUQtestMachine): | ||
19 | output_list += [key + '=' + obj[key]] | ||
20 | return ','.join(output_list) | ||
21 | |||
22 | - def get_qmp_events_filtered(self, wait=True): | ||
23 | + def get_qmp_events_filtered(self, wait=60.0): | ||
24 | result = [] | ||
25 | for ev in self.get_qmp_events(wait=wait): | ||
26 | result.append(filter_qmp_event(ev)) | ||
27 | @@ -XXX,XX +XXX,XX @@ class VM(qtest.QEMUQtestMachine): | ||
28 | |||
29 | # Returns None on success, and an error string on failure | ||
30 | def run_job(self, job, auto_finalize=True, auto_dismiss=False, | ||
31 | - pre_finalize=None): | ||
32 | + pre_finalize=None, wait=60.0): | ||
33 | error = None | ||
34 | while True: | ||
35 | - for ev in self.get_qmp_events_filtered(wait=True): | ||
36 | + for ev in self.get_qmp_events_filtered(wait=wait): | ||
37 | if ev['event'] == 'JOB_STATUS_CHANGE': | ||
38 | status = ev['data']['status'] | ||
39 | if status == 'aborting': | ||
40 | @@ -XXX,XX +XXX,XX @@ class QMPTestCase(unittest.TestCase): | ||
41 | self.assertEqual(self.vm.flatten_qmp_object(json.loads(json_filename[5:])), | ||
42 | self.vm.flatten_qmp_object(reference)) | ||
43 | |||
44 | - def cancel_and_wait(self, drive='drive0', force=False, resume=False): | ||
45 | + def cancel_and_wait(self, drive='drive0', force=False, resume=False, wait=60.0): | ||
46 | '''Cancel a block job and wait for it to finish, returning the event''' | ||
47 | result = self.vm.qmp('block-job-cancel', device=drive, force=force) | ||
48 | self.assert_qmp(result, 'return', {}) | ||
49 | @@ -XXX,XX +XXX,XX @@ class QMPTestCase(unittest.TestCase): | ||
50 | cancelled = False | ||
51 | result = None | ||
52 | while not cancelled: | ||
53 | - for event in self.vm.get_qmp_events(wait=True): | ||
54 | + for event in self.vm.get_qmp_events(wait=wait): | ||
55 | if event['event'] == 'BLOCK_JOB_COMPLETED' or \ | ||
56 | event['event'] == 'BLOCK_JOB_CANCELLED': | ||
57 | self.assert_qmp(event, 'data/device', drive) | ||
58 | @@ -XXX,XX +XXX,XX @@ class QMPTestCase(unittest.TestCase): | ||
59 | self.assert_no_active_block_jobs() | ||
60 | return result | ||
61 | |||
62 | - def wait_until_completed(self, drive='drive0', check_offset=True): | ||
63 | + def wait_until_completed(self, drive='drive0', check_offset=True, wait=60.0): | ||
64 | '''Wait for a block job to finish, returning the event''' | ||
65 | while True: | ||
66 | - for event in self.vm.get_qmp_events(wait=True): | ||
67 | + for event in self.vm.get_qmp_events(wait=wait): | ||
68 | if event['event'] == 'BLOCK_JOB_COMPLETED': | ||
69 | self.assert_qmp(event, 'data/device', drive) | ||
70 | self.assert_qmp_absent(event, 'data/error') | ||
71 | -- | ||
72 | 2.21.0 | ||
73 | |||
74 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: John Snow <jsnow@redhat.com> | ||
2 | 1 | ||
3 | Instead of event_wait which looks for a single event, add an events_wait | ||
4 | which can look for any number of events simultaneously. However, it | ||
5 | will still only return one at a time, whichever happens first. | ||
6 | |||
7 | Signed-off-by: John Snow <jsnow@redhat.com> | ||
8 | Message-id: 20190523170643.20794-4-jsnow@redhat.com | ||
9 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
10 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
11 | --- | ||
12 | python/qemu/__init__.py | 69 +++++++++++++++++++++++++++++------------ | ||
13 | 1 file changed, 49 insertions(+), 20 deletions(-) | ||
14 | |||
15 | diff --git a/python/qemu/__init__.py b/python/qemu/__init__.py | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/python/qemu/__init__.py | ||
18 | +++ b/python/qemu/__init__.py | ||
19 | @@ -XXX,XX +XXX,XX @@ class QEMUMachine(object): | ||
20 | self._qmp.clear_events() | ||
21 | return events | ||
22 | |||
23 | - def event_wait(self, name, timeout=60.0, match=None): | ||
24 | + @staticmethod | ||
25 | + def event_match(event, match=None): | ||
26 | """ | ||
27 | - Wait for specified timeout on named event in QMP; optionally filter | ||
28 | - results by match. | ||
29 | + Check if an event matches optional match criteria. | ||
30 | |||
31 | - The 'match' is checked to be a recursive subset of the 'event'; skips | ||
32 | - branch processing on match's value None | ||
33 | - {"foo": {"bar": 1}} matches {"foo": None} | ||
34 | - {"foo": {"bar": 1}} does not matches {"foo": {"baz": None}} | ||
35 | + The match criteria takes the form of a matching subdict. The event is | ||
36 | + checked to be a superset of the subdict, recursively, with matching | ||
37 | + values whenever those values are not None. | ||
38 | + | ||
39 | + Examples, with the subdict queries on the left: | ||
40 | + - None matches any object. | ||
41 | + - {"foo": None} matches {"foo": {"bar": 1}} | ||
42 | + - {"foo": {"baz": None}} does not match {"foo": {"bar": 1}} | ||
43 | + - {"foo": {"baz": 2}} matches {"foo": {"bar": 1, "baz": 2}} | ||
44 | """ | ||
45 | - def event_match(event, match=None): | ||
46 | - if match is None: | ||
47 | - return True | ||
48 | + if match is None: | ||
49 | + return True | ||
50 | |||
51 | - for key in match: | ||
52 | - if key in event: | ||
53 | - if isinstance(event[key], dict): | ||
54 | - if not event_match(event[key], match[key]): | ||
55 | - return False | ||
56 | - elif event[key] != match[key]: | ||
57 | + for key in match: | ||
58 | + if key in event: | ||
59 | + if isinstance(event[key], dict): | ||
60 | + if not QEMUMachine.event_match(event[key], match[key]): | ||
61 | return False | ||
62 | - else: | ||
63 | + elif event[key] != match[key]: | ||
64 | return False | ||
65 | + else: | ||
66 | + return False | ||
67 | + return True | ||
68 | |||
69 | - return True | ||
70 | + def event_wait(self, name, timeout=60.0, match=None): | ||
71 | + """ | ||
72 | + event_wait waits for and returns a named event from QMP with a timeout. | ||
73 | + | ||
74 | + name: The event to wait for. | ||
75 | + timeout: QEMUMonitorProtocol.pull_event timeout parameter. | ||
76 | + match: Optional match criteria. See event_match for details. | ||
77 | + """ | ||
78 | + return self.events_wait([(name, match)], timeout) | ||
79 | + | ||
80 | + def events_wait(self, events, timeout=60.0): | ||
81 | + """ | ||
82 | + events_wait waits for and returns a named event from QMP with a timeout. | ||
83 | + | ||
84 | + events: a sequence of (name, match_criteria) tuples. | ||
85 | + The match criteria are optional and may be None. | ||
86 | + See event_match for details. | ||
87 | + timeout: QEMUMonitorProtocol.pull_event timeout parameter. | ||
88 | + """ | ||
89 | + def _match(event): | ||
90 | + for name, match in events: | ||
91 | + if (event['event'] == name and | ||
92 | + self.event_match(event, match)): | ||
93 | + return True | ||
94 | + return False | ||
95 | |||
96 | # Search cached events | ||
97 | for event in self._events: | ||
98 | - if (event['event'] == name) and event_match(event, match): | ||
99 | + if _match(event): | ||
100 | self._events.remove(event) | ||
101 | return event | ||
102 | |||
103 | # Poll for new events | ||
104 | while True: | ||
105 | event = self._qmp.pull_event(wait=timeout) | ||
106 | - if (event['event'] == name) and event_match(event, match): | ||
107 | + if _match(event): | ||
108 | return event | ||
109 | self._events.append(event) | ||
110 | |||
111 | -- | ||
112 | 2.21.0 | ||
113 | |||
114 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: John Snow <jsnow@redhat.com> | ||
2 | 1 | ||
3 | Don't pull events out of the queue that don't belong to us; | ||
4 | be choosier so that we can use this method to drive jobs that | ||
5 | were launched by transactions that may have more jobs. | ||
6 | |||
7 | Signed-off-by: John Snow <jsnow@redhat.com> | ||
8 | Message-id: 20190523170643.20794-5-jsnow@redhat.com | ||
9 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
10 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
11 | --- | ||
12 | tests/qemu-iotests/iotests.py | 48 +++++++++++++++++++++-------------- | ||
13 | 1 file changed, 29 insertions(+), 19 deletions(-) | ||
14 | |||
15 | diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/tests/qemu-iotests/iotests.py | ||
18 | +++ b/tests/qemu-iotests/iotests.py | ||
19 | @@ -XXX,XX +XXX,XX @@ class VM(qtest.QEMUQtestMachine): | ||
20 | # Returns None on success, and an error string on failure | ||
21 | def run_job(self, job, auto_finalize=True, auto_dismiss=False, | ||
22 | pre_finalize=None, wait=60.0): | ||
23 | + match_device = {'data': {'device': job}} | ||
24 | + match_id = {'data': {'id': job}} | ||
25 | + events = [ | ||
26 | + ('BLOCK_JOB_COMPLETED', match_device), | ||
27 | + ('BLOCK_JOB_CANCELLED', match_device), | ||
28 | + ('BLOCK_JOB_ERROR', match_device), | ||
29 | + ('BLOCK_JOB_READY', match_device), | ||
30 | + ('BLOCK_JOB_PENDING', match_id), | ||
31 | + ('JOB_STATUS_CHANGE', match_id) | ||
32 | + ] | ||
33 | error = None | ||
34 | while True: | ||
35 | - for ev in self.get_qmp_events_filtered(wait=wait): | ||
36 | - if ev['event'] == 'JOB_STATUS_CHANGE': | ||
37 | - status = ev['data']['status'] | ||
38 | - if status == 'aborting': | ||
39 | - result = self.qmp('query-jobs') | ||
40 | - for j in result['return']: | ||
41 | - if j['id'] == job: | ||
42 | - error = j['error'] | ||
43 | - log('Job failed: %s' % (j['error'])) | ||
44 | - elif status == 'pending' and not auto_finalize: | ||
45 | - if pre_finalize: | ||
46 | - pre_finalize() | ||
47 | - self.qmp_log('job-finalize', id=job) | ||
48 | - elif status == 'concluded' and not auto_dismiss: | ||
49 | - self.qmp_log('job-dismiss', id=job) | ||
50 | - elif status == 'null': | ||
51 | - return error | ||
52 | - else: | ||
53 | - log(ev) | ||
54 | + ev = filter_qmp_event(self.events_wait(events)) | ||
55 | + if ev['event'] != 'JOB_STATUS_CHANGE': | ||
56 | + log(ev) | ||
57 | + continue | ||
58 | + status = ev['data']['status'] | ||
59 | + if status == 'aborting': | ||
60 | + result = self.qmp('query-jobs') | ||
61 | + for j in result['return']: | ||
62 | + if j['id'] == job: | ||
63 | + error = j['error'] | ||
64 | + log('Job failed: %s' % (j['error'])) | ||
65 | + elif status == 'pending' and not auto_finalize: | ||
66 | + if pre_finalize: | ||
67 | + pre_finalize() | ||
68 | + self.qmp_log('job-finalize', id=job) | ||
69 | + elif status == 'concluded' and not auto_dismiss: | ||
70 | + self.qmp_log('job-dismiss', id=job) | ||
71 | + elif status == 'null': | ||
72 | + return error | ||
73 | |||
74 | def node_info(self, node_name): | ||
75 | nodes = self.qmp('query-named-block-nodes') | ||
76 | -- | ||
77 | 2.21.0 | ||
78 | |||
79 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: John Snow <jsnow@redhat.com> | ||
2 | 1 | ||
3 | Signed-off-by: John Snow <jsnow@redhat.com> | ||
4 | Message-id: 20190523170643.20794-6-jsnow@redhat.com | ||
5 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
6 | [mreitz: Moved from 250 to 256] | ||
7 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
8 | --- | ||
9 | tests/qemu-iotests/256 | 122 +++++++++++++++++++++++++++++++++++++ | ||
10 | tests/qemu-iotests/256.out | 119 ++++++++++++++++++++++++++++++++++++ | ||
11 | tests/qemu-iotests/group | 1 + | ||
12 | 3 files changed, 242 insertions(+) | ||
13 | create mode 100755 tests/qemu-iotests/256 | ||
14 | create mode 100644 tests/qemu-iotests/256.out | ||
15 | |||
16 | diff --git a/tests/qemu-iotests/256 b/tests/qemu-iotests/256 | ||
17 | new file mode 100755 | ||
18 | index XXXXXXX..XXXXXXX | ||
19 | --- /dev/null | ||
20 | +++ b/tests/qemu-iotests/256 | ||
21 | @@ -XXX,XX +XXX,XX @@ | ||
22 | +#!/usr/bin/env python | ||
23 | +# | ||
24 | +# Test incremental/backup across iothread contexts | ||
25 | +# | ||
26 | +# Copyright (c) 2019 John Snow for Red Hat, Inc. | ||
27 | +# | ||
28 | +# This program is free software; you can redistribute it and/or modify | ||
29 | +# it under the terms of the GNU General Public License as published by | ||
30 | +# the Free Software Foundation; either version 2 of the License, or | ||
31 | +# (at your option) any later version. | ||
32 | +# | ||
33 | +# This program is distributed in the hope that it will be useful, | ||
34 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
35 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
36 | +# GNU General Public License for more details. | ||
37 | +# | ||
38 | +# You should have received a copy of the GNU General Public License | ||
39 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
40 | +# | ||
41 | +# owner=jsnow@redhat.com | ||
42 | + | ||
43 | +import os | ||
44 | +import iotests | ||
45 | +from iotests import log | ||
46 | + | ||
47 | +iotests.verify_image_format(supported_fmts=['qcow2']) | ||
48 | +size = 64 * 1024 * 1024 | ||
49 | + | ||
50 | +with iotests.FilePath('img0') as img0_path, \ | ||
51 | + iotests.FilePath('img1') as img1_path, \ | ||
52 | + iotests.FilePath('img0-full') as img0_full_path, \ | ||
53 | + iotests.FilePath('img1-full') as img1_full_path, \ | ||
54 | + iotests.FilePath('img0-incr') as img0_incr_path, \ | ||
55 | + iotests.FilePath('img1-incr') as img1_incr_path, \ | ||
56 | + iotests.VM() as vm: | ||
57 | + | ||
58 | + def create_target(filepath, name, size): | ||
59 | + basename = os.path.basename(filepath) | ||
60 | + nodename = "file_{}".format(basename) | ||
61 | + log(vm.command('blockdev-create', job_id='job1', | ||
62 | + options={ | ||
63 | + 'driver': 'file', | ||
64 | + 'filename': filepath, | ||
65 | + 'size': 0, | ||
66 | + })) | ||
67 | + vm.run_job('job1') | ||
68 | + log(vm.command('blockdev-add', driver='file', | ||
69 | + node_name=nodename, filename=filepath)) | ||
70 | + log(vm.command('blockdev-create', job_id='job2', | ||
71 | + options={ | ||
72 | + 'driver': iotests.imgfmt, | ||
73 | + 'file': nodename, | ||
74 | + 'size': size, | ||
75 | + })) | ||
76 | + vm.run_job('job2') | ||
77 | + log(vm.command('blockdev-add', driver=iotests.imgfmt, | ||
78 | + node_name=name, | ||
79 | + file=nodename)) | ||
80 | + | ||
81 | + log('--- Preparing images & VM ---\n') | ||
82 | + vm.add_object('iothread,id=iothread0') | ||
83 | + vm.add_object('iothread,id=iothread1') | ||
84 | + vm.add_device('virtio-scsi-pci,id=scsi0,iothread=iothread0') | ||
85 | + vm.add_device('virtio-scsi-pci,id=scsi1,iothread=iothread1') | ||
86 | + iotests.qemu_img_create('-f', iotests.imgfmt, img0_path, str(size)) | ||
87 | + iotests.qemu_img_create('-f', iotests.imgfmt, img1_path, str(size)) | ||
88 | + vm.add_drive(img0_path, interface='none') | ||
89 | + vm.add_device('scsi-hd,id=device0,drive=drive0,bus=scsi0.0') | ||
90 | + vm.add_drive(img1_path, interface='none') | ||
91 | + vm.add_device('scsi-hd,id=device1,drive=drive1,bus=scsi1.0') | ||
92 | + | ||
93 | + log('--- Starting VM ---\n') | ||
94 | + vm.launch() | ||
95 | + | ||
96 | + log('--- Create Targets & Full Backups ---\n') | ||
97 | + create_target(img0_full_path, 'img0-full', size) | ||
98 | + create_target(img1_full_path, 'img1-full', size) | ||
99 | + ret = vm.qmp_log('transaction', indent=2, actions=[ | ||
100 | + { 'type': 'block-dirty-bitmap-add', | ||
101 | + 'data': { 'node': 'drive0', 'name': 'bitmap0' }}, | ||
102 | + { 'type': 'block-dirty-bitmap-add', | ||
103 | + 'data': { 'node': 'drive1', 'name': 'bitmap1' }}, | ||
104 | + { 'type': 'blockdev-backup', | ||
105 | + 'data': { 'device': 'drive0', | ||
106 | + 'target': 'img0-full', | ||
107 | + 'sync': 'full', | ||
108 | + 'job-id': 'j0' }}, | ||
109 | + { 'type': 'blockdev-backup', | ||
110 | + 'data': { 'device': 'drive1', | ||
111 | + 'target': 'img1-full', | ||
112 | + 'sync': 'full', | ||
113 | + 'job-id': 'j1' }} | ||
114 | + ]) | ||
115 | + if "error" in ret: | ||
116 | + raise Exception(ret['error']['desc']) | ||
117 | + vm.run_job('j0', auto_dismiss=True) | ||
118 | + vm.run_job('j1', auto_dismiss=True) | ||
119 | + | ||
120 | + log('\n--- Create Targets & Incremental Backups ---\n') | ||
121 | + create_target(img0_incr_path, 'img0-incr', size) | ||
122 | + create_target(img1_incr_path, 'img1-incr', size) | ||
123 | + ret = vm.qmp_log('transaction', indent=2, actions=[ | ||
124 | + { 'type': 'blockdev-backup', | ||
125 | + 'data': { 'device': 'drive0', | ||
126 | + 'target': 'img0-incr', | ||
127 | + 'sync': 'incremental', | ||
128 | + 'bitmap': 'bitmap0', | ||
129 | + 'job-id': 'j2' }}, | ||
130 | + { 'type': 'blockdev-backup', | ||
131 | + 'data': { 'device': 'drive1', | ||
132 | + 'target': 'img1-incr', | ||
133 | + 'sync': 'incremental', | ||
134 | + 'bitmap': 'bitmap1', | ||
135 | + 'job-id': 'j3' }} | ||
136 | + ]) | ||
137 | + if "error" in ret: | ||
138 | + raise Exception(ret['error']['desc']) | ||
139 | + vm.run_job('j2', auto_dismiss=True) | ||
140 | + vm.run_job('j3', auto_dismiss=True) | ||
141 | + | ||
142 | + log('\n--- Done ---') | ||
143 | + vm.shutdown() | ||
144 | diff --git a/tests/qemu-iotests/256.out b/tests/qemu-iotests/256.out | ||
145 | new file mode 100644 | ||
146 | index XXXXXXX..XXXXXXX | ||
147 | --- /dev/null | ||
148 | +++ b/tests/qemu-iotests/256.out | ||
149 | @@ -XXX,XX +XXX,XX @@ | ||
150 | +--- Preparing images & VM --- | ||
151 | + | ||
152 | +--- Starting VM --- | ||
153 | + | ||
154 | +--- Create Targets & Full Backups --- | ||
155 | + | ||
156 | +{} | ||
157 | +{"execute": "job-dismiss", "arguments": {"id": "job1"}} | ||
158 | +{"return": {}} | ||
159 | +{} | ||
160 | +{} | ||
161 | +{"execute": "job-dismiss", "arguments": {"id": "job2"}} | ||
162 | +{"return": {}} | ||
163 | +{} | ||
164 | +{} | ||
165 | +{"execute": "job-dismiss", "arguments": {"id": "job1"}} | ||
166 | +{"return": {}} | ||
167 | +{} | ||
168 | +{} | ||
169 | +{"execute": "job-dismiss", "arguments": {"id": "job2"}} | ||
170 | +{"return": {}} | ||
171 | +{} | ||
172 | +{ | ||
173 | + "execute": "transaction", | ||
174 | + "arguments": { | ||
175 | + "actions": [ | ||
176 | + { | ||
177 | + "data": { | ||
178 | + "name": "bitmap0", | ||
179 | + "node": "drive0" | ||
180 | + }, | ||
181 | + "type": "block-dirty-bitmap-add" | ||
182 | + }, | ||
183 | + { | ||
184 | + "data": { | ||
185 | + "name": "bitmap1", | ||
186 | + "node": "drive1" | ||
187 | + }, | ||
188 | + "type": "block-dirty-bitmap-add" | ||
189 | + }, | ||
190 | + { | ||
191 | + "data": { | ||
192 | + "device": "drive0", | ||
193 | + "job-id": "j0", | ||
194 | + "sync": "full", | ||
195 | + "target": "img0-full" | ||
196 | + }, | ||
197 | + "type": "blockdev-backup" | ||
198 | + }, | ||
199 | + { | ||
200 | + "data": { | ||
201 | + "device": "drive1", | ||
202 | + "job-id": "j1", | ||
203 | + "sync": "full", | ||
204 | + "target": "img1-full" | ||
205 | + }, | ||
206 | + "type": "blockdev-backup" | ||
207 | + } | ||
208 | + ] | ||
209 | + } | ||
210 | +} | ||
211 | +{ | ||
212 | + "return": {} | ||
213 | +} | ||
214 | +{"data": {"device": "j0", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} | ||
215 | +{"data": {"device": "j1", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} | ||
216 | + | ||
217 | +--- Create Targets & Incremental Backups --- | ||
218 | + | ||
219 | +{} | ||
220 | +{"execute": "job-dismiss", "arguments": {"id": "job1"}} | ||
221 | +{"return": {}} | ||
222 | +{} | ||
223 | +{} | ||
224 | +{"execute": "job-dismiss", "arguments": {"id": "job2"}} | ||
225 | +{"return": {}} | ||
226 | +{} | ||
227 | +{} | ||
228 | +{"execute": "job-dismiss", "arguments": {"id": "job1"}} | ||
229 | +{"return": {}} | ||
230 | +{} | ||
231 | +{} | ||
232 | +{"execute": "job-dismiss", "arguments": {"id": "job2"}} | ||
233 | +{"return": {}} | ||
234 | +{} | ||
235 | +{ | ||
236 | + "execute": "transaction", | ||
237 | + "arguments": { | ||
238 | + "actions": [ | ||
239 | + { | ||
240 | + "data": { | ||
241 | + "bitmap": "bitmap0", | ||
242 | + "device": "drive0", | ||
243 | + "job-id": "j2", | ||
244 | + "sync": "incremental", | ||
245 | + "target": "img0-incr" | ||
246 | + }, | ||
247 | + "type": "blockdev-backup" | ||
248 | + }, | ||
249 | + { | ||
250 | + "data": { | ||
251 | + "bitmap": "bitmap1", | ||
252 | + "device": "drive1", | ||
253 | + "job-id": "j3", | ||
254 | + "sync": "incremental", | ||
255 | + "target": "img1-incr" | ||
256 | + }, | ||
257 | + "type": "blockdev-backup" | ||
258 | + } | ||
259 | + ] | ||
260 | + } | ||
261 | +} | ||
262 | +{ | ||
263 | + "return": {} | ||
264 | +} | ||
265 | +{"data": {"device": "j2", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} | ||
266 | +{"data": {"device": "j3", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} | ||
267 | + | ||
268 | +--- Done --- | ||
269 | diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group | ||
270 | index XXXXXXX..XXXXXXX 100644 | ||
271 | --- a/tests/qemu-iotests/group | ||
272 | +++ b/tests/qemu-iotests/group | ||
273 | @@ -XXX,XX +XXX,XX @@ | ||
274 | 253 rw auto quick | ||
275 | 254 rw auto backing quick | ||
276 | 255 rw auto quick | ||
277 | +256 rw auto quick | ||
278 | -- | ||
279 | 2.21.0 | ||
280 | |||
281 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: John Snow <jsnow@redhat.com> | ||
2 | 1 | ||
3 | Before, event_match didn't always recurse if the event value was not a | ||
4 | dictionary, and would instead check for equality immediately. | ||
5 | |||
6 | By delaying equality checking to post-recursion, we can allow leaf | ||
7 | values like "5" to match "None" and take advantage of the generic | ||
8 | None-returns-True clause. | ||
9 | |||
10 | This makes the matching a little more obviously consistent at the | ||
11 | expense of being able to check for explicit None values, which is | ||
12 | probably not that important given what this function is used for. | ||
13 | |||
14 | Signed-off-by: John Snow <jsnow@redhat.com> | ||
15 | Message-id: 20190528183857.26167-1-jsnow@redhat.com | ||
16 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
17 | --- | ||
18 | python/qemu/__init__.py | 24 ++++++++++++++---------- | ||
19 | 1 file changed, 14 insertions(+), 10 deletions(-) | ||
20 | |||
21 | diff --git a/python/qemu/__init__.py b/python/qemu/__init__.py | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/python/qemu/__init__.py | ||
24 | +++ b/python/qemu/__init__.py | ||
25 | @@ -XXX,XX +XXX,XX @@ class QEMUMachine(object): | ||
26 | |||
27 | The match criteria takes the form of a matching subdict. The event is | ||
28 | checked to be a superset of the subdict, recursively, with matching | ||
29 | - values whenever those values are not None. | ||
30 | + values whenever the subdict values are not None. | ||
31 | + | ||
32 | + This has a limitation that you cannot explicitly check for None values. | ||
33 | |||
34 | Examples, with the subdict queries on the left: | ||
35 | - None matches any object. | ||
36 | - {"foo": None} matches {"foo": {"bar": 1}} | ||
37 | - - {"foo": {"baz": None}} does not match {"foo": {"bar": 1}} | ||
38 | - - {"foo": {"baz": 2}} matches {"foo": {"bar": 1, "baz": 2}} | ||
39 | + - {"foo": None} matches {"foo": 5} | ||
40 | + - {"foo": {"abc": None}} does not match {"foo": {"bar": 1}} | ||
41 | + - {"foo": {"rab": 2}} matches {"foo": {"bar": 1, "rab": 2}} | ||
42 | """ | ||
43 | if match is None: | ||
44 | return True | ||
45 | |||
46 | - for key in match: | ||
47 | - if key in event: | ||
48 | - if isinstance(event[key], dict): | ||
49 | + try: | ||
50 | + for key in match: | ||
51 | + if key in event: | ||
52 | if not QEMUMachine.event_match(event[key], match[key]): | ||
53 | return False | ||
54 | - elif event[key] != match[key]: | ||
55 | + else: | ||
56 | return False | ||
57 | - else: | ||
58 | - return False | ||
59 | - return True | ||
60 | + return True | ||
61 | + except TypeError: | ||
62 | + # either match or event wasn't iterable (not a dict) | ||
63 | + return match == event | ||
64 | |||
65 | def event_wait(self, name, timeout=60.0, match=None): | ||
66 | """ | ||
67 | -- | ||
68 | 2.21.0 | ||
69 | |||
70 | diff view generated by jsdifflib |