1
The following changes since commit 98b2faeaee96ab084d0b1669918688d8895c155f:
1
The following changes since commit 23919ddfd56135cad3cb468a8f54d5a595f024f4:
2
2
3
Merge remote-tracking branch 'remotes/jnsnow/tags/ide-pull-request' into staging (2017-02-10 18:07:02 +0000)
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
git://github.com/XanClic/qemu.git tags/pull-block-2017-02-12
7
https://github.com/XanClic/qemu.git tags/pull-block-2019-08-27
8
8
9
for you to fetch changes up to 10d6eda1926804a09aa0710ca62933087813de0b:
9
for you to fetch changes up to bb043c056cffcc2f3ce88bfdaf2e76e455c09e2c:
10
10
11
qemu-img: Avoid setting ret to unused value in img_convert() (2017-02-12 00:56:32 +0100)
11
iotests: Unify cache mode quoting (2019-08-27 19:48:44 +0200)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Block patches
14
Block patches:
15
- qemu-io now accepts a file to read a write pattern from
16
- Ensure that raw files have their first block allocated so we can probe
17
the O_DIRECT alignment if necessary
18
- Various fixes
15
19
16
----------------------------------------------------------------
20
----------------------------------------------------------------
17
Alberto Garcia (2):
21
Denis Plotnikov (1):
18
qcow2: Optimize the refcount-block overlap check
22
qemu-io: add pattern file for write command
19
qemu-io: don't allow I/O operations larger than BDRV_REQUEST_MAX_BYTES
20
23
21
Daniel P. Berrange (1):
24
Max Reitz (7):
22
iotests: record separate timings per format,protocol pair
25
iotests: Fix _filter_img_create()
23
26
vmdk: Use bdrv_dirname() for relative extent paths
24
Dou Liyang (2):
27
iotests: Keep testing broken relative extent paths
25
block/qapi: reduce the coupling between the bdrv_query_stats and bdrv_query_bds_stats
28
vmdk: Reject invalid compressed writes
26
block/qapi: reduce the execution time of qmp_query_blockstats
29
iotests: Disable broken streamOptimized tests
27
30
iotests: Disable 110 for vmdk.twoGbMaxExtentSparse
28
Fam Zheng (2):
31
iotests: Disable 126 for flat vmdk subformats
29
qapi: Tweak error message of bdrv_query_image_info
30
iotests: Fix reference output for 059
31
32
Jeff Cody (3):
33
block: check full backing filename when searching protocol filenames
34
qemu-iotests: Don't create fifos / pidfiles with protocol paths
35
qemu-iotest: test to lookup protocol-based image with relative backing
36
37
Max Reitz (1):
38
qemu-img: Improve commit invalid base message
39
32
40
Nir Soffer (3):
33
Nir Soffer (3):
41
qemu-io: Return non-zero exit code on failure
34
block: posix: Always allocate the first block
42
qemu-iotests: Add _unsupported_fmt helper
35
iotests: Test allocate_first_block() with O_DIRECT
43
qemu-io: Add failure regression tests
36
iotests: Unify cache mode quoting
44
37
45
Peter Lieven (2):
38
Stefan Hajnoczi (1):
46
block/nfs: fix NULL pointer dereference in URI parsing
39
file-posix: fix request_alignment typo
47
block/nfs: fix naming of runtime opts
48
40
49
Peter Maydell (2):
41
Thomas Huth (2):
50
qemu-img: Use qemu_strtoul() rather than raw strtoul()
42
iotests: Check for enabled drivers before testing them
51
qemu-img: Avoid setting ret to unused value in img_convert()
43
tests/check-block: Skip iotests when sanitizers are enabled
52
53
QingFeng Hao (2):
54
iotests: Fix a problem in common.filter
55
block/vmdk: Fix the endian problem of buf_len and lba
56
44
57
Vladimir Sementsov-Ogievskiy (1):
45
Vladimir Sementsov-Ogievskiy (1):
58
block: bdrv_invalidate_cache: invalidate children first
46
block: fix permission update in bdrv_replace_node
59
47
60
tests/qemu-iotests/Makefile | 2 +-
48
block.c | 5 +-
61
block/qcow2.h | 1 +
49
block/file-posix.c | 53 +++++++++-
62
block.c | 24 +++++++---
50
block/vmdk.c | 64 ++++++++----
63
block/nfs.c | 49 ++++++++++----------
51
qemu-io-cmds.c | 99 +++++++++++++++++--
64
block/qapi.c | 99 +++++++++++++++++-----------------------
52
tests/check-block.sh | 5 +
65
block/qcow2-refcount.c | 24 +++++++++-
53
tests/qemu-iotests/002 | 1 +
66
block/qcow2.c | 1 +
54
tests/qemu-iotests/003 | 1 +
67
block/vmdk.c | 4 +-
55
tests/qemu-iotests/005 | 3 +-
68
qemu-img.c | 44 +++++++++---------
56
tests/qemu-iotests/009 | 1 +
69
qemu-io-cmds.c | 20 +++++---
57
tests/qemu-iotests/010 | 1 +
70
qemu-io.c | 8 +++-
58
tests/qemu-iotests/011 | 1 +
71
tests/qemu-iotests/.gitignore | 2 +-
59
tests/qemu-iotests/017 | 3 +-
72
tests/qemu-iotests/059.out | 5 +-
60
tests/qemu-iotests/018 | 3 +-
73
tests/qemu-iotests/070.out | 1 -
61
tests/qemu-iotests/019 | 3 +-
74
tests/qemu-iotests/075.out | 7 ---
62
tests/qemu-iotests/020 | 3 +-
75
tests/qemu-iotests/076.out | 3 --
63
tests/qemu-iotests/026 | 4 +-
76
tests/qemu-iotests/078.out | 6 ---
64
tests/qemu-iotests/027 | 1 +
77
tests/qemu-iotests/080.out | 18 --------
65
tests/qemu-iotests/032 | 1 +
78
tests/qemu-iotests/083.out | 17 -------
66
tests/qemu-iotests/033 | 1 +
79
tests/qemu-iotests/088.out | 6 ---
67
tests/qemu-iotests/034 | 3 +-
80
tests/qemu-iotests/092.out | 12 -----
68
tests/qemu-iotests/037 | 3 +-
81
tests/qemu-iotests/116.out | 7 ---
69
tests/qemu-iotests/039 | 4 +-
82
tests/qemu-iotests/131.out | 1 -
70
tests/qemu-iotests/052 | 2 +-
83
tests/qemu-iotests/140.out | 1 -
71
tests/qemu-iotests/059 | 34 ++++++-
84
tests/qemu-iotests/173 | 97 +++++++++++++++++++++++++++++++++++++++
72
tests/qemu-iotests/059.out | 26 +++--
85
tests/qemu-iotests/173.out | 12 +++++
73
tests/qemu-iotests/063 | 3 +-
86
tests/qemu-iotests/174 | 59 ++++++++++++++++++++++++
74
tests/qemu-iotests/071 | 1 +
87
tests/qemu-iotests/174.out | 7 +++
75
tests/qemu-iotests/072 | 1 +
88
tests/qemu-iotests/check | 12 +++--
76
tests/qemu-iotests/081 | 4 +-
89
tests/qemu-iotests/common.config | 6 ++-
77
tests/qemu-iotests/091 | 4 +-
90
tests/qemu-iotests/common.filter | 2 +-
78
tests/qemu-iotests/099 | 1 +
91
tests/qemu-iotests/common.qemu | 10 ++--
79
tests/qemu-iotests/105 | 3 +-
92
tests/qemu-iotests/common.rc | 17 +++++--
80
tests/qemu-iotests/110 | 3 +-
93
tests/qemu-iotests/group | 2 +
81
tests/qemu-iotests/120 | 1 +
94
34 files changed, 366 insertions(+), 220 deletions(-)
82
tests/qemu-iotests/126 | 2 +
95
create mode 100755 tests/qemu-iotests/173
83
tests/qemu-iotests/{150.out => 150.out.qcow2} | 0
96
create mode 100644 tests/qemu-iotests/173.out
84
tests/qemu-iotests/150.out.raw | 12 +++
97
create mode 100755 tests/qemu-iotests/174
85
tests/qemu-iotests/162 | 4 +-
98
create mode 100644 tests/qemu-iotests/174.out
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
99
101
102
--
103
2.21.0
104
105
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Denis Plotnikov <dplotnikov@virtuozzo.com>
2
2
3
Passing a request size larger than BDRV_REQUEST_MAX_BYTES to any of the
3
The patch allows to provide a pattern file for write
4
I/O commands results in an error. While 'read' and 'write' handle the
4
command. There was no similar ability before.
5
error correctly, 'aio_read' and 'aio_write' hit an assertion:
6
5
7
blk_aio_read_entry: Assertion `rwco->qiov->size == acb->bytes' failed.
6
Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com>
8
7
Message-id: 20190820164616.4072-1-dplotnikov@virtuozzo.com
9
The reason is that the QEMU I/O code cannot handle request sizes
8
Reviewed-by: Eric Blake <eblake@redhat.com>
10
larger than BDRV_REQUEST_MAX_BYTES, so this patch makes qemu-io check
9
[mreitz: Keep optstring in alphabetical order]
11
that all values are within range.
12
13
Signed-off-by: Alberto Garcia <berto@igalia.com>
14
Message-id: 79f66648c685929a144396bda24d13a207131dcf.1485878688.git.berto@igalia.com
15
[mreitz: Use BDRV_REQUEST_MAX_BYTES instead of INT_MAX]
16
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
17
---
11
---
18
qemu-io-cmds.c | 20 +++++++++++++-------
12
qemu-io-cmds.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++---
19
1 file changed, 13 insertions(+), 7 deletions(-)
13
1 file changed, 93 insertions(+), 6 deletions(-)
20
14
21
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
15
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
22
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
23
--- a/qemu-io-cmds.c
17
--- a/qemu-io-cmds.c
24
+++ b/qemu-io-cmds.c
18
+++ b/qemu-io-cmds.c
25
@@ -XXX,XX +XXX,XX @@ create_iovec(BlockBackend *blk, QEMUIOVector *qiov, char **argv, int nr_iov,
19
@@ -XXX,XX +XXX,XX @@ static void qemu_io_free(void *p)
26
goto fail;
20
qemu_vfree(p);
27
}
21
}
28
22
29
- if (len > SIZE_MAX) {
23
+/*
30
- printf("Argument '%s' exceeds maximum size %llu\n", arg,
24
+ * qemu_io_alloc_from_file()
31
- (unsigned long long)SIZE_MAX);
25
+ *
32
+ if (len > BDRV_REQUEST_MAX_BYTES) {
26
+ * Allocates the buffer and populates it with the content of the given file
33
+ printf("Argument '%s' exceeds maximum size %" PRIu64 "\n", arg,
27
+ * up to @len bytes. If the file length is less than @len, then the buffer
34
+ (uint64_t)BDRV_REQUEST_MAX_BYTES);
28
+ * is populated with the file content cyclically.
35
+ goto fail;
29
+ *
30
+ * @blk - the block backend where the buffer content is going to be written to
31
+ * @len - the buffer length
32
+ * @file_name - the file to read the content from
33
+ *
34
+ * Returns: the buffer pointer on success
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;
36
+ }
86
+ }
87
+ }
37
+
88
+
38
+ if (count > BDRV_REQUEST_MAX_BYTES - len) {
89
+ return buf_origin;
39
+ printf("The total number of bytes exceed the maximum size %" PRIu64
90
+
40
+ "\n", (uint64_t)BDRV_REQUEST_MAX_BYTES);
91
+error:
41
goto fail;
92
+ qemu_io_free(buf_origin);
42
}
93
+ return NULL;
43
94
+}
44
@@ -XXX,XX +XXX,XX @@ static int read_f(BlockBackend *blk, int argc, char **argv)
95
+
45
if (count < 0) {
96
static void dump_buffer(const void *buffer, int64_t offset, int64_t len)
46
print_cvtnum_err(count, argv[optind]);
97
{
47
return 0;
98
uint64_t i;
48
- } else if (count > SIZE_MAX) {
99
@@ -XXX,XX +XXX,XX @@ static void write_help(void)
49
+ } else if (count > BDRV_REQUEST_MAX_BYTES) {
100
" -n, -- with -z, don't allow slow fallback\n"
50
printf("length cannot exceed %" PRIu64 ", given %s\n",
101
" -p, -- ignored for backwards compatibility\n"
51
- (uint64_t) SIZE_MAX, argv[optind]);
102
" -P, -- use different pattern to fill file\n"
52
+ (uint64_t)BDRV_REQUEST_MAX_BYTES, argv[optind]);
103
+" -s, -- use a pattern file to fill the write buffer\n"
53
return 0;
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;
54
}
149
}
55
150
151
- if (zflag && Pflag) {
152
- printf("-z and -P cannot be specified at the same time\n");
153
+ if (zflag + Pflag + sflag > 1) {
154
+ printf("Only one of -z, -P, and -s "
155
+ "can be specified at the same time\n");
156
return -EINVAL;
157
}
158
56
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
159
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
57
if (count < 0) {
58
print_cvtnum_err(count, argv[optind]);
59
return 0;
60
- } else if (count > SIZE_MAX) {
61
+ } else if (count > BDRV_REQUEST_MAX_BYTES) {
62
printf("length cannot exceed %" PRIu64 ", given %s\n",
63
- (uint64_t) SIZE_MAX, argv[optind]);
64
+ (uint64_t)BDRV_REQUEST_MAX_BYTES, argv[optind]);
65
return 0;
66
}
160
}
67
161
162
if (!zflag) {
163
- buf = qemu_io_alloc(blk, count, pattern);
164
+ if (sflag) {
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
+ }
172
}
173
174
clock_gettime(CLOCK_MONOTONIC, &t1);
68
--
175
--
69
2.11.0
176
2.21.0
70
177
71
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
Current implementation invalidates firstly parent bds and then its
3
It's wrong to OR shared permissions. It may lead to crash on further
4
children. This leads to the following bug:
4
permission updates.
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.
5
9
6
after incoming migration, in bdrv_invalidate_cache_all:
10
Bug was introduced in long ago 234ac1a9025, in 2.9.
7
1. invalidate parent bds - reopen it with BDRV_O_INACTIVE cleared
8
2. child is not yet invalidated
9
3. parent check that its BDRV_O_INACTIVE is cleared
10
4. parent writes to child
11
5. assert in bdrv_co_pwritev, as BDRV_O_INACTIVE is set for child
12
13
This patch fixes it by just changing invalidate sequence: invalidate
14
children first.
15
11
16
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
12
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
17
Message-id: 20170131112308.54189-1-vsementsov@virtuozzo.com
13
Message-id: 20190824100740.61635-1-vsementsov@virtuozzo.com
18
Reviewed-by: Max Reitz <mreitz@redhat.com>
19
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
20
Signed-off-by: Max Reitz <mreitz@redhat.com>
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
21
---
15
---
22
block.c | 11 +++++------
16
block.c | 5 ++---
23
1 file changed, 5 insertions(+), 6 deletions(-)
17
1 file changed, 2 insertions(+), 3 deletions(-)
24
18
25
diff --git a/block.c b/block.c
19
diff --git a/block.c b/block.c
26
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
27
--- a/block.c
21
--- a/block.c
28
+++ b/block.c
22
+++ b/block.c
29
@@ -XXX,XX +XXX,XX @@ void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp)
23
@@ -XXX,XX +XXX,XX @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
30
if (!(bs->open_flags & BDRV_O_INACTIVE)) {
24
{
31
return;
25
BdrvChild *c, *next;
26
GSList *list = NULL, *p;
27
- uint64_t old_perm, old_shared;
28
uint64_t perm = 0, shared = BLK_PERM_ALL;
29
int ret;
30
31
@@ -XXX,XX +XXX,XX @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
32
bdrv_unref(from);
32
}
33
}
33
- bs->open_flags &= ~BDRV_O_INACTIVE;
34
34
35
- bdrv_get_cumulative_perm(to, &old_perm, &old_shared);
35
- if (bs->drv->bdrv_invalidate_cache) {
36
- bdrv_set_perm(to, old_perm | perm, old_shared | shared);
36
- bs->drv->bdrv_invalidate_cache(bs, &local_err);
37
+ bdrv_get_cumulative_perm(to, &perm, &shared);
37
+ QLIST_FOREACH(child, &bs->children, next) {
38
+ bdrv_set_perm(to, perm, shared);
38
+ bdrv_invalidate_cache(child->bs, &local_err);
39
39
if (local_err) {
40
out:
40
- bs->open_flags |= BDRV_O_INACTIVE;
41
g_slist_free(list);
41
error_propagate(errp, local_err);
42
return;
43
}
44
}
45
46
- QLIST_FOREACH(child, &bs->children, next) {
47
- bdrv_invalidate_cache(child->bs, &local_err);
48
+ bs->open_flags &= ~BDRV_O_INACTIVE;
49
+ if (bs->drv->bdrv_invalidate_cache) {
50
+ bs->drv->bdrv_invalidate_cache(bs, &local_err);
51
if (local_err) {
52
bs->open_flags |= BDRV_O_INACTIVE;
53
error_propagate(errp, local_err);
54
--
42
--
55
2.11.0
43
2.21.0
56
44
57
45
diff view generated by jsdifflib
1
From: Nir Soffer <nirsof@gmail.com>
1
From: Nir Soffer <nirsof@gmail.com>
2
2
3
The result of openfile was not checked, leading to failure deep in the
3
When creating an image with preallocation "off" or "falloc", the first
4
actual command with confusing error message, and exiting with exit code 0.
4
block of the image is typically not allocated. When using Gluster
5
5
storage backed by XFS filesystem, reading this block using direct I/O
6
Here is a simple example - trying to read with the wrong format:
6
succeeds regardless of request length, fooling alignment detection.
7
7
8
$ touch file
8
In this case we fallback to a safe value (4096) instead of the optimal
9
$ qemu-io -f qcow2 -c 'read -P 1 0 1024' file; echo $?
9
value (512), which may lead to unneeded data copying when aligning
10
can't open device file: Image is not in qcow2 format
10
requests. Allocating the first block avoids the fallback.
11
no file open, try 'help open'
11
12
0
12
Since we allocate the first block even with preallocation=off, we no
13
13
longer create images with zero disk size:
14
With this patch, we fail earlier with exit code 1:
14
15
15
$ ./qemu-img create -f raw test.raw 1g
16
$ ./qemu-io -f qcow2 -c 'read -P 1 0 1024' file; echo $?
16
Formatting 'test.raw', fmt=raw size=1073741824
17
can't open device file: Image is not in qcow2 format
17
18
1
18
$ ls -lhs test.raw
19
19
4.0K -rw-r--r--. 1 nsoffer nsoffer 1.0G Aug 16 23:48 test.raw
20
Failing earlier, we don't log this error now:
20
21
21
And converting the image requires additional cluster:
22
no file open, try 'help open'
22
23
23
$ ./qemu-img measure -f raw -O qcow2 test.raw
24
But some tests expected it; the line was removed from the test output.
24
required size: 458752
25
25
fully allocated size: 1074135040
26
Signed-off-by: Nir Soffer <nirsof@gmail.com>
26
27
Reviewed-by: Eric Blake <eblake@redhat.com>
27
When using format like vmdk with multiple files per image, we allocate
28
Message-id: 20170201003120.23378-2-nirsof@gmail.com
28
one block per file:
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
29
Reviewed-by: Max Reitz <mreitz@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
qemu-io.c | 8 ++++++--
62
block/file-posix.c | 51 +++++++++++++++++++
33
tests/qemu-iotests/059.out | 3 ---
63
tests/qemu-iotests/059.out | 2 +-
34
tests/qemu-iotests/070.out | 1 -
64
tests/qemu-iotests/{150.out => 150.out.qcow2} | 0
35
tests/qemu-iotests/075.out | 7 -------
65
tests/qemu-iotests/150.out.raw | 12 +++++
36
tests/qemu-iotests/076.out | 3 ---
66
tests/qemu-iotests/175 | 19 ++++---
37
tests/qemu-iotests/078.out | 6 ------
67
tests/qemu-iotests/175.out | 8 +--
38
tests/qemu-iotests/080.out | 18 ------------------
68
tests/qemu-iotests/178.out.qcow2 | 4 +-
39
tests/qemu-iotests/083.out | 17 -----------------
69
tests/qemu-iotests/221.out | 12 +++--
40
tests/qemu-iotests/088.out | 6 ------
70
tests/qemu-iotests/253.out | 12 +++--
41
tests/qemu-iotests/092.out | 12 ------------
71
9 files changed, 99 insertions(+), 21 deletions(-)
42
tests/qemu-iotests/116.out | 7 -------
72
rename tests/qemu-iotests/{150.out => 150.out.qcow2} (100%)
43
tests/qemu-iotests/131.out | 1 -
73
create mode 100644 tests/qemu-iotests/150.out.raw
44
tests/qemu-iotests/140.out | 1 -
74
45
13 files changed, 6 insertions(+), 84 deletions(-)
75
diff --git a/block/file-posix.c b/block/file-posix.c
46
76
index XXXXXXX..XXXXXXX 100644
47
diff --git a/qemu-io.c b/qemu-io.c
77
--- a/block/file-posix.c
48
index XXXXXXX..XXXXXXX 100644
78
+++ b/block/file-posix.c
49
--- a/qemu-io.c
79
@@ -XXX,XX +XXX,XX @@ static int handle_aiocb_discard(void *opaque)
50
+++ b/qemu-io.c
80
return ret;
51
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv)
81
}
52
exit(1);
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);
53
}
138
}
54
opts = qemu_opts_to_qdict(qopts, NULL);
55
- openfile(NULL, flags, writethrough, opts);
56
+ if (openfile(NULL, flags, writethrough, opts)) {
57
+ exit(1);
58
+ }
59
} else {
139
} else {
60
if (format) {
140
result = 0;
61
opts = qdict_new();
141
@@ -XXX,XX +XXX,XX @@ static int handle_aiocb_truncate(void *opaque)
62
qdict_put(opts, "driver", qstring_from_str(format));
142
if (ftruncate(fd, offset) != 0) {
63
}
143
result = -errno;
64
- openfile(argv[optind], flags, writethrough, opts);
144
error_setg_errno(errp, -result, "Could not resize file");
65
+ if (openfile(argv[optind], flags, writethrough, opts)) {
145
+ } else if (current_length == 0 && offset > current_length) {
66
+ exit(1);
146
+ /* Optimize future alignment probing; ignore failures. */
67
+ }
147
+ allocate_first_block(fd, offset);
68
}
148
}
69
}
149
return result;
70
command_loop();
150
default:
71
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
151
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
72
index XXXXXXX..XXXXXXX 100644
152
index XXXXXXX..XXXXXXX 100644
73
--- a/tests/qemu-iotests/059.out
153
--- a/tests/qemu-iotests/059.out
74
+++ b/tests/qemu-iotests/059.out
154
+++ b/tests/qemu-iotests/059.out
75
@@ -XXX,XX +XXX,XX @@ QA output created by 059
155
@@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000 subformat=twoGbMax
76
=== Testing invalid granularity ===
156
image: TEST_DIR/t.vmdk
77
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
157
file format: vmdk
78
can't open device TEST_DIR/t.vmdk: Invalid granularity, image may be corrupt
158
virtual size: 0.977 TiB (1073741824000 bytes)
79
-no file open, try 'help open'
159
-disk size: 16 KiB
80
160
+disk size: 1.97 MiB
81
=== Testing too big L2 table size ===
161
Format specific information:
82
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
162
cid: XXXXXXXX
83
can't open device TEST_DIR/t.vmdk: L2 table size too big
163
parent cid: XXXXXXXX
84
-no file open, try 'help open'
164
diff --git a/tests/qemu-iotests/150.out b/tests/qemu-iotests/150.out.qcow2
85
165
similarity index 100%
86
=== Testing too big L1 table size ===
166
rename from tests/qemu-iotests/150.out
87
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
167
rename to tests/qemu-iotests/150.out.qcow2
88
can't open device TEST_DIR/t.vmdk: L1 size too big
168
diff --git a/tests/qemu-iotests/150.out.raw b/tests/qemu-iotests/150.out.raw
89
-no file open, try 'help open'
169
new file mode 100644
90
170
index XXXXXXX..XXXXXXX
91
=== Testing monolithicFlat creation and opening ===
171
--- /dev/null
92
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat
172
+++ b/tests/qemu-iotests/150.out.raw
93
diff --git a/tests/qemu-iotests/070.out b/tests/qemu-iotests/070.out
173
@@ -XXX,XX +XXX,XX @@
94
index XXXXXXX..XXXXXXX 100644
174
+QA output created by 150
95
--- a/tests/qemu-iotests/070.out
175
+
96
+++ b/tests/qemu-iotests/070.out
176
+=== Mapping sparse conversion ===
97
@@ -XXX,XX +XXX,XX @@ QA output created by 070
177
+
98
can't open device TEST_DIR/iotest-dirtylog-10G-4M.vhdx: VHDX image file 'TEST_DIR/iotest-dirtylog-10G-4M.vhdx' opened read-only, but contains a log that needs to be replayed
178
+Offset Length File
99
To replay the log, run:
179
+0 0x1000 TEST_DIR/t.IMGFMT
100
qemu-img check -r all 'TEST_DIR/iotest-dirtylog-10G-4M.vhdx'
180
+
101
- no file open, try 'help open'
181
+=== Mapping non-sparse conversion ===
102
=== Verify open image replays log ===
182
+
103
read 18874368/18874368 bytes at offset 0
183
+Offset Length File
104
18 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
184
+0 0x100000 TEST_DIR/t.IMGFMT
105
diff --git a/tests/qemu-iotests/075.out b/tests/qemu-iotests/075.out
185
+*** done
106
index XXXXXXX..XXXXXXX 100644
186
diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175
107
--- a/tests/qemu-iotests/075.out
187
index XXXXXXX..XXXXXXX 100755
108
+++ b/tests/qemu-iotests/075.out
188
--- a/tests/qemu-iotests/175
109
@@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 1048064
189
+++ b/tests/qemu-iotests/175
110
190
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
111
== block_size must be a multiple of 512 ==
191
# the file size. This function hides the resulting difference in the
112
can't open device TEST_DIR/simple-pattern.cloop: block_size 513 must be a multiple of 512
192
# stat -c '%b' output.
113
-no file open, try 'help open'
193
# Parameter 1: Number of blocks an empty file occupies
114
194
-# Parameter 2: Image size in bytes
115
== block_size cannot be zero ==
195
+# Parameter 2: Minimal number of blocks in an image
116
can't open device TEST_DIR/simple-pattern.cloop: block_size cannot be zero
196
+# Parameter 3: Image size in bytes
117
-no file open, try 'help open'
197
_filter_blocks()
118
198
{
119
== huge block_size ===
199
extra_blocks=$1
120
can't open device TEST_DIR/simple-pattern.cloop: block_size 4294966784 must be 64 MB or less
200
- img_size=$2
121
-no file open, try 'help open'
201
+ min_blocks=$2
122
202
+ img_size=$3
123
== offsets_size overflow ===
203
124
can't open device TEST_DIR/simple-pattern.cloop: n_blocks 4294967295 must be 536870911 or less
204
- sed -e "s/blocks=$extra_blocks\\(\$\\|[^0-9]\\)/nothing allocated/" \
125
-no file open, try 'help open'
205
- -e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/everything allocated/"
126
206
+ sed -e "s/blocks=$min_blocks\\(\$\\|[^0-9]\\)/min allocation/" \
127
== refuse images that require too many offsets ===
207
+ -e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/max allocation/"
128
can't open device TEST_DIR/simple-pattern.cloop: image requires too many offsets, try increasing block size
208
}
129
-no file open, try 'help open'
209
130
210
# get standard environment, filters and checks
131
== refuse images with non-monotonically increasing offsets ==
211
@@ -XXX,XX +XXX,XX @@ size=$((1 * 1024 * 1024))
132
can't open device TEST_DIR/simple-pattern.cloop: offsets not monotonically increasing at index 1, image file is corrupt
212
touch "$TEST_DIR/empty"
133
-no file open, try 'help open'
213
extra_blocks=$(stat -c '%b' "$TEST_DIR/empty")
134
214
135
== refuse images with invalid compressed block size ==
215
+# We always write the first byte; check how many blocks this filesystem
136
can't open device TEST_DIR/simple-pattern.cloop: invalid compressed block size at index 1, image file is corrupt
216
+# allocates to match empty image alloation.
137
-no file open, try 'help open'
217
+printf "\0" > "$TEST_DIR/empty"
218
+min_blocks=$(stat -c '%b' "$TEST_DIR/empty")
219
+
220
echo
221
echo "== creating image with default preallocation =="
222
_make_test_img $size | _filter_imgfmt
223
-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
225
226
for mode in off full falloc; do
227
echo
228
echo "== creating image with preallocation $mode =="
229
IMGOPTS=preallocation=$mode _make_test_img $size | _filter_imgfmt
230
- 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
232
done
233
234
# success, all done
235
diff --git a/tests/qemu-iotests/175.out b/tests/qemu-iotests/175.out
236
index XXXXXXX..XXXXXXX 100644
237
--- a/tests/qemu-iotests/175.out
238
+++ b/tests/qemu-iotests/175.out
239
@@ -XXX,XX +XXX,XX @@ QA output created by 175
240
241
== creating image with default preallocation ==
242
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
243
-size=1048576, nothing allocated
244
+size=1048576, min allocation
245
246
== creating image with preallocation off ==
247
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=off
248
-size=1048576, nothing allocated
249
+size=1048576, min allocation
250
251
== creating image with preallocation full ==
252
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=full
253
-size=1048576, everything allocated
254
+size=1048576, max allocation
255
256
== creating image with preallocation falloc ==
257
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=falloc
258
-size=1048576, everything allocated
259
+size=1048576, max allocation
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}]
138
*** done
309
*** done
139
diff --git a/tests/qemu-iotests/076.out b/tests/qemu-iotests/076.out
310
diff --git a/tests/qemu-iotests/253.out b/tests/qemu-iotests/253.out
140
index XXXXXXX..XXXXXXX 100644
311
index XXXXXXX..XXXXXXX 100644
141
--- a/tests/qemu-iotests/076.out
312
--- a/tests/qemu-iotests/253.out
142
+++ b/tests/qemu-iotests/076.out
313
+++ b/tests/qemu-iotests/253.out
143
@@ -XXX,XX +XXX,XX @@ read 65536/65536 bytes at offset 0
314
@@ -XXX,XX +XXX,XX @@ QA output created by 253
144
315
=== Check mapping of unaligned raw image ===
145
== Negative catalog size ==
316
146
can't open device TEST_DIR/parallels-v1: Catalog too large
317
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048575
147
-no file open, try 'help open'
318
-[{ "start": 0, "length": 1048576, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
148
319
-[{ "start": 0, "length": 1048576, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
149
== Overflow in catalog allocation ==
320
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
150
can't open device TEST_DIR/parallels-v1: Catalog too large
321
+{ "start": 4096, "length": 1044480, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
151
-no file open, try 'help open'
322
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
152
323
+{ "start": 4096, "length": 1044480, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
153
== Zero sectors per track ==
324
wrote 65535/65535 bytes at offset 983040
154
can't open device TEST_DIR/parallels-v1: Invalid image: Zero sectors per track
325
63.999 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
155
-no file open, try 'help open'
326
-[{ "start": 0, "length": 983040, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
156
327
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
157
== Read from a valid v2 image ==
328
+{ "start": 4096, "length": 978944, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
158
read 65536/65536 bytes at offset 0
329
{ "start": 983040, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": OFFSET}]
159
diff --git a/tests/qemu-iotests/078.out b/tests/qemu-iotests/078.out
330
-[{ "start": 0, "length": 983040, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
160
index XXXXXXX..XXXXXXX 100644
331
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
161
--- a/tests/qemu-iotests/078.out
332
+{ "start": 4096, "length": 978944, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
162
+++ b/tests/qemu-iotests/078.out
333
{ "start": 983040, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": OFFSET}]
163
@@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 0
164
165
== Negative catalog size ==
166
can't open device TEST_DIR/empty.bochs: Catalog size is too large
167
-no file open, try 'help open'
168
169
== Overflow for catalog size * sizeof(uint32_t) ==
170
can't open device TEST_DIR/empty.bochs: Catalog size is too large
171
-no file open, try 'help open'
172
173
== Too small catalog bitmap for image size ==
174
can't open device TEST_DIR/empty.bochs: Catalog size is too small for this disk size
175
-no file open, try 'help open'
176
can't open device TEST_DIR/empty.bochs: Catalog size is too small for this disk size
177
-no file open, try 'help open'
178
179
== Negative extent size ==
180
can't open device TEST_DIR/empty.bochs: Extent size 2147483648 is too large
181
-no file open, try 'help open'
182
183
== Zero extent size ==
184
can't open device TEST_DIR/empty.bochs: Extent size must be at least 512
185
-no file open, try 'help open'
186
*** done
187
diff --git a/tests/qemu-iotests/080.out b/tests/qemu-iotests/080.out
188
index XXXXXXX..XXXXXXX 100644
189
--- a/tests/qemu-iotests/080.out
190
+++ b/tests/qemu-iotests/080.out
191
@@ -XXX,XX +XXX,XX @@ QA output created by 080
192
== Huge header size ==
193
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
194
can't open device TEST_DIR/t.qcow2: qcow2 header exceeds cluster size
195
-no file open, try 'help open'
196
can't open device TEST_DIR/t.qcow2: qcow2 header exceeds cluster size
197
-no file open, try 'help open'
198
199
== Huge unknown header extension ==
200
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
201
can't open device TEST_DIR/t.qcow2: Invalid backing file offset
202
-no file open, try 'help open'
203
can't open device TEST_DIR/t.qcow2: Header extension too large
204
-no file open, try 'help open'
205
can't open device TEST_DIR/t.qcow2: Header extension too large
206
-no file open, try 'help open'
207
208
== Huge refcount table size ==
209
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
210
can't open device TEST_DIR/t.qcow2: Reference count table too large
211
-no file open, try 'help open'
212
can't open device TEST_DIR/t.qcow2: Reference count table too large
213
-no file open, try 'help open'
214
215
== Misaligned refcount table ==
216
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
217
can't open device TEST_DIR/t.qcow2: Invalid reference count table offset
218
-no file open, try 'help open'
219
220
== Huge refcount offset ==
221
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
222
can't open device TEST_DIR/t.qcow2: Invalid reference count table offset
223
-no file open, try 'help open'
224
225
== Invalid snapshot table ==
226
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
227
can't open device TEST_DIR/t.qcow2: Too many snapshots
228
-no file open, try 'help open'
229
can't open device TEST_DIR/t.qcow2: Too many snapshots
230
-no file open, try 'help open'
231
can't open device TEST_DIR/t.qcow2: Invalid snapshot table offset
232
-no file open, try 'help open'
233
can't open device TEST_DIR/t.qcow2: Invalid snapshot table offset
234
-no file open, try 'help open'
235
236
== Hitting snapshot table size limit ==
237
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
238
@@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 0
239
== Invalid L1 table ==
240
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
241
can't open device TEST_DIR/t.qcow2: Active L1 table too large
242
-no file open, try 'help open'
243
can't open device TEST_DIR/t.qcow2: Active L1 table too large
244
-no file open, try 'help open'
245
can't open device TEST_DIR/t.qcow2: Invalid L1 table offset
246
-no file open, try 'help open'
247
can't open device TEST_DIR/t.qcow2: Invalid L1 table offset
248
-no file open, try 'help open'
249
250
== Invalid L1 table (with internal snapshot in the image) ==
251
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
252
@@ -XXX,XX +XXX,XX @@ qemu-img: Could not open 'TEST_DIR/t.IMGFMT': L1 table is too small
253
== Invalid backing file size ==
254
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
255
can't open device TEST_DIR/t.qcow2: Backing file name too long
256
-no file open, try 'help open'
257
258
== Invalid L2 entry (huge physical offset) ==
259
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
260
diff --git a/tests/qemu-iotests/083.out b/tests/qemu-iotests/083.out
261
index XXXXXXX..XXXXXXX 100644
262
--- a/tests/qemu-iotests/083.out
263
+++ b/tests/qemu-iotests/083.out
264
@@ -XXX,XX +XXX,XX @@ QA output created by 083
265
=== Check disconnect before neg1 ===
266
267
can't open device nbd:127.0.0.1:PORT:exportname=foo
268
-no file open, try 'help open'
269
270
=== Check disconnect after neg1 ===
271
272
can't open device nbd:127.0.0.1:PORT:exportname=foo
273
-no file open, try 'help open'
274
275
=== Check disconnect 8 neg1 ===
276
277
can't open device nbd:127.0.0.1:PORT:exportname=foo
278
-no file open, try 'help open'
279
280
=== Check disconnect 16 neg1 ===
281
282
can't open device nbd:127.0.0.1:PORT:exportname=foo
283
-no file open, try 'help open'
284
285
=== Check disconnect before export ===
286
287
can't open device nbd:127.0.0.1:PORT:exportname=foo
288
-no file open, try 'help open'
289
290
=== Check disconnect after export ===
291
292
can't open device nbd:127.0.0.1:PORT:exportname=foo
293
-no file open, try 'help open'
294
295
=== Check disconnect 4 export ===
296
297
can't open device nbd:127.0.0.1:PORT:exportname=foo
298
-no file open, try 'help open'
299
300
=== Check disconnect 12 export ===
301
302
can't open device nbd:127.0.0.1:PORT:exportname=foo
303
-no file open, try 'help open'
304
305
=== Check disconnect 16 export ===
306
307
can't open device nbd:127.0.0.1:PORT:exportname=foo
308
-no file open, try 'help open'
309
310
=== Check disconnect before neg2 ===
311
312
can't open device nbd:127.0.0.1:PORT:exportname=foo
313
-no file open, try 'help open'
314
315
=== Check disconnect after neg2 ===
316
317
@@ -XXX,XX +XXX,XX @@ read failed: Input/output error
318
=== Check disconnect 8 neg2 ===
319
320
can't open device nbd:127.0.0.1:PORT:exportname=foo
321
-no file open, try 'help open'
322
323
=== Check disconnect 10 neg2 ===
324
325
can't open device nbd:127.0.0.1:PORT:exportname=foo
326
-no file open, try 'help open'
327
328
=== Check disconnect before request ===
329
330
@@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 0
331
=== Check disconnect before neg-classic ===
332
333
can't open device nbd:127.0.0.1:PORT
334
-no file open, try 'help open'
335
336
=== Check disconnect 8 neg-classic ===
337
338
can't open device nbd:127.0.0.1:PORT
339
-no file open, try 'help open'
340
341
=== Check disconnect 16 neg-classic ===
342
343
can't open device nbd:127.0.0.1:PORT
344
-no file open, try 'help open'
345
346
=== Check disconnect 24 neg-classic ===
347
348
can't open device nbd:127.0.0.1:PORT
349
-no file open, try 'help open'
350
351
=== Check disconnect 28 neg-classic ===
352
353
can't open device nbd:127.0.0.1:PORT
354
-no file open, try 'help open'
355
356
=== Check disconnect after neg-classic ===
357
358
diff --git a/tests/qemu-iotests/088.out b/tests/qemu-iotests/088.out
359
index XXXXXXX..XXXXXXX 100644
360
--- a/tests/qemu-iotests/088.out
361
+++ b/tests/qemu-iotests/088.out
362
@@ -XXX,XX +XXX,XX @@ QA output created by 088
363
== Invalid block size ==
364
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
365
can't open device TEST_DIR/t.vpc: Invalid block size 0
366
-no file open, try 'help open'
367
can't open device TEST_DIR/t.vpc: Invalid block size 0
368
-no file open, try 'help open'
369
can't open device TEST_DIR/t.vpc: Invalid block size 128
370
-no file open, try 'help open'
371
can't open device TEST_DIR/t.vpc: Invalid block size 128
372
-no file open, try 'help open'
373
can't open device TEST_DIR/t.vpc: Invalid block size 305419896
374
-no file open, try 'help open'
375
can't open device TEST_DIR/t.vpc: Invalid block size 305419896
376
-no file open, try 'help open'
377
*** done
378
diff --git a/tests/qemu-iotests/092.out b/tests/qemu-iotests/092.out
379
index XXXXXXX..XXXXXXX 100644
380
--- a/tests/qemu-iotests/092.out
381
+++ b/tests/qemu-iotests/092.out
382
@@ -XXX,XX +XXX,XX @@ QA output created by 092
383
== Invalid cluster size ==
384
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
385
can't open device TEST_DIR/t.qcow: Cluster size must be between 512 and 64k
386
-no file open, try 'help open'
387
can't open device TEST_DIR/t.qcow: Cluster size must be between 512 and 64k
388
-no file open, try 'help open'
389
can't open device TEST_DIR/t.qcow: Cluster size must be between 512 and 64k
390
-no file open, try 'help open'
391
can't open device TEST_DIR/t.qcow: Cluster size must be between 512 and 64k
392
-no file open, try 'help open'
393
394
== Invalid L2 table size ==
395
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
396
can't open device TEST_DIR/t.qcow: L2 table size must be between 512 and 64k
397
-no file open, try 'help open'
398
can't open device TEST_DIR/t.qcow: L2 table size must be between 512 and 64k
399
-no file open, try 'help open'
400
can't open device TEST_DIR/t.qcow: L2 table size must be between 512 and 64k
401
-no file open, try 'help open'
402
can't open device TEST_DIR/t.qcow: L2 table size must be between 512 and 64k
403
-no file open, try 'help open'
404
405
== Invalid size ==
406
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
407
can't open device TEST_DIR/t.qcow: Image too large
408
-no file open, try 'help open'
409
can't open device TEST_DIR/t.qcow: Image too large
410
-no file open, try 'help open'
411
412
== Invalid backing file length ==
413
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
414
can't open device TEST_DIR/t.qcow: Backing file name too long
415
-no file open, try 'help open'
416
can't open device TEST_DIR/t.qcow: Backing file name too long
417
-no file open, try 'help open'
418
*** done
419
diff --git a/tests/qemu-iotests/116.out b/tests/qemu-iotests/116.out
420
index XXXXXXX..XXXXXXX 100644
421
--- a/tests/qemu-iotests/116.out
422
+++ b/tests/qemu-iotests/116.out
423
@@ -XXX,XX +XXX,XX @@ QA output created by 116
424
== truncated header cluster ==
425
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
426
can't open device TEST_DIR/t.qed: Could not open 'TEST_DIR/t.qed': Invalid argument
427
-no file open, try 'help open'
428
429
== invalid header magic ==
430
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
431
can't open device TEST_DIR/t.qed: Image not in QED format
432
-no file open, try 'help open'
433
434
== invalid cluster size ==
435
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
436
can't open device TEST_DIR/t.qed: Could not open 'TEST_DIR/t.qed': Invalid argument
437
-no file open, try 'help open'
438
439
== invalid table size ==
440
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
441
can't open device TEST_DIR/t.qed: Could not open 'TEST_DIR/t.qed': Invalid argument
442
-no file open, try 'help open'
443
444
== invalid header size ==
445
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
446
can't open device TEST_DIR/t.qed: Could not open 'TEST_DIR/t.qed': Invalid argument
447
-no file open, try 'help open'
448
449
== invalid L1 table offset ==
450
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
451
can't open device TEST_DIR/t.qed: Could not open 'TEST_DIR/t.qed': Invalid argument
452
-no file open, try 'help open'
453
454
== invalid image size ==
455
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
456
can't open device TEST_DIR/t.qed: Could not open 'TEST_DIR/t.qed': Invalid argument
457
-no file open, try 'help open'
458
*** done
459
diff --git a/tests/qemu-iotests/131.out b/tests/qemu-iotests/131.out
460
index XXXXXXX..XXXXXXX 100644
461
--- a/tests/qemu-iotests/131.out
462
+++ b/tests/qemu-iotests/131.out
463
@@ -XXX,XX +XXX,XX @@ read 32768/32768 bytes at offset 0
464
32 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
465
== Corrupt image ==
466
can't open device TEST_DIR/t.parallels: parallels: Image was not closed correctly; cannot be opened read/write
467
-no file open, try 'help open'
468
ERROR image was not closed correctly
469
470
1 errors were found on the image.
471
diff --git a/tests/qemu-iotests/140.out b/tests/qemu-iotests/140.out
472
index XXXXXXX..XXXXXXX 100644
473
--- a/tests/qemu-iotests/140.out
474
+++ b/tests/qemu-iotests/140.out
475
@@ -XXX,XX +XXX,XX @@ read 65536/65536 bytes at offset 0
476
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
477
{"return": {}}
478
can't open device nbd+unix:///drv?socket=TEST_DIR/nbd: No export with name 'drv' available
479
-no file open, try 'help open'
480
{"return": {}}
481
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN"}
482
*** done
334
*** done
483
--
335
--
484
2.11.0
336
2.21.0
485
337
486
338
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Nir Soffer <nirsof@gmail.com>
2
2
3
The metadata overlap checks introduced in a40f1c2add help detect
3
Using block_resize we can test allocate_first_block() with file
4
corruption in the qcow2 image by verifying that data writes don't
4
descriptor opened with O_DIRECT, ensuring that it works for any size
5
overlap with existing metadata sections.
5
larger than 4096 bytes.
6
6
7
The 'refcount-block' check in particular iterates over the refcount
7
Testing smaller sizes is tricky as the result depends on the filesystem
8
table in order to get the addresses of all refcount blocks and check
8
used for testing. For example on NFS any size will work since O_DIRECT
9
that none of them overlap with the region where we want to write.
9
does not require any alignment.
10
10
11
The problem with the refcount table is that since it always occupies
11
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
12
complete clusters its size is usually very big. With the default
13
values of cluster_size=64KB and refcount_bits=16 this table holds 8192
14
entries, each one of them enough to map 2GB worth of host clusters.
15
16
So unless we're using images with several TB of allocated data this
17
table is going to be mostly empty, and iterating over it is a waste of
18
CPU. If the storage backend is fast enough this can have an effect on
19
I/O performance.
20
21
This patch keeps the index of the last used (i.e. non-zero) entry in
22
the refcount table and updates it every time the table changes. The
23
refcount-block overlap check then uses that index instead of reading
24
the whole table.
25
26
In my tests with a 4GB qcow2 file stored in RAM this doubles the
27
amount of write IOPS.
28
29
Signed-off-by: Alberto Garcia <berto@igalia.com>
30
Message-id: 20170201123828.4815-1-berto@igalia.com
31
Reviewed-by: Max Reitz <mreitz@redhat.com>
12
Reviewed-by: Max Reitz <mreitz@redhat.com>
13
Message-id: 20190827010528.8818-3-nsoffer@redhat.com
32
Signed-off-by: Max Reitz <mreitz@redhat.com>
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
33
---
15
---
34
block/qcow2.h | 1 +
16
tests/qemu-iotests/175 | 28 ++++++++++++++++++++++++++++
35
block/qcow2-refcount.c | 24 +++++++++++++++++++++++-
17
tests/qemu-iotests/175.out | 8 ++++++++
36
block/qcow2.c | 1 +
18
2 files changed, 36 insertions(+)
37
3 files changed, 25 insertions(+), 1 deletion(-)
38
19
39
diff --git a/block/qcow2.h b/block/qcow2.h
20
diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175
40
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100755
41
--- a/block/qcow2.h
22
--- a/tests/qemu-iotests/175
42
+++ b/block/qcow2.h
23
+++ b/tests/qemu-iotests/175
43
@@ -XXX,XX +XXX,XX @@ typedef struct BDRVQcow2State {
24
@@ -XXX,XX +XXX,XX @@ _filter_blocks()
44
uint64_t *refcount_table;
25
-e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/max allocation/"
45
uint64_t refcount_table_offset;
26
}
46
uint32_t refcount_table_size;
27
47
+ uint32_t max_refcount_table_index; /* Last used entry in refcount_table */
28
+# Resize image using block_resize.
48
uint64_t free_cluster_index;
29
+# Parameter 1: image path
49
uint64_t free_byte_offset;
30
+# Parameter 2: new size
50
31
+_block_resize()
51
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
52
index XXXXXXX..XXXXXXX 100644
53
--- a/block/qcow2-refcount.c
54
+++ b/block/qcow2-refcount.c
55
@@ -XXX,XX +XXX,XX @@ static Qcow2SetRefcountFunc *const set_refcount_funcs[] = {
56
/*********************************************************/
57
/* refcount handling */
58
59
+static void update_max_refcount_table_index(BDRVQcow2State *s)
60
+{
32
+{
61
+ unsigned i = s->refcount_table_size - 1;
33
+ local path=$1
62
+ while (i > 0 && (s->refcount_table[i] & REFT_OFFSET_MASK) == 0) {
34
+ local size=$2
63
+ i--;
35
+
64
+ }
36
+ $QEMU -qmp stdio -nographic -nodefaults \
65
+ /* Set s->max_refcount_table_index to the index of the last used entry */
37
+ -blockdev file,node-name=file,filename=$path,cache.direct=on \
66
+ s->max_refcount_table_index = i;
38
+ <<EOF
39
+{'execute': 'qmp_capabilities'}
40
+{'execute': 'block_resize', 'arguments': {'node-name': 'file', 'size': $size}}
41
+{'execute': 'quit'}
42
+EOF
67
+}
43
+}
68
+
44
+
69
int qcow2_refcount_init(BlockDriverState *bs)
45
# get standard environment, filters and checks
70
{
46
. ./common.rc
71
BDRVQcow2State *s = bs->opaque;
47
. ./common.filter
72
@@ -XXX,XX +XXX,XX @@ int qcow2_refcount_init(BlockDriverState *bs)
48
@@ -XXX,XX +XXX,XX @@ _supported_fmt raw
73
}
49
_supported_proto file
74
for(i = 0; i < s->refcount_table_size; i++)
50
_supported_os Linux
75
be64_to_cpus(&s->refcount_table[i]);
51
76
+ update_max_refcount_table_index(s);
52
+_default_cache_mode none
77
}
53
+_supported_cache_modes none directsync
78
return 0;
54
+
79
fail:
55
size=$((1 * 1024 * 1024))
80
@@ -XXX,XX +XXX,XX @@ static int alloc_refcount_block(BlockDriverState *bs,
56
81
}
57
touch "$TEST_DIR/empty"
82
58
@@ -XXX,XX +XXX,XX @@ for mode in off full falloc; do
83
s->refcount_table[refcount_table_index] = new_block;
59
stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size
84
+ /* If there's a hole in s->refcount_table then it can happen
60
done
85
+ * that refcount_table_index < s->max_refcount_table_index */
61
86
+ s->max_refcount_table_index =
62
+for new_size in 4096 1048576; do
87
+ MAX(s->max_refcount_table_index, refcount_table_index);
63
+ echo
88
64
+ echo "== resize empty image with block_resize =="
89
/* The new refcount block may be where the caller intended to put its
65
+ _make_test_img 0 | _filter_imgfmt
90
* data, so let it restart the search. */
66
+ _block_resize $TEST_IMG $new_size >/dev/null
91
@@ -XXX,XX +XXX,XX @@ static int alloc_refcount_block(BlockDriverState *bs,
67
+ stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $new_size
92
s->refcount_table = new_table;
68
+done
93
s->refcount_table_size = table_size;
69
+
94
s->refcount_table_offset = table_offset;
70
# success, all done
95
+ update_max_refcount_table_index(s);
71
echo "*** done"
96
72
rm -f $seq.full
97
/* Free old table. */
73
diff --git a/tests/qemu-iotests/175.out b/tests/qemu-iotests/175.out
98
qcow2_free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t),
99
@@ -XXX,XX +XXX,XX @@ write_refblocks:
100
s->refcount_table = on_disk_reftable;
101
s->refcount_table_offset = reftable_offset;
102
s->refcount_table_size = reftable_size;
103
+ update_max_refcount_table_index(s);
104
105
return 0;
106
107
@@ -XXX,XX +XXX,XX @@ int qcow2_check_metadata_overlap(BlockDriverState *bs, int ign, int64_t offset,
108
}
109
110
if ((chk & QCOW2_OL_REFCOUNT_BLOCK) && s->refcount_table) {
111
- for (i = 0; i < s->refcount_table_size; i++) {
112
+ unsigned last_entry = s->max_refcount_table_index;
113
+ assert(last_entry < s->refcount_table_size);
114
+ assert(last_entry + 1 == s->refcount_table_size ||
115
+ (s->refcount_table[last_entry + 1] & REFT_OFFSET_MASK) == 0);
116
+ for (i = 0; i <= last_entry; i++) {
117
if ((s->refcount_table[i] & REFT_OFFSET_MASK) &&
118
overlaps_with(s->refcount_table[i] & REFT_OFFSET_MASK,
119
s->cluster_size)) {
120
@@ -XXX,XX +XXX,XX @@ int qcow2_change_refcount_order(BlockDriverState *bs, int refcount_order,
121
/* Now update the rest of the in-memory information */
122
old_reftable = s->refcount_table;
123
s->refcount_table = new_reftable;
124
+ update_max_refcount_table_index(s);
125
126
s->refcount_bits = 1 << refcount_order;
127
s->refcount_max = UINT64_C(1) << (s->refcount_bits - 1);
128
diff --git a/block/qcow2.c b/block/qcow2.c
129
index XXXXXXX..XXXXXXX 100644
74
index XXXXXXX..XXXXXXX 100644
130
--- a/block/qcow2.c
75
--- a/tests/qemu-iotests/175.out
131
+++ b/block/qcow2.c
76
+++ b/tests/qemu-iotests/175.out
132
@@ -XXX,XX +XXX,XX @@ static int make_completely_empty(BlockDriverState *bs)
77
@@ -XXX,XX +XXX,XX @@ size=1048576, max allocation
133
78
== creating image with preallocation falloc ==
134
s->refcount_table_offset = s->cluster_size;
79
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=falloc
135
s->refcount_table_size = s->cluster_size / sizeof(uint64_t);
80
size=1048576, max allocation
136
+ s->max_refcount_table_index = 0;
81
+
137
82
+== resize empty image with block_resize ==
138
g_free(s->refcount_table);
83
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=0
139
s->refcount_table = new_reftable;
84
+size=4096, min allocation
85
+
86
+== resize empty image with block_resize ==
87
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=0
88
+size=1048576, min allocation
89
*** done
140
--
90
--
141
2.11.0
91
2.21.0
142
92
143
93
diff view generated by jsdifflib
1
From: QingFeng Hao <haoqf@linux.vnet.ibm.com>
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
If TEST_DIR is set to /tmp, test case 144 will fail. The reason is that
5
Fixes: fe646693acc13ac48b98435d14149ab04dc597bc
4
TEST_DIR resembles 144's test image name tmp.qcow2.
6
Signed-off-by: Max Reitz <mreitz@redhat.com>
5
When 144 is testing $TEST_DIR/tmp.qcow2, it wants to replace
7
Reviewed-by: John Snow <jsnow@redhat.com>
6
$TEST_DIR/tmp.qcow2 to TEST_DIR/tmp.qcow2, but actually it will fail
8
Message-id: 20190815153638.4600-2-mreitz@redhat.com
7
and get TEST_DIRTEST_DIR.qcow2 in this case.
9
Reviewed-by: John Snow <jsnow@redhat.com>
8
The fix is just to modify the code to replace $TEST_DIR/ with TEST_DIR/.
9
10
Signed-off-by: QingFeng Hao <haoqf@linux.vnet.ibm.com>
11
Message-id: 20161216054723.96055-2-haoqf@linux.vnet.ibm.com
12
Reviewed-by: Eric Blake <eblake@redhat.com>
13
[mreitz: Fixed commit message and dropped superfluous escaping]
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
---
11
---
16
tests/qemu-iotests/common.filter | 2 +-
12
tests/qemu-iotests/059.out | 16 ++++++++--------
17
1 file changed, 1 insertion(+), 1 deletion(-)
13
tests/qemu-iotests/common.filter | 4 ++--
14
2 files changed, 10 insertions(+), 10 deletions(-)
18
15
16
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
17
index XXXXXXX..XXXXXXX 100644
18
--- a/tests/qemu-iotests/059.out
19
+++ b/tests/qemu-iotests/059.out
20
@@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
21
qemu-io: can't open device TEST_DIR/t.vmdk: L1 size too big
22
23
=== Testing monolithicFlat creation and opening ===
24
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat
25
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648
26
image: TEST_DIR/t.IMGFMT
27
file format: IMGFMT
28
virtual size: 2 GiB (2147483648 bytes)
29
30
=== Testing monolithicFlat with zeroed_grain ===
31
qemu-img: TEST_DIR/t.IMGFMT: Flat image can't enable zeroed grain
32
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat
33
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648
34
35
=== Testing big twoGbMaxExtentFlat ===
36
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000 subformat=twoGbMaxExtentFlat
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
19
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
86
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
20
index XXXXXXX..XXXXXXX 100644
87
index XXXXXXX..XXXXXXX 100644
21
--- a/tests/qemu-iotests/common.filter
88
--- a/tests/qemu-iotests/common.filter
22
+++ b/tests/qemu-iotests/common.filter
89
+++ b/tests/qemu-iotests/common.filter
23
@@ -XXX,XX +XXX,XX @@ _filter_generated_node_ids()
90
@@ -XXX,XX +XXX,XX @@ _filter_img_create()
24
# replace occurrences of the actual TEST_DIR value with TEST_DIR
91
-e "s# compat6=\\(on\\|off\\)##g" \
25
_filter_testdir()
92
-e "s# static=\\(on\\|off\\)##g" \
26
{
93
-e "s# zeroed_grain=\\(on\\|off\\)##g" \
27
- sed -e "s#$TEST_DIR#TEST_DIR#g"
94
- -e "s# subformat='[^']*'##g" \
28
+ sed -e "s#$TEST_DIR/#TEST_DIR/#g"
95
- -e "s# adapter_type='[^']*'##g" \
29
}
96
+ -e "s# subformat=[^ ]*##g" \
30
97
+ -e "s# adapter_type=[^ ]*##g" \
31
# replace occurrences of the actual IMGFMT value with IMGFMT
98
-e "s# hwversion=[^ ]*##g" \
99
-e "s# lazy_refcounts=\\(on\\|off\\)##g" \
100
-e "s# block_size=[0-9]\\+##g" \
32
--
101
--
33
2.11.0
102
2.21.0
34
103
35
104
diff view generated by jsdifflib
1
From: Dou Liyang <douly.fnst@cn.fujitsu.com>
1
This makes iotest 033 pass with e.g. subformat=monolithicFlat. It also
2
turns a former error in 059 into success.
2
3
3
In order to reduce the execution time, this patch optimize
4
Signed-off-by: Max Reitz <mreitz@redhat.com>
4
the qmp_query_blockstats():
5
Message-id: 20190815153638.4600-3-mreitz@redhat.com
5
Remove the next_query_bds function.
6
Reviewed-by: John Snow <jsnow@redhat.com>
6
Remove the bdrv_query_stats function.
7
Remove some judgement sentence.
8
9
The original qmp_query_blockstats calls next_query_bds to get
10
the next objects in each loops. In the next_query_bds, it checks
11
the query_nodes and blk. It also call bdrv_query_stats to get
12
the stats, In the bdrv_query_stats, it checks blk and bs each
13
times. This waste more times, which may stall the main loop a
14
bit. And if the disk is too many and donot use the dataplane
15
feature, this may affect the performance in main loop thread.
16
17
This patch removes that two functions, and makes the structure
18
clearly.
19
20
Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
21
Message-id: 1484467275-27919-3-git-send-email-douly.fnst@cn.fujitsu.com
22
Reviewed-by: Markus Armbruster <armbru@redhat.com>
23
[mreitz: Removed duplicate info->value assignment]
24
Signed-off-by: Max Reitz <mreitz@redhat.com>
7
Signed-off-by: Max Reitz <mreitz@redhat.com>
25
---
8
---
26
block/qapi.c | 73 ++++++++++++++++++++++++------------------------------------
9
block/vmdk.c | 54 ++++++++++++++++++++++++--------------
27
1 file changed, 29 insertions(+), 44 deletions(-)
10
tests/qemu-iotests/059 | 7 +++--
11
tests/qemu-iotests/059.out | 4 ++-
12
3 files changed, 42 insertions(+), 23 deletions(-)
28
13
29
diff --git a/block/qapi.c b/block/qapi.c
14
diff --git a/block/vmdk.c b/block/vmdk.c
30
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
31
--- a/block/qapi.c
16
--- a/block/vmdk.c
32
+++ b/block/qapi.c
17
+++ b/block/vmdk.c
33
@@ -XXX,XX +XXX,XX @@ static BlockStats *bdrv_query_bds_stats(const BlockDriverState *bs,
18
@@ -XXX,XX +XXX,XX @@ static const char *next_line(const char *s)
34
return s;
35
}
19
}
36
20
37
-static BlockStats *bdrv_query_stats(BlockBackend *blk,
21
static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
38
- const BlockDriverState *bs,
22
- const char *desc_file_path, QDict *options,
39
- bool query_backing)
23
- Error **errp)
40
-{
24
+ QDict *options, Error **errp)
41
- BlockStats *s;
42
-
43
- s = bdrv_query_bds_stats(bs, query_backing);
44
-
45
- if (blk) {
46
- s->has_device = true;
47
- s->device = g_strdup(blk_name(blk));
48
- bdrv_query_blk_stats(s->stats, blk);
49
- }
50
-
51
- return s;
52
-}
53
-
54
BlockInfoList *qmp_query_block(Error **errp)
55
{
25
{
56
BlockInfoList *head = NULL, **p_next = &head;
26
int ret;
57
@@ -XXX,XX +XXX,XX @@ BlockInfoList *qmp_query_block(Error **errp)
27
int matches;
58
return head;
28
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
29
const char *p, *np;
30
int64_t sectors = 0;
31
int64_t flat_offset;
32
+ char *desc_file_dir = NULL;
33
char *extent_path;
34
BdrvChild *extent_file;
35
BDRVVmdkState *s = bs->opaque;
36
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
37
continue;
38
}
39
40
- if (!path_is_absolute(fname) && !path_has_protocol(fname) &&
41
- !desc_file_path[0])
42
- {
43
- bdrv_refresh_filename(bs->file->bs);
44
- error_setg(errp, "Cannot use relative extent paths with VMDK "
45
- "descriptor file '%s'", bs->file->bs->filename);
46
- return -EINVAL;
47
- }
48
+ if (path_is_absolute(fname)) {
49
+ extent_path = g_strdup(fname);
50
+ } else {
51
+ if (!desc_file_dir) {
52
+ desc_file_dir = bdrv_dirname(bs->file->bs, errp);
53
+ if (!desc_file_dir) {
54
+ bdrv_refresh_filename(bs->file->bs);
55
+ error_prepend(errp, "Cannot use relative paths with VMDK "
56
+ "descriptor file '%s': ",
57
+ bs->file->bs->filename);
58
+ ret = -EINVAL;
59
+ goto out;
60
+ }
61
+ }
62
63
- extent_path = path_combine(desc_file_path, fname);
64
+ extent_path = g_strconcat(desc_file_dir, fname, NULL);
65
+ }
66
67
ret = snprintf(extent_opt_prefix, 32, "extents.%d", s->num_extents);
68
assert(ret < 32);
69
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
70
g_free(extent_path);
71
if (local_err) {
72
error_propagate(errp, local_err);
73
- return -EINVAL;
74
+ ret = -EINVAL;
75
+ goto out;
76
}
77
78
/* save to extents array */
79
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
80
0, 0, 0, 0, 0, &extent, errp);
81
if (ret < 0) {
82
bdrv_unref_child(bs, extent_file);
83
- return ret;
84
+ goto out;
85
}
86
extent->flat_start_offset = flat_offset << 9;
87
} else if (!strcmp(type, "SPARSE") || !strcmp(type, "VMFSSPARSE")) {
88
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
89
g_free(buf);
90
if (ret) {
91
bdrv_unref_child(bs, extent_file);
92
- return ret;
93
+ goto out;
94
}
95
extent = &s->extents[s->num_extents - 1];
96
} else if (!strcmp(type, "SESPARSE")) {
97
ret = vmdk_open_se_sparse(bs, extent_file, bs->open_flags, errp);
98
if (ret) {
99
bdrv_unref_child(bs, extent_file);
100
- return ret;
101
+ goto out;
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;
114
+
115
+ ret = 0;
116
+ goto out;
117
118
invalid:
119
np = next_line(p);
120
@@ -XXX,XX +XXX,XX @@ invalid:
121
np--;
122
}
123
error_setg(errp, "Invalid extent line: %.*s", (int)(np - p), p);
124
- return -EINVAL;
125
+ ret = -EINVAL;
126
+
127
+out:
128
+ g_free(desc_file_dir);
129
+ return ret;
59
}
130
}
60
131
61
-static bool next_query_bds(BlockBackend **blk, BlockDriverState **bs,
132
static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf,
62
- bool query_nodes)
133
@@ -XXX,XX +XXX,XX @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf,
63
-{
64
- if (query_nodes) {
65
- *bs = bdrv_next_node(*bs);
66
- return !!*bs;
67
- }
68
-
69
- *blk = blk_next(*blk);
70
- *bs = *blk ? blk_bs(*blk) : NULL;
71
-
72
- return !!*blk;
73
-}
74
-
75
BlockStatsList *qmp_query_blockstats(bool has_query_nodes,
76
bool query_nodes,
77
Error **errp)
78
{
79
BlockStatsList *head = NULL, **p_next = &head;
80
- BlockBackend *blk = NULL;
81
- BlockDriverState *bs = NULL;
82
+ BlockBackend *blk;
83
+ BlockDriverState *bs;
84
85
/* Just to be safe if query_nodes is not always initialized */
86
- query_nodes = has_query_nodes && query_nodes;
87
-
88
- while (next_query_bds(&blk, &bs, query_nodes)) {
89
- BlockStatsList *info = g_malloc0(sizeof(*info));
90
- AioContext *ctx = blk ? blk_get_aio_context(blk)
91
- : bdrv_get_aio_context(bs);
92
+ if (has_query_nodes && query_nodes) {
93
+ for (bs = bdrv_next_node(NULL); bs; bs = bdrv_next_node(bs)) {
94
+ BlockStatsList *info = g_malloc0(sizeof(*info));
95
+ AioContext *ctx = bdrv_get_aio_context(bs);
96
97
- aio_context_acquire(ctx);
98
- info->value = bdrv_query_stats(blk, bs, !query_nodes);
99
- aio_context_release(ctx);
100
+ aio_context_acquire(ctx);
101
+ info->value = bdrv_query_bds_stats(bs, false);
102
+ aio_context_release(ctx);
103
104
- *p_next = info;
105
- p_next = &info->next;
106
+ *p_next = info;
107
+ p_next = &info->next;
108
+ }
109
+ } else {
110
+ for (blk = blk_next(NULL); blk; blk = blk_next(blk)) {
111
+ BlockStatsList *info = g_malloc0(sizeof(*info));
112
+ AioContext *ctx = blk_get_aio_context(blk);
113
+ BlockStats *s;
114
+
115
+ aio_context_acquire(ctx);
116
+ s = bdrv_query_bds_stats(blk_bs(blk), true);
117
+ s->has_device = true;
118
+ s->device = g_strdup(blk_name(blk));
119
+ bdrv_query_blk_stats(s->stats, blk);
120
+ aio_context_release(ctx);
121
+
122
+ info->value = s;
123
+ *p_next = info;
124
+ p_next = &info->next;
125
+ }
126
}
134
}
127
135
s->create_type = g_strdup(ct);
128
return head;
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
163
index XXXXXXX..XXXXXXX 100644
164
--- a/tests/qemu-iotests/059.out
165
+++ b/tests/qemu-iotests/059.out
166
@@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240
167
168
=== Testing monolithicFlat with internally generated JSON file name ===
169
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
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"}'
171
+format name: IMGFMT
172
+cluster size: 0 bytes
173
+vm state offset: 0 bytes
174
175
=== Testing version 3 ===
176
image: TEST_DIR/iotest-version3.IMGFMT
129
--
177
--
130
2.11.0
178
2.21.0
131
179
132
180
diff view generated by jsdifflib
1
From: Peter Maydell <peter.maydell@linaro.org>
1
We had a test for a case where relative extent paths did not work, but
2
unfortunately we just fixed the underlying problem, so it works now.
3
This patch adds a new test case that still fails.
2
4
3
Coverity points out that we assign the return value from
5
Signed-off-by: Max Reitz <mreitz@redhat.com>
4
bdrv_snapshot_load_tmp() to 'ret' in img_convert(), but then
6
Reviewed-by: John Snow <jsnow@redhat.com>
5
never use that variable. (We check for failure by looking
7
Message-id: 20190815153638.4600-4-mreitz@redhat.com
6
at local_err instead.) Drop the unused assignment, bringing
8
Reviewed-by: John Snow <jsnow@redhat.com>
7
the call into line with the following call to
8
bdrv_snapshot_laod_tmp_by_id_or_name().
9
10
(Fixes CID 1247240.)
11
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Message-id: 1486744104-15590-3-git-send-email-peter.maydell@linaro.org
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
Signed-off-by: Max Reitz <mreitz@redhat.com>
16
---
10
---
17
qemu-img.c | 8 ++++----
11
tests/qemu-iotests/059 | 27 +++++++++++++++++++++++++++
18
1 file changed, 4 insertions(+), 4 deletions(-)
12
tests/qemu-iotests/059.out | 4 ++++
13
2 files changed, 31 insertions(+)
19
14
20
diff --git a/qemu-img.c b/qemu-img.c
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
21
index XXXXXXX..XXXXXXX 100644
61
index XXXXXXX..XXXXXXX 100644
22
--- a/qemu-img.c
62
--- a/tests/qemu-iotests/059.out
23
+++ b/qemu-img.c
63
+++ b/tests/qemu-iotests/059.out
24
@@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv)
64
@@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240
25
}
65
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
26
66
27
if (sn_opts) {
67
=== Testing monolithicFlat with internally generated JSON file name ===
28
- ret = bdrv_snapshot_load_tmp(bs[0],
68
+--- blkdebug ---
29
- qemu_opt_get(sn_opts, SNAPSHOT_OPT_ID),
69
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
30
- qemu_opt_get(sn_opts, SNAPSHOT_OPT_NAME),
70
format name: IMGFMT
31
- &local_err);
71
cluster size: 0 bytes
32
+ bdrv_snapshot_load_tmp(bs[0],
72
vm state offset: 0 bytes
33
+ qemu_opt_get(sn_opts, SNAPSHOT_OPT_ID),
73
+--- quorum ---
34
+ qemu_opt_get(sn_opts, SNAPSHOT_OPT_NAME),
74
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
35
+ &local_err);
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
36
} else if (snapshot_name != NULL) {
76
37
if (bs_n > 1) {
77
=== Testing version 3 ===
38
error_report("No support for concatenating multiple snapshot");
78
image: TEST_DIR/iotest-version3.IMGFMT
39
--
79
--
40
2.11.0
80
2.21.0
41
81
42
82
diff view generated by jsdifflib
1
From: Peter Lieven <pl@kamp.de>
1
Compressed writes generally have to write full clusters, not just in
2
theory but also in practice when it comes to vmdk's streamOptimized
3
subformat. It currently is just silently broken for writes with
4
non-zero in-cluster offsets:
2
5
3
parse_uint_full wants to put the parsed value into the
6
$ qemu-img create -f vmdk -o subformat=streamOptimized foo.vmdk 1M
4
variable passed via its second argument which is NULL.
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
5
11
6
Fixes: 94d6a7a76e9df9919629428f6c598e2b97d9426c
12
(The technical reason is that vmdk_write_extent() just writes the
7
Cc: qemu-stable@nongnu.org
13
incomplete compressed data actually to offset 4k. When reading the
8
Signed-off-by: Peter Lieven <pl@kamp.de>
14
data, vmdk_read_extent() looks at offset 0 and finds the compressed data
9
Reviewed-by: Eric Blake <eblake@redhat.com>
15
size to be 0, because that is what it reads from there. This yields an
10
Message-id: 1485942829-10756-2-git-send-email-pl@kamp.de
16
error.)
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.
33
34
Signed-off-by: Max Reitz <mreitz@redhat.com>
35
Reviewed-by: John Snow <jsnow@redhat.com>
36
Message-id: 20190815153638.4600-5-mreitz@redhat.com
37
Reviewed-by: John Snow <jsnow@redhat.com>
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
38
Signed-off-by: Max Reitz <mreitz@redhat.com>
12
---
39
---
13
block/nfs.c | 3 ++-
40
block/vmdk.c | 10 ++++++++++
14
1 file changed, 2 insertions(+), 1 deletion(-)
41
1 file changed, 10 insertions(+)
15
42
16
diff --git a/block/nfs.c b/block/nfs.c
43
diff --git a/block/vmdk.c b/block/vmdk.c
17
index XXXXXXX..XXXXXXX 100644
44
index XXXXXXX..XXXXXXX 100644
18
--- a/block/nfs.c
45
--- a/block/vmdk.c
19
+++ b/block/nfs.c
46
+++ b/block/vmdk.c
20
@@ -XXX,XX +XXX,XX @@ static int nfs_parse_uri(const char *filename, QDict *options, Error **errp)
47
@@ -XXX,XX +XXX,XX @@ static int vmdk_write_extent(VmdkExtent *extent, int64_t cluster_offset,
21
qdict_put(options, "path", qstring_from_str(uri->path));
48
if (extent->compressed) {
22
49
void *compressed_data;
23
for (i = 0; i < qp->n; i++) {
50
24
+ unsigned long long val;
51
+ /* Only whole clusters */
25
if (!qp->p[i].value) {
52
+ if (offset_in_cluster ||
26
error_setg(errp, "Value for NFS parameter expected: %s",
53
+ n_bytes > (extent->cluster_sectors * SECTOR_SIZE) ||
27
qp->p[i].name);
54
+ (n_bytes < (extent->cluster_sectors * SECTOR_SIZE) &&
28
goto out;
55
+ offset + n_bytes != extent->end_sector * SECTOR_SIZE))
29
}
56
+ {
30
- if (parse_uint_full(qp->p[i].value, NULL, 0)) {
57
+ ret = -EINVAL;
31
+ if (parse_uint_full(qp->p[i].value, &val, 0)) {
58
+ goto out;
32
error_setg(errp, "Illegal value for NFS parameter: %s",
59
+ }
33
qp->p[i].name);
60
+
61
if (!extent->has_marker) {
62
ret = -EINVAL;
34
goto out;
63
goto out;
35
--
64
--
36
2.11.0
65
2.21.0
37
66
38
67
diff view generated by jsdifflib
1
From: Peter Maydell <peter.maydell@linaro.org>
1
streamOptimized does not support writes that do not span exactly one
2
cluster. Furthermore, it cannot rewrite already allocated clusters.
3
As such, many iotests do not work with it. Disable them.
2
4
3
Some of the argument parsing in qemu-img uses strtoul() to parse
5
Signed-off-by: Max Reitz <mreitz@redhat.com>
4
integer arguments. This is tricky to get correct and in fact the
6
Message-id: 20190815153638.4600-6-mreitz@redhat.com
5
code does not get it right, because it assigns the result of
7
Reviewed-by: John Snow <jsnow@redhat.com>
6
strtoul() to an 'int' variable and then tries to check for > INT_MAX.
7
Coverity correctly complains that the comparison is always false.
8
9
Rewrite to use qemu_strtoul(), which has a saner convention for
10
reporting conversion failures.
11
12
(Fixes CID 1356421, CID 1356422, CID 1356423.)
13
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Message-id: 1486744104-15590-2-git-send-email-peter.maydell@linaro.org
16
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
17
Signed-off-by: Max Reitz <mreitz@redhat.com>
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
18
---
9
---
19
qemu-img.c | 32 ++++++++++++++++----------------
10
tests/qemu-iotests/002 | 1 +
20
1 file changed, 16 insertions(+), 16 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(-)
21
32
22
diff --git a/qemu-img.c b/qemu-img.c
33
diff --git a/tests/qemu-iotests/002 b/tests/qemu-iotests/002
23
index XXXXXXX..XXXXXXX 100644
34
index XXXXXXX..XXXXXXX 100755
24
--- a/qemu-img.c
35
--- a/tests/qemu-iotests/002
25
+++ b/qemu-img.c
36
+++ b/tests/qemu-iotests/002
26
@@ -XXX,XX +XXX,XX @@ static int img_bench(int argc, char **argv)
37
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
27
break;
38
28
case 'c':
39
_supported_fmt generic
29
{
40
_supported_proto generic
30
- char *end;
41
+_unsupported_imgopts "subformat=streamOptimized"
31
- errno = 0;
42
32
- count = strtoul(optarg, &end, 0);
43
33
- if (errno || *end || count > INT_MAX) {
44
size=128M
34
+ unsigned long res;
45
diff --git a/tests/qemu-iotests/003 b/tests/qemu-iotests/003
35
+
46
index XXXXXXX..XXXXXXX 100755
36
+ if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > INT_MAX) {
47
--- a/tests/qemu-iotests/003
37
error_report("Invalid request count specified");
48
+++ b/tests/qemu-iotests/003
38
return 1;
49
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
39
}
50
40
+ count = res;
51
_supported_fmt generic
41
break;
52
_supported_proto generic
42
}
53
+_unsupported_imgopts "subformat=streamOptimized"
43
case 'd':
54
44
{
55
size=128M
45
- char *end;
56
offset=67M
46
- errno = 0;
57
diff --git a/tests/qemu-iotests/005 b/tests/qemu-iotests/005
47
- depth = strtoul(optarg, &end, 0);
58
index XXXXXXX..XXXXXXX 100755
48
- if (errno || *end || depth > INT_MAX) {
59
--- a/tests/qemu-iotests/005
49
+ unsigned long res;
60
+++ b/tests/qemu-iotests/005
50
+
61
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
51
+ if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > INT_MAX) {
62
_supported_proto generic
52
error_report("Invalid queue depth specified");
63
_supported_os Linux
53
return 1;
64
_unsupported_imgopts "subformat=twoGbMaxExtentFlat" \
54
}
65
- "subformat=twoGbMaxExtentSparse"
55
+ depth = res;
66
+ "subformat=twoGbMaxExtentSparse" \
56
break;
67
+ "subformat=streamOptimized"
57
}
68
58
case 'f':
69
# vpc is limited to 127GB, so we can't test it here
59
@@ -XXX,XX +XXX,XX @@ static int img_bench(int argc, char **argv)
70
if [ "$IMGFMT" = "vpc" ]; then
60
break;
71
diff --git a/tests/qemu-iotests/009 b/tests/qemu-iotests/009
61
case OPTION_PATTERN:
72
index XXXXXXX..XXXXXXX 100755
62
{
73
--- a/tests/qemu-iotests/009
63
- char *end;
74
+++ b/tests/qemu-iotests/009
64
- errno = 0;
75
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
65
- pattern = strtoul(optarg, &end, 0);
76
66
- if (errno || *end || pattern > 0xff) {
77
_supported_fmt generic
67
+ unsigned long res;
78
_supported_proto generic
68
+
79
+_unsupported_imgopts "subformat=streamOptimized"
69
+ if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > 0xff) {
80
70
error_report("Invalid pattern byte specified");
81
71
return 1;
82
size=6G
72
}
83
diff --git a/tests/qemu-iotests/010 b/tests/qemu-iotests/010
73
+ pattern = res;
84
index XXXXXXX..XXXXXXX 100755
74
break;
85
--- a/tests/qemu-iotests/010
75
}
86
+++ b/tests/qemu-iotests/010
76
case OPTION_FLUSH_INTERVAL:
87
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
77
{
88
78
- char *end;
89
_supported_fmt generic
79
- errno = 0;
90
_supported_proto generic
80
- flush_interval = strtoul(optarg, &end, 0);
91
+_unsupported_imgopts "subformat=streamOptimized"
81
- if (errno || *end || flush_interval > INT_MAX) {
92
82
+ unsigned long res;
93
83
+
94
size=6G
84
+ if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > INT_MAX) {
95
diff --git a/tests/qemu-iotests/011 b/tests/qemu-iotests/011
85
error_report("Invalid flush interval specified");
96
index XXXXXXX..XXXXXXX 100755
86
return 1;
97
--- a/tests/qemu-iotests/011
87
}
98
+++ b/tests/qemu-iotests/011
88
+ flush_interval = res;
99
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
89
break;
100
90
}
101
_supported_fmt generic
91
case OPTION_NO_DRAIN:
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.
92
--
303
--
93
2.11.0
304
2.21.0
94
305
95
306
diff view generated by jsdifflib
1
From: Fam Zheng <famz@redhat.com>
1
The error message for the test case where we have a quorum node for
2
which no directory name can be generated is different: For
3
twoGbMaxExtentSparse, it complains that it cannot open the extent file.
4
For other (sub)formats, it just notes that it cannot determine the
5
backing file path. Both are fine, but just disable twoGbMaxExtentSparse
6
for simplicity's sake.
2
7
3
@bs doesn't always have a device name, such as when it comes from
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
4
"qemu-img info". Report file name instead.
9
Reviewed-by: John Snow <jsnow@redhat.com>
5
10
Message-id: 20190815153638.4600-7-mreitz@redhat.com
6
Signed-off-by: Fam Zheng <famz@redhat.com>
11
Reviewed-by: John Snow <jsnow@redhat.com>
7
Message-id: 20170119130759.28319-2-famz@redhat.com
8
Reviewed-by: Eric Blake <eblake@redhat.com>
9
Signed-off-by: Max Reitz <mreitz@redhat.com>
12
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
---
13
---
11
block/qapi.c | 4 ++--
14
tests/qemu-iotests/110 | 3 ++-
12
1 file changed, 2 insertions(+), 2 deletions(-)
15
1 file changed, 2 insertions(+), 1 deletion(-)
13
16
14
diff --git a/block/qapi.c b/block/qapi.c
17
diff --git a/tests/qemu-iotests/110 b/tests/qemu-iotests/110
15
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100755
16
--- a/block/qapi.c
19
--- a/tests/qemu-iotests/110
17
+++ b/block/qapi.c
20
+++ b/tests/qemu-iotests/110
18
@@ -XXX,XX +XXX,XX @@ void bdrv_query_image_info(BlockDriverState *bs,
21
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
19
22
# Any format supporting backing files
20
size = bdrv_getlength(bs);
23
_supported_fmt qed qcow qcow2 vmdk
21
if (size < 0) {
24
_supported_proto file
22
- error_setg_errno(errp, -size, "Can't get size of device '%s'",
25
-_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
23
- bdrv_get_device_name(bs));
26
+_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
24
+ error_setg_errno(errp, -size, "Can't get image size '%s'",
27
+ "subformat=twoGbMaxExtentSparse"
25
+ bs->exact_filename);
28
26
goto out;
29
TEST_IMG_REL=$(basename "$TEST_IMG")
27
}
28
30
29
--
31
--
30
2.11.0
32
2.21.0
31
33
32
34
diff view generated by jsdifflib
1
From: Peter Lieven <pl@kamp.de>
1
iotest 126 requires backing file support, which flat vmdks cannot offer.
2
Skip this test for such subformats.
2
3
3
commit 94d6a7a accidentally left the naming of runtime opts and QAPI
4
Signed-off-by: Max Reitz <mreitz@redhat.com>
4
scheme inconsistent. As one consequence passing of parameters in the
5
Message-id: 20190815153638.4600-8-mreitz@redhat.com
5
URI is broken. Sync the naming of the runtime opts to the QAPI
6
Reviewed-by: John Snow <jsnow@redhat.com>
6
scheme.
7
8
Please note that this is technically backwards incompatible with the 2.8
9
release, but the 2.8 release is the only version that had the wrong naming.
10
Furthermore release 2.8 suffered from a NULL pointer dereference during
11
URI parsing.
12
13
Fixes: 94d6a7a76e9df9919629428f6c598e2b97d9426c
14
Cc: qemu-stable@nongnu.org
15
Signed-off-by: Peter Lieven <pl@kamp.de>
16
Message-id: 1485942829-10756-3-git-send-email-pl@kamp.de
17
[mreitz: Fixed commit message]
18
Reviewed-by: Eric Blake <eblake@redhat.com>
19
Signed-off-by: Max Reitz <mreitz@redhat.com>
7
Signed-off-by: Max Reitz <mreitz@redhat.com>
20
---
8
---
21
block/nfs.c | 46 +++++++++++++++++++++++-----------------------
9
tests/qemu-iotests/126 | 2 ++
22
1 file changed, 23 insertions(+), 23 deletions(-)
10
1 file changed, 2 insertions(+)
23
11
24
diff --git a/block/nfs.c b/block/nfs.c
12
diff --git a/tests/qemu-iotests/126 b/tests/qemu-iotests/126
25
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100755
26
--- a/block/nfs.c
14
--- a/tests/qemu-iotests/126
27
+++ b/block/nfs.c
15
+++ b/tests/qemu-iotests/126
28
@@ -XXX,XX +XXX,XX @@ static QemuOptsList runtime_opts = {
16
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
29
.help = "Path of the image on the host",
17
30
},
18
# Needs backing file support
31
{
19
_supported_fmt qcow qcow2 qed vmdk
32
- .name = "uid",
20
+_unsupported_imgopts "subformat=monolithicFlat" \
33
+ .name = "user",
21
+ "subformat=twoGbMaxExtentFlat"
34
.type = QEMU_OPT_NUMBER,
22
# This is the default protocol (and we want to test the difference between
35
.help = "UID value to use when talking to the server",
23
# colons which separate a protocol prefix from the rest and colons which are
36
},
24
# just part of the filename, so we cannot test protocols which require a prefix)
37
{
38
- .name = "gid",
39
+ .name = "group",
40
.type = QEMU_OPT_NUMBER,
41
.help = "GID value to use when talking to the server",
42
},
43
{
44
- .name = "tcp-syncnt",
45
+ .name = "tcp-syn-count",
46
.type = QEMU_OPT_NUMBER,
47
.help = "Number of SYNs to send during the session establish",
48
},
49
{
50
- .name = "readahead",
51
+ .name = "readahead-size",
52
.type = QEMU_OPT_NUMBER,
53
.help = "Set the readahead size in bytes",
54
},
55
{
56
- .name = "pagecache",
57
+ .name = "page-cache-size",
58
.type = QEMU_OPT_NUMBER,
59
.help = "Set the pagecache size in bytes",
60
},
61
@@ -XXX,XX +XXX,XX @@ static int64_t nfs_client_open(NFSClient *client, QDict *options,
62
goto fail;
63
}
64
65
- if (qemu_opt_get(opts, "uid")) {
66
- client->uid = qemu_opt_get_number(opts, "uid", 0);
67
+ if (qemu_opt_get(opts, "user")) {
68
+ client->uid = qemu_opt_get_number(opts, "user", 0);
69
nfs_set_uid(client->context, client->uid);
70
}
71
72
- if (qemu_opt_get(opts, "gid")) {
73
- client->gid = qemu_opt_get_number(opts, "gid", 0);
74
+ if (qemu_opt_get(opts, "group")) {
75
+ client->gid = qemu_opt_get_number(opts, "group", 0);
76
nfs_set_gid(client->context, client->gid);
77
}
78
79
- if (qemu_opt_get(opts, "tcp-syncnt")) {
80
- client->tcp_syncnt = qemu_opt_get_number(opts, "tcp-syncnt", 0);
81
+ if (qemu_opt_get(opts, "tcp-syn-count")) {
82
+ client->tcp_syncnt = qemu_opt_get_number(opts, "tcp-syn-count", 0);
83
nfs_set_tcp_syncnt(client->context, client->tcp_syncnt);
84
}
85
86
#ifdef LIBNFS_FEATURE_READAHEAD
87
- if (qemu_opt_get(opts, "readahead")) {
88
+ if (qemu_opt_get(opts, "readahead-size")) {
89
if (open_flags & BDRV_O_NOCACHE) {
90
error_setg(errp, "Cannot enable NFS readahead "
91
"if cache.direct = on");
92
goto fail;
93
}
94
- client->readahead = qemu_opt_get_number(opts, "readahead", 0);
95
+ client->readahead = qemu_opt_get_number(opts, "readahead-size", 0);
96
if (client->readahead > QEMU_NFS_MAX_READAHEAD_SIZE) {
97
error_report("NFS Warning: Truncating NFS readahead "
98
"size to %d", QEMU_NFS_MAX_READAHEAD_SIZE);
99
@@ -XXX,XX +XXX,XX @@ static int64_t nfs_client_open(NFSClient *client, QDict *options,
100
#endif
101
102
#ifdef LIBNFS_FEATURE_PAGECACHE
103
- if (qemu_opt_get(opts, "pagecache")) {
104
+ if (qemu_opt_get(opts, "page-cache-size")) {
105
if (open_flags & BDRV_O_NOCACHE) {
106
error_setg(errp, "Cannot enable NFS pagecache "
107
"if cache.direct = on");
108
goto fail;
109
}
110
- client->pagecache = qemu_opt_get_number(opts, "pagecache", 0);
111
+ client->pagecache = qemu_opt_get_number(opts, "page-cache-size", 0);
112
if (client->pagecache > QEMU_NFS_MAX_PAGECACHE_SIZE) {
113
error_report("NFS Warning: Truncating NFS pagecache "
114
"size to %d pages", QEMU_NFS_MAX_PAGECACHE_SIZE);
115
@@ -XXX,XX +XXX,XX @@ static void nfs_refresh_filename(BlockDriverState *bs, QDict *options)
116
qdict_put(opts, "path", qstring_from_str(client->path));
117
118
if (client->uid) {
119
- qdict_put(opts, "uid", qint_from_int(client->uid));
120
+ qdict_put(opts, "user", qint_from_int(client->uid));
121
}
122
if (client->gid) {
123
- qdict_put(opts, "gid", qint_from_int(client->gid));
124
+ qdict_put(opts, "group", qint_from_int(client->gid));
125
}
126
if (client->tcp_syncnt) {
127
- qdict_put(opts, "tcp-syncnt",
128
- qint_from_int(client->tcp_syncnt));
129
+ qdict_put(opts, "tcp-syn-cnt",
130
+ qint_from_int(client->tcp_syncnt));
131
}
132
if (client->readahead) {
133
- qdict_put(opts, "readahead",
134
- qint_from_int(client->readahead));
135
+ qdict_put(opts, "readahead-size",
136
+ qint_from_int(client->readahead));
137
}
138
if (client->pagecache) {
139
- qdict_put(opts, "pagecache",
140
- qint_from_int(client->pagecache));
141
+ qdict_put(opts, "page-cache-size",
142
+ qint_from_int(client->pagecache));
143
}
144
if (client->debug) {
145
qdict_put(opts, "debug", qint_from_int(client->debug));
146
--
25
--
147
2.11.0
26
2.21.0
148
27
149
28
diff view generated by jsdifflib
1
From: Dou Liyang <douly.fnst@cn.fujitsu.com>
1
From: Stefan Hajnoczi <stefanha@redhat.com>
2
2
3
The bdrv_query_stats and bdrv_query_bds_stats functions need to call
3
Fixes: a6b257a08e3d72219f03e461a52152672fec0612
4
each other, that increases the coupling. it also makes the program
4
("file-posix: Handle undetectable alignment")
5
complicated and makes some unnecessary tests.
5
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
6
6
Message-id: 20190827101328.4062-1-stefanha@redhat.com
7
Remove the call from bdrv_query_bds_stats to bdrv_query_stats, just
7
Reviewed-by: Thomas Huth <thuth@redhat.com>
8
take some recursion to make it clearly.
9
10
Avoid testing whether the blk is NULL during querying the bds stats.
11
It is unnecessary.
12
13
Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
14
Message-id: 1484467275-27919-2-git-send-email-douly.fnst@cn.fujitsu.com
15
Reviewed-by: Markus Armbruster <armbru@redhat.com>
16
Signed-off-by: Max Reitz <mreitz@redhat.com>
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
17
---
9
---
18
block/qapi.c | 26 ++++++++++++++------------
10
block/file-posix.c | 2 +-
19
1 file changed, 14 insertions(+), 12 deletions(-)
11
1 file changed, 1 insertion(+), 1 deletion(-)
20
12
21
diff --git a/block/qapi.c b/block/qapi.c
13
diff --git a/block/file-posix.c b/block/file-posix.c
22
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
23
--- a/block/qapi.c
15
--- a/block/file-posix.c
24
+++ b/block/qapi.c
16
+++ b/block/file-posix.c
25
@@ -XXX,XX +XXX,XX @@ static void bdrv_query_info(BlockBackend *blk, BlockInfo **p_info,
17
@@ -XXX,XX +XXX,XX @@ static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp)
26
qapi_free_BlockInfo(info);
18
for (i = 0; i < ARRAY_SIZE(alignments); i++) {
27
}
19
align = alignments[i];
28
20
if (raw_is_io_aligned(fd, buf + align, max_align)) {
29
-static BlockStats *bdrv_query_stats(BlockBackend *blk,
21
- /* Fallback to request_aligment. */
30
- const BlockDriverState *bs,
22
+ /* Fallback to request_alignment. */
31
- bool query_backing);
23
s->buf_align = (align != 1) ? align : bs->bl.request_alignment;
32
-
24
break;
33
static void bdrv_query_blk_stats(BlockDeviceStats *ds, BlockBackend *blk)
25
}
34
{
35
BlockAcctStats *stats = blk_get_stats(blk);
36
@@ -XXX,XX +XXX,XX @@ static void bdrv_query_blk_stats(BlockDeviceStats *ds, BlockBackend *blk)
37
}
38
}
39
40
-static void bdrv_query_bds_stats(BlockStats *s, const BlockDriverState *bs,
41
+static BlockStats *bdrv_query_bds_stats(const BlockDriverState *bs,
42
bool query_backing)
43
{
44
+ BlockStats *s = NULL;
45
+
46
+ s = g_malloc0(sizeof(*s));
47
+ s->stats = g_malloc0(sizeof(*s->stats));
48
+
49
+ if (!bs) {
50
+ return s;
51
+ }
52
+
53
if (bdrv_get_node_name(bs)[0]) {
54
s->has_node_name = true;
55
s->node_name = g_strdup(bdrv_get_node_name(bs));
56
@@ -XXX,XX +XXX,XX @@ static void bdrv_query_bds_stats(BlockStats *s, const BlockDriverState *bs,
57
58
if (bs->file) {
59
s->has_parent = true;
60
- s->parent = bdrv_query_stats(NULL, bs->file->bs, query_backing);
61
+ s->parent = bdrv_query_bds_stats(bs->file->bs, query_backing);
62
}
63
64
if (query_backing && bs->backing) {
65
s->has_backing = true;
66
- s->backing = bdrv_query_stats(NULL, bs->backing->bs, query_backing);
67
+ s->backing = bdrv_query_bds_stats(bs->backing->bs, query_backing);
68
}
69
70
+ return s;
71
}
72
73
static BlockStats *bdrv_query_stats(BlockBackend *blk,
74
@@ -XXX,XX +XXX,XX @@ static BlockStats *bdrv_query_stats(BlockBackend *blk,
75
{
76
BlockStats *s;
77
78
- s = g_malloc0(sizeof(*s));
79
- s->stats = g_malloc0(sizeof(*s->stats));
80
+ s = bdrv_query_bds_stats(bs, query_backing);
81
82
if (blk) {
83
s->has_device = true;
84
s->device = g_strdup(blk_name(blk));
85
bdrv_query_blk_stats(s->stats, blk);
86
}
87
- if (bs) {
88
- bdrv_query_bds_stats(s, bs, query_backing);
89
- }
90
91
return s;
92
}
93
--
26
--
94
2.11.0
27
2.21.0
95
28
96
29
diff view generated by jsdifflib
1
From: Nir Soffer <nirsof@gmail.com>
1
From: Thomas Huth <thuth@redhat.com>
2
2
3
This helper allows adding tests supporting any format expect the
3
It is possible to enable only a subset of the block drivers with the
4
specified formats. This may be useful to test that many formats behave
4
"--block-drv-rw-whitelist" option of the "configure" script. All other
5
in a common way.
5
drivers are marked as unusable (or only included as read-only with the
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.
6
12
7
Signed-off-by: Nir Soffer <nirsof@gmail.com>
13
This patch mainly targets the test in the "auto" group which should
8
Message-id: 20170201003120.23378-3-nirsof@gmail.com
14
never fail in such a case, but also improves some of the other tests
9
Reviewed-by: Max Reitz <mreitz@redhat.com>
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
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
21
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
---
22
---
12
tests/qemu-iotests/common.rc | 11 +++++++++++
23
tests/qemu-iotests/071 | 1 +
13
1 file changed, 11 insertions(+)
24
tests/qemu-iotests/081 | 4 +---
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(-)
14
32
33
diff --git a/tests/qemu-iotests/071 b/tests/qemu-iotests/071
34
index XXXXXXX..XXXXXXX 100755
35
--- a/tests/qemu-iotests/071
36
+++ b/tests/qemu-iotests/071
37
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
38
39
_supported_fmt qcow2
40
_supported_proto file
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
103
104
echo
105
echo '=== NBD ==='
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"
15
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
130
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
16
index XXXXXXX..XXXXXXX 100644
131
index XXXXXXX..XXXXXXX 100644
17
--- a/tests/qemu-iotests/common.rc
132
--- a/tests/qemu-iotests/common.rc
18
+++ b/tests/qemu-iotests/common.rc
133
+++ b/tests/qemu-iotests/common.rc
19
@@ -XXX,XX +XXX,XX @@ _supported_fmt()
134
@@ -XXX,XX +XXX,XX @@ _require_command()
20
_notrun "not suitable for this image format: $IMGFMT"
135
[ -x "$c" ] || _notrun "$1 utility required, skipped this test"
21
}
136
}
22
137
23
+# tests whether $IMGFMT is one of the unsupported image format for a test
138
+# Check that a set of drivers has been whitelisted in the QEMU binary
24
+#
139
+#
25
+_unsupported_fmt()
140
+_require_drivers()
26
+{
141
+{
27
+ for f; do
142
+ available=$($QEMU -drive format=help | \
28
+ if [ "$f" = "$IMGFMT" ]; then
143
+ sed -e '/Supported formats:/!d' -e 's/Supported formats://')
29
+ _notrun "not suitable for this image format: $IMGFMT"
144
+ for driver
145
+ do
146
+ if ! echo "$available" | grep -q " $driver\( \|$\)"; then
147
+ _notrun "$driver not available"
30
+ fi
148
+ fi
31
+ done
149
+ done
32
+}
150
+}
33
+
151
+
34
# tests whether $IMGPROTO is one of the supported image protocols for a test
152
# make sure this script returns success
35
#
153
true
36
_supported_proto()
37
--
154
--
38
2.11.0
155
2.21.0
39
156
40
157
diff view generated by jsdifflib
1
When trying to invoke qemu-img commit with a base image file name that
1
From: Thomas Huth <thuth@redhat.com>
2
is not part of the top image's backing chain, the user receives a rather
3
plain "Base not found" error message. This is not really helpful because
4
it does not explain what "not found" means, potentially leaving the user
5
wondering why qemu cannot find a file despite it clearly existing in the
6
file system.
7
2
8
Improve the error message by clarifying that "not found" means "not
3
The sanitizers (especially the address sanitizer from Clang) are
9
found in the top image's backing chain".
4
sometimes printing out warnings or false positives - this spoils
5
the output of the iotests, causing some of the tests to fail.
6
Thus let's skip the automatic iotests during "make check" when the
7
user configured QEMU with --enable-sanitizers.
10
8
11
Reported-by: Ala Hino <ahino@redhat.com>
9
Signed-off-by: Thomas Huth <thuth@redhat.com>
12
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
Message-id: 20190823084203.29734-1-thuth@redhat.com
13
Message-id: 20161201020508.24417-1-mreitz@redhat.com
14
Reviewed-by: Eric Blake <eblake@redhat.com>
15
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
16
---
12
---
17
qemu-img.c | 4 +++-
13
tests/check-block.sh | 5 +++++
18
1 file changed, 3 insertions(+), 1 deletion(-)
14
1 file changed, 5 insertions(+)
19
15
20
diff --git a/qemu-img.c b/qemu-img.c
16
diff --git a/tests/check-block.sh b/tests/check-block.sh
21
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100755
22
--- a/qemu-img.c
18
--- a/tests/check-block.sh
23
+++ b/qemu-img.c
19
+++ b/tests/check-block.sh
24
@@ -XXX,XX +XXX,XX @@ static int img_commit(int argc, char **argv)
20
@@ -XXX,XX +XXX,XX @@ if grep -q "TARGET_GPROF=y" *-softmmu/config-target.mak 2>/dev/null ; then
25
if (base) {
21
exit 0
26
base_bs = bdrv_find_backing_image(bs, base);
22
fi
27
if (!base_bs) {
23
28
- error_setg(&local_err, QERR_BASE_NOT_FOUND, base);
24
+if grep -q "CFLAGS.*-fsanitize" config-host.mak 2>/dev/null ; then
29
+ error_setg(&local_err,
25
+ echo "Sanitizers are enabled ==> Not running the qemu-iotests."
30
+ "Did not find '%s' in the backing chain of '%s'",
26
+ exit 0
31
+ base, filename);
27
+fi
32
goto done;
28
+
33
}
29
if [ -z "$(find . -name 'qemu-system-*' -print)" ]; then
34
} else {
30
echo "No qemu-system binary available ==> Not running the qemu-iotests."
31
exit 0
35
--
32
--
36
2.11.0
33
2.21.0
37
34
38
35
diff view generated by jsdifflib
1
From: Nir Soffer <nirsof@gmail.com>
1
From: Nir Soffer <nirsof@gmail.com>
2
2
3
Add regression tests checking that qemu-io fails with non-zero exit code
3
Quoting cache mode is not needed, and most tests use unquoted values.
4
when reading non-existing file or using the wrong image format.
4
Unify all test to use the same style.
5
5
6
Signed-off-by: Nir Soffer <nirsof@gmail.com>
6
Message-id: 20190827173432.7656-1-nsoffer@redhat.com
7
Message-id: 20170201003120.23378-4-nirsof@gmail.com
7
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
8
Reviewed-by: Max Reitz <mreitz@redhat.com>
9
Signed-off-by: Max Reitz <mreitz@redhat.com>
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
---
9
---
11
tests/qemu-iotests/174 | 59 ++++++++++++++++++++++++++++++++++++++++++++++
10
tests/qemu-iotests/026 | 4 ++--
12
tests/qemu-iotests/174.out | 7 ++++++
11
tests/qemu-iotests/039 | 4 ++--
13
tests/qemu-iotests/group | 1 +
12
tests/qemu-iotests/052 | 2 +-
14
3 files changed, 67 insertions(+)
13
tests/qemu-iotests/091 | 4 ++--
15
create mode 100755 tests/qemu-iotests/174
14
4 files changed, 7 insertions(+), 7 deletions(-)
16
create mode 100644 tests/qemu-iotests/174.out
17
15
18
diff --git a/tests/qemu-iotests/174 b/tests/qemu-iotests/174
16
diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026
19
new file mode 100755
17
index XXXXXXX..XXXXXXX 100755
20
index XXXXXXX..XXXXXXX
18
--- a/tests/qemu-iotests/026
21
--- /dev/null
19
+++ b/tests/qemu-iotests/026
22
+++ b/tests/qemu-iotests/174
20
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
23
@@ -XXX,XX +XXX,XX @@
21
# Currently only qcow2 supports rebasing
24
+#!/bin/bash
22
_supported_fmt qcow2
25
+#
23
_supported_proto file
26
+# Test that qemu-io fail with non-zero exit code
24
-_default_cache_mode "writethrough"
27
+#
25
-_supported_cache_modes "writethrough" "none"
28
+# Copyright (C) 2017 Nir Soffer <nirsof@gmail.com>
26
+_default_cache_mode writethrough
29
+#
27
+_supported_cache_modes writethrough none
30
+# This program is free software; you can redistribute it and/or modify
28
# The refcount table tests expect a certain minimum width for refcount entries
31
+# it under the terms of the GNU General Public License as published by
29
# (so that the refcount table actually needs to grow); that minimum is 16 bits,
32
+# the Free Software Foundation; either version 2 of the License, or
30
# being the default refcount entry width.
33
+# (at your option) any later version.
31
diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
34
+#
32
index XXXXXXX..XXXXXXX 100755
35
+# This program is distributed in the hope that it will be useful,
33
--- a/tests/qemu-iotests/039
36
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
34
+++ b/tests/qemu-iotests/039
37
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
38
+# GNU General Public License for more details.
36
_supported_fmt qcow2
39
+#
37
_supported_proto file
40
+# You should have received a copy of the GNU General Public License
38
_supported_os Linux
41
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
39
-_default_cache_mode "writethrough"
42
+#
40
-_supported_cache_modes "writethrough"
43
+
41
+_default_cache_mode writethrough
44
+# creator
42
+_supported_cache_modes writethrough
45
+owner=nirsof@gmail.com
43
46
+
44
size=128M
47
+seq=`basename $0`
45
48
+echo "QA output created by $seq"
46
diff --git a/tests/qemu-iotests/052 b/tests/qemu-iotests/052
49
+
47
index XXXXXXX..XXXXXXX 100755
50
+here=`pwd`
48
--- a/tests/qemu-iotests/052
51
+status=1    # failure is the default!
49
+++ b/tests/qemu-iotests/052
52
+
50
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
53
+_cleanup()
51
_supported_proto file
54
+{
52
55
+    _cleanup_test_img
53
# Don't do O_DIRECT on tmpfs
56
+}
54
-_supported_cache_modes "writeback" "writethrough" "unsafe"
57
+trap "_cleanup; exit \$status" 0 1 2 3 15
55
+_supported_cache_modes writeback writethrough unsafe
58
+
56
59
+# get standard environment, filters and checks
57
size=128M
60
+. ./common.rc
58
_make_test_img $size
61
+. ./common.filter
59
diff --git a/tests/qemu-iotests/091 b/tests/qemu-iotests/091
62
+
60
index XXXXXXX..XXXXXXX 100755
63
+_unsupported_fmt raw
61
--- a/tests/qemu-iotests/091
64
+
62
+++ b/tests/qemu-iotests/091
65
+
63
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
66
+size=256K
64
_supported_fmt qcow2
67
+IMGFMT=raw IMGOPTS= _make_test_img $size | _filter_imgfmt
65
_supported_proto file
68
+
66
_supported_os Linux
69
+echo
67
-_default_cache_mode "none"
70
+echo "== reading wrong format should fail =="
68
-_supported_cache_modes "writethrough" "none" "writeback"
71
+$QEMU_IO -f $IMGFMT -c "read 0 $size" "$TEST_IMG" 2>/dev/null
69
+_default_cache_mode none
72
+test $? -eq 1 || _fail "did not fail"
70
+_supported_cache_modes writethrough none writeback
73
+
71
74
+echo
72
size=1G
75
+echo "== reading missing file should fail =="
73
76
+$QEMU_IO -c "read 0 $size" "$TEST_DIR/missing" 2>/dev/null
77
+test $? -eq 1 || _fail "did not fail"
78
+
79
+# success, all done
80
+echo "*** done"
81
+rm -f $seq.full
82
+status=0
83
diff --git a/tests/qemu-iotests/174.out b/tests/qemu-iotests/174.out
84
new file mode 100644
85
index XXXXXXX..XXXXXXX
86
--- /dev/null
87
+++ b/tests/qemu-iotests/174.out
88
@@ -XXX,XX +XXX,XX @@
89
+QA output created by 174
90
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=262144
91
+
92
+== reading wrong format should fail ==
93
+
94
+== reading missing file should fail ==
95
+*** done
96
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
97
index XXXXXXX..XXXXXXX 100644
98
--- a/tests/qemu-iotests/group
99
+++ b/tests/qemu-iotests/group
100
@@ -XXX,XX +XXX,XX @@
101
171 rw auto quick
102
172 auto
103
173 rw auto
104
+174 auto
105
--
74
--
106
2.11.0
75
2.21.0
107
76
108
77
diff view generated by jsdifflib