1
The following changes since commit 23919ddfd56135cad3cb468a8f54d5a595f024f4:
1
The following changes since commit 754f756cc4c6d9d14b7230c62b5bb20f9d655888:
2
2
3
Merge remote-tracking branch 'remotes/aperard/tags/pull-xen-20190827' into staging (2019-08-27 15:52:36 +0100)
3
Merge tag 'pull-target-arm-20220422-1' of https://git.linaro.org/people/pmaydell/qemu-arm into staging (2022-04-22 08:03:18 -0700)
4
4
5
are available in the Git repository at:
5
are available in the Git repository at:
6
6
7
https://github.com/XanClic/qemu.git tags/pull-block-2019-08-27
7
https://gitlab.com/hreitz/qemu.git tags/pull-block-2022-04-25
8
8
9
for you to fetch changes up to bb043c056cffcc2f3ce88bfdaf2e76e455c09e2c:
9
for you to fetch changes up to 348a0740afc5b313599533eb69bbb2b95d2f1bba:
10
10
11
iotests: Unify cache mode quoting (2019-08-27 19:48:44 +0200)
11
iotests/108: Fix when missing user_allow_other (2022-04-25 14:46:45 +0200)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Block patches:
14
Block patches:
15
- qemu-io now accepts a file to read a write pattern from
15
- New @force parameter for blockdev-change-medium
16
- Ensure that raw files have their first block allocated so we can probe
16
- Improvements to the iotests to help with debugging
17
the O_DIRECT alignment if necessary
17
- Fix iotest 108 on systems without user_allow_other in fuse.conf
18
- Various fixes
19
18
20
----------------------------------------------------------------
19
----------------------------------------------------------------
21
Denis Plotnikov (1):
20
Denis V. Lunev (1):
22
qemu-io: add pattern file for write command
21
block: add 'force' parameter to 'blockdev-change-medium' command
23
22
24
Max Reitz (7):
23
Hanna Reitz (1):
25
iotests: Fix _filter_img_create()
24
iotests/108: Fix when missing user_allow_other
26
vmdk: Use bdrv_dirname() for relative extent paths
27
iotests: Keep testing broken relative extent paths
28
vmdk: Reject invalid compressed writes
29
iotests: Disable broken streamOptimized tests
30
iotests: Disable 110 for vmdk.twoGbMaxExtentSparse
31
iotests: Disable 126 for flat vmdk subformats
32
25
33
Nir Soffer (3):
26
John Snow (12):
34
block: posix: Always allocate the first block
27
iotests: replace calls to log(qemu_io(...)) with qemu_io_log()
35
iotests: Test allocate_first_block() with O_DIRECT
28
iotests/163: Fix broken qemu-io invocation
36
iotests: Unify cache mode quoting
29
iotests: Don't check qemu_io() output for specific error strings
30
iotests/040: Don't check image pattern on zero-length image
31
iotests/040: Fix TestCommitWithFilters test
32
iotests: create generic qemu_tool() function
33
iotests: rebase qemu_io() on top of qemu_tool()
34
iotests/migration-permissions: use assertRaises() for qemu_io()
35
negative test
36
iotests/image-fleecing: switch to qemu_io()
37
iotests: remove qemu_io_pipe_and_status()
38
iotests: remove qemu_io_silent() and qemu_io_silent_check().
39
iotests: make qemu_io_log() check return codes by default
37
40
38
Stefan Hajnoczi (1):
41
qapi/block.json | 6 ++
39
file-posix: fix request_alignment typo
42
block/qapi-sysemu.c | 3 +-
40
43
monitor/hmp-cmds.c | 4 +-
41
Thomas Huth (2):
44
hmp-commands.hx | 11 ++-
42
iotests: Check for enabled drivers before testing them
45
tests/qemu-iotests/030 | 85 +++++++++++--------
43
tests/check-block: Skip iotests when sanitizers are enabled
46
tests/qemu-iotests/040 | 53 +++++++-----
44
47
tests/qemu-iotests/056 | 2 +-
45
Vladimir Sementsov-Ogievskiy (1):
48
tests/qemu-iotests/108 | 2 +-
46
block: fix permission update in bdrv_replace_node
49
tests/qemu-iotests/149 | 6 +-
47
50
tests/qemu-iotests/163 | 5 +-
48
block.c | 5 +-
51
tests/qemu-iotests/205 | 4 +-
49
block/file-posix.c | 53 +++++++++-
52
tests/qemu-iotests/216 | 12 +--
50
block/vmdk.c | 64 ++++++++----
53
tests/qemu-iotests/218 | 5 +-
51
qemu-io-cmds.c | 99 +++++++++++++++++--
54
tests/qemu-iotests/224 | 4 +-
52
tests/check-block.sh | 5 +
55
tests/qemu-iotests/242 | 6 +-
53
tests/qemu-iotests/002 | 1 +
56
tests/qemu-iotests/245 | 17 ++--
54
tests/qemu-iotests/003 | 1 +
57
tests/qemu-iotests/255 | 4 +-
55
tests/qemu-iotests/005 | 3 +-
58
tests/qemu-iotests/258 | 11 ++-
56
tests/qemu-iotests/009 | 1 +
59
tests/qemu-iotests/298 | 17 ++--
57
tests/qemu-iotests/010 | 1 +
60
tests/qemu-iotests/303 | 4 +-
58
tests/qemu-iotests/011 | 1 +
61
tests/qemu-iotests/310 | 22 ++---
59
tests/qemu-iotests/017 | 3 +-
62
tests/qemu-iotests/iotests.py | 69 ++++++++-------
60
tests/qemu-iotests/018 | 3 +-
63
tests/qemu-iotests/tests/image-fleecing | 30 ++++---
61
tests/qemu-iotests/019 | 3 +-
64
.../qemu-iotests/tests/migration-permissions | 28 +++---
62
tests/qemu-iotests/020 | 3 +-
65
.../tests/mirror-ready-cancel-error | 2 +-
63
tests/qemu-iotests/026 | 4 +-
66
.../qemu-iotests/tests/nbd-reconnect-on-open | 2 +-
64
tests/qemu-iotests/027 | 1 +
67
.../qemu-iotests/tests/stream-error-on-reset | 4 +-
65
tests/qemu-iotests/032 | 1 +
68
ui/cocoa.m | 1 +
66
tests/qemu-iotests/033 | 1 +
69
28 files changed, 231 insertions(+), 188 deletions(-)
67
tests/qemu-iotests/034 | 3 +-
68
tests/qemu-iotests/037 | 3 +-
69
tests/qemu-iotests/039 | 4 +-
70
tests/qemu-iotests/052 | 2 +-
71
tests/qemu-iotests/059 | 34 ++++++-
72
tests/qemu-iotests/059.out | 26 +++--
73
tests/qemu-iotests/063 | 3 +-
74
tests/qemu-iotests/071 | 1 +
75
tests/qemu-iotests/072 | 1 +
76
tests/qemu-iotests/081 | 4 +-
77
tests/qemu-iotests/091 | 4 +-
78
tests/qemu-iotests/099 | 1 +
79
tests/qemu-iotests/105 | 3 +-
80
tests/qemu-iotests/110 | 3 +-
81
tests/qemu-iotests/120 | 1 +
82
tests/qemu-iotests/126 | 2 +
83
tests/qemu-iotests/{150.out => 150.out.qcow2} | 0
84
tests/qemu-iotests/150.out.raw | 12 +++
85
tests/qemu-iotests/162 | 4 +-
86
tests/qemu-iotests/175 | 47 +++++++--
87
tests/qemu-iotests/175.out | 16 ++-
88
tests/qemu-iotests/178.out.qcow2 | 4 +-
89
tests/qemu-iotests/184 | 1 +
90
tests/qemu-iotests/186 | 1 +
91
tests/qemu-iotests/197 | 1 +
92
tests/qemu-iotests/215 | 1 +
93
tests/qemu-iotests/221.out | 12 ++-
94
tests/qemu-iotests/251 | 1 +
95
tests/qemu-iotests/253.out | 12 ++-
96
tests/qemu-iotests/common.filter | 4 +-
97
tests/qemu-iotests/common.rc | 14 +++
98
50 files changed, 391 insertions(+), 87 deletions(-)
99
rename tests/qemu-iotests/{150.out => 150.out.qcow2} (100%)
100
create mode 100644 tests/qemu-iotests/150.out.raw
101
70
102
--
71
--
103
2.21.0
72
2.35.1
104
105
diff view generated by jsdifflib
Deleted patch
1
From: Denis Plotnikov <dplotnikov@virtuozzo.com>
2
1
3
The patch allows to provide a pattern file for write
4
command. There was no similar ability before.
5
6
Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com>
7
Message-id: 20190820164616.4072-1-dplotnikov@virtuozzo.com
8
Reviewed-by: Eric Blake <eblake@redhat.com>
9
[mreitz: Keep optstring in alphabetical order]
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
---
12
qemu-io-cmds.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++---
13
1 file changed, 93 insertions(+), 6 deletions(-)
14
15
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/qemu-io-cmds.c
18
+++ b/qemu-io-cmds.c
19
@@ -XXX,XX +XXX,XX @@ static void qemu_io_free(void *p)
20
qemu_vfree(p);
21
}
22
23
+/*
24
+ * qemu_io_alloc_from_file()
25
+ *
26
+ * Allocates the buffer and populates it with the content of the given file
27
+ * up to @len bytes. If the file length is less than @len, then the buffer
28
+ * is populated with the file content cyclically.
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;
86
+ }
87
+ }
88
+
89
+ return buf_origin;
90
+
91
+error:
92
+ qemu_io_free(buf_origin);
93
+ return NULL;
94
+}
95
+
96
static void dump_buffer(const void *buffer, int64_t offset, int64_t len)
97
{
98
uint64_t i;
99
@@ -XXX,XX +XXX,XX @@ static void write_help(void)
100
" -n, -- with -z, don't allow slow fallback\n"
101
" -p, -- ignored for backwards compatibility\n"
102
" -P, -- use different pattern to fill file\n"
103
+" -s, -- use a pattern file to fill the write buffer\n"
104
" -C, -- report statistics in a machine parsable format\n"
105
" -q, -- quiet mode, do not show I/O statistics\n"
106
" -u, -- with -z, allow unmapping\n"
107
@@ -XXX,XX +XXX,XX @@ static const cmdinfo_t write_cmd = {
108
.perm = BLK_PERM_WRITE,
109
.argmin = 2,
110
.argmax = -1,
111
- .args = "[-bcCfnquz] [-P pattern] off len",
112
+ .args = "[-bcCfnquz] [-P pattern | -s source_file] off len",
113
.oneline = "writes a number of bytes at a specified offset",
114
.help = write_help,
115
};
116
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
117
{
118
struct timespec t1, t2;
119
bool Cflag = false, qflag = false, bflag = false;
120
- bool Pflag = false, zflag = false, cflag = false;
121
+ bool Pflag = false, zflag = false, cflag = false, sflag = false;
122
int flags = 0;
123
int c, cnt, ret;
124
char *buf = NULL;
125
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
126
/* Some compilers get confused and warn if this is not initialized. */
127
int64_t total = 0;
128
int pattern = 0xcd;
129
+ const char *file_name = NULL;
130
131
- while ((c = getopt(argc, argv, "bcCfnpP:quz")) != -1) {
132
+ while ((c = getopt(argc, argv, "bcCfnpP:qs:uz")) != -1) {
133
switch (c) {
134
case 'b':
135
bflag = true;
136
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
137
case 'q':
138
qflag = true;
139
break;
140
+ case 's':
141
+ sflag = true;
142
+ file_name = optarg;
143
+ break;
144
case 'u':
145
flags |= BDRV_REQ_MAY_UNMAP;
146
break;
147
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
148
return -EINVAL;
149
}
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
159
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
160
}
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);
175
--
176
2.21.0
177
178
diff view generated by jsdifflib
1
This makes iotest 033 pass with e.g. subformat=monolithicFlat. It also
1
From: "Denis V. Lunev" <den@openvz.org>
2
turns a former error in 059 into success.
3
2
4
Signed-off-by: Max Reitz <mreitz@redhat.com>
3
'blockdev-change-medium' is a convinient wrapper for the following
5
Message-id: 20190815153638.4600-3-mreitz@redhat.com
4
sequence of commands:
6
Reviewed-by: John Snow <jsnow@redhat.com>
5
* blockdev-open-tray
7
Signed-off-by: Max Reitz <mreitz@redhat.com>
6
* blockdev-remove-medium
7
* blockdev-insert-medium
8
* blockdev-close-tray
9
and should be used f.e. to change ISO image inside the CD-ROM tray.
10
Though the guest could lock the tray and some linux guests like
11
CentOS 8.5 actually does that. In this case the execution if this
12
command results in the error like the following:
13
Device 'scsi0-0-1-0' is locked and force was not specified,
14
wait for tray to open and try again.
15
16
This situation is could be resolved 'blockdev-open-tray' by passing
17
flag 'force' inside. Thus is seems reasonable to add the same
18
capability for 'blockdev-change-medium' too.
19
20
Signed-off-by: Denis V. Lunev <den@openvz.org>
21
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
22
Acked-by: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
23
CC: Kevin Wolf <kwolf@redhat.com>
24
CC: Hanna Reitz <hreitz@redhat.com>
25
CC: Eric Blake <eblake@redhat.com>
26
CC: Markus Armbruster <armbru@redhat.com>
27
Message-Id: <20220412221846.280723-1-den@openvz.org>
28
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
29
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
8
---
30
---
9
block/vmdk.c | 54 ++++++++++++++++++++++++--------------
31
qapi/block.json | 6 ++++++
10
tests/qemu-iotests/059 | 7 +++--
32
block/qapi-sysemu.c | 3 ++-
11
tests/qemu-iotests/059.out | 4 ++-
33
monitor/hmp-cmds.c | 4 +++-
12
3 files changed, 42 insertions(+), 23 deletions(-)
34
hmp-commands.hx | 11 +++++++----
35
ui/cocoa.m | 1 +
36
5 files changed, 19 insertions(+), 6 deletions(-)
13
37
14
diff --git a/block/vmdk.c b/block/vmdk.c
38
diff --git a/qapi/block.json b/qapi/block.json
15
index XXXXXXX..XXXXXXX 100644
39
index XXXXXXX..XXXXXXX 100644
16
--- a/block/vmdk.c
40
--- a/qapi/block.json
17
+++ b/block/vmdk.c
41
+++ b/qapi/block.json
18
@@ -XXX,XX +XXX,XX @@ static const char *next_line(const char *s)
42
@@ -XXX,XX +XXX,XX @@
19
}
43
# @read-only-mode: change the read-only mode of the device; defaults
20
44
# to 'retain'
21
static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
45
#
22
- const char *desc_file_path, QDict *options,
46
+# @force: if false (the default), an eject request through blockdev-open-tray
23
- Error **errp)
47
+# will be sent to the guest if it has locked the tray (and the tray
24
+ QDict *options, Error **errp)
48
+# will not be opened immediately); if true, the tray will be opened
25
{
49
+# regardless of whether it is locked. (since 7.1)
26
int ret;
50
+#
27
int matches;
51
# Features:
28
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
52
# @deprecated: Member @device is deprecated. Use @id instead.
29
const char *p, *np;
53
#
30
int64_t sectors = 0;
54
@@ -XXX,XX +XXX,XX @@
31
int64_t flat_offset;
55
'*id': 'str',
32
+ char *desc_file_dir = NULL;
56
'filename': 'str',
33
char *extent_path;
57
'*format': 'str',
34
BdrvChild *extent_file;
58
+ '*force': 'bool',
35
BDRVVmdkState *s = bs->opaque;
59
'*read-only-mode': 'BlockdevChangeReadOnlyMode' } }
36
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
60
37
continue;
61
62
diff --git a/block/qapi-sysemu.c b/block/qapi-sysemu.c
63
index XXXXXXX..XXXXXXX 100644
64
--- a/block/qapi-sysemu.c
65
+++ b/block/qapi-sysemu.c
66
@@ -XXX,XX +XXX,XX @@ void qmp_blockdev_change_medium(bool has_device, const char *device,
67
bool has_id, const char *id,
68
const char *filename,
69
bool has_format, const char *format,
70
+ bool has_force, bool force,
71
bool has_read_only,
72
BlockdevChangeReadOnlyMode read_only,
73
Error **errp)
74
@@ -XXX,XX +XXX,XX @@ void qmp_blockdev_change_medium(bool has_device, const char *device,
75
76
rc = do_open_tray(has_device ? device : NULL,
77
has_id ? id : NULL,
78
- false, &err);
79
+ force, &err);
80
if (rc && rc != -ENOSYS) {
81
error_propagate(errp, err);
82
goto fail;
83
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
84
index XXXXXXX..XXXXXXX 100644
85
--- a/monitor/hmp-cmds.c
86
+++ b/monitor/hmp-cmds.c
87
@@ -XXX,XX +XXX,XX @@ void hmp_change(Monitor *mon, const QDict *qdict)
88
const char *target = qdict_get_str(qdict, "target");
89
const char *arg = qdict_get_try_str(qdict, "arg");
90
const char *read_only = qdict_get_try_str(qdict, "read-only-mode");
91
+ bool force = qdict_get_try_bool(qdict, "force", false);
92
BlockdevChangeReadOnlyMode read_only_mode = 0;
93
Error *err = NULL;
94
95
@@ -XXX,XX +XXX,XX @@ void hmp_change(Monitor *mon, const QDict *qdict)
38
}
96
}
39
97
40
- if (!path_is_absolute(fname) && !path_has_protocol(fname) &&
98
qmp_blockdev_change_medium(true, device, false, NULL, target,
41
- !desc_file_path[0])
99
- !!arg, arg, !!read_only, read_only_mode,
42
- {
100
+ !!arg, arg, true, force,
43
- bdrv_refresh_filename(bs->file->bs);
101
+ !!read_only, read_only_mode,
44
- error_setg(errp, "Cannot use relative extent paths with VMDK "
102
&err);
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
}
103
}
113
- return 0;
104
105
diff --git a/hmp-commands.hx b/hmp-commands.hx
106
index XXXXXXX..XXXXXXX 100644
107
--- a/hmp-commands.hx
108
+++ b/hmp-commands.hx
109
@@ -XXX,XX +XXX,XX @@ ERST
110
111
{
112
.name = "change",
113
- .args_type = "device:B,target:F,arg:s?,read-only-mode:s?",
114
- .params = "device filename [format [read-only-mode]]",
115
- .help = "change a removable medium, optional format",
116
+ .args_type = "device:B,force:-f,target:F,arg:s?,read-only-mode:s?",
117
+ .params = "device [-f] filename [format [read-only-mode]]",
118
+ .help = "change a removable medium, optional format, use -f to force the operation",
119
.cmd = hmp_change,
120
},
121
122
@@ -XXX,XX +XXX,XX @@ SRST
123
``change`` *device* *setting*
124
Change the configuration of a device.
125
126
- ``change`` *diskdevice* *filename* [*format* [*read-only-mode*]]
127
+ ``change`` *diskdevice* [-f] *filename* [*format* [*read-only-mode*]]
128
Change the medium for a removable disk device to point to *filename*. eg::
129
130
(qemu) change ide1-cd0 /path/to/some.iso
131
132
+ ``-f``
133
+ forces the operation even if the guest has locked the tray.
114
+
134
+
115
+ ret = 0;
135
*format* is optional.
116
+ goto out;
136
117
137
*read-only-mode* may be used to change the read-only status of the device.
118
invalid:
138
diff --git a/ui/cocoa.m b/ui/cocoa.m
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;
130
}
131
132
static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf,
133
@@ -XXX,XX +XXX,XX @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf,
134
}
135
s->create_type = g_strdup(ct);
136
s->desc_offset = 0;
137
- ret = vmdk_parse_extents(buf, bs, bs->file->bs->exact_filename, options,
138
- errp);
139
+ ret = vmdk_parse_extents(buf, bs, options, errp);
140
exit:
141
return ret;
142
}
143
diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059
144
index XXXXXXX..XXXXXXX 100755
145
--- a/tests/qemu-iotests/059
146
+++ b/tests/qemu-iotests/059
147
@@ -XXX,XX +XXX,XX @@ $QEMU_IMG convert -f qcow2 -O vmdk -o subformat=streamOptimized "$TEST_IMG.qcow2
148
149
echo
150
echo "=== Testing monolithicFlat with internally generated JSON file name ==="
151
+# Should work, because bdrv_dirname() works fine with blkdebug
152
IMGOPTS="subformat=monolithicFlat" _make_test_img 64M
153
-$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" 2>&1 \
154
- | _filter_testdir | _filter_imgfmt
155
+$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" \
156
+ -c info \
157
+ 2>&1 \
158
+ | _filter_testdir | _filter_imgfmt | _filter_img_info
159
_cleanup_test_img
160
161
echo
162
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
163
index XXXXXXX..XXXXXXX 100644
139
index XXXXXXX..XXXXXXX 100644
164
--- a/tests/qemu-iotests/059.out
140
--- a/ui/cocoa.m
165
+++ b/tests/qemu-iotests/059.out
141
+++ b/ui/cocoa.m
166
@@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240
142
@@ -XXX,XX +XXX,XX @@ - (void)changeDeviceMedia:(id)sender
167
143
[file cStringUsingEncoding:
168
=== Testing monolithicFlat with internally generated JSON file name ===
144
NSASCIIStringEncoding],
169
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
145
true, "raw",
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"}'
146
+ true, false,
171
+format name: IMGFMT
147
false, 0,
172
+cluster size: 0 bytes
148
&err);
173
+vm state offset: 0 bytes
149
});
174
175
=== Testing version 3 ===
176
image: TEST_DIR/iotest-version3.IMGFMT
177
--
150
--
178
2.21.0
151
2.35.1
179
152
180
153
diff view generated by jsdifflib
1
From: Thomas Huth <thuth@redhat.com>
1
From: John Snow <jsnow@redhat.com>
2
2
3
The sanitizers (especially the address sanitizer from Clang) are
3
This makes these callsites a little simpler, but the real motivation is
4
sometimes printing out warnings or false positives - this spoils
4
a forthcoming commit will change the return type of qemu_io(), so removing
5
the output of the iotests, causing some of the tests to fail.
5
users of the return value now is helpful.
6
Thus let's skip the automatic iotests during "make check" when the
7
user configured QEMU with --enable-sanitizers.
8
6
9
Signed-off-by: Thomas Huth <thuth@redhat.com>
7
Signed-off-by: John Snow <jsnow@redhat.com>
10
Message-id: 20190823084203.29734-1-thuth@redhat.com
8
Reviewed-by: Eric Blake <eblake@redhat.com>
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
10
Message-Id: <20220418211504.943969-2-jsnow@redhat.com>
11
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
12
---
12
---
13
tests/check-block.sh | 5 +++++
13
tests/qemu-iotests/242 | 6 +++---
14
1 file changed, 5 insertions(+)
14
tests/qemu-iotests/255 | 4 +---
15
tests/qemu-iotests/303 | 4 ++--
16
3 files changed, 6 insertions(+), 8 deletions(-)
15
17
16
diff --git a/tests/check-block.sh b/tests/check-block.sh
18
diff --git a/tests/qemu-iotests/242 b/tests/qemu-iotests/242
17
index XXXXXXX..XXXXXXX 100755
19
index XXXXXXX..XXXXXXX 100755
18
--- a/tests/check-block.sh
20
--- a/tests/qemu-iotests/242
19
+++ b/tests/check-block.sh
21
+++ b/tests/qemu-iotests/242
20
@@ -XXX,XX +XXX,XX @@ if grep -q "TARGET_GPROF=y" *-softmmu/config-target.mak 2>/dev/null ; then
22
@@ -XXX,XX +XXX,XX @@
21
exit 0
23
import iotests
22
fi
24
import json
23
25
import struct
24
+if grep -q "CFLAGS.*-fsanitize" config-host.mak 2>/dev/null ; then
26
-from iotests import qemu_img_create, qemu_io, qemu_img_info, \
25
+ echo "Sanitizers are enabled ==> Not running the qemu-iotests."
27
- file_path, img_info_log, log, filter_qemu_io
26
+ exit 0
28
+from iotests import qemu_img_create, qemu_io_log, qemu_img_info, \
27
+fi
29
+ file_path, img_info_log, log
28
+
30
29
if [ -z "$(find . -name 'qemu-system-*' -print)" ]; then
31
iotests.script_initialize(supported_fmts=['qcow2'],
30
echo "No qemu-system binary available ==> Not running the qemu-iotests."
32
supported_protocols=['file'],
31
exit 0
33
@@ -XXX,XX +XXX,XX @@ def add_bitmap(bitmap_number, persistent, disabled):
34
35
def write_to_disk(offset, size):
36
write = 'write {} {}'.format(offset, size)
37
- log(qemu_io('-c', write, disk), filters=[filter_qemu_io])
38
+ qemu_io_log('-c', write, disk)
39
40
41
def toggle_flag(offset):
42
diff --git a/tests/qemu-iotests/255 b/tests/qemu-iotests/255
43
index XXXXXXX..XXXXXXX 100755
44
--- a/tests/qemu-iotests/255
45
+++ b/tests/qemu-iotests/255
46
@@ -XXX,XX +XXX,XX @@ with iotests.FilePath('src.qcow2') as src_path, \
47
iotests.qemu_img_create('-f', iotests.imgfmt, src_path, size_str)
48
iotests.qemu_img_create('-f', iotests.imgfmt, dst_path, size_str)
49
50
- iotests.log(iotests.qemu_io('-f', iotests.imgfmt, '-c', 'write 0 1M',
51
- src_path),
52
- filters=[iotests.filter_test_dir, iotests.filter_qemu_io])
53
+ iotests.qemu_io_log('-f', iotests.imgfmt, '-c', 'write 0 1M', src_path),
54
55
vm.add_object('throttle-group,x-bps-read=4096,id=throttle0')
56
57
diff --git a/tests/qemu-iotests/303 b/tests/qemu-iotests/303
58
index XXXXXXX..XXXXXXX 100755
59
--- a/tests/qemu-iotests/303
60
+++ b/tests/qemu-iotests/303
61
@@ -XXX,XX +XXX,XX @@
62
63
import iotests
64
import subprocess
65
-from iotests import qemu_img_create, qemu_io, file_path, log, filter_qemu_io, \
66
+from iotests import qemu_img_create, qemu_io_log, file_path, log, \
67
verify_qcow2_zstd_compression
68
69
iotests.script_initialize(supported_fmts=['qcow2'],
70
@@ -XXX,XX +XXX,XX @@ def create_bitmap(bitmap_number, disabled):
71
72
def write_to_disk(offset, size):
73
write = f'write {offset} {size}'
74
- log(qemu_io('-c', write, disk), filters=[filter_qemu_io])
75
+ qemu_io_log('-c', write, disk)
76
77
78
def add_bitmap(num, begin, end, disabled):
32
--
79
--
33
2.21.0
80
2.35.1
34
35
diff view generated by jsdifflib
1
From: Thomas Huth <thuth@redhat.com>
1
From: John Snow <jsnow@redhat.com>
2
2
3
It is possible to enable only a subset of the block drivers with the
3
The 'read' commands to qemu-io were malformed, and this invocation only
4
"--block-drv-rw-whitelist" option of the "configure" script. All other
4
worked by coincidence because the error messages were identical. Oops.
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.
12
5
13
This patch mainly targets the test in the "auto" group which should
6
There's no point in checking the patterning of the reference image, so
14
never fail in such a case, but also improves some of the other tests
7
just check the empty image by itself instead.
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
8
19
Signed-off-by: Thomas Huth <thuth@redhat.com>
9
(Note: as of this commit, nothing actually enforces that this command
20
Message-id: 20190823133552.11680-1-thuth@redhat.com
10
completes successfully, but a forthcoming commit in this series will
21
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
enforce that qemu_io() must have a zero status code.)
12
13
Signed-off-by: John Snow <jsnow@redhat.com>
14
Reviewed-by: Eric Blake <eblake@redhat.com>
15
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
16
Message-Id: <20220418211504.943969-3-jsnow@redhat.com>
17
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
22
---
18
---
23
tests/qemu-iotests/071 | 1 +
19
tests/qemu-iotests/163 | 5 +----
24
tests/qemu-iotests/081 | 4 +---
20
1 file changed, 1 insertion(+), 4 deletions(-)
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(-)
32
21
33
diff --git a/tests/qemu-iotests/071 b/tests/qemu-iotests/071
22
diff --git a/tests/qemu-iotests/163 b/tests/qemu-iotests/163
34
index XXXXXXX..XXXXXXX 100755
23
index XXXXXXX..XXXXXXX 100755
35
--- a/tests/qemu-iotests/071
24
--- a/tests/qemu-iotests/163
36
+++ b/tests/qemu-iotests/071
25
+++ b/tests/qemu-iotests/163
37
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
26
@@ -XXX,XX +XXX,XX @@ class ShrinkBaseClass(iotests.QMPTestCase):
38
27
qemu_img('resize', '-f', iotests.imgfmt, '--shrink', test_img,
39
_supported_fmt qcow2
28
self.shrink_size)
40
_supported_proto file
29
41
+_require_drivers blkdebug blkverify
30
- self.assertEqual(
42
31
- qemu_io('-c', 'read -P 0x00 %s'%self.shrink_size, test_img),
43
do_run_qemu()
32
- qemu_io('-c', 'read -P 0x00 %s'%self.shrink_size, check_img),
44
{
33
- "Verifying image content")
45
diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081
34
+ qemu_io('-c', f"read -P 0x00 0 {self.shrink_size}", test_img)
46
index XXXXXXX..XXXXXXX 100755
35
47
--- a/tests/qemu-iotests/081
36
self.image_verify()
48
+++ b/tests/qemu-iotests/081
37
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"
130
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
131
index XXXXXXX..XXXXXXX 100644
132
--- a/tests/qemu-iotests/common.rc
133
+++ b/tests/qemu-iotests/common.rc
134
@@ -XXX,XX +XXX,XX @@ _require_command()
135
[ -x "$c" ] || _notrun "$1 utility required, skipped this test"
136
}
137
138
+# Check that a set of drivers has been whitelisted in the QEMU binary
139
+#
140
+_require_drivers()
141
+{
142
+ available=$($QEMU -drive format=help | \
143
+ sed -e '/Supported formats:/!d' -e 's/Supported formats://')
144
+ for driver
145
+ do
146
+ if ! echo "$available" | grep -q " $driver\( \|$\)"; then
147
+ _notrun "$driver not available"
148
+ fi
149
+ done
150
+}
151
+
152
# make sure this script returns success
153
true
154
--
38
--
155
2.21.0
39
2.35.1
156
157
diff view generated by jsdifflib
1
iotest 126 requires backing file support, which flat vmdks cannot offer.
1
From: John Snow <jsnow@redhat.com>
2
Skip this test for such subformats.
3
2
4
Signed-off-by: Max Reitz <mreitz@redhat.com>
3
A forthcoming commit updates qemu_io() to raise an exception on non-zero
5
Message-id: 20190815153638.4600-8-mreitz@redhat.com
4
return by default, and changes its return type.
6
Reviewed-by: John Snow <jsnow@redhat.com>
5
7
Signed-off-by: Max Reitz <mreitz@redhat.com>
6
In preparation, simplify some calls to qemu_io() that assert that
7
specific error message strings do not appear in qemu-io's
8
output. Asserting that all of these calls return a status code of zero
9
will be a more robust way to guard against failure.
10
11
Signed-off-by: John Snow <jsnow@redhat.com>
12
Reviewed-by: Eric Blake <eblake@redhat.com>
13
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
14
Message-Id: <20220418211504.943969-4-jsnow@redhat.com>
15
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
8
---
16
---
9
tests/qemu-iotests/126 | 2 ++
17
tests/qemu-iotests/040 | 33 ++++++++++++++++-----------------
10
1 file changed, 2 insertions(+)
18
tests/qemu-iotests/056 | 2 +-
19
2 files changed, 17 insertions(+), 18 deletions(-)
11
20
12
diff --git a/tests/qemu-iotests/126 b/tests/qemu-iotests/126
21
diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040
13
index XXXXXXX..XXXXXXX 100755
22
index XXXXXXX..XXXXXXX 100755
14
--- a/tests/qemu-iotests/126
23
--- a/tests/qemu-iotests/040
15
+++ b/tests/qemu-iotests/126
24
+++ b/tests/qemu-iotests/040
16
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
25
@@ -XXX,XX +XXX,XX @@ class TestSingleDrive(ImageCommitTestCase):
17
26
18
# Needs backing file support
27
def test_commit(self):
19
_supported_fmt qcow qcow2 qed vmdk
28
self.run_commit_test(mid_img, backing_img)
20
+_unsupported_imgopts "subformat=monolithicFlat" \
29
- self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img).find("verification failed"))
21
+ "subformat=twoGbMaxExtentFlat"
30
- self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img).find("verification failed"))
22
# This is the default protocol (and we want to test the difference between
31
+ qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img)
23
# colons which separate a protocol prefix from the rest and colons which are
32
+ qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img)
24
# just part of the filename, so we cannot test protocols which require a prefix)
33
34
def test_commit_node(self):
35
self.run_commit_test("mid", "base", node_names=True)
36
- self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img).find("verification failed"))
37
- self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img).find("verification failed"))
38
+ qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img)
39
+ qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img)
40
41
@iotests.skip_if_unsupported(['throttle'])
42
def test_commit_with_filter_and_quit(self):
43
@@ -XXX,XX +XXX,XX @@ class TestSingleDrive(ImageCommitTestCase):
44
45
def test_top_is_active(self):
46
self.run_commit_test(test_img, backing_img, need_ready=True)
47
- self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img).find("verification failed"))
48
- self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img).find("verification failed"))
49
+ qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img)
50
+ qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img)
51
52
def test_top_is_default_active(self):
53
self.run_default_commit_test()
54
- self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img).find("verification failed"))
55
- self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img).find("verification failed"))
56
+ qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img)
57
+ qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img)
58
59
def test_top_and_base_reversed(self):
60
self.assert_no_active_block_jobs()
61
@@ -XXX,XX +XXX,XX @@ class TestRelativePaths(ImageCommitTestCase):
62
63
def test_commit(self):
64
self.run_commit_test(self.mid_img, self.backing_img)
65
- self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', self.backing_img_abs).find("verification failed"))
66
- self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', self.backing_img_abs).find("verification failed"))
67
+ qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', self.backing_img_abs)
68
+ qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', self.backing_img_abs)
69
70
def test_device_not_found(self):
71
result = self.vm.qmp('block-commit', device='nonexistent', top='%s' % self.mid_img)
72
@@ -XXX,XX +XXX,XX @@ class TestRelativePaths(ImageCommitTestCase):
73
74
def test_top_is_active(self):
75
self.run_commit_test(self.test_img, self.backing_img)
76
- self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', self.backing_img_abs).find("verification failed"))
77
- self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', self.backing_img_abs).find("verification failed"))
78
+ qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', self.backing_img_abs)
79
+ qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', self.backing_img_abs)
80
81
def test_top_and_base_reversed(self):
82
self.assert_no_active_block_jobs()
83
@@ -XXX,XX +XXX,XX @@ class TestCommitWithFilters(iotests.QMPTestCase):
84
85
def do_test_io(self, read_or_write):
86
for index, pattern_file in enumerate(self.pattern_files):
87
- result = qemu_io('-f', iotests.imgfmt,
88
- '-c',
89
- f'{read_or_write} -P {index + 1} {index}M 1M',
90
- pattern_file)
91
- self.assertFalse('Pattern verification failed' in result)
92
+ qemu_io('-f', iotests.imgfmt,
93
+ '-c',
94
+ f'{read_or_write} -P {index + 1} {index}M 1M',
95
+ pattern_file)
96
97
@iotests.skip_if_unsupported(['throttle'])
98
def setUp(self):
99
diff --git a/tests/qemu-iotests/056 b/tests/qemu-iotests/056
100
index XXXXXXX..XXXXXXX 100755
101
--- a/tests/qemu-iotests/056
102
+++ b/tests/qemu-iotests/056
103
@@ -XXX,XX +XXX,XX @@ class TestSyncModesNoneAndTop(iotests.QMPTestCase):
104
105
self.vm.shutdown()
106
time.sleep(1)
107
- self.assertEqual(-1, qemu_io('-c', 'read -P0x41 0 512', target_img).find("verification failed"))
108
+ qemu_io('-c', 'read -P0x41 0 512', target_img)
109
110
class TestBeforeWriteNotifier(iotests.QMPTestCase):
111
def setUp(self):
25
--
112
--
26
2.21.0
113
2.35.1
27
28
diff view generated by jsdifflib
1
From: Nir Soffer <nirsof@gmail.com>
1
From: John Snow <jsnow@redhat.com>
2
2
3
Quoting cache mode is not needed, and most tests use unquoted values.
3
qemu-io fails on read/write beyond end-of-file on raw images, so skip
4
Unify all test to use the same style.
4
these invocations when running the zero-length image tests.
5
5
6
Message-id: 20190827173432.7656-1-nsoffer@redhat.com
6
Signed-off-by: John Snow <jsnow@redhat.com>
7
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
7
Reviewed-by: Eric Blake <eblake@redhat.com>
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
8
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
9
Message-Id: <20220418211504.943969-5-jsnow@redhat.com>
10
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
9
---
11
---
10
tests/qemu-iotests/026 | 4 ++--
12
tests/qemu-iotests/040 | 14 ++++++++++++--
11
tests/qemu-iotests/039 | 4 ++--
13
1 file changed, 12 insertions(+), 2 deletions(-)
12
tests/qemu-iotests/052 | 2 +-
13
tests/qemu-iotests/091 | 4 ++--
14
4 files changed, 7 insertions(+), 7 deletions(-)
15
14
16
diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026
15
diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040
17
index XXXXXXX..XXXXXXX 100755
16
index XXXXXXX..XXXXXXX 100755
18
--- a/tests/qemu-iotests/026
17
--- a/tests/qemu-iotests/040
19
+++ b/tests/qemu-iotests/026
18
+++ b/tests/qemu-iotests/040
20
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
19
@@ -XXX,XX +XXX,XX @@ class TestSingleDrive(ImageCommitTestCase):
21
# Currently only qcow2 supports rebasing
20
qemu_img('create', '-f', iotests.imgfmt,
22
_supported_fmt qcow2
21
'-o', 'backing_file=%s' % mid_img,
23
_supported_proto file
22
'-F', iotests.imgfmt, test_img)
24
-_default_cache_mode "writethrough"
23
- qemu_io('-f', 'raw', '-c', 'write -P 0xab 0 524288', backing_img)
25
-_supported_cache_modes "writethrough" "none"
24
- qemu_io('-f', iotests.imgfmt, '-c', 'write -P 0xef 524288 524288', mid_img)
26
+_default_cache_mode writethrough
25
+ if self.image_len:
27
+_supported_cache_modes writethrough none
26
+ qemu_io('-f', 'raw', '-c', 'write -P 0xab 0 524288', backing_img)
28
# The refcount table tests expect a certain minimum width for refcount entries
27
+ qemu_io('-f', iotests.imgfmt, '-c', 'write -P 0xef 524288 524288',
29
# (so that the refcount table actually needs to grow); that minimum is 16 bits,
28
+ mid_img)
30
# being the default refcount entry width.
29
self.vm = iotests.VM().add_drive(test_img, "node-name=top,backing.node-name=mid,backing.backing.node-name=base", interface="none")
31
diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
30
self.vm.add_device('virtio-scsi')
32
index XXXXXXX..XXXXXXX 100755
31
self.vm.add_device("scsi-hd,id=scsi0,drive=drive0")
33
--- a/tests/qemu-iotests/039
32
@@ -XXX,XX +XXX,XX @@ class TestSingleDrive(ImageCommitTestCase):
34
+++ b/tests/qemu-iotests/039
33
35
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
34
def test_commit(self):
36
_supported_fmt qcow2
35
self.run_commit_test(mid_img, backing_img)
37
_supported_proto file
36
+ if not self.image_len:
38
_supported_os Linux
37
+ return
39
-_default_cache_mode "writethrough"
38
qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img)
40
-_supported_cache_modes "writethrough"
39
qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img)
41
+_default_cache_mode writethrough
40
42
+_supported_cache_modes writethrough
41
def test_commit_node(self):
43
42
self.run_commit_test("mid", "base", node_names=True)
44
size=128M
43
+ if not self.image_len:
45
44
+ return
46
diff --git a/tests/qemu-iotests/052 b/tests/qemu-iotests/052
45
qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img)
47
index XXXXXXX..XXXXXXX 100755
46
qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img)
48
--- a/tests/qemu-iotests/052
47
49
+++ b/tests/qemu-iotests/052
48
@@ -XXX,XX +XXX,XX @@ class TestSingleDrive(ImageCommitTestCase):
50
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
49
51
_supported_proto file
50
def test_top_is_active(self):
52
51
self.run_commit_test(test_img, backing_img, need_ready=True)
53
# Don't do O_DIRECT on tmpfs
52
+ if not self.image_len:
54
-_supported_cache_modes "writeback" "writethrough" "unsafe"
53
+ return
55
+_supported_cache_modes writeback writethrough unsafe
54
qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img)
56
55
qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img)
57
size=128M
56
58
_make_test_img $size
57
def test_top_is_default_active(self):
59
diff --git a/tests/qemu-iotests/091 b/tests/qemu-iotests/091
58
self.run_default_commit_test()
60
index XXXXXXX..XXXXXXX 100755
59
+ if not self.image_len:
61
--- a/tests/qemu-iotests/091
60
+ return
62
+++ b/tests/qemu-iotests/091
61
qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img)
63
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
62
qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img)
64
_supported_fmt qcow2
65
_supported_proto file
66
_supported_os Linux
67
-_default_cache_mode "none"
68
-_supported_cache_modes "writethrough" "none" "writeback"
69
+_default_cache_mode none
70
+_supported_cache_modes writethrough none writeback
71
72
size=1G
73
63
74
--
64
--
75
2.21.0
65
2.35.1
76
77
diff view generated by jsdifflib
1
The error message for the test case where we have a quorum node for
1
From: John Snow <jsnow@redhat.com>
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.
7
2
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
3
Without this change, asserting that qemu_io always returns 0 causes this
9
Reviewed-by: John Snow <jsnow@redhat.com>
4
test to fail in a way we happened not to be catching previously:
10
Message-id: 20190815153638.4600-7-mreitz@redhat.com
5
11
Reviewed-by: John Snow <jsnow@redhat.com>
6
qemu.utils.VerboseProcessError: Command
12
Signed-off-by: Max Reitz <mreitz@redhat.com>
7
'('/home/jsnow/src/qemu/bin/git/tests/qemu-iotests/../../qemu-io',
8
'--cache', 'writeback', '--aio', 'threads', '-f', 'qcow2', '-c',
9
'read -P 4 3M 1M',
10
'/home/jsnow/src/qemu/bin/git/tests/qemu-iotests/scratch/3.img')'
11
returned non-zero exit status 1.
12
┏━ output ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
13
┃ qemu-io: can't open device
14
┃ /home/jsnow/src/qemu/bin/git/tests/qemu-iotests/scratch/3.img:
15
┃ Could not open backing file: Could not open backing file: Throttle
16
┃ group 'tg' does not exist
17
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
18
19
The commit jobs changes the backing file string stored in the image file
20
header belonging to the node above the commit’s top node to point to the
21
commit target (the base node). QEMU tries to be as accurate as
22
possible, and so in these test cases will include the filter that is
23
part of the block graph in that backing file string (by virtue of making
24
it a json:{} description of the post-commit subgraph). This makes
25
little sense outside of QEMU, though: Specifically, the throttle node in
26
that subgraph will dearly miss its supposedly associated throttle group
27
object.
28
29
When starting the commit job, we can specify a custom backing file
30
string to write into said image file, so let’s use that feature to write
31
the plain filename of the backing chain’s next actual image file there.
32
33
Explicitly provide the backing file so that opening the file outside of
34
QEMU (Where we will not have throttle groups) will succeed.
35
36
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
37
Signed-off-by: John Snow <jsnow@redhat.com>
38
Reviewed-by: Eric Blake <eblake@redhat.com>
39
Message-Id: <20220418211504.943969-6-jsnow@redhat.com>
13
---
40
---
14
tests/qemu-iotests/110 | 3 ++-
41
tests/qemu-iotests/040 | 6 ++++--
15
1 file changed, 2 insertions(+), 1 deletion(-)
42
1 file changed, 4 insertions(+), 2 deletions(-)
16
43
17
diff --git a/tests/qemu-iotests/110 b/tests/qemu-iotests/110
44
diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040
18
index XXXXXXX..XXXXXXX 100755
45
index XXXXXXX..XXXXXXX 100755
19
--- a/tests/qemu-iotests/110
46
--- a/tests/qemu-iotests/040
20
+++ b/tests/qemu-iotests/110
47
+++ b/tests/qemu-iotests/040
21
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
48
@@ -XXX,XX +XXX,XX @@ class TestCommitWithFilters(iotests.QMPTestCase):
22
# Any format supporting backing files
49
job_id='commit',
23
_supported_fmt qed qcow qcow2 vmdk
50
device='top-filter',
24
_supported_proto file
51
top_node='cow-2',
25
-_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
52
- base_node='cow-1')
26
+_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
53
+ base_node='cow-1',
27
+ "subformat=twoGbMaxExtentSparse"
54
+ backing_file=self.img1)
28
55
self.assert_qmp(result, 'return', {})
29
TEST_IMG_REL=$(basename "$TEST_IMG")
56
self.wait_until_completed(drive='commit')
57
58
@@ -XXX,XX +XXX,XX @@ class TestCommitWithFilters(iotests.QMPTestCase):
59
job_id='commit',
60
device='top-filter',
61
top_node='cow-1',
62
- base_node='cow-0')
63
+ base_node='cow-0',
64
+ backing_file=self.img0)
65
self.assert_qmp(result, 'return', {})
66
self.wait_until_completed(drive='commit')
30
67
31
--
68
--
32
2.21.0
69
2.35.1
33
70
34
71
diff view generated by jsdifflib
1
We had a test for a case where relative extent paths did not work, but
1
From: John Snow <jsnow@redhat.com>
2
unfortunately we just fixed the underlying problem, so it works now.
3
This patch adds a new test case that still fails.
4
2
5
Signed-off-by: Max Reitz <mreitz@redhat.com>
3
reimplement qemu_img() in terms of qemu_tool() in preparation for doing
6
Reviewed-by: John Snow <jsnow@redhat.com>
4
the same with qemu_io().
7
Message-id: 20190815153638.4600-4-mreitz@redhat.com
5
8
Reviewed-by: John Snow <jsnow@redhat.com>
6
Signed-off-by: John Snow <jsnow@redhat.com>
9
Signed-off-by: Max Reitz <mreitz@redhat.com>
7
Reviewed-by: Eric Blake <eblake@redhat.com>
8
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
9
Message-Id: <20220418211504.943969-7-jsnow@redhat.com>
10
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
10
---
11
---
11
tests/qemu-iotests/059 | 27 +++++++++++++++++++++++++++
12
tests/qemu-iotests/iotests.py | 32 +++++++++++++++++++++-----------
12
tests/qemu-iotests/059.out | 4 ++++
13
1 file changed, 21 insertions(+), 11 deletions(-)
13
2 files changed, 31 insertions(+)
14
14
15
diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059
15
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
16
index XXXXXXX..XXXXXXX 100755
16
index XXXXXXX..XXXXXXX 100644
17
--- a/tests/qemu-iotests/059
17
--- a/tests/qemu-iotests/iotests.py
18
+++ b/tests/qemu-iotests/059
18
+++ b/tests/qemu-iotests/iotests.py
19
@@ -XXX,XX +XXX,XX @@ $QEMU_IMG convert -f qcow2 -O vmdk -o subformat=streamOptimized "$TEST_IMG.qcow2
19
@@ -XXX,XX +XXX,XX @@ def qemu_img_create_prepare_args(args: List[str]) -> List[str]:
20
20
21
echo
21
return result
22
echo "=== Testing monolithicFlat with internally generated JSON file name ==="
22
23
-def qemu_img(*args: str, check: bool = True, combine_stdio: bool = True
24
- ) -> 'subprocess.CompletedProcess[str]':
25
- """
26
- Run qemu_img and return the status code and console output.
27
28
- This function always prepends QEMU_IMG_OPTIONS and may further alter
29
- the args for 'create' commands.
30
+def qemu_tool(*args: str, check: bool = True, combine_stdio: bool = True
31
+ ) -> 'subprocess.CompletedProcess[str]':
32
+ """
33
+ Run a qemu tool and return its status code and console output.
34
35
- :param args: command-line arguments to qemu-img.
36
+ :param args: full command line to run.
37
:param check: Enforce a return code of zero.
38
:param combine_stdio: set to False to keep stdout/stderr separated.
39
40
@@ -XXX,XX +XXX,XX @@ def qemu_img(*args: str, check: bool = True, combine_stdio: bool = True
41
properties. If streams are not combined, it will also have a
42
stderr property.
43
"""
44
- full_args = qemu_img_args + qemu_img_create_prepare_args(list(args))
45
-
46
subp = subprocess.run(
47
- full_args,
48
+ args,
49
stdout=subprocess.PIPE,
50
stderr=subprocess.STDOUT if combine_stdio else subprocess.PIPE,
51
universal_newlines=True,
52
@@ -XXX,XX +XXX,XX @@ def qemu_img(*args: str, check: bool = True, combine_stdio: bool = True
53
54
if check and subp.returncode or (subp.returncode < 0):
55
raise VerboseProcessError(
56
- subp.returncode, full_args,
57
+ subp.returncode, args,
58
output=subp.stdout,
59
stderr=subp.stderr,
60
)
61
@@ -XXX,XX +XXX,XX @@ def qemu_img(*args: str, check: bool = True, combine_stdio: bool = True
62
return subp
63
64
65
+def qemu_img(*args: str, check: bool = True, combine_stdio: bool = True
66
+ ) -> 'subprocess.CompletedProcess[str]':
67
+ """
68
+ Run QEMU_IMG_PROG and return its status code and console output.
23
+
69
+
24
+echo '--- blkdebug ---'
70
+ This function always prepends QEMU_IMG_OPTIONS and may further alter
25
# Should work, because bdrv_dirname() works fine with blkdebug
71
+ the args for 'create' commands.
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
+
72
+
37
+filename="json:{
73
+ See `qemu_tool()` for greater detail.
38
+ \"driver\": \"$IMGFMT\",
74
+ """
39
+ \"file\": {
75
+ full_args = qemu_img_args + qemu_img_create_prepare_args(list(args))
40
+ \"driver\": \"quorum\",
76
+ return qemu_tool(*full_args, check=check, combine_stdio=combine_stdio)
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
+
77
+
56
+
78
+
57
echo
79
def ordered_qmp(qmsg, conv_keys=True):
58
echo "=== Testing version 3 ==="
80
# Dictionaries are not ordered prior to 3.6, therefore:
59
_use_sample_img iotest-version3.vmdk.bz2
81
if isinstance(qmsg, list):
60
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
61
index XXXXXXX..XXXXXXX 100644
62
--- a/tests/qemu-iotests/059.out
63
+++ b/tests/qemu-iotests/059.out
64
@@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240
65
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
66
67
=== Testing monolithicFlat with internally generated JSON file name ===
68
+--- blkdebug ---
69
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
70
format name: IMGFMT
71
cluster size: 0 bytes
72
vm state offset: 0 bytes
73
+--- quorum ---
74
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
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
76
77
=== Testing version 3 ===
78
image: TEST_DIR/iotest-version3.IMGFMT
79
--
82
--
80
2.21.0
83
2.35.1
81
82
diff view generated by jsdifflib
1
streamOptimized does not support writes that do not span exactly one
1
From: John Snow <jsnow@redhat.com>
2
cluster. Furthermore, it cannot rewrite already allocated clusters.
2
3
As such, many iotests do not work with it. Disable them.
3
Rework qemu_io() to be analogous to qemu_img(); a function that requires
4
4
a return code of zero by default unless disabled explicitly.
5
Signed-off-by: Max Reitz <mreitz@redhat.com>
5
6
Message-id: 20190815153638.4600-6-mreitz@redhat.com
6
Tests that use qemu_io():
7
Reviewed-by: John Snow <jsnow@redhat.com>
7
030 040 041 044 055 056 093 124 129 132 136 148 149 151 152 163 165 205
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
8
209 219 236 245 248 254 255 257 260 264 280 298 300 302 304
9
image-fleecing migrate-bitmaps-postcopy-test migrate-bitmaps-test
10
migrate-during-backup migration-permissions
11
12
Test that use qemu_io_log():
13
242 245 255 274 303 307 nbd-reconnect-on-open
14
15
Copy-pastables for testing/verification:
16
17
./check -qcow2 030 040 041 044 055 056 124 129 132 151 152 163 165 209 \
18
219 236 242 245 248 254 255 257 260 264 274 \
19
280 298 300 302 303 304 307 image-fleecing \
20
migrate-bitmaps-postcopy-test migrate-bitmaps-test \
21
migrate-during-backup nbd-reconnect-on-open
22
./check -raw 093 136 148 migration-permissions
23
./check -nbd 205
24
25
# ./configure configure --disable-gnutls --enable-gcrypt
26
# this ALSO requires passwordless sudo.
27
./check -luks 149
28
29
# Just the tests that were edited in this commit:
30
./check -qcow2 030 040 242 245
31
./check -raw migration-permissions
32
./check -nbd 205
33
./check -luks 149
34
35
Signed-off-by: John Snow <jsnow@redhat.com>
36
Message-Id: <20220418211504.943969-8-jsnow@redhat.com>
37
Reviewed-by: Eric Blake <eblake@redhat.com>
38
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
9
---
39
---
10
tests/qemu-iotests/002 | 1 +
40
tests/qemu-iotests/030 | 85 +++++++++++--------
11
tests/qemu-iotests/003 | 1 +
41
tests/qemu-iotests/149 | 6 +-
12
tests/qemu-iotests/005 | 3 ++-
42
tests/qemu-iotests/205 | 4 +-
13
tests/qemu-iotests/009 | 1 +
43
tests/qemu-iotests/245 | 17 ++--
14
tests/qemu-iotests/010 | 1 +
44
tests/qemu-iotests/iotests.py | 19 +++--
15
tests/qemu-iotests/011 | 1 +
45
.../qemu-iotests/tests/migration-permissions | 4 +-
16
tests/qemu-iotests/017 | 3 ++-
46
6 files changed, 81 insertions(+), 54 deletions(-)
17
tests/qemu-iotests/018 | 3 ++-
47
18
tests/qemu-iotests/019 | 3 ++-
48
diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030
19
tests/qemu-iotests/020 | 3 ++-
49
index XXXXXXX..XXXXXXX 100755
20
tests/qemu-iotests/027 | 1 +
50
--- a/tests/qemu-iotests/030
21
tests/qemu-iotests/032 | 1 +
51
+++ b/tests/qemu-iotests/030
22
tests/qemu-iotests/033 | 1 +
52
@@ -XXX,XX +XXX,XX @@ class TestSingleDrive(iotests.QMPTestCase):
23
tests/qemu-iotests/034 | 3 ++-
53
self.assert_no_active_block_jobs()
24
tests/qemu-iotests/037 | 3 ++-
54
self.vm.shutdown()
25
tests/qemu-iotests/063 | 3 ++-
55
26
tests/qemu-iotests/072 | 1 +
56
- self.assertEqual(qemu_io('-f', 'raw', '-c', 'map', backing_img),
27
tests/qemu-iotests/105 | 3 ++-
57
- qemu_io('-f', iotests.imgfmt, '-c', 'map', test_img),
28
tests/qemu-iotests/197 | 1 +
58
- 'image file map does not match backing file after streaming')
29
tests/qemu-iotests/215 | 1 +
59
+ self.assertEqual(
30
tests/qemu-iotests/251 | 1 +
60
+ qemu_io('-f', 'raw', '-c', 'map', backing_img).stdout,
31
21 files changed, 30 insertions(+), 9 deletions(-)
61
+ qemu_io('-f', iotests.imgfmt, '-c', 'map', test_img).stdout,
32
62
+ 'image file map does not match backing file after streaming')
33
diff --git a/tests/qemu-iotests/002 b/tests/qemu-iotests/002
63
34
index XXXXXXX..XXXXXXX 100755
64
def test_stream_intermediate(self):
35
--- a/tests/qemu-iotests/002
65
self.assert_no_active_block_jobs()
36
+++ b/tests/qemu-iotests/002
66
37
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
67
- self.assertNotEqual(qemu_io('-f', 'raw', '-rU', '-c', 'map', backing_img),
38
68
- qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', mid_img),
39
_supported_fmt generic
69
- 'image file map matches backing file before streaming')
40
_supported_proto generic
70
+ self.assertNotEqual(
41
+_unsupported_imgopts "subformat=streamOptimized"
71
+ qemu_io('-f', 'raw', '-rU', '-c', 'map', backing_img).stdout,
42
72
+ qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', mid_img).stdout,
43
73
+ 'image file map matches backing file before streaming')
44
size=128M
74
45
diff --git a/tests/qemu-iotests/003 b/tests/qemu-iotests/003
75
result = self.vm.qmp('block-stream', device='mid', job_id='stream-mid')
46
index XXXXXXX..XXXXXXX 100755
76
self.assert_qmp(result, 'return', {})
47
--- a/tests/qemu-iotests/003
77
@@ -XXX,XX +XXX,XX @@ class TestSingleDrive(iotests.QMPTestCase):
48
+++ b/tests/qemu-iotests/003
78
self.assert_no_active_block_jobs()
49
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
79
self.vm.shutdown()
50
80
51
_supported_fmt generic
81
- self.assertEqual(qemu_io('-f', 'raw', '-c', 'map', backing_img),
52
_supported_proto generic
82
- qemu_io('-f', iotests.imgfmt, '-c', 'map', mid_img),
53
+_unsupported_imgopts "subformat=streamOptimized"
83
- 'image file map does not match backing file after streaming')
54
84
+ self.assertEqual(
55
size=128M
85
+ qemu_io('-f', 'raw', '-c', 'map', backing_img).stdout,
56
offset=67M
86
+ qemu_io('-f', iotests.imgfmt, '-c', 'map', mid_img).stdout,
57
diff --git a/tests/qemu-iotests/005 b/tests/qemu-iotests/005
87
+ 'image file map does not match backing file after streaming')
58
index XXXXXXX..XXXXXXX 100755
88
59
--- a/tests/qemu-iotests/005
89
def test_stream_pause(self):
60
+++ b/tests/qemu-iotests/005
90
self.assert_no_active_block_jobs()
61
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
91
@@ -XXX,XX +XXX,XX @@ class TestSingleDrive(iotests.QMPTestCase):
62
_supported_proto generic
92
self.assert_no_active_block_jobs()
63
_supported_os Linux
93
self.vm.shutdown()
64
_unsupported_imgopts "subformat=twoGbMaxExtentFlat" \
94
65
- "subformat=twoGbMaxExtentSparse"
95
- self.assertEqual(qemu_io('-f', 'raw', '-c', 'map', backing_img),
66
+ "subformat=twoGbMaxExtentSparse" \
96
- qemu_io('-f', iotests.imgfmt, '-c', 'map', test_img),
67
+ "subformat=streamOptimized"
97
- 'image file map does not match backing file after streaming')
68
98
+ self.assertEqual(
69
# vpc is limited to 127GB, so we can't test it here
99
+ qemu_io('-f', 'raw', '-c', 'map', backing_img).stdout,
70
if [ "$IMGFMT" = "vpc" ]; then
100
+ qemu_io('-f', iotests.imgfmt, '-c', 'map', test_img).stdout,
71
diff --git a/tests/qemu-iotests/009 b/tests/qemu-iotests/009
101
+ 'image file map does not match backing file after streaming')
72
index XXXXXXX..XXXXXXX 100755
102
73
--- a/tests/qemu-iotests/009
103
def test_stream_no_op(self):
74
+++ b/tests/qemu-iotests/009
104
self.assert_no_active_block_jobs()
75
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
105
76
106
# The image map is empty before the operation
77
_supported_fmt generic
107
- empty_map = qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', test_img)
78
_supported_proto generic
108
+ empty_map = qemu_io(
79
+_unsupported_imgopts "subformat=streamOptimized"
109
+ '-f', iotests.imgfmt, '-rU', '-c', 'map', test_img).stdout
80
110
81
111
# This is a no-op: no data should ever be copied from the base image
82
size=6G
112
result = self.vm.qmp('block-stream', device='drive0', base=mid_img)
83
diff --git a/tests/qemu-iotests/010 b/tests/qemu-iotests/010
113
@@ -XXX,XX +XXX,XX @@ class TestSingleDrive(iotests.QMPTestCase):
84
index XXXXXXX..XXXXXXX 100755
114
self.assert_no_active_block_jobs()
85
--- a/tests/qemu-iotests/010
115
self.vm.shutdown()
86
+++ b/tests/qemu-iotests/010
116
87
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
117
- self.assertEqual(qemu_io('-f', iotests.imgfmt, '-c', 'map', test_img),
88
118
- empty_map, 'image file map changed after a no-op')
89
_supported_fmt generic
119
+ self.assertEqual(
90
_supported_proto generic
120
+ qemu_io('-f', iotests.imgfmt, '-c', 'map', test_img).stdout,
91
+_unsupported_imgopts "subformat=streamOptimized"
121
+ empty_map, 'image file map changed after a no-op')
92
122
93
123
def test_stream_partial(self):
94
size=6G
124
self.assert_no_active_block_jobs()
95
diff --git a/tests/qemu-iotests/011 b/tests/qemu-iotests/011
125
@@ -XXX,XX +XXX,XX @@ class TestSingleDrive(iotests.QMPTestCase):
96
index XXXXXXX..XXXXXXX 100755
126
self.assert_no_active_block_jobs()
97
--- a/tests/qemu-iotests/011
127
self.vm.shutdown()
98
+++ b/tests/qemu-iotests/011
128
99
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
129
- self.assertEqual(qemu_io('-f', iotests.imgfmt, '-c', 'map', mid_img),
100
130
- qemu_io('-f', iotests.imgfmt, '-c', 'map', test_img),
101
_supported_fmt generic
131
- 'image file map does not match backing file after streaming')
102
_supported_proto generic
132
+ self.assertEqual(
103
+_unsupported_imgopts "subformat=streamOptimized"
133
+ qemu_io('-f', iotests.imgfmt, '-c', 'map', mid_img).stdout,
104
134
+ qemu_io('-f', iotests.imgfmt, '-c', 'map', test_img).stdout,
105
135
+ 'image file map does not match backing file after streaming')
106
size=6G
136
107
diff --git a/tests/qemu-iotests/017 b/tests/qemu-iotests/017
137
def test_device_not_found(self):
108
index XXXXXXX..XXXXXXX 100755
138
result = self.vm.qmp('block-stream', device='nonexistent')
109
--- a/tests/qemu-iotests/017
139
@@ -XXX,XX +XXX,XX @@ class TestParallelOps(iotests.QMPTestCase):
110
+++ b/tests/qemu-iotests/017
140
111
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
141
# Check that the maps don't match before the streaming operations
112
_supported_fmt qcow qcow2 vmdk qed
142
for i in range(2, self.num_imgs, 2):
113
_supported_proto generic
143
- self.assertNotEqual(qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', self.imgs[i]),
114
_unsupported_proto vxhs
144
- qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', self.imgs[i-1]),
115
-_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
145
- 'image file map matches backing file before streaming')
116
+_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
146
+ self.assertNotEqual(
117
+ "subformat=streamOptimized"
147
+ qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', self.imgs[i]).stdout,
118
148
+ qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', self.imgs[i-1]).stdout,
119
TEST_OFFSETS="0 4294967296"
149
+ 'image file map matches backing file before streaming')
120
150
121
diff --git a/tests/qemu-iotests/018 b/tests/qemu-iotests/018
151
# Create all streaming jobs
122
index XXXXXXX..XXXXXXX 100755
152
pending_jobs = []
123
--- a/tests/qemu-iotests/018
153
@@ -XXX,XX +XXX,XX @@ class TestParallelOps(iotests.QMPTestCase):
124
+++ b/tests/qemu-iotests/018
154
125
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
155
# Check that all maps match now
126
_supported_fmt qcow qcow2 vmdk qed
156
for i in range(2, self.num_imgs, 2):
127
_supported_proto file
157
- self.assertEqual(qemu_io('-f', iotests.imgfmt, '-c', 'map', self.imgs[i]),
128
_supported_os Linux
158
- qemu_io('-f', iotests.imgfmt, '-c', 'map', self.imgs[i-1]),
129
-_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
159
- 'image file map does not match backing file after streaming')
130
+_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
160
+ self.assertEqual(
131
+ "streamOptimized"
161
+ qemu_io('-f', iotests.imgfmt, '-c', 'map', self.imgs[i]).stdout,
132
162
+ qemu_io('-f', iotests.imgfmt, '-c', 'map', self.imgs[i-1]).stdout,
133
TEST_OFFSETS="0 4294967296"
163
+ 'image file map does not match backing file after streaming')
134
164
135
diff --git a/tests/qemu-iotests/019 b/tests/qemu-iotests/019
165
# Test that it's not possible to perform two block-stream
136
index XXXXXXX..XXXXXXX 100755
166
# operations if there are nodes involved in both.
137
--- a/tests/qemu-iotests/019
167
@@ -XXX,XX +XXX,XX @@ class TestParallelOps(iotests.QMPTestCase):
138
+++ b/tests/qemu-iotests/019
168
def test_stream_base_node_name(self):
139
@@ -XXX,XX +XXX,XX @@ _supported_proto file
169
self.assert_no_active_block_jobs()
140
_supported_os Linux
170
141
_unsupported_imgopts "subformat=monolithicFlat" \
171
- self.assertNotEqual(qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', self.imgs[4]),
142
"subformat=twoGbMaxExtentFlat" \
172
- qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', self.imgs[3]),
143
- "subformat=twoGbMaxExtentSparse"
173
- 'image file map matches backing file before streaming')
144
+ "subformat=twoGbMaxExtentSparse" \
174
+ self.assertNotEqual(
145
+ "subformat=streamOptimized"
175
+ qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', self.imgs[4]).stdout,
146
176
+ qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', self.imgs[3]).stdout,
147
TEST_OFFSETS="0 4294967296"
177
+ 'image file map matches backing file before streaming')
148
CLUSTER_SIZE=65536
178
149
diff --git a/tests/qemu-iotests/020 b/tests/qemu-iotests/020
179
# Error: the base node does not exist
150
index XXXXXXX..XXXXXXX 100755
180
result = self.vm.qmp('block-stream', device='node4', base_node='none', job_id='stream')
151
--- a/tests/qemu-iotests/020
181
@@ -XXX,XX +XXX,XX @@ class TestParallelOps(iotests.QMPTestCase):
152
+++ b/tests/qemu-iotests/020
182
self.assert_no_active_block_jobs()
153
@@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed
183
self.vm.shutdown()
154
_supported_proto file
184
155
_unsupported_imgopts "subformat=monolithicFlat" \
185
- self.assertEqual(qemu_io('-f', iotests.imgfmt, '-c', 'map', self.imgs[4]),
156
"subformat=twoGbMaxExtentFlat" \
186
- qemu_io('-f', iotests.imgfmt, '-c', 'map', self.imgs[3]),
157
- "subformat=twoGbMaxExtentSparse"
187
- 'image file map matches backing file after streaming')
158
+ "subformat=twoGbMaxExtentSparse" \
188
+ self.assertEqual(
159
+ "subformat=streamOptimized"
189
+ qemu_io('-f', iotests.imgfmt, '-c', 'map', self.imgs[4]).stdout,
160
190
+ qemu_io('-f', iotests.imgfmt, '-c', 'map', self.imgs[3]).stdout,
161
TEST_OFFSETS="0 4294967296"
191
+ 'image file map matches backing file after streaming')
162
192
163
diff --git a/tests/qemu-iotests/027 b/tests/qemu-iotests/027
193
class TestQuorum(iotests.QMPTestCase):
164
index XXXXXXX..XXXXXXX 100755
194
num_children = 3
165
--- a/tests/qemu-iotests/027
195
@@ -XXX,XX +XXX,XX @@ class TestQuorum(iotests.QMPTestCase):
166
+++ b/tests/qemu-iotests/027
196
os.remove(img)
167
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
197
168
198
def test_stream_quorum(self):
169
_supported_fmt vmdk qcow qcow2 qed
199
- self.assertNotEqual(qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', self.children[0]),
170
_supported_proto generic
200
- qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', self.backing[0]),
171
+_unsupported_imgopts "subformat=streamOptimized"
201
- 'image file map matches backing file before streaming')
172
202
+ self.assertNotEqual(
173
203
+ qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', self.children[0]).stdout,
174
size=128M
204
+ qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', self.backing[0]).stdout,
175
diff --git a/tests/qemu-iotests/032 b/tests/qemu-iotests/032
205
+ 'image file map matches backing file before streaming')
176
index XXXXXXX..XXXXXXX 100755
206
177
--- a/tests/qemu-iotests/032
207
self.assert_no_active_block_jobs()
178
+++ b/tests/qemu-iotests/032
208
179
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
209
@@ -XXX,XX +XXX,XX @@ class TestQuorum(iotests.QMPTestCase):
180
# This works for any image format (though unlikely to segfault for raw)
210
self.assert_no_active_block_jobs()
181
_supported_fmt generic
211
self.vm.shutdown()
182
_supported_proto generic
212
183
+_unsupported_imgopts "subformat=streamOptimized"
213
- self.assertEqual(qemu_io('-f', iotests.imgfmt, '-c', 'map', self.children[0]),
184
214
- qemu_io('-f', iotests.imgfmt, '-c', 'map', self.backing[0]),
185
echo
215
- 'image file map does not match backing file after streaming')
186
echo === Prepare image ===
216
+ self.assertEqual(
187
diff --git a/tests/qemu-iotests/033 b/tests/qemu-iotests/033
217
+ qemu_io('-f', iotests.imgfmt, '-c', 'map', self.children[0]).stdout,
188
index XXXXXXX..XXXXXXX 100755
218
+ qemu_io('-f', iotests.imgfmt, '-c', 'map', self.backing[0]).stdout,
189
--- a/tests/qemu-iotests/033
219
+ 'image file map does not match backing file after streaming')
190
+++ b/tests/qemu-iotests/033
220
191
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
221
class TestSmallerBackingFile(iotests.QMPTestCase):
192
222
backing_len = 1 * 1024 * 1024 # MB
193
_supported_fmt generic
223
diff --git a/tests/qemu-iotests/149 b/tests/qemu-iotests/149
194
_supported_proto generic
224
index XXXXXXX..XXXXXXX 100755
195
+_unsupported_imgopts "subformat=streamOptimized"
225
--- a/tests/qemu-iotests/149
196
226
+++ b/tests/qemu-iotests/149
197
227
@@ -XXX,XX +XXX,XX @@ def qemu_io_write_pattern(config, pattern, offset_mb, size_mb, dev=False):
198
size=128M
228
args = ["-c", "write -P 0x%x %dM %dM" % (pattern, offset_mb, size_mb)]
199
diff --git a/tests/qemu-iotests/034 b/tests/qemu-iotests/034
229
args.extend(qemu_io_image_args(config, dev))
200
index XXXXXXX..XXXXXXX 100755
230
iotests.log("qemu-io " + " ".join(args), filters=[iotests.filter_test_dir])
201
--- a/tests/qemu-iotests/034
231
- iotests.log(check_cipher_support(config, iotests.qemu_io(*args)),
202
+++ b/tests/qemu-iotests/034
232
+ output = iotests.qemu_io(*args, check=False).stdout
203
@@ -XXX,XX +XXX,XX @@ _supported_proto file
233
+ iotests.log(check_cipher_support(config, output),
204
_supported_os Linux
234
filters=[iotests.filter_test_dir, iotests.filter_qemu_io])
205
_unsupported_imgopts "subformat=monolithicFlat" \
235
206
"subformat=twoGbMaxExtentFlat" \
236
207
- "subformat=twoGbMaxExtentSparse"
237
@@ -XXX,XX +XXX,XX @@ def qemu_io_read_pattern(config, pattern, offset_mb, size_mb, dev=False):
208
+ "subformat=twoGbMaxExtentSparse" \
238
args = ["-c", "read -P 0x%x %dM %dM" % (pattern, offset_mb, size_mb)]
209
+ "subformat=streamOptimized"
239
args.extend(qemu_io_image_args(config, dev))
210
240
iotests.log("qemu-io " + " ".join(args), filters=[iotests.filter_test_dir])
211
CLUSTER_SIZE=4k
241
- iotests.log(check_cipher_support(config, iotests.qemu_io(*args)),
212
size=128M
242
+ output = iotests.qemu_io(*args, check=False).stdout
213
diff --git a/tests/qemu-iotests/037 b/tests/qemu-iotests/037
243
+ iotests.log(check_cipher_support(config, output),
214
index XXXXXXX..XXXXXXX 100755
244
filters=[iotests.filter_test_dir, iotests.filter_qemu_io])
215
--- a/tests/qemu-iotests/037
245
216
+++ b/tests/qemu-iotests/037
246
217
@@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed
247
diff --git a/tests/qemu-iotests/205 b/tests/qemu-iotests/205
218
_supported_proto file
248
index XXXXXXX..XXXXXXX 100755
219
_unsupported_imgopts "subformat=monolithicFlat" \
249
--- a/tests/qemu-iotests/205
220
"subformat=twoGbMaxExtentFlat" \
250
+++ b/tests/qemu-iotests/205
221
- "subformat=twoGbMaxExtentSparse"
251
@@ -XXX,XX +XXX,XX @@ class TestNbdServerRemove(iotests.QMPTestCase):
222
+ "subformat=twoGbMaxExtentSparse" \
252
223
+ "subformat=streamOptimized"
253
def do_test_connect_after_remove(self, mode=None):
224
254
args = ('-r', '-f', 'raw', '-c', 'read 0 512', nbd_uri)
225
CLUSTER_SIZE=4k
255
- self.assertReadOk(qemu_io(*args))
226
size=128M
256
+ self.assertReadOk(qemu_io(*args).stdout)
227
diff --git a/tests/qemu-iotests/063 b/tests/qemu-iotests/063
257
228
index XXXXXXX..XXXXXXX 100755
258
result = self.remove_export('exp', mode)
229
--- a/tests/qemu-iotests/063
259
self.assert_qmp(result, 'return', {})
230
+++ b/tests/qemu-iotests/063
260
231
@@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed raw
261
self.assertExportNotFound('exp')
232
_supported_proto file
262
- self.assertConnectFailed(qemu_io(*args))
233
_unsupported_imgopts "subformat=monolithicFlat" \
263
+ self.assertConnectFailed(qemu_io(*args, check=False).stdout)
234
"subformat=twoGbMaxExtentFlat" \
264
235
- "subformat=twoGbMaxExtentSparse"
265
def test_connect_after_remove_default(self):
236
+ "subformat=twoGbMaxExtentSparse" \
266
self.do_test_connect_after_remove()
237
+ "subformat=streamOptimized"
267
diff --git a/tests/qemu-iotests/245 b/tests/qemu-iotests/245
238
268
index XXXXXXX..XXXXXXX 100755
239
_make_test_img 4M
269
--- a/tests/qemu-iotests/245
240
270
+++ b/tests/qemu-iotests/245
241
diff --git a/tests/qemu-iotests/072 b/tests/qemu-iotests/072
271
@@ -XXX,XX +XXX,XX @@
242
index XXXXXXX..XXXXXXX 100755
272
# along with this program. If not, see <http://www.gnu.org/licenses/>.
243
--- a/tests/qemu-iotests/072
273
#
244
+++ b/tests/qemu-iotests/072
274
245
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
275
+import copy
246
276
+import json
247
_supported_fmt vpc vmdk vhdx vdi qed qcow2 qcow
277
import os
248
_supported_proto file
278
import re
249
+_unsupported_imgopts "subformat=streamOptimized"
279
+from subprocess import CalledProcessError
250
280
+
251
IMG_SIZE=64M
281
import iotests
252
282
-import copy
253
diff --git a/tests/qemu-iotests/105 b/tests/qemu-iotests/105
283
-import json
254
index XXXXXXX..XXXXXXX 100755
284
from iotests import qemu_img, qemu_io
255
--- a/tests/qemu-iotests/105
285
256
+++ b/tests/qemu-iotests/105
286
hd_path = [
257
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
287
@@ -XXX,XX +XXX,XX @@ class TestBlockdevReopen(iotests.QMPTestCase):
258
_supported_fmt qcow2 vmdk vhdx qed
288
259
_supported_proto generic
289
# Reopen an image several times changing some of its options
260
_unsupported_imgopts "subformat=twoGbMaxExtentFlat" \
290
def test_reopen(self):
261
- "subformat=twoGbMaxExtentSparse"
291
- # Check whether the filesystem supports O_DIRECT
262
+ "subformat=twoGbMaxExtentSparse" \
292
- if 'O_DIRECT' in qemu_io('-f', 'raw', '-t', 'none', '-c', 'quit', hd_path[0]):
263
+ "subformat=streamOptimized"
293
- supports_direct = False
264
294
- else:
265
echo
295
+ try:
266
echo "creating large image"
296
+ qemu_io('-f', 'raw', '-t', 'none', '-c', 'quit', hd_path[0])
267
diff --git a/tests/qemu-iotests/197 b/tests/qemu-iotests/197
297
supports_direct = True
268
index XXXXXXX..XXXXXXX 100755
298
+ except CalledProcessError as exc:
269
--- a/tests/qemu-iotests/197
299
+ if 'O_DIRECT' in exc.stdout:
270
+++ b/tests/qemu-iotests/197
300
+ supports_direct = False
271
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
301
+ else:
272
_supported_proto generic
302
+ raise
273
# LUKS support may be possible, but it complicates things.
303
274
_unsupported_fmt luks
304
# Open the hd1 image passing all backing options
275
+_unsupported_imgopts "subformat=streamOptimized"
305
opts = hd_opts(1)
276
306
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
277
echo
307
index XXXXXXX..XXXXXXX 100644
278
echo '=== Copy-on-read ==='
308
--- a/tests/qemu-iotests/iotests.py
279
diff --git a/tests/qemu-iotests/215 b/tests/qemu-iotests/215
309
+++ b/tests/qemu-iotests/iotests.py
280
index XXXXXXX..XXXXXXX 100755
310
@@ -XXX,XX +XXX,XX @@ def qemu_io_wrap_args(args: Sequence[str]) -> List[str]:
281
--- a/tests/qemu-iotests/215
311
def qemu_io_popen(*args):
282
+++ b/tests/qemu-iotests/215
312
return qemu_tool_popen(qemu_io_wrap_args(args))
283
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
313
284
_supported_proto generic
314
-def qemu_io(*args):
285
# LUKS support may be possible, but it complicates things.
315
- '''Run qemu-io and return the stdout data'''
286
_unsupported_fmt luks
316
- return qemu_tool_pipe_and_status('qemu-io', qemu_io_wrap_args(args))[0]
287
+_unsupported_imgopts "subformat=streamOptimized"
317
+def qemu_io(*args: str, check: bool = True, combine_stdio: bool = True
288
318
+ ) -> 'subprocess.CompletedProcess[str]':
289
echo
319
+ """
290
echo '=== Copy-on-read ==='
320
+ Run QEMU_IO_PROG and return the status code and console output.
291
diff --git a/tests/qemu-iotests/251 b/tests/qemu-iotests/251
321
+
292
index XXXXXXX..XXXXXXX 100755
322
+ This function always prepends either QEMU_IO_OPTIONS or
293
--- a/tests/qemu-iotests/251
323
+ QEMU_IO_OPTIONS_NO_FMT.
294
+++ b/tests/qemu-iotests/251
324
+ """
295
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
325
+ return qemu_tool(*qemu_io_wrap_args(args),
296
_supported_fmt generic
326
+ check=check, combine_stdio=combine_stdio)
297
_supported_proto file
327
298
_supported_os Linux
328
def qemu_io_pipe_and_status(*args):
299
+_unsupported_imgopts "subformat=streamOptimized"
329
return qemu_tool_pipe_and_status('qemu-io', qemu_io_wrap_args(args))
300
330
301
if [ "$IMGOPTSSYNTAX" = "true" ]; then
331
-def qemu_io_log(*args):
302
# We use json:{} filenames here, so we cannot work with additional options.
332
- result = qemu_io(*args)
333
- log(result, filters=[filter_testfiles, filter_qemu_io])
334
+def qemu_io_log(*args: str) -> 'subprocess.CompletedProcess[str]':
335
+ result = qemu_io(*args, check=False)
336
+ log(result.stdout, filters=[filter_testfiles, filter_qemu_io])
337
return result
338
339
def qemu_io_silent(*args):
340
diff --git a/tests/qemu-iotests/tests/migration-permissions b/tests/qemu-iotests/tests/migration-permissions
341
index XXXXXXX..XXXXXXX 100755
342
--- a/tests/qemu-iotests/tests/migration-permissions
343
+++ b/tests/qemu-iotests/tests/migration-permissions
344
@@ -XXX,XX +XXX,XX @@ class TestMigrationPermissions(iotests.QMPTestCase):
345
def test_post_migration_permissions(self):
346
# Try to access the image R/W, which should fail because virtio-blk
347
# has not been configured with share-rw=on
348
- log = qemu_io('-f', imgfmt, '-c', 'quit', test_img)
349
+ log = qemu_io('-f', imgfmt, '-c', 'quit', test_img, check=False).stdout
350
if not log.strip():
351
print('ERROR (pre-migration): qemu-io should not be able to '
352
'access this image, but it reported no error')
353
@@ -XXX,XX +XXX,XX @@ class TestMigrationPermissions(iotests.QMPTestCase):
354
355
# Try the same qemu-io access again, verifying that the WRITE
356
# permission remains unshared
357
- log = qemu_io('-f', imgfmt, '-c', 'quit', test_img)
358
+ log = qemu_io('-f', imgfmt, '-c', 'quit', test_img, check=False).stdout
359
if not log.strip():
360
print('ERROR (post-migration): qemu-io should not be able to '
361
'access this image, but it reported no error')
303
--
362
--
304
2.21.0
363
2.35.1
305
306
diff view generated by jsdifflib
1
Compressed writes generally have to write full clusters, not just in
1
From: John Snow <jsnow@redhat.com>
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:
5
2
6
$ qemu-img create -f vmdk -o subformat=streamOptimized foo.vmdk 1M
3
Modify this test to use assertRaises for its negative testing of
7
$ qemu-io -c 'write 4k 4k' -c 'read 4k 4k' foo.vmdk
4
qemu_io. If the exception raised does not match the one we tell it to
8
wrote 4096/4096 bytes at offset 4096
5
expect, we get *that* exception unhandled. If we get no exception, we
9
4 KiB, 1 ops; 00.01 sec (443.724 KiB/sec and 110.9309 ops/sec)
6
get a unittest assertion failure and the provided emsg printed to
10
read failed: Invalid argument
7
screen.
11
8
12
(The technical reason is that vmdk_write_extent() just writes the
9
If we get the CalledProcessError exception but the output is not what we
13
incomplete compressed data actually to offset 4k. When reading the
10
expect, we re-raise the original CalledProcessError.
14
data, vmdk_read_extent() looks at offset 0 and finds the compressed data
15
size to be 0, because that is what it reads from there. This yields an
16
error.)
17
11
18
For incomplete writes with zero in-cluster offsets, the error path when
12
Tidy.
19
reading the rest of the cluster is a bit different, but the result is
20
the same:
21
13
22
$ qemu-img create -f vmdk -o subformat=streamOptimized foo.vmdk 1M
14
(Note: Yes, you can reference "with" objects after that block ends; it
23
$ qemu-io -c 'write 0k 4k' -c 'read 4k 4k' foo.vmdk
15
just means that ctx.__exit__(...) will have been called on it. It does
24
wrote 4096/4096 bytes at offset 0
16
not *actually* go out of scope. unittests expects you to want to inspect
25
4 KiB, 1 ops; 00.01 sec (362.641 KiB/sec and 90.6603 ops/sec)
17
the Exception object, so they leave it defined post-exit.)
26
read failed: Invalid argument
27
18
28
(Here, vmdk_read_extent() finds the data and then sees that the
19
Signed-off-by: John Snow <jsnow@redhat.com>
29
uncompressed data is short.)
20
Reviewed-by: Eric Blake <eblake@redhat.com>
21
Tested-by: Eric Blake <eblake@redhat.com>
22
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
23
Message-Id: <20220418211504.943969-9-jsnow@redhat.com>
24
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
25
---
26
.../qemu-iotests/tests/migration-permissions | 28 +++++++++----------
27
1 file changed, 14 insertions(+), 14 deletions(-)
30
28
31
It is better to reject invalid writes than to make the user believe they
29
diff --git a/tests/qemu-iotests/tests/migration-permissions b/tests/qemu-iotests/tests/migration-permissions
32
might have succeeded and then fail when trying to read it back.
30
index XXXXXXX..XXXXXXX 100755
33
31
--- a/tests/qemu-iotests/tests/migration-permissions
34
Signed-off-by: Max Reitz <mreitz@redhat.com>
32
+++ b/tests/qemu-iotests/tests/migration-permissions
35
Reviewed-by: John Snow <jsnow@redhat.com>
33
@@ -XXX,XX +XXX,XX @@
36
Message-id: 20190815153638.4600-5-mreitz@redhat.com
34
#
37
Reviewed-by: John Snow <jsnow@redhat.com>
35
38
Signed-off-by: Max Reitz <mreitz@redhat.com>
36
import os
39
---
37
+from subprocess import CalledProcessError
40
block/vmdk.c | 10 ++++++++++
41
1 file changed, 10 insertions(+)
42
43
diff --git a/block/vmdk.c b/block/vmdk.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/block/vmdk.c
46
+++ b/block/vmdk.c
47
@@ -XXX,XX +XXX,XX @@ static int vmdk_write_extent(VmdkExtent *extent, int64_t cluster_offset,
48
if (extent->compressed) {
49
void *compressed_data;
50
51
+ /* Only whole clusters */
52
+ if (offset_in_cluster ||
53
+ n_bytes > (extent->cluster_sectors * SECTOR_SIZE) ||
54
+ (n_bytes < (extent->cluster_sectors * SECTOR_SIZE) &&
55
+ offset + n_bytes != extent->end_sector * SECTOR_SIZE))
56
+ {
57
+ ret = -EINVAL;
58
+ goto out;
59
+ }
60
+
38
+
61
if (!extent->has_marker) {
39
import iotests
62
ret = -EINVAL;
40
from iotests import imgfmt, qemu_img_create, qemu_io
63
goto out;
41
42
@@ -XXX,XX +XXX,XX @@ class TestMigrationPermissions(iotests.QMPTestCase):
43
def test_post_migration_permissions(self):
44
# Try to access the image R/W, which should fail because virtio-blk
45
# has not been configured with share-rw=on
46
- log = qemu_io('-f', imgfmt, '-c', 'quit', test_img, check=False).stdout
47
- if not log.strip():
48
- print('ERROR (pre-migration): qemu-io should not be able to '
49
- 'access this image, but it reported no error')
50
- else:
51
- # This is the expected output
52
- assert 'Is another process using the image' in log
53
+ emsg = ('ERROR (pre-migration): qemu-io should not be able to '
54
+ 'access this image, but it reported no error')
55
+ with self.assertRaises(CalledProcessError, msg=emsg) as ctx:
56
+ qemu_io('-f', imgfmt, '-c', 'quit', test_img)
57
+ if 'Is another process using the image' not in ctx.exception.stdout:
58
+ raise ctx.exception
59
60
# Now migrate the VM
61
self.vm_s.qmp('migrate', uri=f'unix:{mig_sock}')
62
@@ -XXX,XX +XXX,XX @@ class TestMigrationPermissions(iotests.QMPTestCase):
63
64
# Try the same qemu-io access again, verifying that the WRITE
65
# permission remains unshared
66
- log = qemu_io('-f', imgfmt, '-c', 'quit', test_img, check=False).stdout
67
- if not log.strip():
68
- print('ERROR (post-migration): qemu-io should not be able to '
69
- 'access this image, but it reported no error')
70
- else:
71
- # This is the expected output
72
- assert 'Is another process using the image' in log
73
+ emsg = ('ERROR (post-migration): qemu-io should not be able to '
74
+ 'access this image, but it reported no error')
75
+ with self.assertRaises(CalledProcessError, msg=emsg) as ctx:
76
+ qemu_io('-f', imgfmt, '-c', 'quit', test_img)
77
+ if 'Is another process using the image' not in ctx.exception.stdout:
78
+ raise ctx.exception
79
80
81
if __name__ == '__main__':
64
--
82
--
65
2.21.0
83
2.35.1
66
67
diff view generated by jsdifflib
1
fe646693acc changed qemu-img create's output so that it no longer prints
1
From: John Snow <jsnow@redhat.com>
2
single quotes around parameter values. The subformat and adapter_type
3
filters in _filter_img_create() have never been adapted to that change.
4
2
5
Fixes: fe646693acc13ac48b98435d14149ab04dc597bc
3
This test expects failure ... but only sometimes. When? Why?
6
Signed-off-by: Max Reitz <mreitz@redhat.com>
4
7
Reviewed-by: John Snow <jsnow@redhat.com>
5
It's for reads of a region not defined by a bitmap. Adjust the test to
8
Message-id: 20190815153638.4600-2-mreitz@redhat.com
6
be more explicit about what it expects to fail and why.
9
Reviewed-by: John Snow <jsnow@redhat.com>
7
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
8
Signed-off-by: John Snow <jsnow@redhat.com>
9
Reviewed-by: Eric Blake <eblake@redhat.com>
10
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
11
Message-Id: <20220418211504.943969-10-jsnow@redhat.com>
12
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
11
---
13
---
12
tests/qemu-iotests/059.out | 16 ++++++++--------
14
tests/qemu-iotests/tests/image-fleecing | 28 +++++++++++++++++--------
13
tests/qemu-iotests/common.filter | 4 ++--
15
1 file changed, 19 insertions(+), 9 deletions(-)
14
2 files changed, 10 insertions(+), 10 deletions(-)
15
16
16
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
17
diff --git a/tests/qemu-iotests/tests/image-fleecing b/tests/qemu-iotests/tests/image-fleecing
17
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100755
18
--- a/tests/qemu-iotests/059.out
19
--- a/tests/qemu-iotests/tests/image-fleecing
19
+++ b/tests/qemu-iotests/059.out
20
+++ b/tests/qemu-iotests/tests/image-fleecing
20
@@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
21
@@ -XXX,XX +XXX,XX @@
21
qemu-io: can't open device TEST_DIR/t.vmdk: L1 size too big
22
#
22
23
# Creator/Owner: John Snow <jsnow@redhat.com>
23
=== Testing monolithicFlat creation and opening ===
24
24
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat
25
+from subprocess import CalledProcessError
25
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648
26
+
26
image: TEST_DIR/t.IMGFMT
27
import iotests
27
file format: IMGFMT
28
-from iotests import log, qemu_img, qemu_io, qemu_io_silent, \
28
virtual size: 2 GiB (2147483648 bytes)
29
- qemu_io_pipe_and_status
29
30
+from iotests import log, qemu_img, qemu_io, qemu_io_silent
30
=== Testing monolithicFlat with zeroed_grain ===
31
31
qemu-img: TEST_DIR/t.IMGFMT: Flat image can't enable zeroed grain
32
iotests.script_initialize(
32
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat
33
supported_fmts=['qcow2'],
33
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648
34
@@ -XXX,XX +XXX,XX @@ def do_test(vm, use_cbw, use_snapshot_access_filter, base_img_path,
34
35
for p in patterns + zeroes:
35
=== Testing big twoGbMaxExtentFlat ===
36
cmd = 'read -P%s %s %s' % p
36
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000 subformat=twoGbMaxExtentFlat
37
log(cmd)
37
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000
38
- out, ret = qemu_io_pipe_and_status('-r', '-f', 'raw', '-c', cmd,
38
image: TEST_DIR/t.vmdk
39
- nbd_uri)
39
file format: vmdk
40
- if ret != 0:
40
virtual size: 0.977 TiB (1073741824000 bytes)
41
- print(out)
41
@@ -XXX,XX +XXX,XX @@ Format specific information:
42
+
42
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Invalid extent line: RW 12582912 VMFS "dummy.IMGFMT" 1
43
+ try:
43
44
+ qemu_io('-r', '-f', 'raw', '-c', cmd, nbd_uri)
44
=== Testing truncated sparse ===
45
+ except CalledProcessError as exc:
45
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=107374182400 subformat=monolithicSparse
46
+ if bitmap and p in zeroes:
46
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=107374182400
47
+ log(exc.stdout)
47
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': File truncated, expecting at least 13172736 bytes
48
+ else:
48
49
+ raise
49
=== Converting to streamOptimized from image with small cluster size===
50
50
@@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240
51
log('')
51
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
52
log('--- Testing COW ---')
52
53
@@ -XXX,XX +XXX,XX @@ def do_test(vm, use_cbw, use_snapshot_access_filter, base_img_path,
53
=== Testing monolithicFlat with internally generated JSON file name ===
54
args += [target_img_path]
54
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 subformat=monolithicFlat
55
else:
55
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
56
args += ['-f', 'raw', nbd_uri]
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
- out, ret = qemu_io_pipe_and_status(*args)
57
58
- if ret != 0:
58
=== Testing version 3 ===
59
- print(out)
59
@@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 64931328
60
+
60
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
61
+ try:
61
62
+ qemu_io(*args)
62
=== Testing 4TB monolithicFlat creation and IO ===
63
+ except CalledProcessError as exc:
63
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4398046511104 subformat=monolithicFlat
64
+ if bitmap and p in zeroes:
64
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4398046511104
65
+ log(exc.stdout)
65
image: TEST_DIR/t.IMGFMT
66
+ else:
66
file format: IMGFMT
67
+ raise
67
virtual size: 4 TiB (4398046511104 bytes)
68
68
@@ -XXX,XX +XXX,XX @@ read 1024/1024 bytes at offset 966367641600
69
log('')
69
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
70
log('--- Cleanup ---')
70
71
=== Testing qemu-img map on extents ===
72
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544 subformat=monolithicSparse
73
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544
74
wrote 1024/1024 bytes at offset 65024
75
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
76
wrote 1024/1024 bytes at offset 2147483136
77
@@ -XXX,XX +XXX,XX @@ Offset Length Mapped to File
78
0 0x20000 0x3f0000 TEST_DIR/t.vmdk
79
0x7fff0000 0x20000 0x410000 TEST_DIR/t.vmdk
80
0x140000000 0x10000 0x430000 TEST_DIR/t.vmdk
81
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544 subformat=twoGbMaxExtentSparse
82
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544
83
wrote 1024/1024 bytes at offset 65024
84
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
85
wrote 1024/1024 bytes at offset 2147483136
86
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
87
index XXXXXXX..XXXXXXX 100644
88
--- a/tests/qemu-iotests/common.filter
89
+++ b/tests/qemu-iotests/common.filter
90
@@ -XXX,XX +XXX,XX @@ _filter_img_create()
91
-e "s# compat6=\\(on\\|off\\)##g" \
92
-e "s# static=\\(on\\|off\\)##g" \
93
-e "s# zeroed_grain=\\(on\\|off\\)##g" \
94
- -e "s# subformat='[^']*'##g" \
95
- -e "s# adapter_type='[^']*'##g" \
96
+ -e "s# subformat=[^ ]*##g" \
97
+ -e "s# adapter_type=[^ ]*##g" \
98
-e "s# hwversion=[^ ]*##g" \
99
-e "s# lazy_refcounts=\\(on\\|off\\)##g" \
100
-e "s# block_size=[0-9]\\+##g" \
101
--
71
--
102
2.21.0
72
2.35.1
103
104
diff view generated by jsdifflib
1
From: Nir Soffer <nirsof@gmail.com>
1
From: John Snow <jsnow@redhat.com>
2
2
3
Using block_resize we can test allocate_first_block() with file
3
I know we just added it, sorry. This is done in favor of qemu_io() which
4
descriptor opened with O_DIRECT, ensuring that it works for any size
4
*also* returns the console output and status, but with more robust error
5
larger than 4096 bytes.
5
handling on failure.
6
6
7
Testing smaller sizes is tricky as the result depends on the filesystem
7
Signed-off-by: John Snow <jsnow@redhat.com>
8
used for testing. For example on NFS any size will work since O_DIRECT
8
Reviewed-by: Eric Blake <eblake@redhat.com>
9
does not require any alignment.
9
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
10
Message-Id: <20220418211504.943969-11-jsnow@redhat.com>
11
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
12
---
13
tests/qemu-iotests/iotests.py | 3 ---
14
1 file changed, 3 deletions(-)
10
15
11
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
16
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
12
Reviewed-by: Max Reitz <mreitz@redhat.com>
13
Message-id: 20190827010528.8818-3-nsoffer@redhat.com
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
---
16
tests/qemu-iotests/175 | 28 ++++++++++++++++++++++++++++
17
tests/qemu-iotests/175.out | 8 ++++++++
18
2 files changed, 36 insertions(+)
19
20
diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175
21
index XXXXXXX..XXXXXXX 100755
22
--- a/tests/qemu-iotests/175
23
+++ b/tests/qemu-iotests/175
24
@@ -XXX,XX +XXX,XX @@ _filter_blocks()
25
-e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/max allocation/"
26
}
27
28
+# Resize image using block_resize.
29
+# Parameter 1: image path
30
+# Parameter 2: new size
31
+_block_resize()
32
+{
33
+ local path=$1
34
+ local size=$2
35
+
36
+ $QEMU -qmp stdio -nographic -nodefaults \
37
+ -blockdev file,node-name=file,filename=$path,cache.direct=on \
38
+ <<EOF
39
+{'execute': 'qmp_capabilities'}
40
+{'execute': 'block_resize', 'arguments': {'node-name': 'file', 'size': $size}}
41
+{'execute': 'quit'}
42
+EOF
43
+}
44
+
45
# get standard environment, filters and checks
46
. ./common.rc
47
. ./common.filter
48
@@ -XXX,XX +XXX,XX @@ _supported_fmt raw
49
_supported_proto file
50
_supported_os Linux
51
52
+_default_cache_mode none
53
+_supported_cache_modes none directsync
54
+
55
size=$((1 * 1024 * 1024))
56
57
touch "$TEST_DIR/empty"
58
@@ -XXX,XX +XXX,XX @@ for mode in off full falloc; do
59
stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size
60
done
61
62
+for new_size in 4096 1048576; do
63
+ echo
64
+ echo "== resize empty image with block_resize =="
65
+ _make_test_img 0 | _filter_imgfmt
66
+ _block_resize $TEST_IMG $new_size >/dev/null
67
+ stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $new_size
68
+done
69
+
70
# success, all done
71
echo "*** done"
72
rm -f $seq.full
73
diff --git a/tests/qemu-iotests/175.out b/tests/qemu-iotests/175.out
74
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
75
--- a/tests/qemu-iotests/175.out
18
--- a/tests/qemu-iotests/iotests.py
76
+++ b/tests/qemu-iotests/175.out
19
+++ b/tests/qemu-iotests/iotests.py
77
@@ -XXX,XX +XXX,XX @@ size=1048576, max allocation
20
@@ -XXX,XX +XXX,XX @@ def qemu_io(*args: str, check: bool = True, combine_stdio: bool = True
78
== creating image with preallocation falloc ==
21
return qemu_tool(*qemu_io_wrap_args(args),
79
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=falloc
22
check=check, combine_stdio=combine_stdio)
80
size=1048576, max allocation
23
81
+
24
-def qemu_io_pipe_and_status(*args):
82
+== resize empty image with block_resize ==
25
- return qemu_tool_pipe_and_status('qemu-io', qemu_io_wrap_args(args))
83
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=0
26
-
84
+size=4096, min allocation
27
def qemu_io_log(*args: str) -> 'subprocess.CompletedProcess[str]':
85
+
28
result = qemu_io(*args, check=False)
86
+== resize empty image with block_resize ==
29
log(result.stdout, filters=[filter_testfiles, filter_qemu_io])
87
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=0
88
+size=1048576, min allocation
89
*** done
90
--
30
--
91
2.21.0
31
2.35.1
92
93
diff view generated by jsdifflib
1
From: Nir Soffer <nirsof@gmail.com>
1
From: John Snow <jsnow@redhat.com>
2
2
3
When creating an image with preallocation "off" or "falloc", the first
3
Like qemu-img, qemu-io returning 0 should be the norm and not the
4
block of the image is typically not allocated. When using Gluster
4
exception. Remove all calls to qemu_io_silent that just assert the
5
storage backed by XFS filesystem, reading this block using direct I/O
5
return code is zero (That's every last call, as it turns out), and
6
succeeds regardless of request length, fooling alignment detection.
6
replace them with a normal qemu_io() call.
7
7
8
In this case we fallback to a safe value (4096) instead of the optimal
8
qemu_io_silent_check() appeared to have been unused already.
9
value (512), which may lead to unneeded data copying when aligning
10
requests. Allocating the first block avoids the fallback.
11
9
12
Since we allocate the first block even with preallocation=off, we no
10
Signed-off-by: John Snow <jsnow@redhat.com>
13
longer create images with zero disk size:
11
Reviewed-by: Eric Blake <eblake@redhat.com>
12
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
13
Message-Id: <20220418211504.943969-12-jsnow@redhat.com>
14
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
15
---
16
tests/qemu-iotests/216 | 12 +++++-----
17
tests/qemu-iotests/218 | 5 ++---
18
tests/qemu-iotests/224 | 4 ++--
19
tests/qemu-iotests/258 | 11 +++++-----
20
tests/qemu-iotests/298 | 17 ++++++--------
21
tests/qemu-iotests/310 | 22 +++++++++----------
22
tests/qemu-iotests/iotests.py | 16 --------------
23
tests/qemu-iotests/tests/image-fleecing | 4 ++--
24
.../tests/mirror-ready-cancel-error | 2 +-
25
.../qemu-iotests/tests/stream-error-on-reset | 4 ++--
26
10 files changed, 38 insertions(+), 59 deletions(-)
14
27
15
$ ./qemu-img create -f raw test.raw 1g
28
diff --git a/tests/qemu-iotests/216 b/tests/qemu-iotests/216
16
Formatting 'test.raw', fmt=raw size=1073741824
29
index XXXXXXX..XXXXXXX 100755
17
30
--- a/tests/qemu-iotests/216
18
$ ls -lhs test.raw
31
+++ b/tests/qemu-iotests/216
19
4.0K -rw-r--r--. 1 nsoffer nsoffer 1.0G Aug 16 23:48 test.raw
32
@@ -XXX,XX +XXX,XX @@
20
33
# Creator/Owner: Hanna Reitz <hreitz@redhat.com>
21
And converting the image requires additional cluster:
34
22
35
import iotests
23
$ ./qemu-img measure -f raw -O qcow2 test.raw
36
-from iotests import log, qemu_img, qemu_io_silent
24
required size: 458752
37
+from iotests import log, qemu_img, qemu_io
25
fully allocated size: 1074135040
38
26
39
# Need backing file support
27
When using format like vmdk with multiple files per image, we allocate
40
iotests.script_initialize(supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk'],
28
one block per file:
41
@@ -XXX,XX +XXX,XX @@ with iotests.FilePath('base.img') as base_img_path, \
29
42
log('')
30
$ ./qemu-img create -f vmdk -o subformat=twoGbMaxExtentFlat test.vmdk 4g
43
31
Formatting 'test.vmdk', fmt=vmdk size=4294967296 compat6=off hwversion=undefined subformat=twoGbMaxExtentFlat
44
qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M')
32
45
- assert qemu_io_silent(base_img_path, '-c', 'write -P 1 0M 1M') == 0
33
$ ls -lhs test*.vmdk
46
+ qemu_io(base_img_path, '-c', 'write -P 1 0M 1M')
34
4.0K -rw-r--r--. 1 nsoffer nsoffer 2.0G Aug 27 03:23 test-f001.vmdk
47
qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path,
35
4.0K -rw-r--r--. 1 nsoffer nsoffer 2.0G Aug 27 03:23 test-f002.vmdk
48
'-F', iotests.imgfmt, top_img_path)
36
4.0K -rw-r--r--. 1 nsoffer nsoffer 353 Aug 27 03:23 test.vmdk
49
- assert qemu_io_silent(top_img_path, '-c', 'write -P 2 1M 1M') == 0
37
50
+ qemu_io(top_img_path, '-c', 'write -P 2 1M 1M')
38
I did quick performance test for copying disks with qemu-img convert to
51
39
new raw target image to Gluster storage with sector size of 512 bytes:
52
log('Done')
40
53
41
for i in $(seq 10); do
54
@@ -XXX,XX +XXX,XX @@ with iotests.FilePath('base.img') as base_img_path, \
42
rm -f dst.raw
55
log('--- Checking COR result ---')
43
sleep 10
56
log('')
44
time ./qemu-img convert -f raw -O raw -t none -T none src.raw dst.raw
57
45
done
58
- assert qemu_io_silent(base_img_path, '-c', 'discard 0 64M') == 0
46
59
- assert qemu_io_silent(top_img_path, '-c', 'read -P 1 0M 1M') == 0
47
Here is a table comparing the total time spent:
60
- assert qemu_io_silent(top_img_path, '-c', 'read -P 2 1M 1M') == 0
48
61
+ qemu_io(base_img_path, '-c', 'discard 0 64M')
49
Type Before(s) After(s) Diff(%)
62
+ qemu_io(top_img_path, '-c', 'read -P 1 0M 1M')
50
---------------------------------------
63
+ qemu_io(top_img_path, '-c', 'read -P 2 1M 1M')
51
real 530.028 469.123 -11.4
64
52
user 17.204 10.768 -37.4
65
log('Done')
53
sys 17.881 7.011 -60.7
66
diff --git a/tests/qemu-iotests/218 b/tests/qemu-iotests/218
54
67
index XXXXXXX..XXXXXXX 100755
55
We can see very clear improvement in CPU usage.
68
--- a/tests/qemu-iotests/218
56
69
+++ b/tests/qemu-iotests/218
57
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
70
@@ -XXX,XX +XXX,XX @@
58
Message-id: 20190827010528.8818-2-nsoffer@redhat.com
71
# Creator/Owner: Hanna Reitz <hreitz@redhat.com>
59
Reviewed-by: Max Reitz <mreitz@redhat.com>
72
60
Signed-off-by: Max Reitz <mreitz@redhat.com>
73
import iotests
61
---
74
-from iotests import log, qemu_img, qemu_io_silent
62
block/file-posix.c | 51 +++++++++++++++++++
75
+from iotests import log, qemu_img, qemu_io
63
tests/qemu-iotests/059.out | 2 +-
76
64
tests/qemu-iotests/{150.out => 150.out.qcow2} | 0
77
iotests.script_initialize(supported_fmts=['qcow2', 'raw'])
65
tests/qemu-iotests/150.out.raw | 12 +++++
78
66
tests/qemu-iotests/175 | 19 ++++---
79
@@ -XXX,XX +XXX,XX @@ with iotests.VM() as vm, \
67
tests/qemu-iotests/175.out | 8 +--
80
iotests.FilePath('src.img') as src_img_path:
68
tests/qemu-iotests/178.out.qcow2 | 4 +-
81
69
tests/qemu-iotests/221.out | 12 +++--
82
qemu_img('create', '-f', iotests.imgfmt, src_img_path, '64M')
70
tests/qemu-iotests/253.out | 12 +++--
83
- assert qemu_io_silent('-f', iotests.imgfmt, src_img_path,
71
9 files changed, 99 insertions(+), 21 deletions(-)
84
- '-c', 'write -P 42 0M 64M') == 0
72
rename tests/qemu-iotests/{150.out => 150.out.qcow2} (100%)
85
+ qemu_io('-f', iotests.imgfmt, src_img_path, '-c', 'write -P 42 0M 64M')
73
create mode 100644 tests/qemu-iotests/150.out.raw
86
74
87
vm.launch()
75
diff --git a/block/file-posix.c b/block/file-posix.c
88
89
diff --git a/tests/qemu-iotests/224 b/tests/qemu-iotests/224
90
index XXXXXXX..XXXXXXX 100755
91
--- a/tests/qemu-iotests/224
92
+++ b/tests/qemu-iotests/224
93
@@ -XXX,XX +XXX,XX @@
94
# Creator/Owner: Hanna Reitz <hreitz@redhat.com>
95
96
import iotests
97
-from iotests import log, qemu_img, qemu_io_silent, filter_qmp_testfiles, \
98
+from iotests import log, qemu_img, qemu_io, filter_qmp_testfiles, \
99
filter_qmp_imgfmt
100
import json
101
102
@@ -XXX,XX +XXX,XX @@ for filter_node_name in False, True:
103
'-F', iotests.imgfmt, top_img_path)
104
105
# Something to commit
106
- assert qemu_io_silent(mid_img_path, '-c', 'write -P 1 0 1M') == 0
107
+ qemu_io(mid_img_path, '-c', 'write -P 1 0 1M')
108
109
vm.launch()
110
111
diff --git a/tests/qemu-iotests/258 b/tests/qemu-iotests/258
112
index XXXXXXX..XXXXXXX 100755
113
--- a/tests/qemu-iotests/258
114
+++ b/tests/qemu-iotests/258
115
@@ -XXX,XX +XXX,XX @@
116
# Creator/Owner: Hanna Reitz <hreitz@redhat.com>
117
118
import iotests
119
-from iotests import log, qemu_img, qemu_io_silent, \
120
+from iotests import log, qemu_img, qemu_io, \
121
filter_qmp_testfiles, filter_qmp_imgfmt
122
123
# Returns a node for blockdev-add
124
@@ -XXX,XX +XXX,XX @@ def test_concurrent_finish(write_to_stream_node):
125
if write_to_stream_node:
126
# This is what (most of the time) makes commit finish
127
# earlier and then pull in stream
128
- assert qemu_io_silent(node2_path,
129
- '-c', 'write %iK 64K' % (65536 - 192),
130
- '-c', 'write %iK 64K' % (65536 - 64)) == 0
131
+ qemu_io(node2_path,
132
+ '-c', 'write %iK 64K' % (65536 - 192),
133
+ '-c', 'write %iK 64K' % (65536 - 64))
134
135
stream_throttle='tg'
136
else:
137
# And this makes stream finish earlier
138
- assert qemu_io_silent(node1_path,
139
- '-c', 'write %iK 64K' % (65536 - 64)) == 0
140
+ qemu_io(node1_path, '-c', 'write %iK 64K' % (65536 - 64))
141
142
commit_throttle='tg'
143
144
diff --git a/tests/qemu-iotests/298 b/tests/qemu-iotests/298
145
index XXXXXXX..XXXXXXX 100755
146
--- a/tests/qemu-iotests/298
147
+++ b/tests/qemu-iotests/298
148
@@ -XXX,XX +XXX,XX @@ class TestTruncate(iotests.QMPTestCase):
149
os.remove(refdisk)
150
151
def do_test(self, prealloc_mode, new_size):
152
- ret = iotests.qemu_io_silent('--image-opts', '-c', 'write 0 10M', '-c',
153
- f'truncate -m {prealloc_mode} {new_size}',
154
- drive_opts)
155
- self.assertEqual(ret, 0)
156
-
157
- ret = iotests.qemu_io_silent('-f', iotests.imgfmt, '-c', 'write 0 10M',
158
- '-c',
159
- f'truncate -m {prealloc_mode} {new_size}',
160
- refdisk)
161
- self.assertEqual(ret, 0)
162
+ iotests.qemu_io('--image-opts', '-c', 'write 0 10M', '-c',
163
+ f'truncate -m {prealloc_mode} {new_size}',
164
+ drive_opts)
165
+
166
+ iotests.qemu_io('-f', iotests.imgfmt, '-c', 'write 0 10M',
167
+ '-c', f'truncate -m {prealloc_mode} {new_size}',
168
+ refdisk)
169
170
stat = os.stat(disk)
171
refstat = os.stat(refdisk)
172
diff --git a/tests/qemu-iotests/310 b/tests/qemu-iotests/310
173
index XXXXXXX..XXXXXXX 100755
174
--- a/tests/qemu-iotests/310
175
+++ b/tests/qemu-iotests/310
176
@@ -XXX,XX +XXX,XX @@
177
#
178
179
import iotests
180
-from iotests import log, qemu_img, qemu_io_silent
181
+from iotests import log, qemu_img, qemu_io
182
183
# Need backing file support
184
iotests.script_initialize(supported_fmts=['qcow2'],
185
@@ -XXX,XX +XXX,XX @@ with iotests.FilePath('base.img') as base_img_path, \
186
log('')
187
188
qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M')
189
- assert qemu_io_silent(base_img_path, '-c', 'write -P 1 0M 1M') == 0
190
- assert qemu_io_silent(base_img_path, '-c', 'write -P 1 3M 1M') == 0
191
+ qemu_io(base_img_path, '-c', 'write -P 1 0M 1M')
192
+ qemu_io(base_img_path, '-c', 'write -P 1 3M 1M')
193
qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path,
194
'-F', iotests.imgfmt, mid_img_path)
195
- assert qemu_io_silent(mid_img_path, '-c', 'write -P 3 2M 1M') == 0
196
- assert qemu_io_silent(mid_img_path, '-c', 'write -P 3 4M 1M') == 0
197
+ qemu_io(mid_img_path, '-c', 'write -P 3 2M 1M')
198
+ qemu_io(mid_img_path, '-c', 'write -P 3 4M 1M')
199
qemu_img('create', '-f', iotests.imgfmt, '-b', mid_img_path,
200
'-F', iotests.imgfmt, top_img_path)
201
- assert qemu_io_silent(top_img_path, '-c', 'write -P 2 1M 1M') == 0
202
+ qemu_io(top_img_path, '-c', 'write -P 2 1M 1M')
203
204
# 0 1 2 3 4
205
# top 2
206
@@ -XXX,XX +XXX,XX @@ with iotests.FilePath('base.img') as base_img_path, \
207
# Detach backing to check that we can read the data from the top level now
208
qemu_img('rebase', '-u', '-b', '', '-f', iotests.imgfmt, top_img_path)
209
210
- assert qemu_io_silent(top_img_path, '-c', 'read -P 0 0 1M') == 0
211
- assert qemu_io_silent(top_img_path, '-c', 'read -P 2 1M 1M') == 0
212
- assert qemu_io_silent(top_img_path, '-c', 'read -P 3 2M 1M') == 0
213
- assert qemu_io_silent(top_img_path, '-c', 'read -P 0 3M 1M') == 0
214
- assert qemu_io_silent(top_img_path, '-c', 'read -P 3 4M 1M') == 0
215
+ qemu_io(top_img_path, '-c', 'read -P 0 0 1M')
216
+ qemu_io(top_img_path, '-c', 'read -P 2 1M 1M')
217
+ qemu_io(top_img_path, '-c', 'read -P 3 2M 1M')
218
+ qemu_io(top_img_path, '-c', 'read -P 0 3M 1M')
219
+ qemu_io(top_img_path, '-c', 'read -P 3 4M 1M')
220
221
log('Done')
222
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
76
index XXXXXXX..XXXXXXX 100644
223
index XXXXXXX..XXXXXXX 100644
77
--- a/block/file-posix.c
224
--- a/tests/qemu-iotests/iotests.py
78
+++ b/block/file-posix.c
225
+++ b/tests/qemu-iotests/iotests.py
79
@@ -XXX,XX +XXX,XX @@ static int handle_aiocb_discard(void *opaque)
226
@@ -XXX,XX +XXX,XX @@ def qemu_io_log(*args: str) -> 'subprocess.CompletedProcess[str]':
80
return ret;
227
log(result.stdout, filters=[filter_testfiles, filter_qemu_io])
81
}
228
return result
82
229
83
+/*
230
-def qemu_io_silent(*args):
84
+ * Help alignment probing by allocating the first block.
231
- '''Run qemu-io and return the exit code, suppressing stdout'''
85
+ *
232
- args = qemu_io_wrap_args(args)
86
+ * When reading with direct I/O from unallocated area on Gluster backed by XFS,
233
- result = subprocess.run(args, stdout=subprocess.DEVNULL, check=False)
87
+ * reading succeeds regardless of request length. In this case we fallback to
234
- if result.returncode < 0:
88
+ * safe alignment which is not optimal. Allocating the first block avoids this
235
- sys.stderr.write('qemu-io received signal %i: %s\n' %
89
+ * fallback.
236
- (-result.returncode, ' '.join(args)))
90
+ *
237
- return result.returncode
91
+ * fd may be opened with O_DIRECT, but we don't know the buffer alignment or
238
-
92
+ * request alignment, so we use safe values.
239
-def qemu_io_silent_check(*args):
93
+ *
240
- '''Run qemu-io and return the true if subprocess returned 0'''
94
+ * Returns: 0 on success, -errno on failure. Since this is an optimization,
241
- args = qemu_io_wrap_args(args)
95
+ * caller may ignore failures.
242
- result = subprocess.run(args, stdout=subprocess.DEVNULL,
96
+ */
243
- stderr=subprocess.STDOUT, check=False)
97
+static int allocate_first_block(int fd, size_t max_size)
244
- return result.returncode == 0
98
+{
245
-
99
+ size_t write_size = (max_size < MAX_BLOCKSIZE)
246
class QemuIoInteractive:
100
+ ? BDRV_SECTOR_SIZE
247
def __init__(self, *args):
101
+ : MAX_BLOCKSIZE;
248
self.args = qemu_io_wrap_args(args)
102
+ size_t max_align = MAX(MAX_BLOCKSIZE, getpagesize());
249
diff --git a/tests/qemu-iotests/tests/image-fleecing b/tests/qemu-iotests/tests/image-fleecing
103
+ void *buf;
250
index XXXXXXX..XXXXXXX 100755
104
+ ssize_t n;
251
--- a/tests/qemu-iotests/tests/image-fleecing
105
+ int ret;
252
+++ b/tests/qemu-iotests/tests/image-fleecing
106
+
253
@@ -XXX,XX +XXX,XX @@
107
+ buf = qemu_memalign(max_align, write_size);
254
from subprocess import CalledProcessError
108
+ memset(buf, 0, write_size);
255
109
+
256
import iotests
110
+ do {
257
-from iotests import log, qemu_img, qemu_io, qemu_io_silent
111
+ n = pwrite(fd, buf, write_size, 0);
258
+from iotests import log, qemu_img, qemu_io
112
+ } while (n == -1 && errno == EINTR);
259
113
+
260
iotests.script_initialize(
114
+ ret = (n == -1) ? -errno : 0;
261
supported_fmts=['qcow2'],
115
+
262
@@ -XXX,XX +XXX,XX @@ def do_test(vm, use_cbw, use_snapshot_access_filter, base_img_path,
116
+ qemu_vfree(buf);
263
for p in overwrite + remainder:
117
+ return ret;
264
cmd = 'read -P%s %s %s' % p
118
+}
265
log(cmd)
119
+
266
- assert qemu_io_silent(base_img_path, '-c', cmd) == 0
120
static int handle_aiocb_truncate(void *opaque)
267
+ qemu_io(base_img_path, '-c', cmd)
121
{
268
122
RawPosixAIOData *aiocb = opaque;
269
log('')
123
@@ -XXX,XX +XXX,XX @@ static int handle_aiocb_truncate(void *opaque)
270
log('Done')
124
/* posix_fallocate() doesn't set errno. */
271
diff --git a/tests/qemu-iotests/tests/mirror-ready-cancel-error b/tests/qemu-iotests/tests/mirror-ready-cancel-error
125
error_setg_errno(errp, -result,
272
index XXXXXXX..XXXXXXX 100755
126
"Could not preallocate new data");
273
--- a/tests/qemu-iotests/tests/mirror-ready-cancel-error
127
+ } else if (current_length == 0) {
274
+++ b/tests/qemu-iotests/tests/mirror-ready-cancel-error
128
+ /*
275
@@ -XXX,XX +XXX,XX @@ class TestMirrorReadyCancelError(iotests.QMPTestCase):
129
+ * posix_fallocate() uses fallocate() if the filesystem
276
# Ensure that mirror will copy something before READY so the
130
+ * supports it, or fallback to manually writing zeroes. If
277
# target format layer will forward the pre-READY flush to its
131
+ * fallocate() was used, unaligned reads from the fallocated
278
# file child
132
+ * area in raw_probe_alignment() will succeed, hence we need to
279
- assert iotests.qemu_io_silent('-c', 'write -P 1 0 64k', source) == 0
133
+ * allocate the first block.
280
+ iotests.qemu_io('-c', 'write -P 1 0 64k', source)
134
+ *
281
135
+ * Optimize future alignment probing; ignore failures.
282
self.vm = iotests.VM()
136
+ */
283
self.vm.launch()
137
+ allocate_first_block(fd, offset);
284
diff --git a/tests/qemu-iotests/tests/stream-error-on-reset b/tests/qemu-iotests/tests/stream-error-on-reset
138
}
285
index XXXXXXX..XXXXXXX 100755
139
} else {
286
--- a/tests/qemu-iotests/tests/stream-error-on-reset
140
result = 0;
287
+++ b/tests/qemu-iotests/tests/stream-error-on-reset
141
@@ -XXX,XX +XXX,XX @@ static int handle_aiocb_truncate(void *opaque)
288
@@ -XXX,XX +XXX,XX @@
142
if (ftruncate(fd, offset) != 0) {
289
143
result = -errno;
290
import os
144
error_setg_errno(errp, -result, "Could not resize file");
291
import iotests
145
+ } else if (current_length == 0 && offset > current_length) {
292
-from iotests import imgfmt, qemu_img_create, qemu_io_silent, QMPTestCase
146
+ /* Optimize future alignment probing; ignore failures. */
293
+from iotests import imgfmt, qemu_img_create, qemu_io, QMPTestCase
147
+ allocate_first_block(fd, offset);
294
148
}
295
149
return result;
296
image_size = 1 * 1024 * 1024
150
default:
297
@@ -XXX,XX +XXX,XX @@ class TestStreamErrorOnReset(QMPTestCase):
151
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
298
- top image is attached to a virtio-scsi device
152
index XXXXXXX..XXXXXXX 100644
299
"""
153
--- a/tests/qemu-iotests/059.out
300
qemu_img_create('-f', imgfmt, base, str(image_size))
154
+++ b/tests/qemu-iotests/059.out
301
- assert qemu_io_silent('-c', f'write 0 {data_size}', base) == 0
155
@@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000 subformat=twoGbMax
302
+ qemu_io('-c', f'write 0 {data_size}', base)
156
image: TEST_DIR/t.vmdk
303
qemu_img_create('-f', imgfmt, top, str(image_size))
157
file format: vmdk
304
158
virtual size: 0.977 TiB (1073741824000 bytes)
305
self.vm = iotests.VM()
159
-disk size: 16 KiB
160
+disk size: 1.97 MiB
161
Format specific information:
162
cid: XXXXXXXX
163
parent cid: XXXXXXXX
164
diff --git a/tests/qemu-iotests/150.out b/tests/qemu-iotests/150.out.qcow2
165
similarity index 100%
166
rename from tests/qemu-iotests/150.out
167
rename to tests/qemu-iotests/150.out.qcow2
168
diff --git a/tests/qemu-iotests/150.out.raw b/tests/qemu-iotests/150.out.raw
169
new file mode 100644
170
index XXXXXXX..XXXXXXX
171
--- /dev/null
172
+++ b/tests/qemu-iotests/150.out.raw
173
@@ -XXX,XX +XXX,XX @@
174
+QA output created by 150
175
+
176
+=== Mapping sparse conversion ===
177
+
178
+Offset Length File
179
+0 0x1000 TEST_DIR/t.IMGFMT
180
+
181
+=== Mapping non-sparse conversion ===
182
+
183
+Offset Length File
184
+0 0x100000 TEST_DIR/t.IMGFMT
185
+*** done
186
diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175
187
index XXXXXXX..XXXXXXX 100755
188
--- a/tests/qemu-iotests/175
189
+++ b/tests/qemu-iotests/175
190
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
191
# the file size. This function hides the resulting difference in the
192
# stat -c '%b' output.
193
# Parameter 1: Number of blocks an empty file occupies
194
-# Parameter 2: Image size in bytes
195
+# Parameter 2: Minimal number of blocks in an image
196
+# Parameter 3: Image size in bytes
197
_filter_blocks()
198
{
199
extra_blocks=$1
200
- img_size=$2
201
+ min_blocks=$2
202
+ img_size=$3
203
204
- sed -e "s/blocks=$extra_blocks\\(\$\\|[^0-9]\\)/nothing allocated/" \
205
- -e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/everything allocated/"
206
+ sed -e "s/blocks=$min_blocks\\(\$\\|[^0-9]\\)/min allocation/" \
207
+ -e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/max allocation/"
208
}
209
210
# get standard environment, filters and checks
211
@@ -XXX,XX +XXX,XX @@ size=$((1 * 1024 * 1024))
212
touch "$TEST_DIR/empty"
213
extra_blocks=$(stat -c '%b' "$TEST_DIR/empty")
214
215
+# We always write the first byte; check how many blocks this filesystem
216
+# allocates to match empty image alloation.
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}]
309
*** done
310
diff --git a/tests/qemu-iotests/253.out b/tests/qemu-iotests/253.out
311
index XXXXXXX..XXXXXXX 100644
312
--- a/tests/qemu-iotests/253.out
313
+++ b/tests/qemu-iotests/253.out
314
@@ -XXX,XX +XXX,XX @@ QA output created by 253
315
=== Check mapping of unaligned raw image ===
316
317
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048575
318
-[{ "start": 0, "length": 1048576, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
319
-[{ "start": 0, "length": 1048576, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
320
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
321
+{ "start": 4096, "length": 1044480, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
322
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
323
+{ "start": 4096, "length": 1044480, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
324
wrote 65535/65535 bytes at offset 983040
325
63.999 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
326
-[{ "start": 0, "length": 983040, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
327
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
328
+{ "start": 4096, "length": 978944, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
329
{ "start": 983040, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": OFFSET}]
330
-[{ "start": 0, "length": 983040, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
331
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
332
+{ "start": 4096, "length": 978944, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
333
{ "start": 983040, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": OFFSET}]
334
*** done
335
--
306
--
336
2.21.0
307
2.35.1
337
338
diff view generated by jsdifflib
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
From: John Snow <jsnow@redhat.com>
2
2
3
It's wrong to OR shared permissions. It may lead to crash on further
3
Just like qemu_img_log(), upgrade qemu_io_log() to enforce a return code
4
permission updates.
4
of zero by default.
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.
9
5
10
Bug was introduced in long ago 234ac1a9025, in 2.9.
6
Tests that use qemu_io_log(): 242 245 255 274 303 307 nbd-reconnect-on-open
11
7
12
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
8
Signed-off-by: John Snow <jsnow@redhat.com>
13
Message-id: 20190824100740.61635-1-vsementsov@virtuozzo.com
9
Reviewed-by: Eric Blake <eblake@redhat.com>
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
11
Message-Id: <20220418211504.943969-13-jsnow@redhat.com>
12
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
15
---
13
---
16
block.c | 5 ++---
14
tests/qemu-iotests/iotests.py | 5 +++--
17
1 file changed, 2 insertions(+), 3 deletions(-)
15
tests/qemu-iotests/tests/nbd-reconnect-on-open | 2 +-
16
2 files changed, 4 insertions(+), 3 deletions(-)
18
17
19
diff --git a/block.c b/block.c
18
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
20
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
21
--- a/block.c
20
--- a/tests/qemu-iotests/iotests.py
22
+++ b/block.c
21
+++ b/tests/qemu-iotests/iotests.py
23
@@ -XXX,XX +XXX,XX @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
22
@@ -XXX,XX +XXX,XX @@ def qemu_io(*args: str, check: bool = True, combine_stdio: bool = True
24
{
23
return qemu_tool(*qemu_io_wrap_args(args),
25
BdrvChild *c, *next;
24
check=check, combine_stdio=combine_stdio)
26
GSList *list = NULL, *p;
25
27
- uint64_t old_perm, old_shared;
26
-def qemu_io_log(*args: str) -> 'subprocess.CompletedProcess[str]':
28
uint64_t perm = 0, shared = BLK_PERM_ALL;
27
- result = qemu_io(*args, check=False)
29
int ret;
28
+def qemu_io_log(*args: str, check: bool = True
30
29
+ ) -> 'subprocess.CompletedProcess[str]':
31
@@ -XXX,XX +XXX,XX @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
30
+ result = qemu_io(*args, check=check)
32
bdrv_unref(from);
31
log(result.stdout, filters=[filter_testfiles, filter_qemu_io])
33
}
32
return result
34
33
35
- bdrv_get_cumulative_perm(to, &old_perm, &old_shared);
34
diff --git a/tests/qemu-iotests/tests/nbd-reconnect-on-open b/tests/qemu-iotests/tests/nbd-reconnect-on-open
36
- bdrv_set_perm(to, old_perm | perm, old_shared | shared);
35
index XXXXXXX..XXXXXXX 100755
37
+ bdrv_get_cumulative_perm(to, &perm, &shared);
36
--- a/tests/qemu-iotests/tests/nbd-reconnect-on-open
38
+ bdrv_set_perm(to, perm, shared);
37
+++ b/tests/qemu-iotests/tests/nbd-reconnect-on-open
39
38
@@ -XXX,XX +XXX,XX @@ def check_fail_to_connect(open_timeout):
40
out:
39
log(f'Check fail to connect with {open_timeout} seconds of timeout')
41
g_slist_free(list);
40
41
start_t = time.time()
42
- qemu_io_log(*create_args(open_timeout))
43
+ qemu_io_log(*create_args(open_timeout), check=False)
44
delta_t = time.time() - start_t
45
46
max_delta = open_timeout + 0.2
42
--
47
--
43
2.21.0
48
2.35.1
44
45
diff view generated by jsdifflib
1
From: Stefan Hajnoczi <stefanha@redhat.com>
1
FUSE exports' allow-other option defaults to "auto", which means that it
2
will try passing allow_other as a mount option, and fall back to not
3
using it when an error occurs. We make no effort to hide fusermount's
4
error message (because it would be difficult, and because users might
5
want to know about the fallback occurring), and so when allow_other does
6
not work (primarily when /etc/fuse.conf does not contain
7
user_allow_other), this error message will appear and break the
8
reference output.
2
9
3
Fixes: a6b257a08e3d72219f03e461a52152672fec0612
10
We do not need allow_other here, though, so we can just pass
4
("file-posix: Handle undetectable alignment")
11
allow-other=off to fix that.
5
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12
6
Message-id: 20190827101328.4062-1-stefanha@redhat.com
13
Reported-by: Markus Armbruster <armbru@redhat.com>
7
Reviewed-by: Thomas Huth <thuth@redhat.com>
14
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
Message-Id: <20220421142435.569600-1-hreitz@redhat.com>
16
Tested-by: Markus Armbruster <armbru@redhat.com>
17
Tested-by: Eric Blake <eblake@redhat.com>
9
---
18
---
10
block/file-posix.c | 2 +-
19
tests/qemu-iotests/108 | 2 +-
11
1 file changed, 1 insertion(+), 1 deletion(-)
20
1 file changed, 1 insertion(+), 1 deletion(-)
12
21
13
diff --git a/block/file-posix.c b/block/file-posix.c
22
diff --git a/tests/qemu-iotests/108 b/tests/qemu-iotests/108
14
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100755
15
--- a/block/file-posix.c
24
--- a/tests/qemu-iotests/108
16
+++ b/block/file-posix.c
25
+++ b/tests/qemu-iotests/108
17
@@ -XXX,XX +XXX,XX @@ static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp)
26
@@ -XXX,XX +XXX,XX @@ else
18
for (i = 0; i < ARRAY_SIZE(alignments); i++) {
27
19
align = alignments[i];
28
$QSD \
20
if (raw_is_io_aligned(fd, buf + align, max_align)) {
29
--blockdev file,node-name=export-node,filename="$TEST_IMG" \
21
- /* Fallback to request_aligment. */
30
- --export fuse,id=fuse-export,node-name=export-node,mountpoint="$export_mp",writable=on,growable=off \
22
+ /* Fallback to request_alignment. */
31
+ --export fuse,id=fuse-export,node-name=export-node,mountpoint="$export_mp",writable=on,growable=off,allow-other=off \
23
s->buf_align = (align != 1) ? align : bs->bl.request_alignment;
32
--pidfile "$TEST_DIR/qsd.pid" \
24
break;
33
--daemonize
25
}
34
fi
26
--
35
--
27
2.21.0
36
2.35.1
28
29
diff view generated by jsdifflib