1
Merge remote-tracking branch 'remotes/edgar/tags/edgar/xilinx-next-2018-05-29-v1.for-upstream' into staging (2018-05-29 13:01:11 +0100)
1
The following changes since commit b2f7a038bb4c4fc5ce6b8486e8513dfd97665e2a:
2
2
3
are available in the git repository at:
3
Merge remote-tracking branch 'remotes/rth/tags/pull-softfloat-20181104' into staging (2018-11-05 10:32:49 +0000)
4
5
are available in the Git repository at:
4
6
5
git://repo.or.cz/qemu/kevin.git tags/for-upstream
7
git://repo.or.cz/qemu/kevin.git tags/for-upstream
6
8
7
for you to fetch changes up to 3fb588a0f2c006122c34e1960a15c87ae2b927eb:
9
for you to fetch changes up to 1240ac558d348f6c7a5752b1a57c1da58e4efe3e:
8
10
9
block/create: Mark blockdev-create stable (2018-05-30 13:31:18 +0200)
11
include: Add a comment to explain the origin of sizes' lookup table (2018-11-05 15:29:59 +0100)
10
12
11
----------------------------------------------------------------
13
----------------------------------------------------------------
12
Block layer patches:
14
Block layer patches:
13
15
14
- Add blockdev-create job
16
- auto-read-only option to fix commit job when used with -blockdev
15
- qcow2: Silence Coverity false positive
17
- Fix help text related qemu-iotests failure (by improving the help text
18
and updating the reference output)
19
- quorum: Add missing checks when adding/removing child nodes
20
- Don't take address of fields in packed structs
21
- vvfat: Fix crash when reporting error about too many files in directory
16
22
17
----------------------------------------------------------------
23
----------------------------------------------------------------
18
Alberto Garcia (1):
24
Alberto Garcia (7):
19
qcow2: Fix Coverity warning when calculating the refcount cache size
25
block: replace "discard" literal with BDRV_OPT_DISCARD macro
26
qcow2: Get the request alignment for encrypted images from QCryptoBlock
27
quorum: Remove quorum_err()
28
quorum: Return an error if the blkverify mode has invalid settings
29
iotest: Test the blkverify mode of the Quorum driver
30
quorum: Forbid adding children in blkverify mode
31
iotest: Test x-blockdev-change on a Quorum
20
32
21
Kevin Wolf (16):
33
Cleber Rosa (1):
22
vdi: Fix vdi_co_do_create() return value
34
iotests: make 083 specific to raw
23
vhdx: Fix vhdx_co_create() return value
24
job: Add error message for failing jobs
25
block/create: Make x-blockdev-create a job
26
qemu-iotests: Add VM.get_qmp_events_filtered()
27
qemu-iotests: Add VM.qmp_log()
28
qemu-iotests: Add iotests.img_info_log()
29
qemu-iotests: Add VM.run_job()
30
qemu-iotests: iotests.py helper for non-file protocols
31
qemu-iotests: Rewrite 206 for blockdev-create job
32
qemu-iotests: Rewrite 207 for blockdev-create job
33
qemu-iotests: Rewrite 210 for blockdev-create job
34
qemu-iotests: Rewrite 211 for blockdev-create job
35
qemu-iotests: Rewrite 212 for blockdev-create job
36
qemu-iotests: Rewrite 213 for blockdev-create job
37
block/create: Mark blockdev-create stable
38
35
39
qapi/block-core.json | 18 +-
36
Daniel P. Berrangé (1):
40
qapi/job.json | 4 +-
37
crypto: initialize sector size even when opening with no IO flag
41
include/qemu/job.h | 7 +-
42
block/backup.c | 2 +-
43
block/commit.c | 2 +-
44
block/create.c | 67 +++--
45
block/mirror.c | 2 +-
46
block/qcow2.c | 5 +-
47
block/stream.c | 2 +-
48
block/vdi.c | 1 +
49
block/vhdx.c | 2 +-
50
job-qmp.c | 9 +-
51
job.c | 16 +-
52
tests/test-bdrv-drain.c | 2 +-
53
tests/test-blockjob-txn.c | 2 +-
54
tests/test-blockjob.c | 2 +-
55
tests/qemu-iotests/206 | 680 ++++++++++++++++--------------------------
56
tests/qemu-iotests/206.out | 253 +++++++++-------
57
tests/qemu-iotests/207 | 440 ++++++++++++---------------
58
tests/qemu-iotests/207.out | 107 +++----
59
tests/qemu-iotests/210 | 393 ++++++++++--------------
60
tests/qemu-iotests/210.out | 197 ++++++++----
61
tests/qemu-iotests/211 | 381 ++++++++++-------------
62
tests/qemu-iotests/211.out | 133 +++++----
63
tests/qemu-iotests/212 | 483 +++++++++++-------------------
64
tests/qemu-iotests/212.out | 191 +++++++-----
65
tests/qemu-iotests/213 | 520 ++++++++++++--------------------
66
tests/qemu-iotests/213.out | 208 ++++++++-----
67
tests/qemu-iotests/iotests.py | 78 +++++
68
29 files changed, 1981 insertions(+), 2226 deletions(-)
69
38
39
Kevin Wolf (12):
40
vpc: Don't leak opts in vpc_open()
41
block: Update flags in bdrv_set_read_only()
42
block: Add auto-read-only option
43
rbd: Close image in qemu_rbd_open() error path
44
block: Require auto-read-only for existing fallbacks
45
nbd: Support auto-read-only option
46
file-posix: Support auto-read-only option
47
curl: Support auto-read-only option
48
gluster: Support auto-read-only option
49
iscsi: Support auto-read-only option
50
block: Make auto-read-only=on default for -drive
51
qemu-iotests: Test auto-read-only with -drive and -blockdev
52
53
Leonid Bloch (2):
54
vdi: Use a literal number of bytes for DEFAULT_CLUSTER_SIZE
55
include: Add a comment to explain the origin of sizes' lookup table
56
57
Li Qiang (1):
58
block: change some function return type to bool
59
60
Max Reitz (5):
61
option: Make option help nicer to read
62
chardev: Indent list of chardevs
63
qdev-monitor: Make device options help nicer
64
object: Make option help nicer to read
65
fw_cfg: Drop newline in @file description
66
67
Peter Maydell (5):
68
block/qcow2: Don't take address of fields in packed structs
69
block/qcow: Don't take address of fields in packed structs
70
block/qcow2-bitmap: Don't take address of fields in packed structs
71
block/vhdx: Don't take address of fields in packed structs
72
block/vdi: Don't take address of fields in packed structs
73
74
Stefan Weil (1):
75
qemu-io-cmds: Fix two format strings
76
77
Thomas Huth (1):
78
block/vvfat: Fix crash when reporting error about too many files in directory
79
80
qapi/block-core.json | 7 +
81
block/vhdx.h | 12 +-
82
include/block/block.h | 5 +-
83
include/qemu/option.h | 2 +-
84
include/qemu/units.h | 18 +
85
include/sysemu/block-backend.h | 6 +-
86
block.c | 60 ++-
87
block/block-backend.c | 8 +-
88
block/bochs.c | 17 +-
89
block/cloop.c | 16 +-
90
block/curl.c | 8 +-
91
block/dmg.c | 16 +-
92
block/file-posix.c | 19 +-
93
block/gluster.c | 12 +-
94
block/iscsi.c | 8 +-
95
block/nbd-client.c | 10 +-
96
block/qcow.c | 18 +-
97
block/qcow2-bitmap.c | 24 +-
98
block/qcow2.c | 66 +--
99
block/quorum.c | 45 +-
100
block/rbd.c | 14 +-
101
block/vdi.c | 68 +--
102
block/vhdx-endian.c | 118 ++---
103
block/vhdx-log.c | 4 +-
104
block/vhdx.c | 18 +-
105
block/vpc.c | 2 +
106
block/vvfat.c | 15 +-
107
blockdev.c | 3 +-
108
chardev/char.c | 2 +-
109
crypto/block-qcow.c | 2 +
110
qdev-monitor.c | 13 +-
111
qemu-img.c | 4 +-
112
qemu-io-cmds.c | 4 +-
113
util/qemu-option.c | 32 +-
114
vl.c | 15 +-
115
tests/qemu-iotests/081 | 116 +++++
116
tests/qemu-iotests/081.out | 70 +++
117
tests/qemu-iotests/082.out | 956 ++++++++++++++++++++---------------------
118
tests/qemu-iotests/083 | 2 +-
119
tests/qemu-iotests/232 | 147 +++++++
120
tests/qemu-iotests/232.out | 59 +++
121
tests/qemu-iotests/group | 1 +
122
42 files changed, 1266 insertions(+), 776 deletions(-)
123
create mode 100755 tests/qemu-iotests/232
124
create mode 100644 tests/qemu-iotests/232.out
125
diff view generated by jsdifflib
New patch
1
From: Thomas Huth <thuth@redhat.com>
1
2
3
When using the vvfat driver with a directory that contains too many files,
4
QEMU currently crashes. This can be triggered like this for example:
5
6
mkdir /tmp/vvfattest
7
cd /tmp/vvfattest
8
for ((x=0;x<=513;x++)); do mkdir $x; done
9
qemu-system-x86_64 -drive \
10
file.driver=vvfat,file.dir=.,read-only=on,media=cdrom
11
12
Seems like read_directory() is changing the mapping->path variable. Make
13
sure we use the right pointer instead.
14
15
Signed-off-by: Thomas Huth <thuth@redhat.com>
16
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
17
---
18
block/vvfat.c | 4 ++--
19
1 file changed, 2 insertions(+), 2 deletions(-)
20
21
diff --git a/block/vvfat.c b/block/vvfat.c
22
index XXXXXXX..XXXXXXX 100644
23
--- a/block/vvfat.c
24
+++ b/block/vvfat.c
25
@@ -XXX,XX +XXX,XX @@ static int init_directories(BDRVVVFATState* s,
26
mapping = array_get(&(s->mapping), i);
27
28
if (mapping->mode & MODE_DIRECTORY) {
29
+ char *path = mapping->path;
30
mapping->begin = cluster;
31
if(read_directory(s, i)) {
32
- error_setg(errp, "Could not read directory %s",
33
- mapping->path);
34
+ error_setg(errp, "Could not read directory %s", path);
35
return -1;
36
}
37
mapping = array_get(&(s->mapping), i);
38
--
39
2.19.1
40
41
diff view generated by jsdifflib
New patch
1
From: Alberto Garcia <berto@igalia.com>
1
2
3
Signed-off-by: Alberto Garcia <berto@igalia.com>
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
5
---
6
block.c | 6 +++---
7
1 file changed, 3 insertions(+), 3 deletions(-)
8
9
diff --git a/block.c b/block.c
10
index XXXXXXX..XXXXXXX 100644
11
--- a/block.c
12
+++ b/block.c
13
@@ -XXX,XX +XXX,XX @@ QemuOptsList bdrv_runtime_opts = {
14
.help = "try to optimize zero writes (off, on, unmap)",
15
},
16
{
17
- .name = "discard",
18
+ .name = BDRV_OPT_DISCARD,
19
.type = QEMU_OPT_STRING,
20
.help = "discard operation (ignore/off, unmap/on)",
21
},
22
@@ -XXX,XX +XXX,XX @@ static int bdrv_open_common(BlockDriverState *bs, BlockBackend *file,
23
}
24
}
25
26
- discard = qemu_opt_get(opts, "discard");
27
+ discard = qemu_opt_get(opts, BDRV_OPT_DISCARD);
28
if (discard != NULL) {
29
if (bdrv_parse_discard_flags(discard, &bs->open_flags) != 0) {
30
error_setg(errp, "Invalid discard option");
31
@@ -XXX,XX +XXX,XX @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
32
33
update_flags_from_options(&reopen_state->flags, opts);
34
35
- discard = qemu_opt_get_del(opts, "discard");
36
+ discard = qemu_opt_get_del(opts, BDRV_OPT_DISCARD);
37
if (discard != NULL) {
38
if (bdrv_parse_discard_flags(discard, &reopen_state->flags) != 0) {
39
error_setg(errp, "Invalid discard option");
40
--
41
2.19.1
42
43
diff view generated by jsdifflib
New patch
1
From: Stefan Weil <sw@weilnetz.de>
1
2
3
Use %zu instead of %zd for unsigned numbers.
4
5
This fixes two error messages from the LSTM static code analyzer:
6
7
This argument should be of type 'ssize_t' but is of type 'unsigned long'
8
9
Signed-off-by: Stefan Weil <sw@weilnetz.de>
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12
---
13
qemu-io-cmds.c | 4 ++--
14
1 file changed, 2 insertions(+), 2 deletions(-)
15
16
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/qemu-io-cmds.c
19
+++ b/qemu-io-cmds.c
20
@@ -XXX,XX +XXX,XX @@ static int readv_f(BlockBackend *blk, int argc, char **argv)
21
memset(cmp_buf, pattern, qiov.size);
22
if (memcmp(buf, cmp_buf, qiov.size)) {
23
printf("Pattern verification failed at offset %"
24
- PRId64 ", %zd bytes\n", offset, qiov.size);
25
+ PRId64 ", %zu bytes\n", offset, qiov.size);
26
ret = -EINVAL;
27
}
28
g_free(cmp_buf);
29
@@ -XXX,XX +XXX,XX @@ static void aio_read_done(void *opaque, int ret)
30
memset(cmp_buf, ctx->pattern, ctx->qiov.size);
31
if (memcmp(ctx->buf, cmp_buf, ctx->qiov.size)) {
32
printf("Pattern verification failed at offset %"
33
- PRId64 ", %zd bytes\n", ctx->offset, ctx->qiov.size);
34
+ PRId64 ", %zu bytes\n", ctx->offset, ctx->qiov.size);
35
}
36
g_free(cmp_buf);
37
}
38
--
39
2.19.1
40
41
diff view generated by jsdifflib
New patch
1
From: Peter Maydell <peter.maydell@linaro.org>
1
2
3
Taking the address of a field in a packed struct is a bad idea, because
4
it might not be actually aligned enough for that pointer type (and
5
thus cause a crash on dereference on some host architectures). Newer
6
versions of clang warn about this. Avoid the bug by not using the
7
"modify in place" byte swapping functions.
8
9
There are a few places where the in-place swap function is
10
used on something other than a packed struct field; we convert
11
those anyway, for consistency.
12
13
This patch was produced with the following spatch script
14
(and hand-editing to fold a few resulting overlength lines):
15
16
@@
17
expression E;
18
@@
19
-be16_to_cpus(&E);
20
+E = be16_to_cpu(E);
21
@@
22
expression E;
23
@@
24
-be32_to_cpus(&E);
25
+E = be32_to_cpu(E);
26
@@
27
expression E;
28
@@
29
-be64_to_cpus(&E);
30
+E = be64_to_cpu(E);
31
@@
32
expression E;
33
@@
34
-cpu_to_be16s(&E);
35
+E = cpu_to_be16(E);
36
@@
37
expression E;
38
@@
39
-cpu_to_be32s(&E);
40
+E = cpu_to_be32(E);
41
@@
42
expression E;
43
@@
44
-cpu_to_be64s(&E);
45
+E = cpu_to_be64(E);
46
47
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
48
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
49
Tested-by: John Snow <jsnow@redhat.com>
50
Reviewed-by: John Snow <jsnow@redhat.com>
51
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
52
---
53
block/qcow2.c | 64 +++++++++++++++++++++++++++------------------------
54
1 file changed, 34 insertions(+), 30 deletions(-)
55
56
diff --git a/block/qcow2.c b/block/qcow2.c
57
index XXXXXXX..XXXXXXX 100644
58
--- a/block/qcow2.c
59
+++ b/block/qcow2.c
60
@@ -XXX,XX +XXX,XX @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset,
61
"pread fail from offset %" PRIu64, offset);
62
return 1;
63
}
64
- be32_to_cpus(&ext.magic);
65
- be32_to_cpus(&ext.len);
66
+ ext.magic = be32_to_cpu(ext.magic);
67
+ ext.len = be32_to_cpu(ext.len);
68
offset += sizeof(ext);
69
#ifdef DEBUG_EXT
70
printf("ext.magic = 0x%x\n", ext.magic);
71
@@ -XXX,XX +XXX,XX @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset,
72
"Unable to read CRYPTO header extension");
73
return ret;
74
}
75
- be64_to_cpus(&s->crypto_header.offset);
76
- be64_to_cpus(&s->crypto_header.length);
77
+ s->crypto_header.offset = be64_to_cpu(s->crypto_header.offset);
78
+ s->crypto_header.length = be64_to_cpu(s->crypto_header.length);
79
80
if ((s->crypto_header.offset % s->cluster_size) != 0) {
81
error_setg(errp, "Encryption header offset '%" PRIu64 "' is "
82
@@ -XXX,XX +XXX,XX @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset,
83
return -EINVAL;
84
}
85
86
- be32_to_cpus(&bitmaps_ext.nb_bitmaps);
87
- be64_to_cpus(&bitmaps_ext.bitmap_directory_size);
88
- be64_to_cpus(&bitmaps_ext.bitmap_directory_offset);
89
+ bitmaps_ext.nb_bitmaps = be32_to_cpu(bitmaps_ext.nb_bitmaps);
90
+ bitmaps_ext.bitmap_directory_size =
91
+ be64_to_cpu(bitmaps_ext.bitmap_directory_size);
92
+ bitmaps_ext.bitmap_directory_offset =
93
+ be64_to_cpu(bitmaps_ext.bitmap_directory_offset);
94
95
if (bitmaps_ext.nb_bitmaps > QCOW2_MAX_BITMAPS) {
96
error_setg(errp,
97
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
98
error_setg_errno(errp, -ret, "Could not read qcow2 header");
99
goto fail;
100
}
101
- be32_to_cpus(&header.magic);
102
- be32_to_cpus(&header.version);
103
- be64_to_cpus(&header.backing_file_offset);
104
- be32_to_cpus(&header.backing_file_size);
105
- be64_to_cpus(&header.size);
106
- be32_to_cpus(&header.cluster_bits);
107
- be32_to_cpus(&header.crypt_method);
108
- be64_to_cpus(&header.l1_table_offset);
109
- be32_to_cpus(&header.l1_size);
110
- be64_to_cpus(&header.refcount_table_offset);
111
- be32_to_cpus(&header.refcount_table_clusters);
112
- be64_to_cpus(&header.snapshots_offset);
113
- be32_to_cpus(&header.nb_snapshots);
114
+ header.magic = be32_to_cpu(header.magic);
115
+ header.version = be32_to_cpu(header.version);
116
+ header.backing_file_offset = be64_to_cpu(header.backing_file_offset);
117
+ header.backing_file_size = be32_to_cpu(header.backing_file_size);
118
+ header.size = be64_to_cpu(header.size);
119
+ header.cluster_bits = be32_to_cpu(header.cluster_bits);
120
+ header.crypt_method = be32_to_cpu(header.crypt_method);
121
+ header.l1_table_offset = be64_to_cpu(header.l1_table_offset);
122
+ header.l1_size = be32_to_cpu(header.l1_size);
123
+ header.refcount_table_offset = be64_to_cpu(header.refcount_table_offset);
124
+ header.refcount_table_clusters =
125
+ be32_to_cpu(header.refcount_table_clusters);
126
+ header.snapshots_offset = be64_to_cpu(header.snapshots_offset);
127
+ header.nb_snapshots = be32_to_cpu(header.nb_snapshots);
128
129
if (header.magic != QCOW_MAGIC) {
130
error_setg(errp, "Image is not in qcow2 format");
131
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
132
header.refcount_order = 4;
133
header.header_length = 72;
134
} else {
135
- be64_to_cpus(&header.incompatible_features);
136
- be64_to_cpus(&header.compatible_features);
137
- be64_to_cpus(&header.autoclear_features);
138
- be32_to_cpus(&header.refcount_order);
139
- be32_to_cpus(&header.header_length);
140
+ header.incompatible_features =
141
+ be64_to_cpu(header.incompatible_features);
142
+ header.compatible_features = be64_to_cpu(header.compatible_features);
143
+ header.autoclear_features = be64_to_cpu(header.autoclear_features);
144
+ header.refcount_order = be32_to_cpu(header.refcount_order);
145
+ header.header_length = be32_to_cpu(header.header_length);
146
147
if (header.header_length < 104) {
148
error_setg(errp, "qcow2 header too short");
149
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
150
goto fail;
151
}
152
for(i = 0;i < s->l1_size; i++) {
153
- be64_to_cpus(&s->l1_table[i]);
154
+ s->l1_table[i] = be64_to_cpu(s->l1_table[i]);
155
}
156
}
157
158
@@ -XXX,XX +XXX,XX @@ int qcow2_update_header(BlockDriverState *bs)
159
160
/* Full disk encryption header pointer extension */
161
if (s->crypto_header.offset != 0) {
162
- cpu_to_be64s(&s->crypto_header.offset);
163
- cpu_to_be64s(&s->crypto_header.length);
164
+ s->crypto_header.offset = cpu_to_be64(s->crypto_header.offset);
165
+ s->crypto_header.length = cpu_to_be64(s->crypto_header.length);
166
ret = header_ext_add(buf, QCOW2_EXT_MAGIC_CRYPTO_HEADER,
167
&s->crypto_header, sizeof(s->crypto_header),
168
buflen);
169
- be64_to_cpus(&s->crypto_header.offset);
170
- be64_to_cpus(&s->crypto_header.length);
171
+ s->crypto_header.offset = be64_to_cpu(s->crypto_header.offset);
172
+ s->crypto_header.length = be64_to_cpu(s->crypto_header.length);
173
if (ret < 0) {
174
goto fail;
175
}
176
--
177
2.19.1
178
179
diff view generated by jsdifflib
New patch
1
From: Peter Maydell <peter.maydell@linaro.org>
1
2
3
Taking the address of a field in a packed struct is a bad idea, because
4
it might not be actually aligned enough for that pointer type (and
5
thus cause a crash on dereference on some host architectures). Newer
6
versions of clang warn about this. Avoid the bug by not using the
7
"modify in place" byte swapping functions.
8
9
There are a few places where the in-place swap function is
10
used on something other than a packed struct field; we convert
11
those anyway, for consistency.
12
13
This patch was produced with the following spatch script:
14
15
@@
16
expression E;
17
@@
18
-be16_to_cpus(&E);
19
+E = be16_to_cpu(E);
20
@@
21
expression E;
22
@@
23
-be32_to_cpus(&E);
24
+E = be32_to_cpu(E);
25
@@
26
expression E;
27
@@
28
-be64_to_cpus(&E);
29
+E = be64_to_cpu(E);
30
@@
31
expression E;
32
@@
33
-cpu_to_be16s(&E);
34
+E = cpu_to_be16(E);
35
@@
36
expression E;
37
@@
38
-cpu_to_be32s(&E);
39
+E = cpu_to_be32(E);
40
@@
41
expression E;
42
@@
43
-cpu_to_be64s(&E);
44
+E = cpu_to_be64(E);
45
46
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
47
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
48
Tested-by: John Snow <jsnow@redhat.com>
49
Reviewed-by: John Snow <jsnow@redhat.com>
50
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
51
---
52
block/qcow.c | 18 +++++++++---------
53
1 file changed, 9 insertions(+), 9 deletions(-)
54
55
diff --git a/block/qcow.c b/block/qcow.c
56
index XXXXXXX..XXXXXXX 100644
57
--- a/block/qcow.c
58
+++ b/block/qcow.c
59
@@ -XXX,XX +XXX,XX @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
60
if (ret < 0) {
61
goto fail;
62
}
63
- be32_to_cpus(&header.magic);
64
- be32_to_cpus(&header.version);
65
- be64_to_cpus(&header.backing_file_offset);
66
- be32_to_cpus(&header.backing_file_size);
67
- be32_to_cpus(&header.mtime);
68
- be64_to_cpus(&header.size);
69
- be32_to_cpus(&header.crypt_method);
70
- be64_to_cpus(&header.l1_table_offset);
71
+ header.magic = be32_to_cpu(header.magic);
72
+ header.version = be32_to_cpu(header.version);
73
+ header.backing_file_offset = be64_to_cpu(header.backing_file_offset);
74
+ header.backing_file_size = be32_to_cpu(header.backing_file_size);
75
+ header.mtime = be32_to_cpu(header.mtime);
76
+ header.size = be64_to_cpu(header.size);
77
+ header.crypt_method = be32_to_cpu(header.crypt_method);
78
+ header.l1_table_offset = be64_to_cpu(header.l1_table_offset);
79
80
if (header.magic != QCOW_MAGIC) {
81
error_setg(errp, "Image not in qcow format");
82
@@ -XXX,XX +XXX,XX @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
83
}
84
85
for(i = 0;i < s->l1_size; i++) {
86
- be64_to_cpus(&s->l1_table[i]);
87
+ s->l1_table[i] = be64_to_cpu(s->l1_table[i]);
88
}
89
90
/* alloc L2 cache (max. 64k * 16 * 8 = 8 MB) */
91
--
92
2.19.1
93
94
diff view generated by jsdifflib
New patch
1
From: Peter Maydell <peter.maydell@linaro.org>
1
2
3
Taking the address of a field in a packed struct is a bad idea, because
4
it might not be actually aligned enough for that pointer type (and
5
thus cause a crash on dereference on some host architectures). Newer
6
versions of clang warn about this. Avoid the bug by not using the
7
"modify in place" byte swapping functions.
8
9
There are a few places where the in-place swap function is
10
used on something other than a packed struct field; we convert
11
those anyway, for consistency.
12
13
This patch was produced with the following spatch script:
14
15
@@
16
expression E;
17
@@
18
-be16_to_cpus(&E);
19
+E = be16_to_cpu(E);
20
@@
21
expression E;
22
@@
23
-be32_to_cpus(&E);
24
+E = be32_to_cpu(E);
25
@@
26
expression E;
27
@@
28
-be64_to_cpus(&E);
29
+E = be64_to_cpu(E);
30
@@
31
expression E;
32
@@
33
-cpu_to_be16s(&E);
34
+E = cpu_to_be16(E);
35
@@
36
expression E;
37
@@
38
-cpu_to_be32s(&E);
39
+E = cpu_to_be32(E);
40
@@
41
expression E;
42
@@
43
-cpu_to_be64s(&E);
44
+E = cpu_to_be64(E);
45
46
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
47
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
48
Tested-by: John Snow <jsnow@redhat.com>
49
Reviewed-by: John Snow <jsnow@redhat.com>
50
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
51
---
52
block/qcow2-bitmap.c | 24 ++++++++++++------------
53
1 file changed, 12 insertions(+), 12 deletions(-)
54
55
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
56
index XXXXXXX..XXXXXXX 100644
57
--- a/block/qcow2-bitmap.c
58
+++ b/block/qcow2-bitmap.c
59
@@ -XXX,XX +XXX,XX @@ static inline void bitmap_table_to_be(uint64_t *bitmap_table, size_t size)
60
size_t i;
61
62
for (i = 0; i < size; ++i) {
63
- cpu_to_be64s(&bitmap_table[i]);
64
+ bitmap_table[i] = cpu_to_be64(bitmap_table[i]);
65
}
66
}
67
68
@@ -XXX,XX +XXX,XX @@ static int bitmap_table_load(BlockDriverState *bs, Qcow2BitmapTable *tb,
69
}
70
71
for (i = 0; i < tb->size; ++i) {
72
- be64_to_cpus(&table[i]);
73
+ table[i] = be64_to_cpu(table[i]);
74
ret = check_table_entry(table[i], s->cluster_size);
75
if (ret < 0) {
76
goto fail;
77
@@ -XXX,XX +XXX,XX @@ fail:
78
79
static inline void bitmap_dir_entry_to_cpu(Qcow2BitmapDirEntry *entry)
80
{
81
- be64_to_cpus(&entry->bitmap_table_offset);
82
- be32_to_cpus(&entry->bitmap_table_size);
83
- be32_to_cpus(&entry->flags);
84
- be16_to_cpus(&entry->name_size);
85
- be32_to_cpus(&entry->extra_data_size);
86
+ entry->bitmap_table_offset = be64_to_cpu(entry->bitmap_table_offset);
87
+ entry->bitmap_table_size = be32_to_cpu(entry->bitmap_table_size);
88
+ entry->flags = be32_to_cpu(entry->flags);
89
+ entry->name_size = be16_to_cpu(entry->name_size);
90
+ entry->extra_data_size = be32_to_cpu(entry->extra_data_size);
91
}
92
93
static inline void bitmap_dir_entry_to_be(Qcow2BitmapDirEntry *entry)
94
{
95
- cpu_to_be64s(&entry->bitmap_table_offset);
96
- cpu_to_be32s(&entry->bitmap_table_size);
97
- cpu_to_be32s(&entry->flags);
98
- cpu_to_be16s(&entry->name_size);
99
- cpu_to_be32s(&entry->extra_data_size);
100
+ entry->bitmap_table_offset = cpu_to_be64(entry->bitmap_table_offset);
101
+ entry->bitmap_table_size = cpu_to_be32(entry->bitmap_table_size);
102
+ entry->flags = cpu_to_be32(entry->flags);
103
+ entry->name_size = cpu_to_be16(entry->name_size);
104
+ entry->extra_data_size = cpu_to_be32(entry->extra_data_size);
105
}
106
107
static inline int calc_dir_entry_size(size_t name_size, size_t extra_data_size)
108
--
109
2.19.1
110
111
diff view generated by jsdifflib
New patch
1
From: Daniel P. Berrangé <berrange@redhat.com>
1
2
3
The qcow2 block driver expects to see a valid sector size even when it
4
has opened the crypto layer with QCRYPTO_BLOCK_OPEN_NO_IO.
5
6
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7
Reviewed-by: Alberto Garcia <berto@igalia.com>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9
---
10
crypto/block-qcow.c | 2 ++
11
1 file changed, 2 insertions(+)
12
13
diff --git a/crypto/block-qcow.c b/crypto/block-qcow.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/crypto/block-qcow.c
16
+++ b/crypto/block-qcow.c
17
@@ -XXX,XX +XXX,XX @@ qcrypto_block_qcow_open(QCryptoBlock *block,
18
Error **errp)
19
{
20
if (flags & QCRYPTO_BLOCK_OPEN_NO_IO) {
21
+ block->sector_size = QCRYPTO_BLOCK_QCOW_SECTOR_SIZE;
22
+ block->payload_offset = 0;
23
return 0;
24
} else {
25
if (!options->u.qcow.key_secret) {
26
--
27
2.19.1
28
29
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Alberto Garcia <berto@igalia.com>
2
2
3
MIN_REFCOUNT_CACHE_SIZE is 4 and the cluster size is guaranteed to be
3
This doesn't have any practical effect at the moment because the
4
at most 2MB, so the minimum refcount cache size (in bytes) is always
4
values of BDRV_SECTOR_SIZE, QCRYPTO_BLOCK_LUKS_SECTOR_SIZE and
5
going to fit in a 32-bit integer.
5
QCRYPTO_BLOCK_QCOW_SECTOR_SIZE are all the same (512 bytes), but
6
future encryption methods could have different requirements.
6
7
7
Coverity doesn't know that, and since we're storing the result in a
8
uint64_t (*refcount_cache_size) it thinks that we need the 64 bits and
9
that we probably want to do a 64-bit multiplication to prevent the
10
result from being truncated.
11
12
This is a false positive in this case, but it's a fair warning.
13
We could do a 64-bit multiplication to get rid of it, but since we
14
know that a 32-bit variable is enough to store this value let's simply
15
reuse min_refcount_cache, make it a normal int and stop doing casts.
16
17
Reported-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Alberto Garcia <berto@igalia.com>
8
Signed-off-by: Alberto Garcia <berto@igalia.com>
19
Reviewed-by: Eric Blake <eblake@redhat.com>
9
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
20
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
21
---
11
---
22
block/qcow2.c | 5 ++---
12
block/qcow2.c | 2 +-
23
1 file changed, 2 insertions(+), 3 deletions(-)
13
1 file changed, 1 insertion(+), 1 deletion(-)
24
14
25
diff --git a/block/qcow2.c b/block/qcow2.c
15
diff --git a/block/qcow2.c b/block/qcow2.c
26
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
27
--- a/block/qcow2.c
17
--- a/block/qcow2.c
28
+++ b/block/qcow2.c
18
+++ b/block/qcow2.c
29
@@ -XXX,XX +XXX,XX @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts,
19
@@ -XXX,XX +XXX,XX @@ static void qcow2_refresh_limits(BlockDriverState *bs, Error **errp)
30
BDRVQcow2State *s = bs->opaque;
20
31
uint64_t combined_cache_size;
21
if (bs->encrypted) {
32
bool l2_cache_size_set, refcount_cache_size_set, combined_cache_size_set;
22
/* Encryption works on a sector granularity */
33
+ int min_refcount_cache = MIN_REFCOUNT_CACHE_SIZE * s->cluster_size;
23
- bs->bl.request_alignment = BDRV_SECTOR_SIZE;
34
24
+ bs->bl.request_alignment = qcrypto_block_get_sector_size(s->crypto);
35
combined_cache_size_set = qemu_opt_get(opts, QCOW2_OPT_CACHE_SIZE);
36
l2_cache_size_set = qemu_opt_get(opts, QCOW2_OPT_L2_CACHE_SIZE);
37
@@ -XXX,XX +XXX,XX @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts,
38
} else {
39
uint64_t virtual_disk_size = bs->total_sectors * BDRV_SECTOR_SIZE;
40
uint64_t max_l2_cache = virtual_disk_size / (s->cluster_size / 8);
41
- uint64_t min_refcount_cache =
42
- (uint64_t) MIN_REFCOUNT_CACHE_SIZE * s->cluster_size;
43
44
/* Assign as much memory as possible to the L2 cache, and
45
* use the remainder for the refcount cache */
46
@@ -XXX,XX +XXX,XX @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts,
47
* s->cluster_size);
48
}
49
if (!refcount_cache_size_set) {
50
- *refcount_cache_size = MIN_REFCOUNT_CACHE_SIZE * s->cluster_size;
51
+ *refcount_cache_size = min_refcount_cache;
52
}
53
}
25
}
54
26
bs->bl.pwrite_zeroes_alignment = s->cluster_size;
27
bs->bl.pdiscard_alignment = s->cluster_size;
55
--
28
--
56
2.13.6
29
2.19.1
57
30
58
31
diff view generated by jsdifflib
New patch
1
From: Li Qiang <liq3ea@163.com>
1
2
3
Signed-off-by: Li Qiang <liq3ea@163.com>
4
Reviewed-by: Alberto Garcia <berto@igalia.com>
5
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
6
---
7
include/sysemu/block-backend.h | 6 +++---
8
block/block-backend.c | 8 ++++----
9
2 files changed, 7 insertions(+), 7 deletions(-)
10
11
diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
12
index XXXXXXX..XXXXXXX 100644
13
--- a/include/sysemu/block-backend.h
14
+++ b/include/sysemu/block-backend.h
15
@@ -XXX,XX +XXX,XX @@ BlockErrorAction blk_get_error_action(BlockBackend *blk, bool is_read,
16
int error);
17
void blk_error_action(BlockBackend *blk, BlockErrorAction action,
18
bool is_read, int error);
19
-int blk_is_read_only(BlockBackend *blk);
20
-int blk_is_sg(BlockBackend *blk);
21
-int blk_enable_write_cache(BlockBackend *blk);
22
+bool blk_is_read_only(BlockBackend *blk);
23
+bool blk_is_sg(BlockBackend *blk);
24
+bool blk_enable_write_cache(BlockBackend *blk);
25
void blk_set_enable_write_cache(BlockBackend *blk, bool wce);
26
void blk_invalidate_cache(BlockBackend *blk, Error **errp);
27
bool blk_is_inserted(BlockBackend *blk);
28
diff --git a/block/block-backend.c b/block/block-backend.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/block/block-backend.c
31
+++ b/block/block-backend.c
32
@@ -XXX,XX +XXX,XX @@ void blk_error_action(BlockBackend *blk, BlockErrorAction action,
33
}
34
}
35
36
-int blk_is_read_only(BlockBackend *blk)
37
+bool blk_is_read_only(BlockBackend *blk)
38
{
39
BlockDriverState *bs = blk_bs(blk);
40
41
@@ -XXX,XX +XXX,XX @@ int blk_is_read_only(BlockBackend *blk)
42
}
43
}
44
45
-int blk_is_sg(BlockBackend *blk)
46
+bool blk_is_sg(BlockBackend *blk)
47
{
48
BlockDriverState *bs = blk_bs(blk);
49
50
if (!bs) {
51
- return 0;
52
+ return false;
53
}
54
55
return bdrv_is_sg(bs);
56
}
57
58
-int blk_enable_write_cache(BlockBackend *blk)
59
+bool blk_enable_write_cache(BlockBackend *blk)
60
{
61
return blk->enable_write_cache;
62
}
63
--
64
2.19.1
65
66
diff view generated by jsdifflib
1
This adds a helper function that logs both the QMP request and the
1
From: Cleber Rosa <crosa@redhat.com>
2
received response before returning it.
3
2
3
While testing the Python 3 changes which touch the 083 test, I noticed
4
that it would fail with qcow2. Expanding the testing, I noticed it
5
had nothing to do with the Python 3 changes, and in fact, it would not
6
pass on anything but raw:
7
8
raw: pass
9
bochs: not generic
10
cloop: not generic
11
parallels: fail
12
qcow: fail
13
qcow2: fail
14
qed: fail
15
vdi: fail
16
vhdx: fail
17
vmdk: fail
18
vpc: fail
19
luks: fail
20
21
The errors are a mixture I/O and "image not in xxx format", such as:
22
23
=== Check disconnect before data ===
24
25
Unexpected end-of-file before all bytes were read
26
-read failed: Input/output error
27
+can't open device nbd+tcp://127.0.0.1:PORT/foo: Could not open 'nbd://127.0.0.1:PORT/foo': Input/output error
28
29
=== Check disconnect after data ===
30
31
-read 512/512 bytes at offset 0
32
-512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
33
+can't open device nbd+tcp://127.0.0.1:PORT/foo: Image not in qcow format
34
35
I'm not aware if there's a quick fix, so, for the time being, it looks
36
like the honest approach is to make the test known to work on raw
37
only.
38
39
Signed-off-by: Cleber Rosa <crosa@redhat.com>
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
40
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
5
Reviewed-by: Jeff Cody <jcody@redhat.com>
6
Reviewed-by: Max Reitz <mreitz@redhat.com>
7
---
41
---
8
tests/qemu-iotests/iotests.py | 11 +++++++++++
42
tests/qemu-iotests/083 | 2 +-
9
1 file changed, 11 insertions(+)
43
1 file changed, 1 insertion(+), 1 deletion(-)
10
44
11
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
45
diff --git a/tests/qemu-iotests/083 b/tests/qemu-iotests/083
12
index XXXXXXX..XXXXXXX 100644
46
index XXXXXXX..XXXXXXX 100755
13
--- a/tests/qemu-iotests/iotests.py
47
--- a/tests/qemu-iotests/083
14
+++ b/tests/qemu-iotests/iotests.py
48
+++ b/tests/qemu-iotests/083
15
@@ -XXX,XX +XXX,XX @@ def filter_qmp_event(event):
49
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
16
event['timestamp']['microseconds'] = 'USECS'
50
. ./common.rc
17
return event
51
. ./common.filter
18
52
19
+def filter_testfiles(msg):
53
-_supported_fmt generic
20
+ prefix = os.path.join(test_dir, "%s-" % (os.getpid()))
54
+_supported_fmt raw
21
+ return msg.replace(prefix, 'TEST_DIR/PID-')
55
_supported_proto nbd
22
+
56
_supported_os Linux
23
def log(msg, filters=[]):
24
for flt in filters:
25
msg = flt(msg)
26
@@ -XXX,XX +XXX,XX @@ class VM(qtest.QEMUQtestMachine):
27
result.append(filter_qmp_event(ev))
28
return result
29
30
+ def qmp_log(self, cmd, filters=[filter_testfiles], **kwargs):
31
+ logmsg = "{'execute': '%s', 'arguments': %s}" % (cmd, kwargs)
32
+ log(logmsg, filters)
33
+ result = self.qmp(cmd, **kwargs)
34
+ log(str(result), filters)
35
+ return result
36
+
37
38
index_re = re.compile(r'([^\[]+)\[([^\]]+)\]')
39
57
40
--
58
--
41
2.13.6
59
2.19.1
42
60
43
61
diff view generated by jsdifflib
New patch
1
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2
Reviewed-by: Alberto Garcia <berto@igalia.com>
3
---
4
block/vpc.c | 2 ++
5
1 file changed, 2 insertions(+)
1
6
7
diff --git a/block/vpc.c b/block/vpc.c
8
index XXXXXXX..XXXXXXX 100644
9
--- a/block/vpc.c
10
+++ b/block/vpc.c
11
@@ -XXX,XX +XXX,XX @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags,
12
}
13
14
qemu_co_mutex_init(&s->lock);
15
+ qemu_opts_del(opts);
16
17
return 0;
18
19
fail:
20
+ qemu_opts_del(opts);
21
qemu_vfree(s->pagetable);
22
#ifdef CACHE
23
g_free(s->pageentry_u8);
24
--
25
2.19.1
26
27
diff view generated by jsdifflib
1
.bdrv_co_create() is supposed to return 0 on success, but vhdx could
1
From: Peter Maydell <peter.maydell@linaro.org>
2
return a positive value instead. Fix this.
2
3
3
Taking the address of a field in a packed struct is a bad idea, because
4
it might not be actually aligned enough for that pointer type (and
5
thus cause a crash on dereference on some host architectures). Newer
6
versions of clang warn about this. Avoid the bug by not using the
7
"modify in place" byte swapping functions.
8
9
There are a few places where the in-place swap function is
10
used on something other than a packed struct field; we convert
11
those anyway, for consistency.
12
13
Patch produced with scripts/coccinelle/inplace-byteswaps.cocci.
14
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
17
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
5
Reviewed-by: Max Reitz <mreitz@redhat.com>
6
Reviewed-by: Jeff Cody <jcody@redhat.com>
7
---
18
---
8
block/vhdx.c | 2 +-
19
block/vhdx.h | 12 ++---
9
1 file changed, 1 insertion(+), 1 deletion(-)
20
block/vhdx-endian.c | 118 ++++++++++++++++++++++----------------------
10
21
block/vhdx-log.c | 4 +-
22
block/vhdx.c | 18 +++----
23
4 files changed, 76 insertions(+), 76 deletions(-)
24
25
diff --git a/block/vhdx.h b/block/vhdx.h
26
index XXXXXXX..XXXXXXX 100644
27
--- a/block/vhdx.h
28
+++ b/block/vhdx.h
29
@@ -XXX,XX +XXX,XX @@ int vhdx_log_write_and_flush(BlockDriverState *bs, BDRVVHDXState *s,
30
31
static inline void leguid_to_cpus(MSGUID *guid)
32
{
33
- le32_to_cpus(&guid->data1);
34
- le16_to_cpus(&guid->data2);
35
- le16_to_cpus(&guid->data3);
36
+ guid->data1 = le32_to_cpu(guid->data1);
37
+ guid->data2 = le16_to_cpu(guid->data2);
38
+ guid->data3 = le16_to_cpu(guid->data3);
39
}
40
41
static inline void cpu_to_leguids(MSGUID *guid)
42
{
43
- cpu_to_le32s(&guid->data1);
44
- cpu_to_le16s(&guid->data2);
45
- cpu_to_le16s(&guid->data3);
46
+ guid->data1 = cpu_to_le32(guid->data1);
47
+ guid->data2 = cpu_to_le16(guid->data2);
48
+ guid->data3 = cpu_to_le16(guid->data3);
49
}
50
51
void vhdx_header_le_import(VHDXHeader *h);
52
diff --git a/block/vhdx-endian.c b/block/vhdx-endian.c
53
index XXXXXXX..XXXXXXX 100644
54
--- a/block/vhdx-endian.c
55
+++ b/block/vhdx-endian.c
56
@@ -XXX,XX +XXX,XX @@ void vhdx_header_le_import(VHDXHeader *h)
57
{
58
assert(h != NULL);
59
60
- le32_to_cpus(&h->signature);
61
- le32_to_cpus(&h->checksum);
62
- le64_to_cpus(&h->sequence_number);
63
+ h->signature = le32_to_cpu(h->signature);
64
+ h->checksum = le32_to_cpu(h->checksum);
65
+ h->sequence_number = le64_to_cpu(h->sequence_number);
66
67
leguid_to_cpus(&h->file_write_guid);
68
leguid_to_cpus(&h->data_write_guid);
69
leguid_to_cpus(&h->log_guid);
70
71
- le16_to_cpus(&h->log_version);
72
- le16_to_cpus(&h->version);
73
- le32_to_cpus(&h->log_length);
74
- le64_to_cpus(&h->log_offset);
75
+ h->log_version = le16_to_cpu(h->log_version);
76
+ h->version = le16_to_cpu(h->version);
77
+ h->log_length = le32_to_cpu(h->log_length);
78
+ h->log_offset = le64_to_cpu(h->log_offset);
79
}
80
81
void vhdx_header_le_export(VHDXHeader *orig_h, VHDXHeader *new_h)
82
@@ -XXX,XX +XXX,XX @@ void vhdx_log_desc_le_import(VHDXLogDescriptor *d)
83
{
84
assert(d != NULL);
85
86
- le32_to_cpus(&d->signature);
87
- le64_to_cpus(&d->file_offset);
88
- le64_to_cpus(&d->sequence_number);
89
+ d->signature = le32_to_cpu(d->signature);
90
+ d->file_offset = le64_to_cpu(d->file_offset);
91
+ d->sequence_number = le64_to_cpu(d->sequence_number);
92
}
93
94
void vhdx_log_desc_le_export(VHDXLogDescriptor *d)
95
{
96
assert(d != NULL);
97
98
- cpu_to_le32s(&d->signature);
99
- cpu_to_le32s(&d->trailing_bytes);
100
- cpu_to_le64s(&d->leading_bytes);
101
- cpu_to_le64s(&d->file_offset);
102
- cpu_to_le64s(&d->sequence_number);
103
+ d->signature = cpu_to_le32(d->signature);
104
+ d->trailing_bytes = cpu_to_le32(d->trailing_bytes);
105
+ d->leading_bytes = cpu_to_le64(d->leading_bytes);
106
+ d->file_offset = cpu_to_le64(d->file_offset);
107
+ d->sequence_number = cpu_to_le64(d->sequence_number);
108
}
109
110
void vhdx_log_data_le_import(VHDXLogDataSector *d)
111
{
112
assert(d != NULL);
113
114
- le32_to_cpus(&d->data_signature);
115
- le32_to_cpus(&d->sequence_high);
116
- le32_to_cpus(&d->sequence_low);
117
+ d->data_signature = le32_to_cpu(d->data_signature);
118
+ d->sequence_high = le32_to_cpu(d->sequence_high);
119
+ d->sequence_low = le32_to_cpu(d->sequence_low);
120
}
121
122
void vhdx_log_data_le_export(VHDXLogDataSector *d)
123
{
124
assert(d != NULL);
125
126
- cpu_to_le32s(&d->data_signature);
127
- cpu_to_le32s(&d->sequence_high);
128
- cpu_to_le32s(&d->sequence_low);
129
+ d->data_signature = cpu_to_le32(d->data_signature);
130
+ d->sequence_high = cpu_to_le32(d->sequence_high);
131
+ d->sequence_low = cpu_to_le32(d->sequence_low);
132
}
133
134
void vhdx_log_entry_hdr_le_import(VHDXLogEntryHeader *hdr)
135
{
136
assert(hdr != NULL);
137
138
- le32_to_cpus(&hdr->signature);
139
- le32_to_cpus(&hdr->checksum);
140
- le32_to_cpus(&hdr->entry_length);
141
- le32_to_cpus(&hdr->tail);
142
- le64_to_cpus(&hdr->sequence_number);
143
- le32_to_cpus(&hdr->descriptor_count);
144
+ hdr->signature = le32_to_cpu(hdr->signature);
145
+ hdr->checksum = le32_to_cpu(hdr->checksum);
146
+ hdr->entry_length = le32_to_cpu(hdr->entry_length);
147
+ hdr->tail = le32_to_cpu(hdr->tail);
148
+ hdr->sequence_number = le64_to_cpu(hdr->sequence_number);
149
+ hdr->descriptor_count = le32_to_cpu(hdr->descriptor_count);
150
leguid_to_cpus(&hdr->log_guid);
151
- le64_to_cpus(&hdr->flushed_file_offset);
152
- le64_to_cpus(&hdr->last_file_offset);
153
+ hdr->flushed_file_offset = le64_to_cpu(hdr->flushed_file_offset);
154
+ hdr->last_file_offset = le64_to_cpu(hdr->last_file_offset);
155
}
156
157
void vhdx_log_entry_hdr_le_export(VHDXLogEntryHeader *hdr)
158
{
159
assert(hdr != NULL);
160
161
- cpu_to_le32s(&hdr->signature);
162
- cpu_to_le32s(&hdr->checksum);
163
- cpu_to_le32s(&hdr->entry_length);
164
- cpu_to_le32s(&hdr->tail);
165
- cpu_to_le64s(&hdr->sequence_number);
166
- cpu_to_le32s(&hdr->descriptor_count);
167
+ hdr->signature = cpu_to_le32(hdr->signature);
168
+ hdr->checksum = cpu_to_le32(hdr->checksum);
169
+ hdr->entry_length = cpu_to_le32(hdr->entry_length);
170
+ hdr->tail = cpu_to_le32(hdr->tail);
171
+ hdr->sequence_number = cpu_to_le64(hdr->sequence_number);
172
+ hdr->descriptor_count = cpu_to_le32(hdr->descriptor_count);
173
cpu_to_leguids(&hdr->log_guid);
174
- cpu_to_le64s(&hdr->flushed_file_offset);
175
- cpu_to_le64s(&hdr->last_file_offset);
176
+ hdr->flushed_file_offset = cpu_to_le64(hdr->flushed_file_offset);
177
+ hdr->last_file_offset = cpu_to_le64(hdr->last_file_offset);
178
}
179
180
181
@@ -XXX,XX +XXX,XX @@ void vhdx_region_header_le_import(VHDXRegionTableHeader *hdr)
182
{
183
assert(hdr != NULL);
184
185
- le32_to_cpus(&hdr->signature);
186
- le32_to_cpus(&hdr->checksum);
187
- le32_to_cpus(&hdr->entry_count);
188
+ hdr->signature = le32_to_cpu(hdr->signature);
189
+ hdr->checksum = le32_to_cpu(hdr->checksum);
190
+ hdr->entry_count = le32_to_cpu(hdr->entry_count);
191
}
192
193
void vhdx_region_header_le_export(VHDXRegionTableHeader *hdr)
194
{
195
assert(hdr != NULL);
196
197
- cpu_to_le32s(&hdr->signature);
198
- cpu_to_le32s(&hdr->checksum);
199
- cpu_to_le32s(&hdr->entry_count);
200
+ hdr->signature = cpu_to_le32(hdr->signature);
201
+ hdr->checksum = cpu_to_le32(hdr->checksum);
202
+ hdr->entry_count = cpu_to_le32(hdr->entry_count);
203
}
204
205
void vhdx_region_entry_le_import(VHDXRegionTableEntry *e)
206
@@ -XXX,XX +XXX,XX @@ void vhdx_region_entry_le_import(VHDXRegionTableEntry *e)
207
assert(e != NULL);
208
209
leguid_to_cpus(&e->guid);
210
- le64_to_cpus(&e->file_offset);
211
- le32_to_cpus(&e->length);
212
- le32_to_cpus(&e->data_bits);
213
+ e->file_offset = le64_to_cpu(e->file_offset);
214
+ e->length = le32_to_cpu(e->length);
215
+ e->data_bits = le32_to_cpu(e->data_bits);
216
}
217
218
void vhdx_region_entry_le_export(VHDXRegionTableEntry *e)
219
@@ -XXX,XX +XXX,XX @@ void vhdx_region_entry_le_export(VHDXRegionTableEntry *e)
220
assert(e != NULL);
221
222
cpu_to_leguids(&e->guid);
223
- cpu_to_le64s(&e->file_offset);
224
- cpu_to_le32s(&e->length);
225
- cpu_to_le32s(&e->data_bits);
226
+ e->file_offset = cpu_to_le64(e->file_offset);
227
+ e->length = cpu_to_le32(e->length);
228
+ e->data_bits = cpu_to_le32(e->data_bits);
229
}
230
231
232
@@ -XXX,XX +XXX,XX @@ void vhdx_metadata_header_le_import(VHDXMetadataTableHeader *hdr)
233
{
234
assert(hdr != NULL);
235
236
- le64_to_cpus(&hdr->signature);
237
- le16_to_cpus(&hdr->entry_count);
238
+ hdr->signature = le64_to_cpu(hdr->signature);
239
+ hdr->entry_count = le16_to_cpu(hdr->entry_count);
240
}
241
242
void vhdx_metadata_header_le_export(VHDXMetadataTableHeader *hdr)
243
{
244
assert(hdr != NULL);
245
246
- cpu_to_le64s(&hdr->signature);
247
- cpu_to_le16s(&hdr->entry_count);
248
+ hdr->signature = cpu_to_le64(hdr->signature);
249
+ hdr->entry_count = cpu_to_le16(hdr->entry_count);
250
}
251
252
void vhdx_metadata_entry_le_import(VHDXMetadataTableEntry *e)
253
@@ -XXX,XX +XXX,XX @@ void vhdx_metadata_entry_le_import(VHDXMetadataTableEntry *e)
254
assert(e != NULL);
255
256
leguid_to_cpus(&e->item_id);
257
- le32_to_cpus(&e->offset);
258
- le32_to_cpus(&e->length);
259
- le32_to_cpus(&e->data_bits);
260
+ e->offset = le32_to_cpu(e->offset);
261
+ e->length = le32_to_cpu(e->length);
262
+ e->data_bits = le32_to_cpu(e->data_bits);
263
}
264
void vhdx_metadata_entry_le_export(VHDXMetadataTableEntry *e)
265
{
266
assert(e != NULL);
267
268
cpu_to_leguids(&e->item_id);
269
- cpu_to_le32s(&e->offset);
270
- cpu_to_le32s(&e->length);
271
- cpu_to_le32s(&e->data_bits);
272
+ e->offset = cpu_to_le32(e->offset);
273
+ e->length = cpu_to_le32(e->length);
274
+ e->data_bits = cpu_to_le32(e->data_bits);
275
}
276
diff --git a/block/vhdx-log.c b/block/vhdx-log.c
277
index XXXXXXX..XXXXXXX 100644
278
--- a/block/vhdx-log.c
279
+++ b/block/vhdx-log.c
280
@@ -XXX,XX +XXX,XX @@ static void vhdx_log_raw_to_le_sector(VHDXLogDescriptor *desc,
281
/* 8 + 4084 + 4 = 4096, 1 log sector */
282
memcpy(&desc->leading_bytes, data, 8);
283
data += 8;
284
- cpu_to_le64s(&desc->leading_bytes);
285
+ desc->leading_bytes = cpu_to_le64(desc->leading_bytes);
286
memcpy(sector->data, data, 4084);
287
data += 4084;
288
memcpy(&desc->trailing_bytes, data, 4);
289
- cpu_to_le32s(&desc->trailing_bytes);
290
+ desc->trailing_bytes = cpu_to_le32(desc->trailing_bytes);
291
data += 4;
292
293
sector->sequence_high = (uint32_t) (seq >> 32);
11
diff --git a/block/vhdx.c b/block/vhdx.c
294
diff --git a/block/vhdx.c b/block/vhdx.c
12
index XXXXXXX..XXXXXXX 100644
295
index XXXXXXX..XXXXXXX 100644
13
--- a/block/vhdx.c
296
--- a/block/vhdx.c
14
+++ b/block/vhdx.c
297
+++ b/block/vhdx.c
15
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn vhdx_co_create(BlockdevCreateOptions *opts,
298
@@ -XXX,XX +XXX,XX @@ uint32_t vhdx_update_checksum(uint8_t *buf, size_t size, int crc_offset)
16
goto delete_and_exit;
299
300
memset(buf + crc_offset, 0, sizeof(crc));
301
crc = crc32c(0xffffffff, buf, size);
302
- cpu_to_le32s(&crc);
303
+ crc = cpu_to_le32(crc);
304
memcpy(buf + crc_offset, &crc, sizeof(crc));
305
306
return crc;
307
@@ -XXX,XX +XXX,XX @@ static int vhdx_parse_metadata(BlockDriverState *bs, BDRVVHDXState *s)
308
goto exit;
17
}
309
}
18
310
19
-
311
- le32_to_cpus(&s->params.block_size);
20
+ ret = 0;
312
- le32_to_cpus(&s->params.data_bits);
21
delete_and_exit:
313
+ s->params.block_size = le32_to_cpu(s->params.block_size);
22
blk_unref(blk);
314
+ s->params.data_bits = le32_to_cpu(s->params.data_bits);
23
bdrv_unref(bs);
315
316
317
/* We now have the file parameters, so we can tell if this is a
318
@@ -XXX,XX +XXX,XX @@ static int vhdx_parse_metadata(BlockDriverState *bs, BDRVVHDXState *s)
319
goto exit;
320
}
321
322
- le64_to_cpus(&s->virtual_disk_size);
323
- le32_to_cpus(&s->logical_sector_size);
324
- le32_to_cpus(&s->physical_sector_size);
325
+ s->virtual_disk_size = le64_to_cpu(s->virtual_disk_size);
326
+ s->logical_sector_size = le32_to_cpu(s->logical_sector_size);
327
+ s->physical_sector_size = le32_to_cpu(s->physical_sector_size);
328
329
if (s->params.block_size < VHDX_BLOCK_SIZE_MIN ||
330
s->params.block_size > VHDX_BLOCK_SIZE_MAX) {
331
@@ -XXX,XX +XXX,XX @@ static int vhdx_open(BlockDriverState *bs, QDict *options, int flags,
332
/* endian convert, and verify populated BAT field file offsets against
333
* region table and log entries */
334
for (i = 0; i < s->bat_entries; i++) {
335
- le64_to_cpus(&s->bat[i]);
336
+ s->bat[i] = le64_to_cpu(s->bat[i]);
337
if (payblocks--) {
338
/* payload bat entries */
339
if ((s->bat[i] & VHDX_BAT_STATE_BIT_MASK) ==
340
@@ -XXX,XX +XXX,XX @@ static int vhdx_create_new_metadata(BlockBackend *blk,
341
mt_file_params->block_size = cpu_to_le32(block_size);
342
if (type == VHDX_TYPE_FIXED) {
343
mt_file_params->data_bits |= VHDX_PARAMS_LEAVE_BLOCKS_ALLOCED;
344
- cpu_to_le32s(&mt_file_params->data_bits);
345
+ mt_file_params->data_bits = cpu_to_le32(mt_file_params->data_bits);
346
}
347
348
vhdx_guid_generate(&mt_page83->page_83_data);
349
@@ -XXX,XX +XXX,XX @@ static int vhdx_create_bat(BlockBackend *blk, BDRVVHDXState *s,
350
sinfo.file_offset = ROUND_UP(sinfo.file_offset, MiB);
351
vhdx_update_bat_table_entry(blk_bs(blk), s, &sinfo, &unused, &unused,
352
block_state);
353
- cpu_to_le64s(&s->bat[sinfo.bat_idx]);
354
+ s->bat[sinfo.bat_idx] = cpu_to_le64(s->bat[sinfo.bat_idx]);
355
sector_num += s->sectors_per_block;
356
}
357
ret = blk_pwrite(blk, file_offset, s->bat, length, 0);
24
--
358
--
25
2.13.6
359
2.19.1
26
360
27
361
diff view generated by jsdifflib
New patch
1
From: Peter Maydell <peter.maydell@linaro.org>
1
2
3
Taking the address of a field in a packed struct is a bad idea, because
4
it might not be actually aligned enough for that pointer type (and
5
thus cause a crash on dereference on some host architectures). Newer
6
versions of clang warn about this. Avoid the bug by not using the
7
"modify in place" byte swapping functions.
8
9
There are a few places where the in-place swap function is
10
used on something other than a packed struct field; we convert
11
those anyway, for consistency.
12
13
Patch produced with scripts/coccinelle/inplace-byteswaps.cocci.
14
15
There are other places where we take the address of a packed member
16
in this file for other purposes than passing it to a byteswap
17
function (all the calls to qemu_uuid_*()); we leave those for now.
18
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
21
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
22
---
23
block/vdi.c | 64 ++++++++++++++++++++++++++---------------------------
24
1 file changed, 32 insertions(+), 32 deletions(-)
25
26
diff --git a/block/vdi.c b/block/vdi.c
27
index XXXXXXX..XXXXXXX 100644
28
--- a/block/vdi.c
29
+++ b/block/vdi.c
30
@@ -XXX,XX +XXX,XX @@ typedef struct {
31
32
static void vdi_header_to_cpu(VdiHeader *header)
33
{
34
- le32_to_cpus(&header->signature);
35
- le32_to_cpus(&header->version);
36
- le32_to_cpus(&header->header_size);
37
- le32_to_cpus(&header->image_type);
38
- le32_to_cpus(&header->image_flags);
39
- le32_to_cpus(&header->offset_bmap);
40
- le32_to_cpus(&header->offset_data);
41
- le32_to_cpus(&header->cylinders);
42
- le32_to_cpus(&header->heads);
43
- le32_to_cpus(&header->sectors);
44
- le32_to_cpus(&header->sector_size);
45
- le64_to_cpus(&header->disk_size);
46
- le32_to_cpus(&header->block_size);
47
- le32_to_cpus(&header->block_extra);
48
- le32_to_cpus(&header->blocks_in_image);
49
- le32_to_cpus(&header->blocks_allocated);
50
+ header->signature = le32_to_cpu(header->signature);
51
+ header->version = le32_to_cpu(header->version);
52
+ header->header_size = le32_to_cpu(header->header_size);
53
+ header->image_type = le32_to_cpu(header->image_type);
54
+ header->image_flags = le32_to_cpu(header->image_flags);
55
+ header->offset_bmap = le32_to_cpu(header->offset_bmap);
56
+ header->offset_data = le32_to_cpu(header->offset_data);
57
+ header->cylinders = le32_to_cpu(header->cylinders);
58
+ header->heads = le32_to_cpu(header->heads);
59
+ header->sectors = le32_to_cpu(header->sectors);
60
+ header->sector_size = le32_to_cpu(header->sector_size);
61
+ header->disk_size = le64_to_cpu(header->disk_size);
62
+ header->block_size = le32_to_cpu(header->block_size);
63
+ header->block_extra = le32_to_cpu(header->block_extra);
64
+ header->blocks_in_image = le32_to_cpu(header->blocks_in_image);
65
+ header->blocks_allocated = le32_to_cpu(header->blocks_allocated);
66
qemu_uuid_bswap(&header->uuid_image);
67
qemu_uuid_bswap(&header->uuid_last_snap);
68
qemu_uuid_bswap(&header->uuid_link);
69
@@ -XXX,XX +XXX,XX @@ static void vdi_header_to_cpu(VdiHeader *header)
70
71
static void vdi_header_to_le(VdiHeader *header)
72
{
73
- cpu_to_le32s(&header->signature);
74
- cpu_to_le32s(&header->version);
75
- cpu_to_le32s(&header->header_size);
76
- cpu_to_le32s(&header->image_type);
77
- cpu_to_le32s(&header->image_flags);
78
- cpu_to_le32s(&header->offset_bmap);
79
- cpu_to_le32s(&header->offset_data);
80
- cpu_to_le32s(&header->cylinders);
81
- cpu_to_le32s(&header->heads);
82
- cpu_to_le32s(&header->sectors);
83
- cpu_to_le32s(&header->sector_size);
84
- cpu_to_le64s(&header->disk_size);
85
- cpu_to_le32s(&header->block_size);
86
- cpu_to_le32s(&header->block_extra);
87
- cpu_to_le32s(&header->blocks_in_image);
88
- cpu_to_le32s(&header->blocks_allocated);
89
+ header->signature = cpu_to_le32(header->signature);
90
+ header->version = cpu_to_le32(header->version);
91
+ header->header_size = cpu_to_le32(header->header_size);
92
+ header->image_type = cpu_to_le32(header->image_type);
93
+ header->image_flags = cpu_to_le32(header->image_flags);
94
+ header->offset_bmap = cpu_to_le32(header->offset_bmap);
95
+ header->offset_data = cpu_to_le32(header->offset_data);
96
+ header->cylinders = cpu_to_le32(header->cylinders);
97
+ header->heads = cpu_to_le32(header->heads);
98
+ header->sectors = cpu_to_le32(header->sectors);
99
+ header->sector_size = cpu_to_le32(header->sector_size);
100
+ header->disk_size = cpu_to_le64(header->disk_size);
101
+ header->block_size = cpu_to_le32(header->block_size);
102
+ header->block_extra = cpu_to_le32(header->block_extra);
103
+ header->blocks_in_image = cpu_to_le32(header->blocks_in_image);
104
+ header->blocks_allocated = cpu_to_le32(header->blocks_allocated);
105
qemu_uuid_bswap(&header->uuid_image);
106
qemu_uuid_bswap(&header->uuid_last_snap);
107
qemu_uuid_bswap(&header->uuid_link);
108
--
109
2.19.1
110
111
diff view generated by jsdifflib
1
This rewrites the test case 213 to work with the new x-blockdev-create
1
From: Alberto Garcia <berto@igalia.com>
2
job rather than the old synchronous version of the command.
3
2
4
All of the test cases stay the same as before, but in order to be able
3
This is a static function with only one caller, so there's no need to
5
to implement proper job handling, the test case is rewritten in Python.
4
keep it. Inlining the code in quorum_compare() makes it much simpler.
6
5
6
Signed-off-by: Alberto Garcia <berto@igalia.com>
7
Reported-by: Markus Armbruster <armbru@redhat.com>
7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
Reviewed-by: Max Reitz <mreitz@redhat.com>
9
---
9
---
10
tests/qemu-iotests/213 | 520 +++++++++++++++++----------------------------
10
block/quorum.c | 24 +++++-------------------
11
tests/qemu-iotests/213.out | 208 +++++++++++-------
11
1 file changed, 5 insertions(+), 19 deletions(-)
12
tests/qemu-iotests/group | 4 +-
13
3 files changed, 319 insertions(+), 413 deletions(-)
14
12
15
diff --git a/tests/qemu-iotests/213 b/tests/qemu-iotests/213
13
diff --git a/block/quorum.c b/block/quorum.c
16
index XXXXXXX..XXXXXXX 100755
14
index XXXXXXX..XXXXXXX 100644
17
--- a/tests/qemu-iotests/213
15
--- a/block/quorum.c
18
+++ b/tests/qemu-iotests/213
16
+++ b/block/quorum.c
19
@@ -XXX,XX +XXX,XX @@
17
@@ -XXX,XX +XXX,XX @@ static bool quorum_iovec_compare(QEMUIOVector *a, QEMUIOVector *b)
20
-#!/bin/bash
18
return true;
21
+#!/usr/bin/env python
19
}
22
#
20
23
# Test vhdx and file image creation
21
-static void GCC_FMT_ATTR(2, 3) quorum_err(QuorumAIOCB *acb,
24
#
22
- const char *fmt, ...)
25
# Copyright (C) 2018 Red Hat, Inc.
23
-{
26
#
24
- va_list ap;
27
+# Creator/Owner: Kevin Wolf <kwolf@redhat.com>
28
+#
29
# This program is free software; you can redistribute it and/or modify
30
# it under the terms of the GNU General Public License as published by
31
# the Free Software Foundation; either version 2 of the License, or
32
@@ -XXX,XX +XXX,XX @@
33
# along with this program. If not, see <http://www.gnu.org/licenses/>.
34
#
35
36
-# creator
37
-owner=kwolf@redhat.com
38
-
25
-
39
-seq=`basename $0`
26
- va_start(ap, fmt);
40
-echo "QA output created by $seq"
27
- fprintf(stderr, "quorum: offset=%" PRIu64 " bytes=%" PRIu64 " ",
41
-
28
- acb->offset, acb->bytes);
42
-here=`pwd`
29
- vfprintf(stderr, fmt, ap);
43
-status=1    # failure is the default!
30
- fprintf(stderr, "\n");
44
-
31
- va_end(ap);
45
-# get standard environment, filters and checks
32
- exit(1);
46
-. ./common.rc
47
-. ./common.filter
48
-
49
-_supported_fmt vhdx
50
-_supported_proto file
51
-_supported_os Linux
52
-
53
-function do_run_qemu()
54
-{
55
- echo Testing: "$@"
56
- $QEMU -nographic -qmp stdio -serial none "$@"
57
- echo
58
-}
33
-}
59
-
34
-
60
-function run_qemu()
35
-static bool quorum_compare(QuorumAIOCB *acb,
61
-{
36
- QEMUIOVector *a,
62
- do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \
37
- QEMUIOVector *b)
63
- | _filter_qemu | _filter_imgfmt \
38
+static bool quorum_compare(QuorumAIOCB *acb, QEMUIOVector *a, QEMUIOVector *b)
64
- | _filter_actual_image_size
39
{
65
-}
40
BDRVQuorumState *s = acb->bs->opaque;
66
-
41
ssize_t offset;
67
-echo
42
@@ -XXX,XX +XXX,XX @@ static bool quorum_compare(QuorumAIOCB *acb,
68
-echo "=== Successful image creation (defaults) ==="
43
if (s->is_blkverify) {
69
-echo
44
offset = qemu_iovec_compare(a, b);
70
-
45
if (offset != -1) {
71
-size=$((128 * 1024 * 1024))
46
- quorum_err(acb, "contents mismatch at offset %" PRIu64,
72
-
47
- acb->offset + offset);
73
-run_qemu <<EOF
48
+ fprintf(stderr, "quorum: offset=%" PRIu64 " bytes=%" PRIu64
74
-{ "execute": "qmp_capabilities" }
49
+ " contents mismatch at offset %" PRIu64 "\n",
75
-{ "execute": "x-blockdev-create",
50
+ acb->offset, acb->bytes, acb->offset + offset);
76
- "arguments": {
51
+ exit(1);
77
- "driver": "file",
52
}
78
- "filename": "$TEST_IMG",
53
return true;
79
- "size": 0
54
}
80
- }
81
-}
82
-{ "execute": "blockdev-add",
83
- "arguments": {
84
- "driver": "file",
85
- "node-name": "imgfile",
86
- "filename": "$TEST_IMG"
87
- }
88
-}
89
-{ "execute": "x-blockdev-create",
90
- "arguments": {
91
- "driver": "$IMGFMT",
92
- "file": "imgfile",
93
- "size": $size
94
- }
95
-}
96
-{ "execute": "quit" }
97
-EOF
98
-
99
-_img_info --format-specific | _filter_img_info --format-specific
100
-
101
-echo
102
-echo "=== Successful image creation (explicit defaults) ==="
103
-echo
104
-
105
-# Choose a different size to show that we got a new image
106
-size=$((64 * 1024 * 1024))
107
-
108
-run_qemu <<EOF
109
-{ "execute": "qmp_capabilities" }
110
-{ "execute": "x-blockdev-create",
111
- "arguments": {
112
- "driver": "file",
113
- "filename": "$TEST_IMG",
114
- "size": 0
115
- }
116
-}
117
-{ "execute": "x-blockdev-create",
118
- "arguments": {
119
- "driver": "$IMGFMT",
120
- "file": {
121
- "driver": "file",
122
- "filename": "$TEST_IMG"
123
- },
124
- "size": $size,
125
- "log-size": 1048576,
126
- "block-size": 8388608,
127
- "subformat": "dynamic",
128
- "block-state-zero": true
129
- }
130
-}
131
-{ "execute": "quit" }
132
-EOF
133
-
134
-_img_info --format-specific | _filter_img_info --format-specific
135
-
136
-echo
137
-echo "=== Successful image creation (with non-default options) ==="
138
-echo
139
-
140
-# Choose a different size to show that we got a new image
141
-size=$((32 * 1024 * 1024))
142
-
143
-run_qemu <<EOF
144
-{ "execute": "qmp_capabilities" }
145
-{ "execute": "x-blockdev-create",
146
- "arguments": {
147
- "driver": "file",
148
- "filename": "$TEST_IMG",
149
- "size": 0
150
- }
151
-}
152
-{ "execute": "x-blockdev-create",
153
- "arguments": {
154
- "driver": "$IMGFMT",
155
- "file": {
156
- "driver": "file",
157
- "filename": "$TEST_IMG"
158
- },
159
- "size": $size,
160
- "log-size": 8388608,
161
- "block-size": 268435456,
162
- "subformat": "fixed",
163
- "block-state-zero": false
164
- }
165
-}
166
-{ "execute": "quit" }
167
-EOF
168
-
169
-_img_info --format-specific | _filter_img_info --format-specific
170
-
171
-echo
172
-echo "=== Invalid BlockdevRef ==="
173
-echo
174
-
175
-run_qemu <<EOF
176
-{ "execute": "qmp_capabilities" }
177
-{ "execute": "x-blockdev-create",
178
- "arguments": {
179
- "driver": "$IMGFMT",
180
- "file": "this doesn't exist",
181
- "size": $size
182
- }
183
-}
184
-{ "execute": "quit" }
185
-EOF
186
-
187
-echo
188
-echo "=== Zero size ==="
189
-echo
190
-
191
-run_qemu -blockdev driver=file,filename="$TEST_IMG",node-name=node0 <<EOF
192
-{ "execute": "qmp_capabilities" }
193
-{ "execute": "x-blockdev-create",
194
- "arguments": {
195
- "driver": "$IMGFMT",
196
- "file": "node0",
197
- "size": 0
198
- }
199
-}
200
-{ "execute": "quit" }
201
-EOF
202
-
203
-_img_info | _filter_img_info
204
-
205
-echo
206
-echo "=== Maximum size ==="
207
-echo
208
-
209
-run_qemu -blockdev driver=file,filename="$TEST_IMG",node-name=node0 <<EOF
210
-{ "execute": "qmp_capabilities" }
211
-{ "execute": "x-blockdev-create",
212
- "arguments": {
213
- "driver": "$IMGFMT",
214
- "file": "node0",
215
- "size": 70368744177664
216
- }
217
-}
218
-{ "execute": "quit" }
219
-EOF
220
-
221
-_img_info | _filter_img_info
222
-
223
-echo
224
-echo "=== Invalid sizes ==="
225
-echo
226
-
227
-# TODO Negative image sizes aren't handled correctly, but this is a problem
228
-# with QAPI's implementation of the 'size' type and affects other commands as
229
-# well. Once this is fixed, we may want to add a test case here.
230
-
231
-# 1. 2^64 - 512
232
-# 2. 2^63 = 8 EB (qemu-img enforces image sizes less than this)
233
-# 3. 2^63 - 512 (generally valid, but with the image header the file will
234
-# exceed 63 bits)
235
-# 4. 2^46 + 1 (one byte more than maximum image size)
236
-
237
-run_qemu -blockdev driver=file,filename="$TEST_IMG",node-name=node0 <<EOF
238
-{ "execute": "qmp_capabilities" }
239
-{ "execute": "x-blockdev-create",
240
- "arguments": {
241
- "driver": "$IMGFMT",
242
- "file": "node0",
243
- "size": 18446744073709551104
244
- }
245
-}
246
-{ "execute": "x-blockdev-create",
247
- "arguments": {
248
- "driver": "$IMGFMT",
249
- "file": "node0",
250
- "size": 9223372036854775808
251
- }
252
-}
253
-{ "execute": "x-blockdev-create",
254
- "arguments": {
255
- "driver": "$IMGFMT",
256
- "file": "node0",
257
- "size": 9223372036854775296
258
- }
259
-}
260
-{ "execute": "x-blockdev-create",
261
- "arguments": {
262
- "driver": "$IMGFMT",
263
- "file": "node0",
264
- "size": 70368744177665
265
- }
266
-}
267
-{ "execute": "quit" }
268
-EOF
269
-
270
-echo
271
-echo "=== Invalid block size ==="
272
-echo
273
-
274
-run_qemu -blockdev driver=file,filename="$TEST_IMG",node-name=node0 <<EOF
275
-{ "execute": "qmp_capabilities" }
276
-{ "execute": "x-blockdev-create",
277
- "arguments": {
278
- "driver": "$IMGFMT",
279
- "file": "node0",
280
- "size": 67108864,
281
- "block-size": 1234567
282
- }
283
-}
284
-{ "execute": "x-blockdev-create",
285
- "arguments": {
286
- "driver": "$IMGFMT",
287
- "file": "node0",
288
- "size": 67108864,
289
- "block-size": 128
290
- }
291
-}
292
-{ "execute": "x-blockdev-create",
293
- "arguments": {
294
- "driver": "$IMGFMT",
295
- "file": "node0",
296
- "size": 67108864,
297
- "block-size": 3145728
298
- }
299
-}
300
-{ "execute": "x-blockdev-create",
301
- "arguments": {
302
- "driver": "$IMGFMT",
303
- "file": "node0",
304
- "size": 67108864,
305
- "block-size": 536870912
306
- }
307
-}
308
-{ "execute": "x-blockdev-create",
309
- "arguments": {
310
- "driver": "$IMGFMT",
311
- "file": "node0",
312
- "size": 67108864,
313
- "block-size": 0
314
- }
315
-}
316
-{ "execute": "quit" }
317
-EOF
318
-
319
-echo
320
-echo "=== Invalid log size ==="
321
-echo
322
-
323
-run_qemu -blockdev driver=file,filename="$TEST_IMG",node-name=node0 <<EOF
324
-{ "execute": "qmp_capabilities" }
325
-{ "execute": "x-blockdev-create",
326
- "arguments": {
327
- "driver": "$IMGFMT",
328
- "file": "node0",
329
- "size": 67108864,
330
- "log-size": 1234567
331
- }
332
-}
333
-{ "execute": "x-blockdev-create",
334
- "arguments": {
335
- "driver": "$IMGFMT",
336
- "file": "node0",
337
- "size": 67108864,
338
- "log-size": 128
339
- }
340
-}
341
-{ "execute": "x-blockdev-create",
342
- "arguments": {
343
- "driver": "$IMGFMT",
344
- "file": "node0",
345
- "size": 67108864,
346
- "log-size": 4294967296
347
- }
348
-}
349
-{ "execute": "x-blockdev-create",
350
- "arguments": {
351
- "driver": "$IMGFMT",
352
- "file": "node0",
353
- "size": 67108864,
354
- "log-size": 0
355
- }
356
-}
357
-{ "execute": "quit" }
358
-EOF
359
-
360
-
361
-# success, all done
362
-echo "*** done"
363
-rm -f $seq.full
364
-status=0
365
+import iotests
366
+from iotests import imgfmt
367
+
368
+iotests.verify_image_format(supported_fmts=['vhdx'])
369
+iotests.verify_protocol(supported=['file'])
370
+
371
+def blockdev_create(vm, options):
372
+ result = vm.qmp_log('x-blockdev-create', job_id='job0', options=options)
373
+
374
+ if 'return' in result:
375
+ assert result['return'] == {}
376
+ vm.run_job('job0')
377
+ iotests.log("")
378
+
379
+with iotests.FilePath('t.vhdx') as disk_path, \
380
+ iotests.VM() as vm:
381
+
382
+ #
383
+ # Successful image creation (defaults)
384
+ #
385
+ iotests.log("=== Successful image creation (defaults) ===")
386
+ iotests.log("")
387
+
388
+ size = 128 * 1024 * 1024
389
+
390
+ vm.launch()
391
+ blockdev_create(vm, { 'driver': 'file',
392
+ 'filename': disk_path,
393
+ 'size': 0 })
394
+
395
+ vm.qmp_log('blockdev-add', driver='file', filename=disk_path,
396
+ node_name='imgfile')
397
+
398
+ blockdev_create(vm, { 'driver': imgfmt,
399
+ 'file': 'imgfile',
400
+ 'size': size })
401
+ vm.shutdown()
402
+
403
+ iotests.img_info_log(disk_path)
404
+
405
+ #
406
+ # Successful image creation (explicit defaults)
407
+ #
408
+ iotests.log("=== Successful image creation (explicit defaults) ===")
409
+ iotests.log("")
410
+
411
+ # Choose a different size to show that we got a new image
412
+ size = 64 * 1024 * 1024
413
+
414
+ vm.launch()
415
+ blockdev_create(vm, { 'driver': 'file',
416
+ 'filename': disk_path,
417
+ 'size': 0 })
418
+ blockdev_create(vm, { 'driver': imgfmt,
419
+ 'file': {
420
+ 'driver': 'file',
421
+ 'filename': disk_path,
422
+ },
423
+ 'size': size,
424
+ 'log-size': 1048576,
425
+ 'block-size': 8388608,
426
+ 'subformat': 'dynamic',
427
+ 'block-state-zero': True })
428
+ vm.shutdown()
429
+
430
+ iotests.img_info_log(disk_path)
431
+
432
+ #
433
+ # Successful image creation (with non-default options)
434
+ #
435
+ iotests.log("=== Successful image creation (with non-default options) ===")
436
+ iotests.log("")
437
+
438
+ # Choose a different size to show that we got a new image
439
+ size = 32 * 1024 * 1024
440
+
441
+ vm.launch()
442
+ blockdev_create(vm, { 'driver': 'file',
443
+ 'filename': disk_path,
444
+ 'size': 0 })
445
+ blockdev_create(vm, { 'driver': imgfmt,
446
+ 'file': {
447
+ 'driver': 'file',
448
+ 'filename': disk_path,
449
+ },
450
+ 'size': size,
451
+ 'log-size': 8388608,
452
+ 'block-size': 268435456,
453
+ 'subformat': 'fixed',
454
+ 'block-state-zero': False })
455
+ vm.shutdown()
456
+
457
+ iotests.img_info_log(disk_path)
458
+
459
+ #
460
+ # Invalid BlockdevRef
461
+ #
462
+ iotests.log("=== Invalid BlockdevRef ===")
463
+ iotests.log("")
464
+
465
+ vm.launch()
466
+ blockdev_create(vm, { 'driver': imgfmt,
467
+ 'file': "this doesn't exist",
468
+ 'size': size })
469
+ vm.shutdown()
470
+
471
+ #
472
+ # Zero size
473
+ #
474
+ iotests.log("=== Zero size ===")
475
+ iotests.log("")
476
+
477
+ vm.add_blockdev('driver=file,filename=%s,node-name=node0' % (disk_path))
478
+ vm.launch()
479
+ blockdev_create(vm, { 'driver': imgfmt,
480
+ 'file': 'node0',
481
+ 'size': 0 })
482
+ vm.shutdown()
483
+
484
+ iotests.img_info_log(disk_path)
485
+
486
+ #
487
+ # Maximum size
488
+ #
489
+ iotests.log("=== Maximum size ===")
490
+ iotests.log("")
491
+
492
+ vm.launch()
493
+ blockdev_create(vm, { 'driver': imgfmt,
494
+ 'file': 'node0',
495
+ 'size': 70368744177664 })
496
+ vm.shutdown()
497
+
498
+ iotests.img_info_log(disk_path)
499
+
500
+ #
501
+ # Invalid sizes
502
+ #
503
+
504
+ # TODO Negative image sizes aren't handled correctly, but this is a problem
505
+ # with QAPI's implementation of the 'size' type and affects other commands
506
+ # as well. Once this is fixed, we may want to add a test case here.
507
+
508
+ # 1. 2^64 - 512
509
+ # 2. 2^63 = 8 EB (qemu-img enforces image sizes less than this)
510
+ # 3. 2^63 - 512 (generally valid, but with the image header the file will
511
+ # exceed 63 bits)
512
+ # 4. 2^46 + 1 (one byte more than maximum image size)
513
+
514
+ iotests.log("=== Invalid sizes ===")
515
+ iotests.log("")
516
+
517
+ vm.launch()
518
+ for size in [ 18446744073709551104, 9223372036854775808,
519
+ 9223372036854775296, 70368744177665 ]:
520
+ blockdev_create(vm, { 'driver': imgfmt,
521
+ 'file': 'node0',
522
+ 'size': size })
523
+ vm.shutdown()
524
+
525
+ #
526
+ # Invalid block size
527
+ #
528
+ iotests.log("=== Invalid block size ===")
529
+ iotests.log("")
530
+
531
+ vm.launch()
532
+ for bsize in [ 1234567, 128, 3145728, 536870912, 0 ]:
533
+ blockdev_create(vm, { 'driver': imgfmt,
534
+ 'file': 'node0',
535
+ 'size': 67108864,
536
+ 'block-size': bsize })
537
+ vm.shutdown()
538
+
539
+ #
540
+ # Invalid log size
541
+ #
542
+ iotests.log("=== Invalid log size ===")
543
+ iotests.log("")
544
+
545
+ vm.launch()
546
+ for lsize in [ 1234567, 128, 4294967296, 0 ]:
547
+ blockdev_create(vm, { 'driver': imgfmt,
548
+ 'file': 'node0',
549
+ 'size': 67108864,
550
+ 'log-size': lsize })
551
+ vm.shutdown()
552
diff --git a/tests/qemu-iotests/213.out b/tests/qemu-iotests/213.out
553
index XXXXXXX..XXXXXXX 100644
554
--- a/tests/qemu-iotests/213.out
555
+++ b/tests/qemu-iotests/213.out
556
@@ -XXX,XX +XXX,XX @@
557
-QA output created by 213
558
-
559
=== Successful image creation (defaults) ===
560
561
-Testing:
562
-QMP_VERSION
563
-{"return": {}}
564
-{"return": {}}
565
-{"return": {}}
566
-{"return": {}}
567
-{"return": {}}
568
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
569
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.vhdx'}}}
570
+{u'return': {}}
571
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
572
+{u'return': {}}
573
+
574
+{'execute': 'blockdev-add', 'arguments': {'node_name': 'imgfile', 'driver': 'file', 'filename': 'TEST_DIR/PID-t.vhdx'}}
575
+{u'return': {}}
576
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'file': 'imgfile', 'size': 134217728}}}
577
+{u'return': {}}
578
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
579
+{u'return': {}}
580
581
-image: TEST_DIR/t.IMGFMT
582
+image: TEST_IMG
583
file format: IMGFMT
584
virtual size: 128M (134217728 bytes)
585
+cluster_size: 8388608
586
587
=== Successful image creation (explicit defaults) ===
588
589
-Testing:
590
-QMP_VERSION
591
-{"return": {}}
592
-{"return": {}}
593
-{"return": {}}
594
-{"return": {}}
595
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
596
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.vhdx'}}}
597
+{u'return': {}}
598
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
599
+{u'return': {}}
600
601
-image: TEST_DIR/t.IMGFMT
602
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'block-size': 8388608, 'driver': 'vhdx', 'subformat': 'dynamic', 'log-size': 1048576, 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.vhdx'}, 'block-state-zero': True, 'size': 67108864}}}
603
+{u'return': {}}
604
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
605
+{u'return': {}}
606
+
607
+image: TEST_IMG
608
file format: IMGFMT
609
virtual size: 64M (67108864 bytes)
610
+cluster_size: 8388608
611
612
=== Successful image creation (with non-default options) ===
613
614
-Testing:
615
-QMP_VERSION
616
-{"return": {}}
617
-{"return": {}}
618
-{"return": {}}
619
-{"return": {}}
620
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
621
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.vhdx'}}}
622
+{u'return': {}}
623
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
624
+{u'return': {}}
625
+
626
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'block-size': 268435456, 'driver': 'vhdx', 'subformat': 'fixed', 'log-size': 8388608, 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.vhdx'}, 'block-state-zero': False, 'size': 33554432}}}
627
+{u'return': {}}
628
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
629
+{u'return': {}}
630
631
-image: TEST_DIR/t.IMGFMT
632
+image: TEST_IMG
633
file format: IMGFMT
634
virtual size: 32M (33554432 bytes)
635
+cluster_size: 268435456
636
637
=== Invalid BlockdevRef ===
638
639
-Testing:
640
-QMP_VERSION
641
-{"return": {}}
642
-{"error": {"class": "GenericError", "desc": "Cannot find device=this doesn't exist nor node_name=this doesn't exist"}}
643
-{"return": {}}
644
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
645
-
646
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'file': "this doesn't exist", 'size': 33554432}}}
647
+{u'return': {}}
648
+Job failed: Cannot find device=this doesn't exist nor node_name=this doesn't exist
649
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
650
+{u'return': {}}
651
652
=== Zero size ===
653
654
-Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0
655
-QMP_VERSION
656
-{"return": {}}
657
-{"return": {}}
658
-{"return": {}}
659
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
660
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'file': 'node0', 'size': 0}}}
661
+{u'return': {}}
662
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
663
+{u'return': {}}
664
665
-image: TEST_DIR/t.IMGFMT
666
+image: TEST_IMG
667
file format: IMGFMT
668
virtual size: 0 (0 bytes)
669
+cluster_size: 8388608
670
671
=== Maximum size ===
672
673
-Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0
674
-QMP_VERSION
675
-{"return": {}}
676
-{"return": {}}
677
-{"return": {}}
678
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
679
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'file': 'node0', 'size': 70368744177664}}}
680
+{u'return': {}}
681
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
682
+{u'return': {}}
683
684
-image: TEST_DIR/t.IMGFMT
685
+image: TEST_IMG
686
file format: IMGFMT
687
virtual size: 64T (70368744177664 bytes)
688
+cluster_size: 67108864
689
690
=== Invalid sizes ===
691
692
-Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0
693
-QMP_VERSION
694
-{"return": {}}
695
-{"error": {"class": "GenericError", "desc": "Image size too large; max of 64TB"}}
696
-{"error": {"class": "GenericError", "desc": "Image size too large; max of 64TB"}}
697
-{"error": {"class": "GenericError", "desc": "Image size too large; max of 64TB"}}
698
-{"error": {"class": "GenericError", "desc": "Image size too large; max of 64TB"}}
699
-{"return": {}}
700
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
701
-
702
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'file': 'node0', 'size': 18446744073709551104L}}}
703
+{u'return': {}}
704
+Job failed: Image size too large; max of 64TB
705
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
706
+{u'return': {}}
707
+
708
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'file': 'node0', 'size': 9223372036854775808L}}}
709
+{u'return': {}}
710
+Job failed: Image size too large; max of 64TB
711
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
712
+{u'return': {}}
713
+
714
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'file': 'node0', 'size': 9223372036854775296}}}
715
+{u'return': {}}
716
+Job failed: Image size too large; max of 64TB
717
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
718
+{u'return': {}}
719
+
720
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'file': 'node0', 'size': 70368744177665}}}
721
+{u'return': {}}
722
+Job failed: Image size too large; max of 64TB
723
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
724
+{u'return': {}}
725
726
=== Invalid block size ===
727
728
-Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0
729
-QMP_VERSION
730
-{"return": {}}
731
-{"error": {"class": "GenericError", "desc": "Block size must be a multiple of 1 MB"}}
732
-{"error": {"class": "GenericError", "desc": "Block size must be a multiple of 1 MB"}}
733
-{"error": {"class": "GenericError", "desc": "Block size must be a power of two"}}
734
-{"error": {"class": "GenericError", "desc": "Block size must not exceed 268435456"}}
735
-{"error": {"class": "GenericError", "desc": "Block size must be a multiple of 1 MB"}}
736
-{"return": {}}
737
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
738
-
739
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'block-size': 1234567, 'file': 'node0', 'size': 67108864}}}
740
+{u'return': {}}
741
+Job failed: Block size must be a multiple of 1 MB
742
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
743
+{u'return': {}}
744
+
745
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'block-size': 128, 'file': 'node0', 'size': 67108864}}}
746
+{u'return': {}}
747
+Job failed: Block size must be a multiple of 1 MB
748
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
749
+{u'return': {}}
750
+
751
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'block-size': 3145728, 'file': 'node0', 'size': 67108864}}}
752
+{u'return': {}}
753
+Job failed: Block size must be a power of two
754
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
755
+{u'return': {}}
756
+
757
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'block-size': 536870912, 'file': 'node0', 'size': 67108864}}}
758
+{u'return': {}}
759
+Job failed: Block size must not exceed 268435456
760
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
761
+{u'return': {}}
762
+
763
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'block-size': 0, 'file': 'node0', 'size': 67108864}}}
764
+{u'return': {}}
765
+Job failed: Block size must be a multiple of 1 MB
766
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
767
+{u'return': {}}
768
769
=== Invalid log size ===
770
771
-Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0
772
-QMP_VERSION
773
-{"return": {}}
774
-{"error": {"class": "GenericError", "desc": "Log size must be a multiple of 1 MB"}}
775
-{"error": {"class": "GenericError", "desc": "Log size must be a multiple of 1 MB"}}
776
-{"error": {"class": "GenericError", "desc": "Log size must be smaller than 4 GB"}}
777
-{"error": {"class": "GenericError", "desc": "Log size must be a multiple of 1 MB"}}
778
-{"return": {}}
779
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
780
-
781
-*** done
782
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'log-size': 1234567, 'driver': 'vhdx', 'file': 'node0', 'size': 67108864}}}
783
+{u'return': {}}
784
+Job failed: Log size must be a multiple of 1 MB
785
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
786
+{u'return': {}}
787
+
788
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'log-size': 128, 'driver': 'vhdx', 'file': 'node0', 'size': 67108864}}}
789
+{u'return': {}}
790
+Job failed: Log size must be a multiple of 1 MB
791
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
792
+{u'return': {}}
793
+
794
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'log-size': 4294967296, 'driver': 'vhdx', 'file': 'node0', 'size': 67108864}}}
795
+{u'return': {}}
796
+Job failed: Log size must be smaller than 4 GB
797
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
798
+{u'return': {}}
799
+
800
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'log-size': 0, 'driver': 'vhdx', 'file': 'node0', 'size': 67108864}}}
801
+{u'return': {}}
802
+Job failed: Log size must be a multiple of 1 MB
803
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
804
+{u'return': {}}
805
+
806
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
807
index XXXXXXX..XXXXXXX 100644
808
--- a/tests/qemu-iotests/group
809
+++ b/tests/qemu-iotests/group
810
@@ -XXX,XX +XXX,XX @@
811
210 rw auto
812
211 rw auto quick
813
212 rw auto quick
814
-# TODO The following commented out tests need to be reworked to work
815
-# with the x-blockdev-create job
816
-#213 rw auto quick
817
+213 rw auto quick
818
214 rw auto
819
215 rw auto quick
820
216 rw auto quick
821
--
55
--
822
2.13.6
56
2.19.1
823
57
824
58
diff view generated by jsdifflib
New patch
1
From: Alberto Garcia <berto@igalia.com>
1
2
3
The blkverify mode of Quorum can only be enabled if the number of
4
children is exactly two and the value of vote-threshold is also two.
5
6
If the user tries to enable it but the other settings are incorrect
7
then QEMU simply prints an error message to stderr and carries on
8
disabling the blkverify setting.
9
10
This patch makes quorum_open() fail and return an error in this case.
11
12
Signed-off-by: Alberto Garcia <berto@igalia.com>
13
Reported-by: Markus Armbruster <armbru@redhat.com>
14
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
15
---
16
block/quorum.c | 13 ++++++-------
17
1 file changed, 6 insertions(+), 7 deletions(-)
18
19
diff --git a/block/quorum.c b/block/quorum.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/block/quorum.c
22
+++ b/block/quorum.c
23
@@ -XXX,XX +XXX,XX @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
24
s->read_pattern = ret;
25
26
if (s->read_pattern == QUORUM_READ_PATTERN_QUORUM) {
27
- /* is the driver in blkverify mode */
28
- if (qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false) &&
29
- s->num_children == 2 && s->threshold == 2) {
30
- s->is_blkverify = true;
31
- } else if (qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false)) {
32
- fprintf(stderr, "blkverify mode is set by setting blkverify=on "
33
- "and using two files with vote_threshold=2\n");
34
+ s->is_blkverify = qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false);
35
+ if (s->is_blkverify && (s->num_children != 2 || s->threshold != 2)) {
36
+ error_setg(&local_err, "blkverify=on can only be set if there are "
37
+ "exactly two files and vote-threshold is 2");
38
+ ret = -EINVAL;
39
+ goto exit;
40
}
41
42
s->rewrite_corrupted = qemu_opt_get_bool(opts, QUORUM_OPT_REWRITE,
43
--
44
2.19.1
45
46
diff view generated by jsdifflib
New patch
1
From: Alberto Garcia <berto@igalia.com>
1
2
3
Signed-off-by: Alberto Garcia <berto@igalia.com>
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
5
---
6
tests/qemu-iotests/081 | 30 ++++++++++++++++++++++++++++++
7
tests/qemu-iotests/081.out | 16 ++++++++++++++++
8
2 files changed, 46 insertions(+)
9
10
diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081
11
index XXXXXXX..XXXXXXX 100755
12
--- a/tests/qemu-iotests/081
13
+++ b/tests/qemu-iotests/081
14
@@ -XXX,XX +XXX,XX @@ echo "== checking that quorum is broken =="
15
16
$QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io
17
18
+echo
19
+echo "== checking the blkverify mode with broken content =="
20
+
21
+quorum="driver=raw,file.driver=quorum,file.vote-threshold=2,file.blkverify=on"
22
+quorum="$quorum,file.children.0.file.filename=$TEST_DIR/1.raw"
23
+quorum="$quorum,file.children.1.file.filename=$TEST_DIR/2.raw"
24
+quorum="$quorum,file.children.0.driver=raw"
25
+quorum="$quorum,file.children.1.driver=raw"
26
+
27
+$QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io
28
+
29
+echo
30
+echo "== writing the same data to both files =="
31
+
32
+$QEMU_IO -c "write -P 0x32 0 $size" "$TEST_DIR/1.raw" | _filter_qemu_io
33
+$QEMU_IO -c "write -P 0x32 0 $size" "$TEST_DIR/2.raw" | _filter_qemu_io
34
+
35
+echo
36
+echo "== checking the blkverify mode with valid content =="
37
+
38
+$QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io
39
+
40
+echo
41
+echo "== checking the blkverify mode with invalid settings =="
42
+
43
+quorum="$quorum,file.children.2.file.filename=$TEST_DIR/3.raw"
44
+quorum="$quorum,file.children.2.driver=raw"
45
+
46
+$QEMU_IO -c "open -o $quorum" | _filter_qemu_io
47
+
48
# success, all done
49
echo "*** done"
50
rm -f $seq.full
51
diff --git a/tests/qemu-iotests/081.out b/tests/qemu-iotests/081.out
52
index XXXXXXX..XXXXXXX 100644
53
--- a/tests/qemu-iotests/081.out
54
+++ b/tests/qemu-iotests/081.out
55
@@ -XXX,XX +XXX,XX @@ wrote 10485760/10485760 bytes at offset 0
56
57
== checking that quorum is broken ==
58
read failed: Input/output error
59
+
60
+== checking the blkverify mode with broken content ==
61
+quorum: offset=0 bytes=10485760 contents mismatch at offset 0
62
+
63
+== writing the same data to both files ==
64
+wrote 10485760/10485760 bytes at offset 0
65
+10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
66
+wrote 10485760/10485760 bytes at offset 0
67
+10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
68
+
69
+== checking the blkverify mode with valid content ==
70
+read 10485760/10485760 bytes at offset 0
71
+10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
72
+
73
+== checking the blkverify mode with invalid settings ==
74
+can't open: blkverify=on can only be set if there are exactly two files and vote-threshold is 2
75
*** done
76
--
77
2.19.1
78
79
diff view generated by jsdifflib
1
This changes the x-blockdev-create QMP command so that it doesn't block
1
From: Alberto Garcia <berto@igalia.com>
2
the monitor and the main loop any more, but starts a background job that
3
performs the image creation.
4
2
5
The basic job as implemented here is all that is necessary to make image
3
The blkverify mode of Quorum only works when the number of children is
6
creation asynchronous and to provide a QMP interface that can be marked
4
exactly two, so any attempt to add a new one must return an error.
7
stable, but it still lacks a few features that jobs usually provide: The
8
job will ignore pause commands and it doesn't publish more than very
9
basic progress yet (total-progress is 1 and current-progress advances
10
from 0 to 1 when the driver callbacks returns). These features can be
11
added later without breaking compatibility.
12
5
6
quorum_del_child() on the other hand doesn't need any additional check
7
because decreasing the number of children would make it go under the
8
vote threshold.
9
10
Signed-off-by: Alberto Garcia <berto@igalia.com>
11
Reported-by: Kevin Wolf <kwolf@redhat.com>
13
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14
Reviewed-by: Max Reitz <mreitz@redhat.com>
15
Reviewed-by: Jeff Cody <jcody@redhat.com>
16
---
13
---
17
qapi/block-core.json | 14 ++++++----
14
block/quorum.c | 8 ++++++++
18
qapi/job.json | 4 ++-
15
1 file changed, 8 insertions(+)
19
block/create.c | 67 +++++++++++++++++++++++++++++++++---------------
20
tests/qemu-iotests/group | 14 +++++-----
21
4 files changed, 66 insertions(+), 33 deletions(-)
22
16
23
diff --git a/qapi/block-core.json b/qapi/block-core.json
17
diff --git a/block/quorum.c b/block/quorum.c
24
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
25
--- a/qapi/block-core.json
19
--- a/block/quorum.c
26
+++ b/qapi/block-core.json
20
+++ b/block/quorum.c
27
@@ -XXX,XX +XXX,XX @@
21
@@ -XXX,XX +XXX,XX @@ static void quorum_add_child(BlockDriverState *bs, BlockDriverState *child_bs,
28
##
22
char indexstr[32];
29
# @x-blockdev-create:
30
#
31
-# Create an image format on a given node.
32
-# TODO Replace with something asynchronous (block job?)
33
+# Starts a job to create an image format on a given node. The job is
34
+# automatically finalized, but a manual job-dismiss is required.
35
#
36
-# Since: 2.12
37
+# @job-id: Identifier for the newly created job.
38
+#
39
+# @options: Options for the image creation.
40
+#
41
+# Since: 3.0
42
##
43
{ 'command': 'x-blockdev-create',
44
- 'data': 'BlockdevCreateOptions',
45
- 'boxed': true }
46
+ 'data': { 'job-id': 'str',
47
+ 'options': 'BlockdevCreateOptions' } }
48
49
##
50
# @blockdev-open-tray:
51
diff --git a/qapi/job.json b/qapi/job.json
52
index XXXXXXX..XXXXXXX 100644
53
--- a/qapi/job.json
54
+++ b/qapi/job.json
55
@@ -XXX,XX +XXX,XX @@
56
#
57
# @backup: drive backup job type, see "drive-backup"
58
#
59
+# @create: image creation job type, see "x-blockdev-create" (since 3.0)
60
+#
61
# Since: 1.7
62
##
63
{ 'enum': 'JobType',
64
- 'data': ['commit', 'stream', 'mirror', 'backup'] }
65
+ 'data': ['commit', 'stream', 'mirror', 'backup', 'create'] }
66
67
##
68
# @JobStatus:
69
diff --git a/block/create.c b/block/create.c
70
index XXXXXXX..XXXXXXX 100644
71
--- a/block/create.c
72
+++ b/block/create.c
73
@@ -XXX,XX +XXX,XX @@
74
75
#include "qemu/osdep.h"
76
#include "block/block_int.h"
77
+#include "qemu/job.h"
78
#include "qapi/qapi-commands-block-core.h"
79
+#include "qapi/qapi-visit-block-core.h"
80
+#include "qapi/clone-visitor.h"
81
#include "qapi/error.h"
82
83
-typedef struct BlockdevCreateCo {
84
+typedef struct BlockdevCreateJob {
85
+ Job common;
86
BlockDriver *drv;
87
BlockdevCreateOptions *opts;
88
int ret;
23
int ret;
89
- Error **errp;
24
90
-} BlockdevCreateCo;
25
+ if (s->is_blkverify) {
91
+ Error *err;
26
+ error_setg(errp, "Cannot add a child to a quorum in blkverify mode");
92
+} BlockdevCreateJob;
27
+ return;
93
28
+ }
94
-static void coroutine_fn bdrv_co_create_co_entry(void *opaque)
95
+static void blockdev_create_complete(Job *job, void *opaque)
96
{
97
- BlockdevCreateCo *cco = opaque;
98
- cco->ret = cco->drv->bdrv_co_create(cco->opts, cco->errp);
99
+ BlockdevCreateJob *s = container_of(job, BlockdevCreateJob, common);
100
+
29
+
101
+ job_completed(job, s->ret, s->err);
30
assert(s->num_children <= INT_MAX / sizeof(BdrvChild *));
102
}
31
if (s->num_children == INT_MAX / sizeof(BdrvChild *) ||
103
32
s->next_child_index == UINT_MAX) {
104
-void qmp_x_blockdev_create(BlockdevCreateOptions *options, Error **errp)
33
@@ -XXX,XX +XXX,XX @@ static void quorum_del_child(BlockDriverState *bs, BdrvChild *child,
105
+static void coroutine_fn blockdev_create_run(void *opaque)
106
{
107
+ BlockdevCreateJob *s = opaque;
108
+
109
+ job_progress_set_remaining(&s->common, 1);
110
+ s->ret = s->drv->bdrv_co_create(s->opts, &s->err);
111
+ job_progress_update(&s->common, 1);
112
+
113
+ qapi_free_BlockdevCreateOptions(s->opts);
114
+ job_defer_to_main_loop(&s->common, blockdev_create_complete, NULL);
115
+}
116
+
117
+static const JobDriver blockdev_create_job_driver = {
118
+ .instance_size = sizeof(BlockdevCreateJob),
119
+ .job_type = JOB_TYPE_CREATE,
120
+ .start = blockdev_create_run,
121
+};
122
+
123
+void qmp_x_blockdev_create(const char *job_id, BlockdevCreateOptions *options,
124
+ Error **errp)
125
+{
126
+ BlockdevCreateJob *s;
127
const char *fmt = BlockdevDriver_str(options->driver);
128
BlockDriver *drv = bdrv_find_format(fmt);
129
- Coroutine *co;
130
- BlockdevCreateCo cco;
131
132
/* If the driver is in the schema, we know that it exists. But it may not
133
* be whitelisted. */
134
@@ -XXX,XX +XXX,XX @@ void qmp_x_blockdev_create(BlockdevCreateOptions *options, Error **errp)
135
return;
34
return;
136
}
35
}
137
36
138
- /* Call callback if it exists */
37
+ /* We know now that num_children > threshold, so blkverify must be false */
139
+ /* Error out if the driver doesn't support .bdrv_co_create */
38
+ assert(!s->is_blkverify);
140
if (!drv->bdrv_co_create) {
141
error_setg(errp, "Driver does not support blockdev-create");
142
return;
143
}
144
145
- cco = (BlockdevCreateCo) {
146
- .drv = drv,
147
- .opts = options,
148
- .ret = -EINPROGRESS,
149
- .errp = errp,
150
- };
151
-
152
- co = qemu_coroutine_create(bdrv_co_create_co_entry, &cco);
153
- qemu_coroutine_enter(co);
154
- while (cco.ret == -EINPROGRESS) {
155
- aio_poll(qemu_get_aio_context(), true);
156
+ /* Create the block job */
157
+ /* TODO Running in the main context. Block drivers need to error out or add
158
+ * locking when they use a BDS in a different AioContext. */
159
+ s = job_create(job_id, &blockdev_create_job_driver, NULL,
160
+ qemu_get_aio_context(), JOB_DEFAULT | JOB_MANUAL_DISMISS,
161
+ NULL, NULL, errp);
162
+ if (!s) {
163
+ return;
164
}
165
+
39
+
166
+ s->drv = drv,
40
bdrv_drained_begin(bs);
167
+ s->opts = QAPI_CLONE(BlockdevCreateOptions, options),
41
168
+
42
/* We can safely remove this child now */
169
+ job_start(&s->common);
170
}
171
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
172
index XXXXXXX..XXXXXXX 100644
173
--- a/tests/qemu-iotests/group
174
+++ b/tests/qemu-iotests/group
175
@@ -XXX,XX +XXX,XX @@
176
203 rw auto migration
177
204 rw auto quick
178
205 rw auto quick
179
-206 rw auto
180
-207 rw auto
181
+# TODO The following commented out tests need to be reworked to work
182
+# with the x-blockdev-create job
183
+#206 rw auto
184
+#207 rw auto
185
208 rw auto quick
186
209 rw auto quick
187
-210 rw auto
188
-211 rw auto quick
189
-212 rw auto quick
190
-213 rw auto quick
191
+#210 rw auto
192
+#211 rw auto quick
193
+#212 rw auto quick
194
+#213 rw auto quick
195
214 rw auto
196
215 rw auto quick
197
216 rw auto quick
198
--
43
--
199
2.13.6
44
2.19.1
200
45
201
46
diff view generated by jsdifflib
New patch
1
From: Alberto Garcia <berto@igalia.com>
1
2
3
This patch tests that you can add and remove drives from a Quorum
4
using the x-blockdev-change command.
5
6
Signed-off-by: Alberto Garcia <berto@igalia.com>
7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
---
9
tests/qemu-iotests/081 | 86 ++++++++++++++++++++++++++++++++++++++
10
tests/qemu-iotests/081.out | 54 ++++++++++++++++++++++++
11
2 files changed, 140 insertions(+)
12
13
diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081
14
index XXXXXXX..XXXXXXX 100755
15
--- a/tests/qemu-iotests/081
16
+++ b/tests/qemu-iotests/081
17
@@ -XXX,XX +XXX,XX @@ quorum="$quorum,file.children.2.driver=raw"
18
19
$QEMU_IO -c "open -o $quorum" | _filter_qemu_io
20
21
+echo
22
+echo "== dynamically adding a child to a quorum =="
23
+
24
+for verify in false true; do
25
+ run_qemu <<EOF
26
+ { "execute": "qmp_capabilities" }
27
+ { "execute": "blockdev-add",
28
+ "arguments": {
29
+ "driver": "quorum",
30
+ "node-name": "drive0-quorum",
31
+ "vote-threshold": 2,
32
+ "blkverify": ${verify},
33
+ "children": [
34
+ {
35
+ "driver": "$IMGFMT",
36
+ "file": {
37
+ "driver": "file",
38
+ "filename": "$TEST_DIR/1.raw"
39
+ }
40
+ },
41
+ {
42
+ "driver": "$IMGFMT",
43
+ "file": {
44
+ "driver": "file",
45
+ "filename": "$TEST_DIR/2.raw"
46
+ }
47
+ }
48
+ ]
49
+ }
50
+ }
51
+ { "execute": "blockdev-add",
52
+ "arguments": {
53
+ "node-name": "drive3",
54
+ "driver": "$IMGFMT",
55
+ "file": {
56
+ "driver": "file",
57
+ "filename": "$TEST_DIR/2.raw"
58
+ }
59
+ }
60
+ }
61
+ { "execute": "x-blockdev-change",
62
+ "arguments": { "parent": "drive0-quorum",
63
+ "node": "drive3" } }
64
+ { "execute": "quit" }
65
+EOF
66
+done
67
+
68
+echo
69
+echo "== dynamically removing a child from a quorum =="
70
+
71
+for verify in false true; do
72
+ for vote_threshold in 1 2; do
73
+ run_qemu <<EOF
74
+ { "execute": "qmp_capabilities" }
75
+ { "execute": "blockdev-add",
76
+ "arguments": {
77
+ "driver": "quorum",
78
+ "node-name": "drive0-quorum",
79
+ "vote-threshold": ${vote_threshold},
80
+ "blkverify": ${verify},
81
+ "children": [
82
+ {
83
+ "driver": "$IMGFMT",
84
+ "file": {
85
+ "driver": "file",
86
+ "filename": "$TEST_DIR/1.raw"
87
+ }
88
+ },
89
+ {
90
+ "driver": "$IMGFMT",
91
+ "file": {
92
+ "driver": "file",
93
+ "filename": "$TEST_DIR/2.raw"
94
+ }
95
+ }
96
+ ]
97
+ }
98
+ }
99
+ { "execute": "x-blockdev-change",
100
+ "arguments": { "parent": "drive0-quorum",
101
+ "child": "children.1" } }
102
+ { "execute": "quit" }
103
+EOF
104
+ done
105
+done
106
+
107
# success, all done
108
echo "*** done"
109
rm -f $seq.full
110
diff --git a/tests/qemu-iotests/081.out b/tests/qemu-iotests/081.out
111
index XXXXXXX..XXXXXXX 100644
112
--- a/tests/qemu-iotests/081.out
113
+++ b/tests/qemu-iotests/081.out
114
@@ -XXX,XX +XXX,XX @@ read 10485760/10485760 bytes at offset 0
115
116
== checking the blkverify mode with invalid settings ==
117
can't open: blkverify=on can only be set if there are exactly two files and vote-threshold is 2
118
+
119
+== dynamically adding a child to a quorum ==
120
+Testing:
121
+QMP_VERSION
122
+{"return": {}}
123
+{"return": {}}
124
+{"return": {}}
125
+{"return": {}}
126
+{"return": {}}
127
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
128
+
129
+Testing:
130
+QMP_VERSION
131
+{"return": {}}
132
+{"return": {}}
133
+{"return": {}}
134
+{"error": {"class": "GenericError", "desc": "Cannot add a child to a quorum in blkverify mode"}}
135
+{"return": {}}
136
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
137
+
138
+
139
+== dynamically removing a child from a quorum ==
140
+Testing:
141
+QMP_VERSION
142
+{"return": {}}
143
+{"return": {}}
144
+{"return": {}}
145
+{"return": {}}
146
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
147
+
148
+Testing:
149
+QMP_VERSION
150
+{"return": {}}
151
+{"return": {}}
152
+{"error": {"class": "GenericError", "desc": "The number of children cannot be lower than the vote threshold 2"}}
153
+{"return": {}}
154
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
155
+
156
+Testing:
157
+QMP_VERSION
158
+{"return": {}}
159
+{"error": {"class": "GenericError", "desc": "blkverify=on can only be set if there are exactly two files and vote-threshold is 2"}}
160
+{"error": {"class": "GenericError", "desc": "Cannot find device=drive0-quorum nor node_name=drive0-quorum"}}
161
+{"return": {}}
162
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
163
+
164
+Testing:
165
+QMP_VERSION
166
+{"return": {}}
167
+{"return": {}}
168
+{"error": {"class": "GenericError", "desc": "The number of children cannot be lower than the vote threshold 2"}}
169
+{"return": {}}
170
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
171
+
172
*** done
173
--
174
2.19.1
175
176
diff view generated by jsdifflib
1
Add an iotests.py function that runs a job and only returns when it is
1
To fully change the read-only state of a node, we must not only change
2
destroyed. An error is logged when the job failed and job-finalize and
2
bs->read_only, but also update bs->open_flags.
3
job-dismiss commands are issued if necessary.
4
3
5
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
6
Reviewed-by: Max Reitz <mreitz@redhat.com>
5
Reviewed-by: Eric Blake <eblake@redhat.com>
7
Reviewed-by: Jeff Cody <jcody@redhat.com>
6
Reviewed-by: Alberto Garcia <berto@igalia.com>
8
---
7
---
9
tests/qemu-iotests/iotests.py | 19 +++++++++++++++++++
8
block.c | 7 +++++++
10
1 file changed, 19 insertions(+)
9
1 file changed, 7 insertions(+)
11
10
12
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
11
diff --git a/block.c b/block.c
13
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
14
--- a/tests/qemu-iotests/iotests.py
13
--- a/block.c
15
+++ b/tests/qemu-iotests/iotests.py
14
+++ b/block.c
16
@@ -XXX,XX +XXX,XX @@ class VM(qtest.QEMUQtestMachine):
15
@@ -XXX,XX +XXX,XX @@ int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
17
log(str(result), filters)
16
}
18
return result
17
19
18
bs->read_only = read_only;
20
+ def run_job(self, job, auto_finalize=True, auto_dismiss=False):
21
+ while True:
22
+ for ev in self.get_qmp_events_filtered(wait=True):
23
+ if ev['event'] == 'JOB_STATUS_CHANGE':
24
+ status = ev['data']['status']
25
+ if status == 'aborting':
26
+ result = self.qmp('query-jobs')
27
+ for j in result['return']:
28
+ if j['id'] == job:
29
+ log('Job failed: %s' % (j['error']))
30
+ elif status == 'pending' and not auto_finalize:
31
+ self.qmp_log('job-finalize', id=job)
32
+ elif status == 'concluded' and not auto_dismiss:
33
+ self.qmp_log('job-dismiss', id=job)
34
+ elif status == 'null':
35
+ return
36
+ else:
37
+ iotests.log(ev)
38
+
19
+
39
20
+ if (read_only) {
40
index_re = re.compile(r'([^\[]+)\[([^\]]+)\]')
21
+ bs->open_flags &= ~BDRV_O_RDWR;
22
+ } else {
23
+ bs->open_flags |= BDRV_O_RDWR;
24
+ }
25
+
26
return 0;
27
}
41
28
42
--
29
--
43
2.13.6
30
2.19.1
44
31
45
32
diff view generated by jsdifflib
1
We're ready to declare the blockdev-create job stable. This renames the
1
If a management application builds the block graph node by node, the
2
corresponding QMP command from x-blockdev-create to blockdev-create.
2
protocol layer doesn't inherit its read-only option from the format
3
layer any more, so it must be set explicitly.
4
5
Backing files should work on read-only storage, but at the same time, a
6
block job like commit should be able to reopen them read-write if they
7
are on read-write storage. However, without option inheritance, reopen
8
only changes the read-only option for the root node (typically the
9
format layer), but not the protocol layer, so reopening fails (the
10
format layer wants to get write permissions, but the protocol layer is
11
still read-only).
12
13
A simple workaround for the problem in the management tool would be to
14
open the protocol layer always read-write and to make only the format
15
layer read-only for backing files. However, sometimes the file is
16
actually stored on read-only storage and we don't know whether the image
17
can be opened read-write (for example, for NBD it depends on the server
18
we're trying to connect to). This adds an option that makes QEMU try to
19
open the image read-write, but allows it to degrade to a read-only mode
20
without returning an error.
21
22
The documentation for this option is consciously phrased in a way that
23
allows QEMU to switch to a better model eventually: Instead of trying
24
when the image is first opened, making the read-only flag dynamic and
25
changing it automatically whenever the first BLK_PERM_WRITE user is
26
attached or the last one is detached would be much more useful
27
behaviour.
28
29
Unfortunately, this more useful behaviour is also a lot harder to
30
implement, and libvirt needs a solution now before it can switch to
31
-blockdev, so let's start with this easier approach for now.
32
33
Instead of adding a new auto-read-only option, turning the existing
34
read-only into an enum (with a bool alternate for compatibility) was
35
considered, but it complicated the implementation to the point that it
36
didn't seem to be worth it.
3
37
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
38
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
5
Reviewed-by: Max Reitz <mreitz@redhat.com>
39
Reviewed-by: Eric Blake <eblake@redhat.com>
6
Reviewed-by: Jeff Cody <jcody@redhat.com>
7
---
40
---
8
qapi/block-core.json | 4 ++--
41
qapi/block-core.json | 7 +++++++
9
qapi/job.json | 2 +-
42
include/block/block.h | 2 ++
10
block/create.c | 4 ++--
43
block.c | 17 +++++++++++++++++
11
tests/qemu-iotests/206 | 2 +-
44
block/vvfat.c | 1 +
12
tests/qemu-iotests/206.out | 54 +++++++++++++++++++++++-----------------------
45
blockdev.c | 2 +-
13
tests/qemu-iotests/207 | 2 +-
46
5 files changed, 28 insertions(+), 1 deletion(-)
14
tests/qemu-iotests/207.out | 18 ++++++++--------
15
tests/qemu-iotests/210 | 2 +-
16
tests/qemu-iotests/210.out | 18 ++++++++--------
17
tests/qemu-iotests/211 | 2 +-
18
tests/qemu-iotests/211.out | 24 ++++++++++-----------
19
tests/qemu-iotests/212 | 2 +-
20
tests/qemu-iotests/212.out | 42 ++++++++++++++++++------------------
21
tests/qemu-iotests/213 | 2 +-
22
tests/qemu-iotests/213.out | 44 ++++++++++++++++++-------------------
23
15 files changed, 111 insertions(+), 111 deletions(-)
24
47
25
diff --git a/qapi/block-core.json b/qapi/block-core.json
48
diff --git a/qapi/block-core.json b/qapi/block-core.json
26
index XXXXXXX..XXXXXXX 100644
49
index XXXXXXX..XXXXXXX 100644
27
--- a/qapi/block-core.json
50
--- a/qapi/block-core.json
28
+++ b/qapi/block-core.json
51
+++ b/qapi/block-core.json
29
@@ -XXX,XX +XXX,XX @@
52
@@ -XXX,XX +XXX,XX @@
30
} }
53
# either generally or in certain configurations. In this case,
31
54
# the default value does not work and the option must be
32
##
55
# specified explicitly.
33
-# @x-blockdev-create:
56
+# @auto-read-only: if true and @read-only is false, QEMU may automatically
34
+# @blockdev-create:
57
+# decide not to open the image read-write as requested, but
35
#
58
+# fall back to read-only instead (and switch between the modes
36
# Starts a job to create an image format on a given node. The job is
59
+# later), e.g. depending on whether the image file is writable
37
# automatically finalized, but a manual job-dismiss is required.
60
+# or whether a writing user is attached to the node
61
+# (default: false, since 3.1)
62
# @detect-zeroes: detect and optimize zero writes (Since 2.1)
63
# (default: off)
64
# @force-share: force share all permission on added nodes.
38
@@ -XXX,XX +XXX,XX @@
65
@@ -XXX,XX +XXX,XX @@
39
#
66
'*discard': 'BlockdevDiscardOptions',
40
# Since: 3.0
67
'*cache': 'BlockdevCacheOptions',
41
##
68
'*read-only': 'bool',
42
-{ 'command': 'x-blockdev-create',
69
+ '*auto-read-only': 'bool',
43
+{ 'command': 'blockdev-create',
70
'*force-share': 'bool',
44
'data': { 'job-id': 'str',
71
'*detect-zeroes': 'BlockdevDetectZeroesOptions' },
45
'options': 'BlockdevCreateOptions' } }
72
'discriminator': 'driver',
46
73
diff --git a/include/block/block.h b/include/block/block.h
47
diff --git a/qapi/job.json b/qapi/job.json
48
index XXXXXXX..XXXXXXX 100644
74
index XXXXXXX..XXXXXXX 100644
49
--- a/qapi/job.json
75
--- a/include/block/block.h
50
+++ b/qapi/job.json
76
+++ b/include/block/block.h
51
@@ -XXX,XX +XXX,XX @@
77
@@ -XXX,XX +XXX,XX @@ typedef struct HDGeometry {
52
#
78
select an appropriate protocol driver,
53
# @backup: drive backup job type, see "drive-backup"
79
ignoring the format layer */
54
#
80
#define BDRV_O_NO_IO 0x10000 /* don't initialize for I/O */
55
-# @create: image creation job type, see "x-blockdev-create" (since 3.0)
81
+#define BDRV_O_AUTO_RDONLY 0x20000 /* degrade to read-only if opening read-write fails */
56
+# @create: image creation job type, see "blockdev-create" (since 3.0)
82
57
#
83
#define BDRV_O_CACHE_MASK (BDRV_O_NOCACHE | BDRV_O_NO_FLUSH)
58
# Since: 1.7
84
59
##
85
@@ -XXX,XX +XXX,XX @@ typedef struct HDGeometry {
60
diff --git a/block/create.c b/block/create.c
86
#define BDRV_OPT_CACHE_DIRECT "cache.direct"
87
#define BDRV_OPT_CACHE_NO_FLUSH "cache.no-flush"
88
#define BDRV_OPT_READ_ONLY "read-only"
89
+#define BDRV_OPT_AUTO_READ_ONLY "auto-read-only"
90
#define BDRV_OPT_DISCARD "discard"
91
#define BDRV_OPT_FORCE_SHARE "force-share"
92
93
diff --git a/block.c b/block.c
61
index XXXXXXX..XXXXXXX 100644
94
index XXXXXXX..XXXXXXX 100644
62
--- a/block/create.c
95
--- a/block.c
63
+++ b/block/create.c
96
+++ b/block.c
64
@@ -XXX,XX +XXX,XX @@ static const JobDriver blockdev_create_job_driver = {
97
@@ -XXX,XX +XXX,XX @@ static void bdrv_inherited_options(int *child_flags, QDict *child_options,
65
.start = blockdev_create_run,
98
66
};
99
/* Inherit the read-only option from the parent if it's not set */
67
100
qdict_copy_default(child_options, parent_options, BDRV_OPT_READ_ONLY);
68
-void qmp_x_blockdev_create(const char *job_id, BlockdevCreateOptions *options,
101
+ qdict_copy_default(child_options, parent_options, BDRV_OPT_AUTO_READ_ONLY);
69
- Error **errp)
102
70
+void qmp_blockdev_create(const char *job_id, BlockdevCreateOptions *options,
103
/* Our block drivers take care to send flushes and respect unmap policy,
71
+ Error **errp)
104
* so we can default to enable both on lower layers regardless of the
105
@@ -XXX,XX +XXX,XX @@ static void bdrv_backing_options(int *child_flags, QDict *child_options,
106
107
/* backing files always opened read-only */
108
qdict_set_default_str(child_options, BDRV_OPT_READ_ONLY, "on");
109
+ qdict_set_default_str(child_options, BDRV_OPT_AUTO_READ_ONLY, "off");
110
flags &= ~BDRV_O_COPY_ON_READ;
111
112
/* snapshot=on is handled on the top layer */
113
@@ -XXX,XX +XXX,XX @@ static void update_flags_from_options(int *flags, QemuOpts *opts)
114
*flags |= BDRV_O_RDWR;
115
}
116
117
+ assert(qemu_opt_find(opts, BDRV_OPT_AUTO_READ_ONLY));
118
+ if (qemu_opt_get_bool_del(opts, BDRV_OPT_AUTO_READ_ONLY, false)) {
119
+ *flags |= BDRV_O_AUTO_RDONLY;
120
+ }
121
}
122
123
static void update_options_from_flags(QDict *options, int flags)
124
@@ -XXX,XX +XXX,XX @@ static void update_options_from_flags(QDict *options, int flags)
125
if (!qdict_haskey(options, BDRV_OPT_READ_ONLY)) {
126
qdict_put_bool(options, BDRV_OPT_READ_ONLY, !(flags & BDRV_O_RDWR));
127
}
128
+ if (!qdict_haskey(options, BDRV_OPT_AUTO_READ_ONLY)) {
129
+ qdict_put_bool(options, BDRV_OPT_AUTO_READ_ONLY,
130
+ flags & BDRV_O_AUTO_RDONLY);
131
+ }
132
}
133
134
static void bdrv_assign_node_name(BlockDriverState *bs,
135
@@ -XXX,XX +XXX,XX @@ QemuOptsList bdrv_runtime_opts = {
136
.type = QEMU_OPT_BOOL,
137
.help = "Node is opened in read-only mode",
138
},
139
+ {
140
+ .name = BDRV_OPT_AUTO_READ_ONLY,
141
+ .type = QEMU_OPT_BOOL,
142
+ .help = "Node can become read-only if opening read-write fails",
143
+ },
144
{
145
.name = "detect-zeroes",
146
.type = QEMU_OPT_STRING,
147
@@ -XXX,XX +XXX,XX @@ BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp)
148
qdict_set_default_str(qdict, BDRV_OPT_CACHE_DIRECT, "off");
149
qdict_set_default_str(qdict, BDRV_OPT_CACHE_NO_FLUSH, "off");
150
qdict_set_default_str(qdict, BDRV_OPT_READ_ONLY, "off");
151
+ qdict_set_default_str(qdict, BDRV_OPT_AUTO_READ_ONLY, "off");
152
+
153
}
154
155
bs = bdrv_open_inherit(NULL, reference, qdict, 0, NULL, NULL, errp);
156
diff --git a/block/vvfat.c b/block/vvfat.c
157
index XXXXXXX..XXXXXXX 100644
158
--- a/block/vvfat.c
159
+++ b/block/vvfat.c
160
@@ -XXX,XX +XXX,XX @@ static void vvfat_qcow_options(int *child_flags, QDict *child_options,
161
int parent_flags, QDict *parent_options)
72
{
162
{
73
BlockdevCreateJob *s;
163
qdict_set_default_str(child_options, BDRV_OPT_READ_ONLY, "off");
74
const char *fmt = BlockdevDriver_str(options->driver);
164
+ qdict_set_default_str(child_options, BDRV_OPT_AUTO_READ_ONLY, "off");
75
diff --git a/tests/qemu-iotests/206 b/tests/qemu-iotests/206
165
qdict_set_default_str(child_options, BDRV_OPT_CACHE_NO_FLUSH, "on");
76
index XXXXXXX..XXXXXXX 100755
166
}
77
--- a/tests/qemu-iotests/206
167
78
+++ b/tests/qemu-iotests/206
168
diff --git a/blockdev.c b/blockdev.c
79
@@ -XXX,XX +XXX,XX @@ from iotests import imgfmt
80
iotests.verify_image_format(supported_fmts=['qcow2'])
81
82
def blockdev_create(vm, options):
83
- result = vm.qmp_log('x-blockdev-create', job_id='job0', options=options)
84
+ result = vm.qmp_log('blockdev-create', job_id='job0', options=options)
85
86
if 'return' in result:
87
assert result['return'] == {}
88
diff --git a/tests/qemu-iotests/206.out b/tests/qemu-iotests/206.out
89
index XXXXXXX..XXXXXXX 100644
169
index XXXXXXX..XXXXXXX 100644
90
--- a/tests/qemu-iotests/206.out
170
--- a/blockdev.c
91
+++ b/tests/qemu-iotests/206.out
171
+++ b/blockdev.c
92
@@ -XXX,XX +XXX,XX @@
172
@@ -XXX,XX +XXX,XX @@ void qmp_blockdev_change_medium(bool has_device, const char *device,
93
=== Successful image creation (defaults) ===
173
94
174
bdrv_flags = blk_get_open_flags_from_root_state(blk);
95
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}}}
175
bdrv_flags &= ~(BDRV_O_TEMPORARY | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING |
96
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}}}
176
- BDRV_O_PROTOCOL);
97
{u'return': {}}
177
+ BDRV_O_PROTOCOL | BDRV_O_AUTO_RDONLY);
98
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
178
99
{u'return': {}}
179
if (!has_read_only) {
100
180
read_only = BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN;
101
{'execute': 'blockdev-add', 'arguments': {'node_name': 'imgfile', 'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}}
102
{u'return': {}}
103
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'qcow2', 'file': 'imgfile', 'size': 134217728}}}
104
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'qcow2', 'file': 'imgfile', 'size': 134217728}}}
105
{u'return': {}}
106
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
107
{u'return': {}}
108
@@ -XXX,XX +XXX,XX @@ Format specific information:
109
110
=== Successful image creation (inline blockdev-add, explicit defaults) ===
111
112
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'nocow': False, 'preallocation': 'off', 'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}}}
113
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'nocow': False, 'preallocation': 'off', 'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}}}
114
{u'return': {}}
115
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
116
{u'return': {}}
117
118
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 65536, 'refcount-bits': 16, 'version': 'v3', 'preallocation': 'off', 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}, 'lazy-refcounts': False, 'driver': 'qcow2', 'size': 67108864}}}
119
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 65536, 'refcount-bits': 16, 'version': 'v3', 'preallocation': 'off', 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}, 'lazy-refcounts': False, 'driver': 'qcow2', 'size': 67108864}}}
120
{u'return': {}}
121
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
122
{u'return': {}}
123
@@ -XXX,XX +XXX,XX @@ Format specific information:
124
125
=== Successful image creation (v3 non-default options) ===
126
127
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'nocow': True, 'preallocation': 'falloc', 'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}}}
128
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'nocow': True, 'preallocation': 'falloc', 'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}}}
129
{u'return': {}}
130
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
131
{u'return': {}}
132
133
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 2097152, 'refcount-bits': 1, 'version': 'v3', 'preallocation': 'metadata', 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}, 'lazy-refcounts': True, 'driver': 'qcow2', 'size': 33554432}}}
134
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 2097152, 'refcount-bits': 1, 'version': 'v3', 'preallocation': 'metadata', 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}, 'lazy-refcounts': True, 'driver': 'qcow2', 'size': 33554432}}}
135
{u'return': {}}
136
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
137
{u'return': {}}
138
@@ -XXX,XX +XXX,XX @@ Format specific information:
139
140
=== Successful image creation (v2 non-default options) ===
141
142
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}}}
143
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}}}
144
{u'return': {}}
145
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
146
{u'return': {}}
147
148
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 512, 'backing-fmt': 'qcow2', 'driver': 'qcow2', 'version': 'v2', 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}, 'backing-file': 'TEST_DIR/PID-t.qcow2.base', 'size': 33554432}}}
149
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 512, 'backing-fmt': 'qcow2', 'driver': 'qcow2', 'version': 'v2', 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}, 'backing-file': 'TEST_DIR/PID-t.qcow2.base', 'size': 33554432}}}
150
{u'return': {}}
151
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
152
{u'return': {}}
153
@@ -XXX,XX +XXX,XX @@ Format specific information:
154
155
=== Successful image creation (encrypted) ===
156
157
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'encrypt': {'key-secret': 'keysec0', 'iter-time': 10, 'cipher-mode': 'ctr', 'ivgen-hash-alg': 'md5', 'cipher-alg': 'twofish-128', 'format': 'luks', 'ivgen-alg': 'plain64', 'hash-alg': 'sha1'}, 'driver': 'qcow2', 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}, 'size': 33554432}}}
158
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'encrypt': {'key-secret': 'keysec0', 'iter-time': 10, 'cipher-mode': 'ctr', 'ivgen-hash-alg': 'md5', 'cipher-alg': 'twofish-128', 'format': 'luks', 'ivgen-alg': 'plain64', 'hash-alg': 'sha1'}, 'driver': 'qcow2', 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}, 'size': 33554432}}}
159
{u'return': {}}
160
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
161
{u'return': {}}
162
@@ -XXX,XX +XXX,XX @@ Format specific information:
163
164
=== Invalid BlockdevRef ===
165
166
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'qcow2', 'file': "this doesn't exist", 'size': 33554432}}}
167
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'qcow2', 'file': "this doesn't exist", 'size': 33554432}}}
168
{u'return': {}}
169
Job failed: Cannot find device=this doesn't exist nor node_name=this doesn't exist
170
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
171
{u'return': {}}
172
173
=== Invalid sizes ===
174
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'qcow2', 'file': 'node0', 'size': 1234}}}
175
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'qcow2', 'file': 'node0', 'size': 1234}}}
176
{u'return': {}}
177
Job failed: Image size must be a multiple of 512 bytes
178
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
179
{u'return': {}}
180
181
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'qcow2', 'file': 'node0', 'size': 18446744073709551104L}}}
182
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'qcow2', 'file': 'node0', 'size': 18446744073709551104L}}}
183
{u'return': {}}
184
Job failed: Could not resize image: Image size cannot be negative
185
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
186
{u'return': {}}
187
188
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'qcow2', 'file': 'node0', 'size': 9223372036854775808L}}}
189
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'qcow2', 'file': 'node0', 'size': 9223372036854775808L}}}
190
{u'return': {}}
191
Job failed: Could not resize image: Image size cannot be negative
192
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
193
{u'return': {}}
194
195
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'qcow2', 'file': 'node0', 'size': 9223372036854775296}}}
196
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'qcow2', 'file': 'node0', 'size': 9223372036854775296}}}
197
{u'return': {}}
198
Job failed: Could not resize image: Failed to grow the L1 table: File too large
199
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
200
{u'return': {}}
201
202
=== Invalid version ===
203
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'version': 'v1', 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
204
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'version': 'v1', 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
205
{u'error': {u'class': u'GenericError', u'desc': u"Invalid parameter 'v1'"}}
206
207
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'lazy-refcounts': True, 'version': 'v2', 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
208
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'lazy-refcounts': True, 'version': 'v2', 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
209
{u'return': {}}
210
Job failed: Lazy refcounts only supported with compatibility level 1.1 and above (use version=v3 or greater)
211
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
212
{u'return': {}}
213
214
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'refcount-bits': 8, 'version': 'v2', 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
215
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'refcount-bits': 8, 'version': 'v2', 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
216
{u'return': {}}
217
Job failed: Different refcount widths than 16 bits require compatibility level 1.1 or above (use version=v3 or greater)
218
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
219
{u'return': {}}
220
221
=== Invalid backing file options ===
222
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'preallocation': 'full', 'driver': 'qcow2', 'backing-file': '/dev/null', 'file': 'node0', 'size': 67108864}}}
223
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'preallocation': 'full', 'driver': 'qcow2', 'backing-file': '/dev/null', 'file': 'node0', 'size': 67108864}}}
224
{u'return': {}}
225
Job failed: Backing file and preallocation cannot be used at the same time
226
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
227
{u'return': {}}
228
229
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'backing-fmt': 'qcow2', 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
230
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'backing-fmt': 'qcow2', 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
231
{u'return': {}}
232
Job failed: Backing format cannot be used without backing file
233
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
234
{u'return': {}}
235
236
=== Invalid cluster size ===
237
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 1234, 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
238
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 1234, 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
239
{u'return': {}}
240
Job failed: Cluster size must be a power of two between 512 and 2048k
241
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
242
{u'return': {}}
243
244
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 128, 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
245
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 128, 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
246
{u'return': {}}
247
Job failed: Cluster size must be a power of two between 512 and 2048k
248
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
249
{u'return': {}}
250
251
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 4194304, 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
252
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 4194304, 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
253
{u'return': {}}
254
Job failed: Cluster size must be a power of two between 512 and 2048k
255
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
256
{u'return': {}}
257
258
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 0, 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
259
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 0, 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
260
{u'return': {}}
261
Job failed: Cluster size must be a power of two between 512 and 2048k
262
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
263
{u'return': {}}
264
265
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 512, 'driver': 'qcow2', 'file': 'node0', 'size': 281474976710656}}}
266
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 512, 'driver': 'qcow2', 'file': 'node0', 'size': 281474976710656}}}
267
{u'return': {}}
268
Job failed: Could not resize image: Failed to grow the L1 table: File too large
269
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
270
{u'return': {}}
271
272
=== Invalid refcount width ===
273
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'refcount-bits': 128, 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
274
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'refcount-bits': 128, 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
275
{u'return': {}}
276
Job failed: Refcount width must be a power of two and may not exceed 64 bits
277
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
278
{u'return': {}}
279
280
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'refcount-bits': 0, 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
281
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'refcount-bits': 0, 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
282
{u'return': {}}
283
Job failed: Refcount width must be a power of two and may not exceed 64 bits
284
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
285
{u'return': {}}
286
287
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'refcount-bits': 7, 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
288
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'refcount-bits': 7, 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
289
{u'return': {}}
290
Job failed: Refcount width must be a power of two and may not exceed 64 bits
291
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
292
diff --git a/tests/qemu-iotests/207 b/tests/qemu-iotests/207
293
index XXXXXXX..XXXXXXX 100755
294
--- a/tests/qemu-iotests/207
295
+++ b/tests/qemu-iotests/207
296
@@ -XXX,XX +XXX,XX @@ def filter_hash(msg):
297
return re.sub("'hash': '[0-9a-f]+'", "'hash': HASH", msg)
298
299
def blockdev_create(vm, options):
300
- result = vm.qmp_log('x-blockdev-create', job_id='job0', options=options,
301
+ result = vm.qmp_log('blockdev-create', job_id='job0', options=options,
302
filters=[iotests.filter_testfiles, filter_hash])
303
304
if 'return' in result:
305
diff --git a/tests/qemu-iotests/207.out b/tests/qemu-iotests/207.out
306
index XXXXXXX..XXXXXXX 100644
307
--- a/tests/qemu-iotests/207.out
308
+++ b/tests/qemu-iotests/207.out
309
@@ -XXX,XX +XXX,XX @@
310
=== Successful image creation (defaults) ===
311
312
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'ssh', 'location': {'path': 'TEST_DIR/PID-t.img', 'server': {'host': '127.0.0.1', 'port': '22'}}, 'size': 4194304}}}
313
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'ssh', 'location': {'path': 'TEST_DIR/PID-t.img', 'server': {'host': '127.0.0.1', 'port': '22'}}, 'size': 4194304}}}
314
{u'return': {}}
315
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
316
{u'return': {}}
317
@@ -XXX,XX +XXX,XX @@ virtual size: 4.0M (4194304 bytes)
318
319
=== Test host-key-check options ===
320
321
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'ssh', 'location': {'path': 'TEST_DIR/PID-t.img', 'host-key-check': {'mode': 'none'}, 'server': {'host': '127.0.0.1', 'port': '22'}}, 'size': 8388608}}}
322
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'ssh', 'location': {'path': 'TEST_DIR/PID-t.img', 'host-key-check': {'mode': 'none'}, 'server': {'host': '127.0.0.1', 'port': '22'}}, 'size': 8388608}}}
323
{u'return': {}}
324
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
325
{u'return': {}}
326
@@ -XXX,XX +XXX,XX @@ image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "server.po
327
file format: IMGFMT
328
virtual size: 8.0M (8388608 bytes)
329
330
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'ssh', 'location': {'path': 'TEST_DIR/PID-t.img', 'host-key-check': {'mode': 'known_hosts'}, 'server': {'host': '127.0.0.1', 'port': '22'}}, 'size': 4194304}}}
331
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'ssh', 'location': {'path': 'TEST_DIR/PID-t.img', 'host-key-check': {'mode': 'known_hosts'}, 'server': {'host': '127.0.0.1', 'port': '22'}}, 'size': 4194304}}}
332
{u'return': {}}
333
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
334
{u'return': {}}
335
@@ -XXX,XX +XXX,XX @@ image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "server.po
336
file format: IMGFMT
337
virtual size: 4.0M (4194304 bytes)
338
339
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'ssh', 'location': {'path': 'TEST_DIR/PID-t.img', 'host-key-check': {'hash': 'wrong', 'type': 'md5', 'mode': 'hash'}, 'server': {'host': '127.0.0.1', 'port': '22'}}, 'size': 2097152}}}
340
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'ssh', 'location': {'path': 'TEST_DIR/PID-t.img', 'host-key-check': {'hash': 'wrong', 'type': 'md5', 'mode': 'hash'}, 'server': {'host': '127.0.0.1', 'port': '22'}}, 'size': 2097152}}}
341
{u'return': {}}
342
Job failed: remote host key does not match host_key_check 'wrong'
343
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
344
{u'return': {}}
345
346
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'ssh', 'location': {'path': 'TEST_DIR/PID-t.img', 'host-key-check': {'hash': HASH, 'type': 'md5', 'mode': 'hash'}, 'server': {'host': '127.0.0.1', 'port': '22'}}, 'size': 8388608}}}
347
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'ssh', 'location': {'path': 'TEST_DIR/PID-t.img', 'host-key-check': {'hash': HASH, 'type': 'md5', 'mode': 'hash'}, 'server': {'host': '127.0.0.1', 'port': '22'}}, 'size': 8388608}}}
348
{u'return': {}}
349
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
350
{u'return': {}}
351
@@ -XXX,XX +XXX,XX @@ image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "server.po
352
file format: IMGFMT
353
virtual size: 8.0M (8388608 bytes)
354
355
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'ssh', 'location': {'path': 'TEST_DIR/PID-t.img', 'host-key-check': {'hash': 'wrong', 'type': 'sha1', 'mode': 'hash'}, 'server': {'host': '127.0.0.1', 'port': '22'}}, 'size': 2097152}}}
356
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'ssh', 'location': {'path': 'TEST_DIR/PID-t.img', 'host-key-check': {'hash': 'wrong', 'type': 'sha1', 'mode': 'hash'}, 'server': {'host': '127.0.0.1', 'port': '22'}}, 'size': 2097152}}}
357
{u'return': {}}
358
Job failed: remote host key does not match host_key_check 'wrong'
359
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
360
{u'return': {}}
361
362
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'ssh', 'location': {'path': 'TEST_DIR/PID-t.img', 'host-key-check': {'hash': HASH, 'type': 'sha1', 'mode': 'hash'}, 'server': {'host': '127.0.0.1', 'port': '22'}}, 'size': 4194304}}}
363
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'ssh', 'location': {'path': 'TEST_DIR/PID-t.img', 'host-key-check': {'hash': HASH, 'type': 'sha1', 'mode': 'hash'}, 'server': {'host': '127.0.0.1', 'port': '22'}}, 'size': 4194304}}}
364
{u'return': {}}
365
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
366
{u'return': {}}
367
@@ -XXX,XX +XXX,XX @@ virtual size: 4.0M (4194304 bytes)
368
369
=== Invalid path and user ===
370
371
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'ssh', 'location': {'path': '/this/is/not/an/existing/path', 'host-key-check': {'mode': 'none'}, 'server': {'host': '127.0.0.1', 'port': '22'}}, 'size': 4194304}}}
372
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'ssh', 'location': {'path': '/this/is/not/an/existing/path', 'host-key-check': {'mode': 'none'}, 'server': {'host': '127.0.0.1', 'port': '22'}}, 'size': 4194304}}}
373
{u'return': {}}
374
Job failed: failed to open remote file '/this/is/not/an/existing/path': Failed opening remote file (libssh2 error code: -31)
375
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
376
{u'return': {}}
377
378
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'ssh', 'location': {'path': 'TEST_DIR/PID-t.img', 'host-key-check': {'mode': 'none'}, 'user': 'invalid user', 'server': {'host': '127.0.0.1', 'port': '22'}}, 'size': 4194304}}}
379
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'ssh', 'location': {'path': 'TEST_DIR/PID-t.img', 'host-key-check': {'mode': 'none'}, 'user': 'invalid user', 'server': {'host': '127.0.0.1', 'port': '22'}}, 'size': 4194304}}}
380
{u'return': {}}
381
Job failed: failed to authenticate using publickey authentication and the identities held by your ssh-agent
382
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
383
diff --git a/tests/qemu-iotests/210 b/tests/qemu-iotests/210
384
index XXXXXXX..XXXXXXX 100755
385
--- a/tests/qemu-iotests/210
386
+++ b/tests/qemu-iotests/210
387
@@ -XXX,XX +XXX,XX @@ iotests.verify_image_format(supported_fmts=['luks'])
388
iotests.verify_protocol(supported=['file'])
389
390
def blockdev_create(vm, options):
391
- result = vm.qmp_log('x-blockdev-create', job_id='job0', options=options)
392
+ result = vm.qmp_log('blockdev-create', job_id='job0', options=options)
393
394
if 'return' in result:
395
assert result['return'] == {}
396
diff --git a/tests/qemu-iotests/210.out b/tests/qemu-iotests/210.out
397
index XXXXXXX..XXXXXXX 100644
398
--- a/tests/qemu-iotests/210.out
399
+++ b/tests/qemu-iotests/210.out
400
@@ -XXX,XX +XXX,XX @@
401
=== Successful image creation (defaults) ===
402
403
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.luks'}}}
404
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.luks'}}}
405
{u'return': {}}
406
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
407
{u'return': {}}
408
409
{'execute': 'blockdev-add', 'arguments': {'node_name': 'imgfile', 'driver': 'file', 'filename': 'TEST_DIR/PID-t.luks'}}
410
{u'return': {}}
411
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'key-secret': 'keysec0', 'iter-time': 10, 'driver': 'luks', 'file': 'imgfile', 'size': 134217728}}}
412
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'key-secret': 'keysec0', 'iter-time': 10, 'driver': 'luks', 'file': 'imgfile', 'size': 134217728}}}
413
{u'return': {}}
414
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
415
{u'return': {}}
416
@@ -XXX,XX +XXX,XX @@ Format specific information:
417
418
=== Successful image creation (with non-default options) ===
419
420
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.luks'}}}
421
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.luks'}}}
422
{u'return': {}}
423
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
424
{u'return': {}}
425
426
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'key-secret': 'keysec0', 'hash-alg': 'sha1', 'cipher-mode': 'ctr', 'cipher-alg': 'twofish-128', 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.luks'}, 'iter-time': 10, 'ivgen-alg': 'plain64', 'ivgen-hash-alg': 'md5', 'driver': 'luks', 'size': 67108864}}}
427
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'key-secret': 'keysec0', 'hash-alg': 'sha1', 'cipher-mode': 'ctr', 'cipher-alg': 'twofish-128', 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.luks'}, 'iter-time': 10, 'ivgen-alg': 'plain64', 'ivgen-hash-alg': 'md5', 'driver': 'luks', 'size': 67108864}}}
428
{u'return': {}}
429
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
430
{u'return': {}}
431
@@ -XXX,XX +XXX,XX @@ Format specific information:
432
433
=== Invalid BlockdevRef ===
434
435
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'luks', 'file': "this doesn't exist", 'size': 67108864}}}
436
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'luks', 'file': "this doesn't exist", 'size': 67108864}}}
437
{u'return': {}}
438
Job failed: Cannot find device=this doesn't exist nor node_name=this doesn't exist
439
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
440
@@ -XXX,XX +XXX,XX @@ Job failed: Cannot find device=this doesn't exist nor node_name=this doesn't exi
441
442
=== Zero size ===
443
444
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'key-secret': 'keysec0', 'iter-time': 10, 'driver': 'luks', 'file': 'node0', 'size': 0}}}
445
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'key-secret': 'keysec0', 'iter-time': 10, 'driver': 'luks', 'file': 'node0', 'size': 0}}}
446
{u'return': {}}
447
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
448
{u'return': {}}
449
@@ -XXX,XX +XXX,XX @@ Format specific information:
450
451
=== Invalid sizes ===
452
453
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'key-secret': 'keysec0', 'driver': 'luks', 'file': 'node0', 'size': 18446744073709551104L}}}
454
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'key-secret': 'keysec0', 'driver': 'luks', 'file': 'node0', 'size': 18446744073709551104L}}}
455
{u'return': {}}
456
Job failed: The requested file size is too large
457
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
458
{u'return': {}}
459
460
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'key-secret': 'keysec0', 'driver': 'luks', 'file': 'node0', 'size': 9223372036854775808L}}}
461
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'key-secret': 'keysec0', 'driver': 'luks', 'file': 'node0', 'size': 9223372036854775808L}}}
462
{u'return': {}}
463
Job failed: The requested file size is too large
464
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
465
{u'return': {}}
466
467
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'key-secret': 'keysec0', 'driver': 'luks', 'file': 'node0', 'size': 9223372036854775296}}}
468
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'key-secret': 'keysec0', 'driver': 'luks', 'file': 'node0', 'size': 9223372036854775296}}}
469
{u'return': {}}
470
Job failed: The requested file size is too large
471
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
472
diff --git a/tests/qemu-iotests/211 b/tests/qemu-iotests/211
473
index XXXXXXX..XXXXXXX 100755
474
--- a/tests/qemu-iotests/211
475
+++ b/tests/qemu-iotests/211
476
@@ -XXX,XX +XXX,XX @@ iotests.verify_image_format(supported_fmts=['vdi'])
477
iotests.verify_protocol(supported=['file'])
478
479
def blockdev_create(vm, options):
480
- result = vm.qmp_log('x-blockdev-create', job_id='job0', options=options)
481
+ result = vm.qmp_log('blockdev-create', job_id='job0', options=options)
482
483
if 'return' in result:
484
assert result['return'] == {}
485
diff --git a/tests/qemu-iotests/211.out b/tests/qemu-iotests/211.out
486
index XXXXXXX..XXXXXXX 100644
487
--- a/tests/qemu-iotests/211.out
488
+++ b/tests/qemu-iotests/211.out
489
@@ -XXX,XX +XXX,XX @@
490
=== Successful image creation (defaults) ===
491
492
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.vdi'}}}
493
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.vdi'}}}
494
{u'return': {}}
495
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
496
{u'return': {}}
497
498
{'execute': 'blockdev-add', 'arguments': {'node_name': 'imgfile', 'driver': 'file', 'filename': 'TEST_DIR/PID-t.vdi'}}
499
{u'return': {}}
500
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vdi', 'file': 'imgfile', 'size': 134217728}}}
501
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vdi', 'file': 'imgfile', 'size': 134217728}}}
502
{u'return': {}}
503
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
504
{u'return': {}}
505
@@ -XXX,XX +XXX,XX @@ cluster_size: 1048576
506
507
=== Successful image creation (explicit defaults) ===
508
509
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.vdi'}}}
510
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.vdi'}}}
511
{u'return': {}}
512
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
513
{u'return': {}}
514
515
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'preallocation': 'off', 'driver': 'vdi', 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.vdi'}, 'size': 67108864}}}
516
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'preallocation': 'off', 'driver': 'vdi', 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.vdi'}, 'size': 67108864}}}
517
{u'return': {}}
518
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
519
{u'return': {}}
520
@@ -XXX,XX +XXX,XX @@ cluster_size: 1048576
521
522
=== Successful image creation (with non-default options) ===
523
524
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.vdi'}}}
525
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.vdi'}}}
526
{u'return': {}}
527
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
528
{u'return': {}}
529
530
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'preallocation': 'metadata', 'driver': 'vdi', 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.vdi'}, 'size': 33554432}}}
531
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'preallocation': 'metadata', 'driver': 'vdi', 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.vdi'}, 'size': 33554432}}}
532
{u'return': {}}
533
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
534
{u'return': {}}
535
@@ -XXX,XX +XXX,XX @@ cluster_size: 1048576
536
537
=== Invalid BlockdevRef ===
538
539
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vdi', 'file': "this doesn't exist", 'size': 33554432}}}
540
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vdi', 'file': "this doesn't exist", 'size': 33554432}}}
541
{u'return': {}}
542
Job failed: Cannot find device=this doesn't exist nor node_name=this doesn't exist
543
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
544
@@ -XXX,XX +XXX,XX @@ Job failed: Cannot find device=this doesn't exist nor node_name=this doesn't exi
545
546
=== Zero size ===
547
548
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vdi', 'file': 'node0', 'size': 0}}}
549
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vdi', 'file': 'node0', 'size': 0}}}
550
{u'return': {}}
551
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
552
{u'return': {}}
553
@@ -XXX,XX +XXX,XX @@ cluster_size: 1048576
554
555
=== Maximum size ===
556
557
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vdi', 'file': 'node0', 'size': 562949819203584}}}
558
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vdi', 'file': 'node0', 'size': 562949819203584}}}
559
{u'return': {}}
560
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
561
{u'return': {}}
562
@@ -XXX,XX +XXX,XX @@ cluster_size: 1048576
563
564
=== Invalid sizes ===
565
566
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vdi', 'file': 'node0', 'size': 18446744073709551104L}}}
567
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vdi', 'file': 'node0', 'size': 18446744073709551104L}}}
568
{u'return': {}}
569
Job failed: Unsupported VDI image size (size is 0xfffffffffffffe00, max supported is 0x1fffff8000000)
570
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
571
{u'return': {}}
572
573
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vdi', 'file': 'node0', 'size': 9223372036854775808L}}}
574
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vdi', 'file': 'node0', 'size': 9223372036854775808L}}}
575
{u'return': {}}
576
Job failed: Unsupported VDI image size (size is 0x8000000000000000, max supported is 0x1fffff8000000)
577
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
578
{u'return': {}}
579
580
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vdi', 'file': 'node0', 'size': 562949819203585}}}
581
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vdi', 'file': 'node0', 'size': 562949819203585}}}
582
{u'return': {}}
583
Job failed: Unsupported VDI image size (size is 0x1fffff8000001, max supported is 0x1fffff8000000)
584
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
585
diff --git a/tests/qemu-iotests/212 b/tests/qemu-iotests/212
586
index XXXXXXX..XXXXXXX 100755
587
--- a/tests/qemu-iotests/212
588
+++ b/tests/qemu-iotests/212
589
@@ -XXX,XX +XXX,XX @@ iotests.verify_image_format(supported_fmts=['parallels'])
590
iotests.verify_protocol(supported=['file'])
591
592
def blockdev_create(vm, options):
593
- result = vm.qmp_log('x-blockdev-create', job_id='job0', options=options)
594
+ result = vm.qmp_log('blockdev-create', job_id='job0', options=options)
595
596
if 'return' in result:
597
assert result['return'] == {}
598
diff --git a/tests/qemu-iotests/212.out b/tests/qemu-iotests/212.out
599
index XXXXXXX..XXXXXXX 100644
600
--- a/tests/qemu-iotests/212.out
601
+++ b/tests/qemu-iotests/212.out
602
@@ -XXX,XX +XXX,XX @@
603
=== Successful image creation (defaults) ===
604
605
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.parallels'}}}
606
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.parallels'}}}
607
{u'return': {}}
608
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
609
{u'return': {}}
610
611
{'execute': 'blockdev-add', 'arguments': {'node_name': 'imgfile', 'driver': 'file', 'filename': 'TEST_DIR/PID-t.parallels'}}
612
{u'return': {}}
613
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': 'imgfile', 'size': 134217728}}}
614
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': 'imgfile', 'size': 134217728}}}
615
{u'return': {}}
616
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
617
{u'return': {}}
618
@@ -XXX,XX +XXX,XX @@ virtual size: 128M (134217728 bytes)
619
620
=== Successful image creation (explicit defaults) ===
621
622
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.parallels'}}}
623
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.parallels'}}}
624
{u'return': {}}
625
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
626
{u'return': {}}
627
628
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 1048576, 'driver': 'parallels', 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.parallels'}, 'size': 67108864}}}
629
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 1048576, 'driver': 'parallels', 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.parallels'}, 'size': 67108864}}}
630
{u'return': {}}
631
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
632
{u'return': {}}
633
@@ -XXX,XX +XXX,XX @@ virtual size: 64M (67108864 bytes)
634
635
=== Successful image creation (with non-default options) ===
636
637
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.parallels'}}}
638
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.parallels'}}}
639
{u'return': {}}
640
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
641
{u'return': {}}
642
643
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 65536, 'driver': 'parallels', 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.parallels'}, 'size': 33554432}}}
644
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 65536, 'driver': 'parallels', 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.parallels'}, 'size': 33554432}}}
645
{u'return': {}}
646
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
647
{u'return': {}}
648
@@ -XXX,XX +XXX,XX @@ virtual size: 32M (33554432 bytes)
649
650
=== Invalid BlockdevRef ===
651
652
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': "this doesn't exist", 'size': 33554432}}}
653
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': "this doesn't exist", 'size': 33554432}}}
654
{u'return': {}}
655
Job failed: Cannot find device=this doesn't exist nor node_name=this doesn't exist
656
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
657
@@ -XXX,XX +XXX,XX @@ Job failed: Cannot find device=this doesn't exist nor node_name=this doesn't exi
658
659
=== Zero size ===
660
661
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': 'node0', 'size': 0}}}
662
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': 'node0', 'size': 0}}}
663
{u'return': {}}
664
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
665
{u'return': {}}
666
@@ -XXX,XX +XXX,XX @@ virtual size: 0 (0 bytes)
667
668
=== Maximum size ===
669
670
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': 'node0', 'size': 4503599627369984}}}
671
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': 'node0', 'size': 4503599627369984}}}
672
{u'return': {}}
673
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
674
{u'return': {}}
675
@@ -XXX,XX +XXX,XX @@ virtual size: 4096T (4503599627369984 bytes)
676
677
=== Invalid sizes ===
678
679
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': 'node0', 'size': 1234}}}
680
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': 'node0', 'size': 1234}}}
681
{u'return': {}}
682
Job failed: Image size must be a multiple of 512 bytes
683
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
684
{u'return': {}}
685
686
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': 'node0', 'size': 18446744073709551104L}}}
687
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': 'node0', 'size': 18446744073709551104L}}}
688
{u'return': {}}
689
Job failed: Image size is too large for this cluster size
690
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
691
{u'return': {}}
692
693
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': 'node0', 'size': 9223372036854775808L}}}
694
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': 'node0', 'size': 9223372036854775808L}}}
695
{u'return': {}}
696
Job failed: Image size is too large for this cluster size
697
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
698
{u'return': {}}
699
700
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': 'node0', 'size': 9223372036854775296}}}
701
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': 'node0', 'size': 9223372036854775296}}}
702
{u'return': {}}
703
Job failed: Image size is too large for this cluster size
704
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
705
{u'return': {}}
706
707
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': 'node0', 'size': 4503599627370497}}}
708
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': 'node0', 'size': 4503599627370497}}}
709
{u'return': {}}
710
Job failed: Image size is too large for this cluster size
711
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
712
@@ -XXX,XX +XXX,XX @@ Job failed: Image size is too large for this cluster size
713
714
=== Invalid cluster size ===
715
716
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 1234, 'driver': 'parallels', 'file': 'node0', 'size': 67108864}}}
717
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 1234, 'driver': 'parallels', 'file': 'node0', 'size': 67108864}}}
718
{u'return': {}}
719
Job failed: Cluster size must be a multiple of 512 bytes
720
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
721
{u'return': {}}
722
723
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 128, 'driver': 'parallels', 'file': 'node0', 'size': 67108864}}}
724
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 128, 'driver': 'parallels', 'file': 'node0', 'size': 67108864}}}
725
{u'return': {}}
726
Job failed: Cluster size must be a multiple of 512 bytes
727
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
728
{u'return': {}}
729
730
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 4294967296, 'driver': 'parallels', 'file': 'node0', 'size': 67108864}}}
731
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 4294967296, 'driver': 'parallels', 'file': 'node0', 'size': 67108864}}}
732
{u'return': {}}
733
Job failed: Cluster size is too large
734
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
735
{u'return': {}}
736
737
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 9223372036854775808L, 'driver': 'parallels', 'file': 'node0', 'size': 67108864}}}
738
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 9223372036854775808L, 'driver': 'parallels', 'file': 'node0', 'size': 67108864}}}
739
{u'return': {}}
740
Job failed: Cluster size is too large
741
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
742
{u'return': {}}
743
744
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 18446744073709551104L, 'driver': 'parallels', 'file': 'node0', 'size': 67108864}}}
745
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 18446744073709551104L, 'driver': 'parallels', 'file': 'node0', 'size': 67108864}}}
746
{u'return': {}}
747
Job failed: Cluster size is too large
748
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
749
{u'return': {}}
750
751
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 0, 'driver': 'parallels', 'file': 'node0', 'size': 67108864}}}
752
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 0, 'driver': 'parallels', 'file': 'node0', 'size': 67108864}}}
753
{u'return': {}}
754
Job failed: Image size is too large for this cluster size
755
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
756
{u'return': {}}
757
758
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 512, 'driver': 'parallels', 'file': 'node0', 'size': 281474976710656}}}
759
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 512, 'driver': 'parallels', 'file': 'node0', 'size': 281474976710656}}}
760
{u'return': {}}
761
Job failed: Image size is too large for this cluster size
762
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
763
diff --git a/tests/qemu-iotests/213 b/tests/qemu-iotests/213
764
index XXXXXXX..XXXXXXX 100755
765
--- a/tests/qemu-iotests/213
766
+++ b/tests/qemu-iotests/213
767
@@ -XXX,XX +XXX,XX @@ iotests.verify_image_format(supported_fmts=['vhdx'])
768
iotests.verify_protocol(supported=['file'])
769
770
def blockdev_create(vm, options):
771
- result = vm.qmp_log('x-blockdev-create', job_id='job0', options=options)
772
+ result = vm.qmp_log('blockdev-create', job_id='job0', options=options)
773
774
if 'return' in result:
775
assert result['return'] == {}
776
diff --git a/tests/qemu-iotests/213.out b/tests/qemu-iotests/213.out
777
index XXXXXXX..XXXXXXX 100644
778
--- a/tests/qemu-iotests/213.out
779
+++ b/tests/qemu-iotests/213.out
780
@@ -XXX,XX +XXX,XX @@
781
=== Successful image creation (defaults) ===
782
783
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.vhdx'}}}
784
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.vhdx'}}}
785
{u'return': {}}
786
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
787
{u'return': {}}
788
789
{'execute': 'blockdev-add', 'arguments': {'node_name': 'imgfile', 'driver': 'file', 'filename': 'TEST_DIR/PID-t.vhdx'}}
790
{u'return': {}}
791
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'file': 'imgfile', 'size': 134217728}}}
792
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'file': 'imgfile', 'size': 134217728}}}
793
{u'return': {}}
794
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
795
{u'return': {}}
796
@@ -XXX,XX +XXX,XX @@ cluster_size: 8388608
797
798
=== Successful image creation (explicit defaults) ===
799
800
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.vhdx'}}}
801
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.vhdx'}}}
802
{u'return': {}}
803
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
804
{u'return': {}}
805
806
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'block-size': 8388608, 'driver': 'vhdx', 'subformat': 'dynamic', 'log-size': 1048576, 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.vhdx'}, 'block-state-zero': True, 'size': 67108864}}}
807
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'block-size': 8388608, 'driver': 'vhdx', 'subformat': 'dynamic', 'log-size': 1048576, 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.vhdx'}, 'block-state-zero': True, 'size': 67108864}}}
808
{u'return': {}}
809
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
810
{u'return': {}}
811
@@ -XXX,XX +XXX,XX @@ cluster_size: 8388608
812
813
=== Successful image creation (with non-default options) ===
814
815
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.vhdx'}}}
816
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.vhdx'}}}
817
{u'return': {}}
818
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
819
{u'return': {}}
820
821
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'block-size': 268435456, 'driver': 'vhdx', 'subformat': 'fixed', 'log-size': 8388608, 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.vhdx'}, 'block-state-zero': False, 'size': 33554432}}}
822
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'block-size': 268435456, 'driver': 'vhdx', 'subformat': 'fixed', 'log-size': 8388608, 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.vhdx'}, 'block-state-zero': False, 'size': 33554432}}}
823
{u'return': {}}
824
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
825
{u'return': {}}
826
@@ -XXX,XX +XXX,XX @@ cluster_size: 268435456
827
828
=== Invalid BlockdevRef ===
829
830
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'file': "this doesn't exist", 'size': 33554432}}}
831
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'file': "this doesn't exist", 'size': 33554432}}}
832
{u'return': {}}
833
Job failed: Cannot find device=this doesn't exist nor node_name=this doesn't exist
834
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
835
@@ -XXX,XX +XXX,XX @@ Job failed: Cannot find device=this doesn't exist nor node_name=this doesn't exi
836
837
=== Zero size ===
838
839
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'file': 'node0', 'size': 0}}}
840
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'file': 'node0', 'size': 0}}}
841
{u'return': {}}
842
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
843
{u'return': {}}
844
@@ -XXX,XX +XXX,XX @@ cluster_size: 8388608
845
846
=== Maximum size ===
847
848
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'file': 'node0', 'size': 70368744177664}}}
849
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'file': 'node0', 'size': 70368744177664}}}
850
{u'return': {}}
851
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
852
{u'return': {}}
853
@@ -XXX,XX +XXX,XX @@ cluster_size: 67108864
854
855
=== Invalid sizes ===
856
857
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'file': 'node0', 'size': 18446744073709551104L}}}
858
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'file': 'node0', 'size': 18446744073709551104L}}}
859
{u'return': {}}
860
Job failed: Image size too large; max of 64TB
861
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
862
{u'return': {}}
863
864
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'file': 'node0', 'size': 9223372036854775808L}}}
865
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'file': 'node0', 'size': 9223372036854775808L}}}
866
{u'return': {}}
867
Job failed: Image size too large; max of 64TB
868
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
869
{u'return': {}}
870
871
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'file': 'node0', 'size': 9223372036854775296}}}
872
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'file': 'node0', 'size': 9223372036854775296}}}
873
{u'return': {}}
874
Job failed: Image size too large; max of 64TB
875
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
876
{u'return': {}}
877
878
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'file': 'node0', 'size': 70368744177665}}}
879
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'file': 'node0', 'size': 70368744177665}}}
880
{u'return': {}}
881
Job failed: Image size too large; max of 64TB
882
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
883
@@ -XXX,XX +XXX,XX @@ Job failed: Image size too large; max of 64TB
884
885
=== Invalid block size ===
886
887
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'block-size': 1234567, 'file': 'node0', 'size': 67108864}}}
888
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'block-size': 1234567, 'file': 'node0', 'size': 67108864}}}
889
{u'return': {}}
890
Job failed: Block size must be a multiple of 1 MB
891
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
892
{u'return': {}}
893
894
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'block-size': 128, 'file': 'node0', 'size': 67108864}}}
895
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'block-size': 128, 'file': 'node0', 'size': 67108864}}}
896
{u'return': {}}
897
Job failed: Block size must be a multiple of 1 MB
898
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
899
{u'return': {}}
900
901
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'block-size': 3145728, 'file': 'node0', 'size': 67108864}}}
902
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'block-size': 3145728, 'file': 'node0', 'size': 67108864}}}
903
{u'return': {}}
904
Job failed: Block size must be a power of two
905
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
906
{u'return': {}}
907
908
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'block-size': 536870912, 'file': 'node0', 'size': 67108864}}}
909
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'block-size': 536870912, 'file': 'node0', 'size': 67108864}}}
910
{u'return': {}}
911
Job failed: Block size must not exceed 268435456
912
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
913
{u'return': {}}
914
915
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'block-size': 0, 'file': 'node0', 'size': 67108864}}}
916
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vhdx', 'block-size': 0, 'file': 'node0', 'size': 67108864}}}
917
{u'return': {}}
918
Job failed: Block size must be a multiple of 1 MB
919
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
920
@@ -XXX,XX +XXX,XX @@ Job failed: Block size must be a multiple of 1 MB
921
922
=== Invalid log size ===
923
924
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'log-size': 1234567, 'driver': 'vhdx', 'file': 'node0', 'size': 67108864}}}
925
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'log-size': 1234567, 'driver': 'vhdx', 'file': 'node0', 'size': 67108864}}}
926
{u'return': {}}
927
Job failed: Log size must be a multiple of 1 MB
928
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
929
{u'return': {}}
930
931
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'log-size': 128, 'driver': 'vhdx', 'file': 'node0', 'size': 67108864}}}
932
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'log-size': 128, 'driver': 'vhdx', 'file': 'node0', 'size': 67108864}}}
933
{u'return': {}}
934
Job failed: Log size must be a multiple of 1 MB
935
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
936
{u'return': {}}
937
938
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'log-size': 4294967296, 'driver': 'vhdx', 'file': 'node0', 'size': 67108864}}}
939
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'log-size': 4294967296, 'driver': 'vhdx', 'file': 'node0', 'size': 67108864}}}
940
{u'return': {}}
941
Job failed: Log size must be smaller than 4 GB
942
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
943
{u'return': {}}
944
945
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'log-size': 0, 'driver': 'vhdx', 'file': 'node0', 'size': 67108864}}}
946
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'log-size': 0, 'driver': 'vhdx', 'file': 'node0', 'size': 67108864}}}
947
{u'return': {}}
948
Job failed: Log size must be a multiple of 1 MB
949
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
950
--
181
--
951
2.13.6
182
2.19.1
952
183
953
184
diff view generated by jsdifflib
1
This adds two helper functions that are useful for test cases that make
1
Commit e2b8247a322 introduced an error path in qemu_rbd_open() after
2
use of a non-file protocol (specifically ssh).
2
calling rbd_open(), but neglected to close the image again in this error
3
path. The error path should contain everything that the regular close
4
function qemu_rbd_close() contains.
5
6
This adds the missing rbd_close() call.
3
7
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
5
Reviewed-by: Max Reitz <mreitz@redhat.com>
9
Reviewed-by: Eric Blake <eblake@redhat.com>
6
Reviewed-by: Jeff Cody <jcody@redhat.com>
7
---
10
---
8
tests/qemu-iotests/iotests.py | 17 +++++++++++++++++
11
block/rbd.c | 1 +
9
1 file changed, 17 insertions(+)
12
1 file changed, 1 insertion(+)
10
13
11
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
14
diff --git a/block/rbd.c b/block/rbd.c
12
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
13
--- a/tests/qemu-iotests/iotests.py
16
--- a/block/rbd.c
14
+++ b/tests/qemu-iotests/iotests.py
17
+++ b/block/rbd.c
15
@@ -XXX,XX +XXX,XX @@ def file_path(*names):
18
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
16
19
"automatically marking the image read-only.");
17
return paths[0] if len(paths) == 1 else paths
20
r = bdrv_set_read_only(bs, true, &local_err);
18
21
if (r < 0) {
19
+def remote_filename(path):
22
+ rbd_close(s->image);
20
+ if imgproto == 'file':
23
error_propagate(errp, local_err);
21
+ return path
24
goto failed_open;
22
+ elif imgproto == 'ssh':
25
}
23
+ return "ssh://127.0.0.1%s" % (path)
24
+ else:
25
+ raise Exception("Protocol %s not supported" % (imgproto))
26
27
class VM(qtest.QEMUQtestMachine):
28
'''A QEMU VM'''
29
@@ -XXX,XX +XXX,XX @@ def verify_image_format(supported_fmts=[], unsupported_fmts=[]):
30
if not_sup or (imgfmt in unsupported_fmts):
31
notrun('not suitable for this image format: %s' % imgfmt)
32
33
+def verify_protocol(supported=[], unsupported=[]):
34
+ assert not (supported and unsupported)
35
+
36
+ if 'generic' in supported:
37
+ return
38
+
39
+ not_sup = supported and (imgproto not in supported)
40
+ if not_sup or (imgproto in unsupported):
41
+ notrun('not suitable for this protocol: %s' % imgproto)
42
+
43
def verify_platform(supported_oses=['linux']):
44
if True not in [sys.platform.startswith(x) for x in supported_oses]:
45
notrun('not suitable for this OS: %s' % sys.platform)
46
--
26
--
47
2.13.6
27
2.19.1
48
28
49
29
diff view generated by jsdifflib
New patch
1
1
Some block drivers have traditionally changed their node to read-only
2
mode without asking the user. This behaviour has been marked deprecated
3
since 2.11, expecting users to provide an explicit read-only=on option.
4
5
Now that we have auto-read-only=on, enable these drivers to make use of
6
the option.
7
8
This is the only use of bdrv_set_read_only(), so we can make it a bit
9
more specific and turn it into a bdrv_apply_auto_read_only() that is
10
more convenient for drivers to use.
11
12
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13
Reviewed-by: Eric Blake <eblake@redhat.com>
14
---
15
include/block/block.h | 3 ++-
16
block.c | 42 +++++++++++++++++++++++++++---------------
17
block/bochs.c | 17 ++++++-----------
18
block/cloop.c | 16 +++++-----------
19
block/dmg.c | 16 +++++-----------
20
block/rbd.c | 15 ++++-----------
21
block/vvfat.c | 10 ++--------
22
7 files changed, 51 insertions(+), 68 deletions(-)
23
24
diff --git a/include/block/block.h b/include/block/block.h
25
index XXXXXXX..XXXXXXX 100644
26
--- a/include/block/block.h
27
+++ b/include/block/block.h
28
@@ -XXX,XX +XXX,XX @@ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base,
29
bool bdrv_is_read_only(BlockDriverState *bs);
30
int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only,
31
bool ignore_allow_rdw, Error **errp);
32
-int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp);
33
+int bdrv_apply_auto_read_only(BlockDriverState *bs, const char *errmsg,
34
+ Error **errp);
35
bool bdrv_is_writable(BlockDriverState *bs);
36
bool bdrv_is_sg(BlockDriverState *bs);
37
bool bdrv_is_inserted(BlockDriverState *bs);
38
diff --git a/block.c b/block.c
39
index XXXXXXX..XXXXXXX 100644
40
--- a/block.c
41
+++ b/block.c
42
@@ -XXX,XX +XXX,XX @@ int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only,
43
return 0;
44
}
45
46
-/* TODO Remove (deprecated since 2.11)
47
- * Block drivers are not supposed to automatically change bs->read_only.
48
- * Instead, they should just check whether they can provide what the user
49
- * explicitly requested and error out if read-write is requested, but they can
50
- * only provide read-only access. */
51
-int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
52
+/*
53
+ * Called by a driver that can only provide a read-only image.
54
+ *
55
+ * Returns 0 if the node is already read-only or it could switch the node to
56
+ * read-only because BDRV_O_AUTO_RDONLY is set.
57
+ *
58
+ * Returns -EACCES if the node is read-write and BDRV_O_AUTO_RDONLY is not set
59
+ * or bdrv_can_set_read_only() forbids making the node read-only. If @errmsg
60
+ * is not NULL, it is used as the error message for the Error object.
61
+ */
62
+int bdrv_apply_auto_read_only(BlockDriverState *bs, const char *errmsg,
63
+ Error **errp)
64
{
65
int ret = 0;
66
67
- ret = bdrv_can_set_read_only(bs, read_only, false, errp);
68
- if (ret < 0) {
69
- return ret;
70
+ if (!(bs->open_flags & BDRV_O_RDWR)) {
71
+ return 0;
72
+ }
73
+ if (!(bs->open_flags & BDRV_O_AUTO_RDONLY)) {
74
+ goto fail;
75
}
76
77
- bs->read_only = read_only;
78
-
79
- if (read_only) {
80
- bs->open_flags &= ~BDRV_O_RDWR;
81
- } else {
82
- bs->open_flags |= BDRV_O_RDWR;
83
+ ret = bdrv_can_set_read_only(bs, true, false, NULL);
84
+ if (ret < 0) {
85
+ goto fail;
86
}
87
88
+ bs->read_only = true;
89
+ bs->open_flags &= ~BDRV_O_RDWR;
90
+
91
return 0;
92
+
93
+fail:
94
+ error_setg(errp, "%s", errmsg ?: "Image is read-only");
95
+ return -EACCES;
96
}
97
98
void bdrv_get_full_backing_filename_from_filename(const char *backed,
99
diff --git a/block/bochs.c b/block/bochs.c
100
index XXXXXXX..XXXXXXX 100644
101
--- a/block/bochs.c
102
+++ b/block/bochs.c
103
@@ -XXX,XX +XXX,XX @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags,
104
struct bochs_header bochs;
105
int ret;
106
107
+ /* No write support yet */
108
+ ret = bdrv_apply_auto_read_only(bs, NULL, errp);
109
+ if (ret < 0) {
110
+ return ret;
111
+ }
112
+
113
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
114
false, errp);
115
if (!bs->file) {
116
return -EINVAL;
117
}
118
119
- if (!bdrv_is_read_only(bs)) {
120
- error_report("Opening bochs images without an explicit read-only=on "
121
- "option is deprecated. Future versions will refuse to "
122
- "open the image instead of automatically marking the "
123
- "image read-only.");
124
- ret = bdrv_set_read_only(bs, true, errp); /* no write support yet */
125
- if (ret < 0) {
126
- return ret;
127
- }
128
- }
129
-
130
ret = bdrv_pread(bs->file, 0, &bochs, sizeof(bochs));
131
if (ret < 0) {
132
return ret;
133
diff --git a/block/cloop.c b/block/cloop.c
134
index XXXXXXX..XXXXXXX 100644
135
--- a/block/cloop.c
136
+++ b/block/cloop.c
137
@@ -XXX,XX +XXX,XX @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags,
138
uint32_t offsets_size, max_compressed_block_size = 1, i;
139
int ret;
140
141
+ ret = bdrv_apply_auto_read_only(bs, NULL, errp);
142
+ if (ret < 0) {
143
+ return ret;
144
+ }
145
+
146
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
147
false, errp);
148
if (!bs->file) {
149
return -EINVAL;
150
}
151
152
- if (!bdrv_is_read_only(bs)) {
153
- error_report("Opening cloop images without an explicit read-only=on "
154
- "option is deprecated. Future versions will refuse to "
155
- "open the image instead of automatically marking the "
156
- "image read-only.");
157
- ret = bdrv_set_read_only(bs, true, errp);
158
- if (ret < 0) {
159
- return ret;
160
- }
161
- }
162
-
163
/* read header */
164
ret = bdrv_pread(bs->file, 128, &s->block_size, 4);
165
if (ret < 0) {
166
diff --git a/block/dmg.c b/block/dmg.c
167
index XXXXXXX..XXXXXXX 100644
168
--- a/block/dmg.c
169
+++ b/block/dmg.c
170
@@ -XXX,XX +XXX,XX @@ static int dmg_open(BlockDriverState *bs, QDict *options, int flags,
171
int64_t offset;
172
int ret;
173
174
+ ret = bdrv_apply_auto_read_only(bs, NULL, errp);
175
+ if (ret < 0) {
176
+ return ret;
177
+ }
178
+
179
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
180
false, errp);
181
if (!bs->file) {
182
return -EINVAL;
183
}
184
185
- if (!bdrv_is_read_only(bs)) {
186
- error_report("Opening dmg images without an explicit read-only=on "
187
- "option is deprecated. Future versions will refuse to "
188
- "open the image instead of automatically marking the "
189
- "image read-only.");
190
- ret = bdrv_set_read_only(bs, true, errp);
191
- if (ret < 0) {
192
- return ret;
193
- }
194
- }
195
-
196
block_module_load_one("dmg-bz2");
197
198
s->n_chunks = 0;
199
diff --git a/block/rbd.c b/block/rbd.c
200
index XXXXXXX..XXXXXXX 100644
201
--- a/block/rbd.c
202
+++ b/block/rbd.c
203
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
204
/* If we are using an rbd snapshot, we must be r/o, otherwise
205
* leave as-is */
206
if (s->snap != NULL) {
207
- if (!bdrv_is_read_only(bs)) {
208
- error_report("Opening rbd snapshots without an explicit "
209
- "read-only=on option is deprecated. Future versions "
210
- "will refuse to open the image instead of "
211
- "automatically marking the image read-only.");
212
- r = bdrv_set_read_only(bs, true, &local_err);
213
- if (r < 0) {
214
- rbd_close(s->image);
215
- error_propagate(errp, local_err);
216
- goto failed_open;
217
- }
218
+ r = bdrv_apply_auto_read_only(bs, "rbd snapshots are read-only", errp);
219
+ if (r < 0) {
220
+ rbd_close(s->image);
221
+ goto failed_open;
222
}
223
}
224
225
diff --git a/block/vvfat.c b/block/vvfat.c
226
index XXXXXXX..XXXXXXX 100644
227
--- a/block/vvfat.c
228
+++ b/block/vvfat.c
229
@@ -XXX,XX +XXX,XX @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
230
"Unable to set VVFAT to 'rw' when drive is read-only");
231
goto fail;
232
}
233
- } else if (!bdrv_is_read_only(bs)) {
234
- error_report("Opening non-rw vvfat images without an explicit "
235
- "read-only=on option is deprecated. Future versions "
236
- "will refuse to open the image instead of "
237
- "automatically marking the image read-only.");
238
- /* read only is the default for safety */
239
- ret = bdrv_set_read_only(bs, true, &local_err);
240
+ } else {
241
+ ret = bdrv_apply_auto_read_only(bs, NULL, errp);
242
if (ret < 0) {
243
- error_propagate(errp, local_err);
244
goto fail;
245
}
246
}
247
--
248
2.19.1
249
250
diff view generated by jsdifflib
1
This rewrites the test case 212 to work with the new x-blockdev-create
1
If read-only=off, but auto-read-only=on is given, open a read-write NBD
2
job rather than the old synchronous version of the command.
2
connection if the server provides a read-write export, but instead of
3
3
erroring out for read-only exports, just degrade to read-only.
4
All of the test cases stay the same as before, but in order to be able
5
to implement proper job handling, the test case is rewritten in Python.
6
4
7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
5
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
Reviewed-by: Max Reitz <mreitz@redhat.com>
6
Reviewed-by: Eric Blake <eblake@redhat.com>
9
---
7
---
10
tests/qemu-iotests/212 | 483 +++++++++++++++++----------------------------
8
block/nbd-client.c | 10 +++++-----
11
tests/qemu-iotests/212.out | 191 +++++++++++-------
9
1 file changed, 5 insertions(+), 5 deletions(-)
12
tests/qemu-iotests/group | 2 +-
13
3 files changed, 295 insertions(+), 381 deletions(-)
14
10
15
diff --git a/tests/qemu-iotests/212 b/tests/qemu-iotests/212
11
diff --git a/block/nbd-client.c b/block/nbd-client.c
16
index XXXXXXX..XXXXXXX 100755
17
--- a/tests/qemu-iotests/212
18
+++ b/tests/qemu-iotests/212
19
@@ -XXX,XX +XXX,XX @@
20
-#!/bin/bash
21
+#!/usr/bin/env python
22
#
23
# Test parallels and file image creation
24
#
25
# Copyright (C) 2018 Red Hat, Inc.
26
#
27
+# Creator/Owner: Kevin Wolf <kwolf@redhat.com>
28
+#
29
# This program is free software; you can redistribute it and/or modify
30
# it under the terms of the GNU General Public License as published by
31
# the Free Software Foundation; either version 2 of the License, or
32
@@ -XXX,XX +XXX,XX @@
33
# along with this program. If not, see <http://www.gnu.org/licenses/>.
34
#
35
36
-# creator
37
-owner=kwolf@redhat.com
38
-
39
-seq=`basename $0`
40
-echo "QA output created by $seq"
41
-
42
-here=`pwd`
43
-status=1    # failure is the default!
44
-
45
-# get standard environment, filters and checks
46
-. ./common.rc
47
-. ./common.filter
48
-
49
-_supported_fmt parallels
50
-_supported_proto file
51
-_supported_os Linux
52
-
53
-function do_run_qemu()
54
-{
55
- echo Testing: "$@"
56
- $QEMU -nographic -qmp stdio -serial none "$@"
57
- echo
58
-}
59
-
60
-function run_qemu()
61
-{
62
- do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \
63
- | _filter_qemu | _filter_imgfmt \
64
- | _filter_actual_image_size
65
-}
66
-
67
-echo
68
-echo "=== Successful image creation (defaults) ==="
69
-echo
70
-
71
-size=$((128 * 1024 * 1024))
72
-
73
-run_qemu <<EOF
74
-{ "execute": "qmp_capabilities" }
75
-{ "execute": "x-blockdev-create",
76
- "arguments": {
77
- "driver": "file",
78
- "filename": "$TEST_IMG",
79
- "size": 0
80
- }
81
-}
82
-{ "execute": "blockdev-add",
83
- "arguments": {
84
- "driver": "file",
85
- "node-name": "imgfile",
86
- "filename": "$TEST_IMG"
87
- }
88
-}
89
-{ "execute": "x-blockdev-create",
90
- "arguments": {
91
- "driver": "$IMGFMT",
92
- "file": "imgfile",
93
- "size": $size
94
- }
95
-}
96
-{ "execute": "quit" }
97
-EOF
98
-
99
-_img_info --format-specific | _filter_img_info --format-specific
100
-
101
-echo
102
-echo "=== Successful image creation (explicit defaults) ==="
103
-echo
104
-
105
-# Choose a different size to show that we got a new image
106
-size=$((64 * 1024 * 1024))
107
-
108
-run_qemu <<EOF
109
-{ "execute": "qmp_capabilities" }
110
-{ "execute": "x-blockdev-create",
111
- "arguments": {
112
- "driver": "file",
113
- "filename": "$TEST_IMG",
114
- "size": 0
115
- }
116
-}
117
-{ "execute": "x-blockdev-create",
118
- "arguments": {
119
- "driver": "$IMGFMT",
120
- "file": {
121
- "driver": "file",
122
- "filename": "$TEST_IMG"
123
- },
124
- "size": $size,
125
- "cluster-size": 1048576
126
- }
127
-}
128
-{ "execute": "quit" }
129
-EOF
130
-
131
-_img_info --format-specific | _filter_img_info --format-specific
132
-
133
-echo
134
-echo "=== Successful image creation (with non-default options) ==="
135
-echo
136
-
137
-# Choose a different size to show that we got a new image
138
-size=$((32 * 1024 * 1024))
139
-
140
-run_qemu <<EOF
141
-{ "execute": "qmp_capabilities" }
142
-{ "execute": "x-blockdev-create",
143
- "arguments": {
144
- "driver": "file",
145
- "filename": "$TEST_IMG",
146
- "size": 0
147
- }
148
-}
149
-{ "execute": "x-blockdev-create",
150
- "arguments": {
151
- "driver": "$IMGFMT",
152
- "file": {
153
- "driver": "file",
154
- "filename": "$TEST_IMG"
155
- },
156
- "size": $size,
157
- "cluster-size": 65536
158
- }
159
-}
160
-{ "execute": "quit" }
161
-EOF
162
-
163
-_img_info --format-specific | _filter_img_info --format-specific
164
-
165
-echo
166
-echo "=== Invalid BlockdevRef ==="
167
-echo
168
-
169
-run_qemu <<EOF
170
-{ "execute": "qmp_capabilities" }
171
-{ "execute": "x-blockdev-create",
172
- "arguments": {
173
- "driver": "$IMGFMT",
174
- "file": "this doesn't exist",
175
- "size": $size
176
- }
177
-}
178
-{ "execute": "quit" }
179
-EOF
180
-
181
-echo
182
-echo "=== Zero size ==="
183
-echo
184
-
185
-run_qemu -blockdev driver=file,filename="$TEST_IMG",node-name=node0 <<EOF
186
-{ "execute": "qmp_capabilities" }
187
-{ "execute": "x-blockdev-create",
188
- "arguments": {
189
- "driver": "$IMGFMT",
190
- "file": "node0",
191
- "size": 0
192
- }
193
-}
194
-{ "execute": "quit" }
195
-EOF
196
-
197
-_img_info | _filter_img_info
198
-
199
-echo
200
-echo "=== Maximum size ==="
201
-echo
202
-
203
-run_qemu -blockdev driver=file,filename="$TEST_IMG",node-name=node0 <<EOF
204
-{ "execute": "qmp_capabilities" }
205
-{ "execute": "x-blockdev-create",
206
- "arguments": {
207
- "driver": "$IMGFMT",
208
- "file": "node0",
209
- "size": 4503599627369984
210
- }
211
-}
212
-{ "execute": "quit" }
213
-EOF
214
-
215
-_img_info | _filter_img_info
216
-
217
-echo
218
-echo "=== Invalid sizes ==="
219
-echo
220
-
221
-# TODO Negative image sizes aren't handled correctly, but this is a problem
222
-# with QAPI's implementation of the 'size' type and affects other commands as
223
-# well. Once this is fixed, we may want to add a test case here.
224
-
225
-# 1. Misaligned image size
226
-# 2. 2^64 - 512
227
-# 3. 2^63 = 8 EB (qemu-img enforces image sizes less than this)
228
-# 4. 2^63 - 512 (generally valid, but with the image header the file will
229
-# exceed 63 bits)
230
-# 5. 2^52 (512 bytes more than maximum image size)
231
-
232
-run_qemu -blockdev driver=file,filename="$TEST_IMG",node-name=node0 <<EOF
233
-{ "execute": "qmp_capabilities" }
234
-{ "execute": "x-blockdev-create",
235
- "arguments": {
236
- "driver": "$IMGFMT",
237
- "file": "node0",
238
- "size": 1234
239
- }
240
-}
241
-{ "execute": "x-blockdev-create",
242
- "arguments": {
243
- "driver": "$IMGFMT",
244
- "file": "node0",
245
- "size": 18446744073709551104
246
- }
247
-}
248
-{ "execute": "x-blockdev-create",
249
- "arguments": {
250
- "driver": "$IMGFMT",
251
- "file": "node0",
252
- "size": 9223372036854775808
253
- }
254
-}
255
-{ "execute": "x-blockdev-create",
256
- "arguments": {
257
- "driver": "$IMGFMT",
258
- "file": "node0",
259
- "size": 9223372036854775296
260
- }
261
-}
262
-{ "execute": "x-blockdev-create",
263
- "arguments": {
264
- "driver": "$IMGFMT",
265
- "file": "node0",
266
- "size": 4503599627370497
267
- }
268
-}
269
-{ "execute": "quit" }
270
-EOF
271
-
272
-echo
273
-echo "=== Invalid cluster size ==="
274
-echo
275
-
276
-run_qemu -blockdev driver=file,filename="$TEST_IMG",node-name=node0 <<EOF
277
-{ "execute": "qmp_capabilities" }
278
-{ "execute": "x-blockdev-create",
279
- "arguments": {
280
- "driver": "$IMGFMT",
281
- "file": "node0",
282
- "size": 67108864,
283
- "cluster-size": 1234
284
- }
285
-}
286
-{ "execute": "x-blockdev-create",
287
- "arguments": {
288
- "driver": "$IMGFMT",
289
- "file": "node0",
290
- "size": 67108864,
291
- "cluster-size": 128
292
- }
293
-}
294
-{ "execute": "x-blockdev-create",
295
- "arguments": {
296
- "driver": "$IMGFMT",
297
- "file": "node0",
298
- "size": 67108864,
299
- "cluster-size": 4294967296
300
- }
301
-}
302
-{ "execute": "x-blockdev-create",
303
- "arguments": {
304
- "driver": "$IMGFMT",
305
- "file": "node0",
306
- "size": 67108864,
307
- "cluster-size": 9223372036854775808
308
- }
309
-}
310
-{ "execute": "x-blockdev-create",
311
- "arguments": {
312
- "driver": "$IMGFMT",
313
- "file": "node0",
314
- "size": 67108864,
315
- "cluster-size": 18446744073709551104
316
- }
317
-}
318
-{ "execute": "x-blockdev-create",
319
- "arguments": {
320
- "driver": "$IMGFMT",
321
- "file": "node0",
322
- "size": 67108864,
323
- "cluster-size": 0
324
- }
325
-}
326
-{ "execute": "x-blockdev-create",
327
- "arguments": {
328
- "driver": "$IMGFMT",
329
- "file": "node0",
330
- "size": 281474976710656,
331
- "cluster-size": 512
332
- }
333
-}
334
-{ "execute": "quit" }
335
-EOF
336
-
337
-
338
-# success, all done
339
-echo "*** done"
340
-rm -f $seq.full
341
-status=0
342
+import iotests
343
+from iotests import imgfmt
344
+
345
+iotests.verify_image_format(supported_fmts=['parallels'])
346
+iotests.verify_protocol(supported=['file'])
347
+
348
+def blockdev_create(vm, options):
349
+ result = vm.qmp_log('x-blockdev-create', job_id='job0', options=options)
350
+
351
+ if 'return' in result:
352
+ assert result['return'] == {}
353
+ vm.run_job('job0')
354
+ iotests.log("")
355
+
356
+with iotests.FilePath('t.parallels') as disk_path, \
357
+ iotests.VM() as vm:
358
+
359
+ #
360
+ # Successful image creation (defaults)
361
+ #
362
+ iotests.log("=== Successful image creation (defaults) ===")
363
+ iotests.log("")
364
+
365
+ size = 128 * 1024 * 1024
366
+
367
+ vm.launch()
368
+ blockdev_create(vm, { 'driver': 'file',
369
+ 'filename': disk_path,
370
+ 'size': 0 })
371
+
372
+ vm.qmp_log('blockdev-add', driver='file', filename=disk_path,
373
+ node_name='imgfile')
374
+
375
+ blockdev_create(vm, { 'driver': imgfmt,
376
+ 'file': 'imgfile',
377
+ 'size': size })
378
+ vm.shutdown()
379
+
380
+ iotests.img_info_log(disk_path)
381
+
382
+ #
383
+ # Successful image creation (explicit defaults)
384
+ #
385
+ iotests.log("=== Successful image creation (explicit defaults) ===")
386
+ iotests.log("")
387
+
388
+ # Choose a different size to show that we got a new image
389
+ size = 64 * 1024 * 1024
390
+
391
+ vm.launch()
392
+ blockdev_create(vm, { 'driver': 'file',
393
+ 'filename': disk_path,
394
+ 'size': 0 })
395
+ blockdev_create(vm, { 'driver': imgfmt,
396
+ 'file': {
397
+ 'driver': 'file',
398
+ 'filename': disk_path,
399
+ },
400
+ 'size': size,
401
+ 'cluster-size': 1048576 })
402
+ vm.shutdown()
403
+
404
+ iotests.img_info_log(disk_path)
405
+
406
+ #
407
+ # Successful image creation (with non-default options)
408
+ #
409
+ iotests.log("=== Successful image creation (with non-default options) ===")
410
+ iotests.log("")
411
+
412
+ # Choose a different size to show that we got a new image
413
+ size = 32 * 1024 * 1024
414
+
415
+ vm.launch()
416
+ blockdev_create(vm, { 'driver': 'file',
417
+ 'filename': disk_path,
418
+ 'size': 0 })
419
+ blockdev_create(vm, { 'driver': imgfmt,
420
+ 'file': {
421
+ 'driver': 'file',
422
+ 'filename': disk_path,
423
+ },
424
+ 'size': size,
425
+ 'cluster-size': 65536 })
426
+ vm.shutdown()
427
+
428
+ iotests.img_info_log(disk_path)
429
+
430
+ #
431
+ # Invalid BlockdevRef
432
+ #
433
+ iotests.log("=== Invalid BlockdevRef ===")
434
+ iotests.log("")
435
+
436
+ vm.launch()
437
+ blockdev_create(vm, { 'driver': imgfmt,
438
+ 'file': "this doesn't exist",
439
+ 'size': size })
440
+ vm.shutdown()
441
+
442
+ #
443
+ # Zero size
444
+ #
445
+ iotests.log("=== Zero size ===")
446
+ iotests.log("")
447
+
448
+ vm.add_blockdev('driver=file,filename=%s,node-name=node0' % (disk_path))
449
+ vm.launch()
450
+ blockdev_create(vm, { 'driver': imgfmt,
451
+ 'file': 'node0',
452
+ 'size': 0 })
453
+ vm.shutdown()
454
+
455
+ iotests.img_info_log(disk_path)
456
+
457
+ #
458
+ # Maximum size
459
+ #
460
+ iotests.log("=== Maximum size ===")
461
+ iotests.log("")
462
+
463
+ vm.launch()
464
+ blockdev_create(vm, { 'driver': imgfmt,
465
+ 'file': 'node0',
466
+ 'size': 4503599627369984})
467
+ vm.shutdown()
468
+
469
+ iotests.img_info_log(disk_path)
470
+
471
+ #
472
+ # Invalid sizes
473
+ #
474
+
475
+ # TODO Negative image sizes aren't handled correctly, but this is a problem
476
+ # with QAPI's implementation of the 'size' type and affects other commands
477
+ # as well. Once this is fixed, we may want to add a test case here.
478
+
479
+ # 1. Misaligned image size
480
+ # 2. 2^64 - 512
481
+ # 3. 2^63 = 8 EB (qemu-img enforces image sizes less than this)
482
+ # 4. 2^63 - 512 (generally valid, but with the image header the file will
483
+ # exceed 63 bits)
484
+ # 5. 2^52 (512 bytes more than maximum image size)
485
+
486
+ iotests.log("=== Invalid sizes ===")
487
+ iotests.log("")
488
+
489
+ vm.launch()
490
+ for size in [ 1234, 18446744073709551104, 9223372036854775808,
491
+ 9223372036854775296, 4503599627370497 ]:
492
+ blockdev_create(vm, { 'driver': imgfmt,
493
+ 'file': 'node0',
494
+ 'size': size })
495
+ vm.shutdown()
496
+
497
+ #
498
+ # Invalid cluster size
499
+ #
500
+ iotests.log("=== Invalid cluster size ===")
501
+ iotests.log("")
502
+
503
+ vm.launch()
504
+ for csize in [ 1234, 128, 4294967296, 9223372036854775808,
505
+ 18446744073709551104, 0 ]:
506
+ blockdev_create(vm, { 'driver': imgfmt,
507
+ 'file': 'node0',
508
+ 'size': 67108864,
509
+ 'cluster-size': csize })
510
+ blockdev_create(vm, { 'driver': imgfmt,
511
+ 'file': 'node0',
512
+ 'size': 281474976710656,
513
+ 'cluster-size': 512 })
514
+ vm.shutdown()
515
diff --git a/tests/qemu-iotests/212.out b/tests/qemu-iotests/212.out
516
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
517
--- a/tests/qemu-iotests/212.out
13
--- a/block/nbd-client.c
518
+++ b/tests/qemu-iotests/212.out
14
+++ b/block/nbd-client.c
519
@@ -XXX,XX +XXX,XX @@
15
@@ -XXX,XX +XXX,XX @@ int nbd_client_init(BlockDriverState *bs,
520
-QA output created by 212
16
logout("Failed to negotiate with the NBD server\n");
521
-
17
return ret;
522
=== Successful image creation (defaults) ===
18
}
523
19
- if (client->info.flags & NBD_FLAG_READ_ONLY &&
524
-Testing:
20
- !bdrv_is_read_only(bs)) {
525
-QMP_VERSION
21
- error_setg(errp,
526
-{"return": {}}
22
- "request for write access conflicts with read-only export");
527
-{"return": {}}
23
- return -EACCES;
528
-{"return": {}}
24
+ if (client->info.flags & NBD_FLAG_READ_ONLY) {
529
-{"return": {}}
25
+ ret = bdrv_apply_auto_read_only(bs, "NBD export is read-only", errp);
530
-{"return": {}}
26
+ if (ret < 0) {
531
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
27
+ return ret;
532
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.parallels'}}}
28
+ }
533
+{u'return': {}}
29
}
534
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
30
if (client->info.flags & NBD_FLAG_SEND_FUA) {
535
+{u'return': {}}
31
bs->supported_write_flags = BDRV_REQ_FUA;
536
+
537
+{'execute': 'blockdev-add', 'arguments': {'node_name': 'imgfile', 'driver': 'file', 'filename': 'TEST_DIR/PID-t.parallels'}}
538
+{u'return': {}}
539
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': 'imgfile', 'size': 134217728}}}
540
+{u'return': {}}
541
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
542
+{u'return': {}}
543
544
-image: TEST_DIR/t.IMGFMT
545
+image: TEST_IMG
546
file format: IMGFMT
547
virtual size: 128M (134217728 bytes)
548
549
=== Successful image creation (explicit defaults) ===
550
551
-Testing:
552
-QMP_VERSION
553
-{"return": {}}
554
-{"return": {}}
555
-{"return": {}}
556
-{"return": {}}
557
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
558
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.parallels'}}}
559
+{u'return': {}}
560
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
561
+{u'return': {}}
562
563
-image: TEST_DIR/t.IMGFMT
564
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 1048576, 'driver': 'parallels', 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.parallels'}, 'size': 67108864}}}
565
+{u'return': {}}
566
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
567
+{u'return': {}}
568
+
569
+image: TEST_IMG
570
file format: IMGFMT
571
virtual size: 64M (67108864 bytes)
572
573
=== Successful image creation (with non-default options) ===
574
575
-Testing:
576
-QMP_VERSION
577
-{"return": {}}
578
-{"return": {}}
579
-{"return": {}}
580
-{"return": {}}
581
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
582
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.parallels'}}}
583
+{u'return': {}}
584
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
585
+{u'return': {}}
586
+
587
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 65536, 'driver': 'parallels', 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.parallels'}, 'size': 33554432}}}
588
+{u'return': {}}
589
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
590
+{u'return': {}}
591
592
-image: TEST_DIR/t.IMGFMT
593
+image: TEST_IMG
594
file format: IMGFMT
595
virtual size: 32M (33554432 bytes)
596
597
=== Invalid BlockdevRef ===
598
599
-Testing:
600
-QMP_VERSION
601
-{"return": {}}
602
-{"error": {"class": "GenericError", "desc": "Cannot find device=this doesn't exist nor node_name=this doesn't exist"}}
603
-{"return": {}}
604
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
605
-
606
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': "this doesn't exist", 'size': 33554432}}}
607
+{u'return': {}}
608
+Job failed: Cannot find device=this doesn't exist nor node_name=this doesn't exist
609
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
610
+{u'return': {}}
611
612
=== Zero size ===
613
614
-Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0
615
-QMP_VERSION
616
-{"return": {}}
617
-{"return": {}}
618
-{"return": {}}
619
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
620
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': 'node0', 'size': 0}}}
621
+{u'return': {}}
622
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
623
+{u'return': {}}
624
625
-image: TEST_DIR/t.IMGFMT
626
+image: TEST_IMG
627
file format: IMGFMT
628
virtual size: 0 (0 bytes)
629
630
=== Maximum size ===
631
632
-Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0
633
-QMP_VERSION
634
-{"return": {}}
635
-{"return": {}}
636
-{"return": {}}
637
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
638
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': 'node0', 'size': 4503599627369984}}}
639
+{u'return': {}}
640
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
641
+{u'return': {}}
642
643
-image: TEST_DIR/t.IMGFMT
644
+image: TEST_IMG
645
file format: IMGFMT
646
virtual size: 4096T (4503599627369984 bytes)
647
648
=== Invalid sizes ===
649
650
-Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0
651
-QMP_VERSION
652
-{"return": {}}
653
-{"error": {"class": "GenericError", "desc": "Image size must be a multiple of 512 bytes"}}
654
-{"error": {"class": "GenericError", "desc": "Image size is too large for this cluster size"}}
655
-{"error": {"class": "GenericError", "desc": "Image size is too large for this cluster size"}}
656
-{"error": {"class": "GenericError", "desc": "Image size is too large for this cluster size"}}
657
-{"error": {"class": "GenericError", "desc": "Image size is too large for this cluster size"}}
658
-{"return": {}}
659
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
660
-
661
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': 'node0', 'size': 1234}}}
662
+{u'return': {}}
663
+Job failed: Image size must be a multiple of 512 bytes
664
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
665
+{u'return': {}}
666
+
667
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': 'node0', 'size': 18446744073709551104L}}}
668
+{u'return': {}}
669
+Job failed: Image size is too large for this cluster size
670
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
671
+{u'return': {}}
672
+
673
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': 'node0', 'size': 9223372036854775808L}}}
674
+{u'return': {}}
675
+Job failed: Image size is too large for this cluster size
676
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
677
+{u'return': {}}
678
+
679
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': 'node0', 'size': 9223372036854775296}}}
680
+{u'return': {}}
681
+Job failed: Image size is too large for this cluster size
682
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
683
+{u'return': {}}
684
+
685
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': 'node0', 'size': 4503599627370497}}}
686
+{u'return': {}}
687
+Job failed: Image size is too large for this cluster size
688
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
689
+{u'return': {}}
690
691
=== Invalid cluster size ===
692
693
-Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0
694
-QMP_VERSION
695
-{"return": {}}
696
-{"error": {"class": "GenericError", "desc": "Cluster size must be a multiple of 512 bytes"}}
697
-{"error": {"class": "GenericError", "desc": "Cluster size must be a multiple of 512 bytes"}}
698
-{"error": {"class": "GenericError", "desc": "Cluster size is too large"}}
699
-{"error": {"class": "GenericError", "desc": "Cluster size is too large"}}
700
-{"error": {"class": "GenericError", "desc": "Cluster size is too large"}}
701
-{"error": {"class": "GenericError", "desc": "Image size is too large for this cluster size"}}
702
-{"error": {"class": "GenericError", "desc": "Image size is too large for this cluster size"}}
703
-{"return": {}}
704
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
705
-
706
-*** done
707
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 1234, 'driver': 'parallels', 'file': 'node0', 'size': 67108864}}}
708
+{u'return': {}}
709
+Job failed: Cluster size must be a multiple of 512 bytes
710
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
711
+{u'return': {}}
712
+
713
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 128, 'driver': 'parallels', 'file': 'node0', 'size': 67108864}}}
714
+{u'return': {}}
715
+Job failed: Cluster size must be a multiple of 512 bytes
716
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
717
+{u'return': {}}
718
+
719
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 4294967296, 'driver': 'parallels', 'file': 'node0', 'size': 67108864}}}
720
+{u'return': {}}
721
+Job failed: Cluster size is too large
722
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
723
+{u'return': {}}
724
+
725
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 9223372036854775808L, 'driver': 'parallels', 'file': 'node0', 'size': 67108864}}}
726
+{u'return': {}}
727
+Job failed: Cluster size is too large
728
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
729
+{u'return': {}}
730
+
731
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 18446744073709551104L, 'driver': 'parallels', 'file': 'node0', 'size': 67108864}}}
732
+{u'return': {}}
733
+Job failed: Cluster size is too large
734
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
735
+{u'return': {}}
736
+
737
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 0, 'driver': 'parallels', 'file': 'node0', 'size': 67108864}}}
738
+{u'return': {}}
739
+Job failed: Image size is too large for this cluster size
740
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
741
+{u'return': {}}
742
+
743
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 512, 'driver': 'parallels', 'file': 'node0', 'size': 281474976710656}}}
744
+{u'return': {}}
745
+Job failed: Image size is too large for this cluster size
746
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
747
+{u'return': {}}
748
+
749
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
750
index XXXXXXX..XXXXXXX 100644
751
--- a/tests/qemu-iotests/group
752
+++ b/tests/qemu-iotests/group
753
@@ -XXX,XX +XXX,XX @@
754
209 rw auto quick
755
210 rw auto
756
211 rw auto quick
757
+212 rw auto quick
758
# TODO The following commented out tests need to be reworked to work
759
# with the x-blockdev-create job
760
-#212 rw auto quick
761
#213 rw auto quick
762
214 rw auto
763
215 rw auto quick
764
--
32
--
765
2.13.6
33
2.19.1
766
34
767
35
diff view generated by jsdifflib
1
This rewrites the test case 211 to work with the new x-blockdev-create
1
If read-only=off, but auto-read-only=on is given, open the file
2
job rather than the old synchronous version of the command.
2
read-write if we have the permissions, but instead of erroring out for
3
3
read-only files, just degrade to read-only.
4
All of the test cases stay the same as before, but in order to be able
5
to implement proper job handling, the test case is rewritten in Python.
6
4
7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
5
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
Reviewed-by: Max Reitz <mreitz@redhat.com>
6
Reviewed-by: Eric Blake <eblake@redhat.com>
9
---
7
---
10
tests/qemu-iotests/211 | 381 ++++++++++++++++++---------------------------
8
block/file-posix.c | 19 ++++++++++++++++---
11
tests/qemu-iotests/211.out | 133 +++++++++-------
9
1 file changed, 16 insertions(+), 3 deletions(-)
12
tests/qemu-iotests/group | 2 +-
13
3 files changed, 229 insertions(+), 287 deletions(-)
14
10
15
diff --git a/tests/qemu-iotests/211 b/tests/qemu-iotests/211
11
diff --git a/block/file-posix.c b/block/file-posix.c
16
index XXXXXXX..XXXXXXX 100755
12
index XXXXXXX..XXXXXXX 100644
17
--- a/tests/qemu-iotests/211
13
--- a/block/file-posix.c
18
+++ b/tests/qemu-iotests/211
14
+++ b/block/file-posix.c
19
@@ -XXX,XX +XXX,XX @@
15
@@ -XXX,XX +XXX,XX @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
20
-#!/bin/bash
16
21
+#!/usr/bin/env python
17
s->fd = -1;
22
#
18
fd = qemu_open(filename, s->open_flags, 0644);
23
# Test VDI and file image creation
19
- if (fd < 0) {
24
#
20
- ret = -errno;
25
# Copyright (C) 2018 Red Hat, Inc.
21
- error_setg_errno(errp, errno, "Could not open '%s'", filename);
26
#
22
+ ret = fd < 0 ? -errno : 0;
27
+# Creator/Owner: Kevin Wolf <kwolf@redhat.com>
28
+#
29
# This program is free software; you can redistribute it and/or modify
30
# it under the terms of the GNU General Public License as published by
31
# the Free Software Foundation; either version 2 of the License, or
32
@@ -XXX,XX +XXX,XX @@
33
# along with this program. If not, see <http://www.gnu.org/licenses/>.
34
#
35
36
-# creator
37
-owner=kwolf@redhat.com
38
-
39
-seq=`basename $0`
40
-echo "QA output created by $seq"
41
-
42
-here=`pwd`
43
-status=1    # failure is the default!
44
-
45
-# get standard environment, filters and checks
46
-. ./common.rc
47
-. ./common.filter
48
-
49
-_supported_fmt vdi
50
-_supported_proto file
51
-_supported_os Linux
52
-
53
-function do_run_qemu()
54
-{
55
- echo Testing: "$@"
56
- $QEMU -nographic -qmp stdio -serial none "$@"
57
- echo
58
-}
59
-
60
-function run_qemu()
61
-{
62
- do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \
63
- | _filter_qemu | _filter_imgfmt \
64
- | _filter_actual_image_size
65
-}
66
-
67
-echo
68
-echo "=== Successful image creation (defaults) ==="
69
-echo
70
-
71
-size=$((128 * 1024 * 1024))
72
-
73
-run_qemu <<EOF
74
-{ "execute": "qmp_capabilities" }
75
-{ "execute": "x-blockdev-create",
76
- "arguments": {
77
- "driver": "file",
78
- "filename": "$TEST_IMG",
79
- "size": 0
80
- }
81
-}
82
-{ "execute": "blockdev-add",
83
- "arguments": {
84
- "driver": "file",
85
- "node-name": "imgfile",
86
- "filename": "$TEST_IMG"
87
- }
88
-}
89
-{ "execute": "x-blockdev-create",
90
- "arguments": {
91
- "driver": "$IMGFMT",
92
- "file": "imgfile",
93
- "size": $size
94
- }
95
-}
96
-{ "execute": "quit" }
97
-EOF
98
-
99
-_img_info --format-specific | _filter_img_info --format-specific
100
-$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map
101
-
102
-echo
103
-echo "=== Successful image creation (explicit defaults) ==="
104
-echo
105
-
106
-# Choose a different size to show that we got a new image
107
-size=$((64 * 1024 * 1024))
108
-
109
-run_qemu <<EOF
110
-{ "execute": "qmp_capabilities" }
111
-{ "execute": "x-blockdev-create",
112
- "arguments": {
113
- "driver": "file",
114
- "filename": "$TEST_IMG",
115
- "size": 0
116
- }
117
-}
118
-{ "execute": "x-blockdev-create",
119
- "arguments": {
120
- "driver": "$IMGFMT",
121
- "file": {
122
- "driver": "file",
123
- "filename": "$TEST_IMG"
124
- },
125
- "size": $size,
126
- "preallocation": "off"
127
- }
128
-}
129
-{ "execute": "quit" }
130
-EOF
131
-
132
-_img_info --format-specific | _filter_img_info --format-specific
133
-$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map
134
-
135
-echo
136
-echo "=== Successful image creation (with non-default options) ==="
137
-echo
138
-
139
-# Choose a different size to show that we got a new image
140
-size=$((32 * 1024 * 1024))
141
-
142
-run_qemu <<EOF
143
-{ "execute": "qmp_capabilities" }
144
-{ "execute": "x-blockdev-create",
145
- "arguments": {
146
- "driver": "file",
147
- "filename": "$TEST_IMG",
148
- "size": 0
149
- }
150
-}
151
-{ "execute": "x-blockdev-create",
152
- "arguments": {
153
- "driver": "$IMGFMT",
154
- "file": {
155
- "driver": "file",
156
- "filename": "$TEST_IMG"
157
- },
158
- "size": $size,
159
- "preallocation": "metadata"
160
- }
161
-}
162
-{ "execute": "quit" }
163
-EOF
164
-
165
-_img_info --format-specific | _filter_img_info --format-specific
166
-$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map
167
-
168
-echo
169
-echo "=== Invalid BlockdevRef ==="
170
-echo
171
-
172
-run_qemu <<EOF
173
-{ "execute": "qmp_capabilities" }
174
-{ "execute": "x-blockdev-create",
175
- "arguments": {
176
- "driver": "$IMGFMT",
177
- "file": "this doesn't exist",
178
- "size": $size
179
- }
180
-}
181
-{ "execute": "quit" }
182
-EOF
183
-
184
-echo
185
-echo "=== Zero size ==="
186
-echo
187
-
188
-run_qemu -blockdev driver=file,filename="$TEST_IMG",node-name=node0 <<EOF
189
-{ "execute": "qmp_capabilities" }
190
-{ "execute": "x-blockdev-create",
191
- "arguments": {
192
- "driver": "$IMGFMT",
193
- "file": "node0",
194
- "size": 0
195
- }
196
-}
197
-{ "execute": "quit" }
198
-EOF
199
-
200
-_img_info | _filter_img_info
201
-
202
-echo
203
-echo "=== Maximum size ==="
204
-echo
205
-
206
-run_qemu -blockdev driver=file,filename="$TEST_IMG",node-name=node0 <<EOF
207
-{ "execute": "qmp_capabilities" }
208
-{ "execute": "x-blockdev-create",
209
- "arguments": {
210
- "driver": "$IMGFMT",
211
- "file": "node0",
212
- "size": 562949819203584
213
- }
214
-}
215
-{ "execute": "quit" }
216
-EOF
217
-
218
-_img_info | _filter_img_info
219
-
220
-echo
221
-echo "=== Invalid sizes ==="
222
-echo
223
-
224
-# TODO Negative image sizes aren't handled correctly, but this is a problem
225
-# with QAPI's implementation of the 'size' type and affects other commands as
226
-# well. Once this is fixed, we may want to add a test case here.
227
-
228
-# 1. 2^64 - 512
229
-# 2. 2^63 = 8 EB (qemu-img enforces image sizes less than this)
230
-# 3. 0x1fffff8000001 (one byte more than maximum image size for VDI)
231
-
232
-run_qemu -blockdev driver=file,filename="$TEST_IMG",node-name=node0 <<EOF
233
-{ "execute": "qmp_capabilities" }
234
-{ "execute": "x-blockdev-create",
235
- "arguments": {
236
- "driver": "$IMGFMT",
237
- "file": "node0",
238
- "size": 18446744073709551104
239
- }
240
-}
241
-{ "execute": "x-blockdev-create",
242
- "arguments": {
243
- "driver": "$IMGFMT",
244
- "file": "node0",
245
- "size": 9223372036854775808
246
- }
247
-}
248
-{ "execute": "x-blockdev-create",
249
- "arguments": {
250
- "driver": "$IMGFMT",
251
- "file": "node0",
252
- "size": 562949819203585
253
- }
254
-}
255
-{ "execute": "quit" }
256
-EOF
257
-
258
-# success, all done
259
-echo "*** done"
260
-rm -f $seq.full
261
-status=0
262
+import iotests
263
+from iotests import imgfmt
264
+
23
+
265
+iotests.verify_image_format(supported_fmts=['vdi'])
24
+ if (ret == -EACCES || ret == -EROFS) {
266
+iotests.verify_protocol(supported=['file'])
25
+ /* Try to degrade to read-only, but if it doesn't work, still use the
26
+ * normal error message. */
27
+ if (bdrv_apply_auto_read_only(bs, NULL, NULL) == 0) {
28
+ bdrv_flags &= ~BDRV_O_RDWR;
29
+ raw_parse_flags(bdrv_flags, &s->open_flags);
30
+ assert(!(s->open_flags & O_CREAT));
31
+ fd = qemu_open(filename, s->open_flags);
32
+ ret = fd < 0 ? -errno : 0;
33
+ }
34
+ }
267
+
35
+
268
+def blockdev_create(vm, options):
36
+ if (ret < 0) {
269
+ result = vm.qmp_log('x-blockdev-create', job_id='job0', options=options)
37
+ error_setg_errno(errp, -ret, "Could not open '%s'", filename);
270
+
38
if (ret == -EROFS) {
271
+ if 'return' in result:
39
ret = -EACCES;
272
+ assert result['return'] == {}
40
}
273
+ vm.run_job('job0')
274
+ iotests.log("")
275
+
276
+with iotests.FilePath('t.vdi') as disk_path, \
277
+ iotests.VM() as vm:
278
+
279
+ #
280
+ # Successful image creation (defaults)
281
+ #
282
+ iotests.log("=== Successful image creation (defaults) ===")
283
+ iotests.log("")
284
+
285
+ size = 128 * 1024 * 1024
286
+
287
+ vm.launch()
288
+ blockdev_create(vm, { 'driver': 'file',
289
+ 'filename': disk_path,
290
+ 'size': 0 })
291
+
292
+ vm.qmp_log('blockdev-add', driver='file', filename=disk_path,
293
+ node_name='imgfile')
294
+
295
+ blockdev_create(vm, { 'driver': imgfmt,
296
+ 'file': 'imgfile',
297
+ 'size': size })
298
+ vm.shutdown()
299
+
300
+ iotests.img_info_log(disk_path)
301
+ iotests.log(iotests.qemu_img_pipe('map', '--output=json', disk_path))
302
+
303
+ #
304
+ # Successful image creation (explicit defaults)
305
+ #
306
+ iotests.log("=== Successful image creation (explicit defaults) ===")
307
+ iotests.log("")
308
+
309
+ size = 64 * 1024 * 1024
310
+
311
+ vm.launch()
312
+ blockdev_create(vm, { 'driver': 'file',
313
+ 'filename': disk_path,
314
+ 'size': 0 })
315
+ blockdev_create(vm, { 'driver': imgfmt,
316
+ 'file': {
317
+ 'driver': 'file',
318
+ 'filename': disk_path,
319
+ },
320
+ 'size': size,
321
+ 'preallocation': 'off' })
322
+ vm.shutdown()
323
+
324
+ iotests.img_info_log(disk_path)
325
+ iotests.log(iotests.qemu_img_pipe('map', '--output=json', disk_path))
326
+
327
+ #
328
+ # Successful image creation (with non-default options)
329
+ #
330
+ iotests.log("=== Successful image creation (with non-default options) ===")
331
+ iotests.log("")
332
+
333
+ size = 32 * 1024 * 1024
334
+
335
+ vm.launch()
336
+ blockdev_create(vm, { 'driver': 'file',
337
+ 'filename': disk_path,
338
+ 'size': 0 })
339
+ blockdev_create(vm, { 'driver': imgfmt,
340
+ 'file': {
341
+ 'driver': 'file',
342
+ 'filename': disk_path,
343
+ },
344
+ 'size': size,
345
+ 'preallocation': 'metadata' })
346
+ vm.shutdown()
347
+
348
+ iotests.img_info_log(disk_path)
349
+ iotests.log(iotests.qemu_img_pipe('map', '--output=json', disk_path))
350
+
351
+ #
352
+ # Invalid BlockdevRef
353
+ #
354
+ iotests.log("=== Invalid BlockdevRef ===")
355
+ iotests.log("")
356
+
357
+ vm.launch()
358
+ blockdev_create(vm, { 'driver': imgfmt,
359
+ 'file': "this doesn't exist",
360
+ 'size': size })
361
+ vm.shutdown()
362
+
363
+ #
364
+ # Zero size
365
+ #
366
+ iotests.log("=== Zero size ===")
367
+ iotests.log("")
368
+
369
+ vm.add_blockdev('driver=file,filename=%s,node-name=node0' % (disk_path))
370
+ vm.launch()
371
+ blockdev_create(vm, { 'driver': imgfmt,
372
+ 'file': 'node0',
373
+ 'size': 0 })
374
+ vm.shutdown()
375
+
376
+ iotests.img_info_log(disk_path)
377
+
378
+ #
379
+ # Maximum size
380
+ #
381
+ iotests.log("=== Maximum size ===")
382
+ iotests.log("")
383
+
384
+ vm.launch()
385
+ blockdev_create(vm, { 'driver': imgfmt,
386
+ 'file': 'node0',
387
+ 'size': 562949819203584 })
388
+ vm.shutdown()
389
+
390
+ iotests.img_info_log(disk_path)
391
+
392
+ #
393
+ # Invalid sizes
394
+ #
395
+
396
+ # TODO Negative image sizes aren't handled correctly, but this is a problem
397
+ # with QAPI's implementation of the 'size' type and affects other commands
398
+ # as well. Once this is fixed, we may want to add a test case here.
399
+
400
+ # 1. 2^64 - 512
401
+ # 2. 2^63 = 8 EB (qemu-img enforces image sizes less than this)
402
+ # 3. 0x1fffff8000001 (one byte more than maximum image size for VDI)
403
+
404
+ iotests.log("=== Invalid sizes ===")
405
+ iotests.log("")
406
+
407
+ vm.launch()
408
+ for size in [ 18446744073709551104, 9223372036854775808, 562949819203585 ]:
409
+ blockdev_create(vm, { 'driver': imgfmt,
410
+ 'file': 'node0',
411
+ 'size': size })
412
+ vm.shutdown()
413
diff --git a/tests/qemu-iotests/211.out b/tests/qemu-iotests/211.out
414
index XXXXXXX..XXXXXXX 100644
415
--- a/tests/qemu-iotests/211.out
416
+++ b/tests/qemu-iotests/211.out
417
@@ -XXX,XX +XXX,XX @@
418
-QA output created by 211
419
-
420
=== Successful image creation (defaults) ===
421
422
-Testing:
423
-QMP_VERSION
424
-{"return": {}}
425
-{"return": {}}
426
-{"return": {}}
427
-{"return": {}}
428
-{"return": {}}
429
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
430
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.vdi'}}}
431
+{u'return': {}}
432
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
433
+{u'return': {}}
434
+
435
+{'execute': 'blockdev-add', 'arguments': {'node_name': 'imgfile', 'driver': 'file', 'filename': 'TEST_DIR/PID-t.vdi'}}
436
+{u'return': {}}
437
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vdi', 'file': 'imgfile', 'size': 134217728}}}
438
+{u'return': {}}
439
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
440
+{u'return': {}}
441
442
-image: TEST_DIR/t.IMGFMT
443
+image: TEST_IMG
444
file format: IMGFMT
445
virtual size: 128M (134217728 bytes)
446
+cluster_size: 1048576
447
+
448
[{ "start": 0, "length": 134217728, "depth": 0, "zero": true, "data": false}]
449
450
=== Successful image creation (explicit defaults) ===
451
452
-Testing:
453
-QMP_VERSION
454
-{"return": {}}
455
-{"return": {}}
456
-{"return": {}}
457
-{"return": {}}
458
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
459
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.vdi'}}}
460
+{u'return': {}}
461
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
462
+{u'return': {}}
463
464
-image: TEST_DIR/t.IMGFMT
465
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'preallocation': 'off', 'driver': 'vdi', 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.vdi'}, 'size': 67108864}}}
466
+{u'return': {}}
467
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
468
+{u'return': {}}
469
+
470
+image: TEST_IMG
471
file format: IMGFMT
472
virtual size: 64M (67108864 bytes)
473
+cluster_size: 1048576
474
+
475
[{ "start": 0, "length": 67108864, "depth": 0, "zero": true, "data": false}]
476
477
=== Successful image creation (with non-default options) ===
478
479
-Testing:
480
-QMP_VERSION
481
-{"return": {}}
482
-{"return": {}}
483
-{"return": {}}
484
-{"return": {}}
485
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
486
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.vdi'}}}
487
+{u'return': {}}
488
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
489
+{u'return': {}}
490
491
-image: TEST_DIR/t.IMGFMT
492
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'preallocation': 'metadata', 'driver': 'vdi', 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.vdi'}, 'size': 33554432}}}
493
+{u'return': {}}
494
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
495
+{u'return': {}}
496
+
497
+image: TEST_IMG
498
file format: IMGFMT
499
virtual size: 32M (33554432 bytes)
500
-[{ "start": 0, "length": 3072, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
501
-{ "start": 3072, "length": 33551360, "depth": 0, "zero": true, "data": true, "offset": OFFSET}]
502
+cluster_size: 1048576
503
504
-=== Invalid BlockdevRef ===
505
+[{ "start": 0, "length": 3072, "depth": 0, "zero": false, "data": true, "offset": 1024},
506
+{ "start": 3072, "length": 33551360, "depth": 0, "zero": true, "data": true, "offset": 4096}]
507
508
-Testing:
509
-QMP_VERSION
510
-{"return": {}}
511
-{"error": {"class": "GenericError", "desc": "Cannot find device=this doesn't exist nor node_name=this doesn't exist"}}
512
-{"return": {}}
513
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
514
+=== Invalid BlockdevRef ===
515
516
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vdi', 'file': "this doesn't exist", 'size': 33554432}}}
517
+{u'return': {}}
518
+Job failed: Cannot find device=this doesn't exist nor node_name=this doesn't exist
519
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
520
+{u'return': {}}
521
522
=== Zero size ===
523
524
-Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0
525
-QMP_VERSION
526
-{"return": {}}
527
-{"return": {}}
528
-{"return": {}}
529
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
530
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vdi', 'file': 'node0', 'size': 0}}}
531
+{u'return': {}}
532
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
533
+{u'return': {}}
534
535
-image: TEST_DIR/t.IMGFMT
536
+image: TEST_IMG
537
file format: IMGFMT
538
virtual size: 0 (0 bytes)
539
+cluster_size: 1048576
540
541
=== Maximum size ===
542
543
-Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0
544
-QMP_VERSION
545
-{"return": {}}
546
-{"return": {}}
547
-{"return": {}}
548
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
549
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vdi', 'file': 'node0', 'size': 562949819203584}}}
550
+{u'return': {}}
551
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
552
+{u'return': {}}
553
554
-image: TEST_DIR/t.IMGFMT
555
+image: TEST_IMG
556
file format: IMGFMT
557
virtual size: 512T (562949819203584 bytes)
558
+cluster_size: 1048576
559
560
=== Invalid sizes ===
561
562
-Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0
563
-QMP_VERSION
564
-{"return": {}}
565
-{"error": {"class": "GenericError", "desc": "Unsupported VDI image size (size is 0xfffffffffffffe00, max supported is 0x1fffff8000000)"}}
566
-{"error": {"class": "GenericError", "desc": "Unsupported VDI image size (size is 0x8000000000000000, max supported is 0x1fffff8000000)"}}
567
-{"error": {"class": "GenericError", "desc": "Unsupported VDI image size (size is 0x1fffff8000001, max supported is 0x1fffff8000000)"}}
568
-{"return": {}}
569
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
570
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vdi', 'file': 'node0', 'size': 18446744073709551104L}}}
571
+{u'return': {}}
572
+Job failed: Unsupported VDI image size (size is 0xfffffffffffffe00, max supported is 0x1fffff8000000)
573
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
574
+{u'return': {}}
575
+
576
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vdi', 'file': 'node0', 'size': 9223372036854775808L}}}
577
+{u'return': {}}
578
+Job failed: Unsupported VDI image size (size is 0x8000000000000000, max supported is 0x1fffff8000000)
579
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
580
+{u'return': {}}
581
+
582
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'vdi', 'file': 'node0', 'size': 562949819203585}}}
583
+{u'return': {}}
584
+Job failed: Unsupported VDI image size (size is 0x1fffff8000001, max supported is 0x1fffff8000000)
585
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
586
+{u'return': {}}
587
588
-*** done
589
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
590
index XXXXXXX..XXXXXXX 100644
591
--- a/tests/qemu-iotests/group
592
+++ b/tests/qemu-iotests/group
593
@@ -XXX,XX +XXX,XX @@
594
208 rw auto quick
595
209 rw auto quick
596
210 rw auto
597
+211 rw auto quick
598
# TODO The following commented out tests need to be reworked to work
599
# with the x-blockdev-create job
600
-#211 rw auto quick
601
#212 rw auto quick
602
#213 rw auto quick
603
214 rw auto
604
--
41
--
605
2.13.6
42
2.19.1
606
43
607
44
diff view generated by jsdifflib
1
So far we relied on job->ret and strerror() to produce an error message
1
If read-only=off, but auto-read-only=on is given, just degrade to
2
for failed jobs. Not surprisingly, this tends to result in completely
2
read-only.
3
useless messages.
4
5
This adds a Job.error field that can contain an error string for a
6
failing job, and a parameter to job_completed() that sets the field. As
7
a default, if NULL is passed, we continue to use strerror(job->ret).
8
9
All existing callers are changed to pass NULL. They can be improved in
10
separate patches.
11
3
12
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13
Reviewed-by: Max Reitz <mreitz@redhat.com>
5
Reviewed-by: Eric Blake <eblake@redhat.com>
14
Reviewed-by: Jeff Cody <jcody@redhat.com>
15
---
6
---
16
include/qemu/job.h | 7 ++++++-
7
block/curl.c | 8 ++++----
17
block/backup.c | 2 +-
8
1 file changed, 4 insertions(+), 4 deletions(-)
18
block/commit.c | 2 +-
19
block/mirror.c | 2 +-
20
block/stream.c | 2 +-
21
job-qmp.c | 9 ++-------
22
job.c | 16 ++++++++++++++--
23
tests/test-bdrv-drain.c | 2 +-
24
tests/test-blockjob-txn.c | 2 +-
25
tests/test-blockjob.c | 2 +-
26
10 files changed, 29 insertions(+), 17 deletions(-)
27
9
28
diff --git a/include/qemu/job.h b/include/qemu/job.h
10
diff --git a/block/curl.c b/block/curl.c
29
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
30
--- a/include/qemu/job.h
12
--- a/block/curl.c
31
+++ b/include/qemu/job.h
13
+++ b/block/curl.c
32
@@ -XXX,XX +XXX,XX @@ typedef struct Job {
14
@@ -XXX,XX +XXX,XX @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
33
/** Estimated progress_current value at the completion of the job */
15
const char *protocol_delimiter;
34
int64_t progress_total;
35
36
+ /** Error string for a failed job (NULL if, and only if, job->ret == 0) */
37
+ char *error;
38
+
39
/** ret code passed to job_completed. */
40
int ret;
16
int ret;
41
17
42
@@ -XXX,XX +XXX,XX @@ void job_transition_to_ready(Job *job);
18
-
43
/**
19
- if (flags & BDRV_O_RDWR) {
44
* @job: The job being completed.
20
- error_setg(errp, "curl block device does not support writes");
45
* @ret: The status code.
21
- return -EROFS;
46
+ * @error: The error message for a failing job (only with @ret < 0). If @ret is
22
+ ret = bdrv_apply_auto_read_only(bs, "curl driver does not support writes",
47
+ * negative, but NULL is given for @error, strerror() is used.
23
+ errp);
48
*
24
+ if (ret < 0) {
49
* Marks @job as completed. If @ret is non-zero, the job transaction it is part
25
+ return ret;
50
* of is aborted. If @ret is zero, the job moves into the WAITING state. If it
51
* is the last job to complete in its transaction, all jobs in the transaction
52
* move from WAITING to PENDING.
53
*/
54
-void job_completed(Job *job, int ret);
55
+void job_completed(Job *job, int ret, Error *error);
56
57
/** Asynchronously complete the specified @job. */
58
void job_complete(Job *job, Error **errp);
59
diff --git a/block/backup.c b/block/backup.c
60
index XXXXXXX..XXXXXXX 100644
61
--- a/block/backup.c
62
+++ b/block/backup.c
63
@@ -XXX,XX +XXX,XX @@ static void backup_complete(Job *job, void *opaque)
64
{
65
BackupCompleteData *data = opaque;
66
67
- job_completed(job, data->ret);
68
+ job_completed(job, data->ret, NULL);
69
g_free(data);
70
}
71
72
diff --git a/block/commit.c b/block/commit.c
73
index XXXXXXX..XXXXXXX 100644
74
--- a/block/commit.c
75
+++ b/block/commit.c
76
@@ -XXX,XX +XXX,XX @@ static void commit_complete(Job *job, void *opaque)
77
* bdrv_set_backing_hd() to fail. */
78
block_job_remove_all_bdrv(bjob);
79
80
- job_completed(job, ret);
81
+ job_completed(job, ret, NULL);
82
g_free(data);
83
84
/* If bdrv_drop_intermediate() didn't already do that, remove the commit
85
diff --git a/block/mirror.c b/block/mirror.c
86
index XXXXXXX..XXXXXXX 100644
87
--- a/block/mirror.c
88
+++ b/block/mirror.c
89
@@ -XXX,XX +XXX,XX @@ static void mirror_exit(Job *job, void *opaque)
90
blk_set_perm(bjob->blk, 0, BLK_PERM_ALL, &error_abort);
91
blk_insert_bs(bjob->blk, mirror_top_bs, &error_abort);
92
93
- job_completed(job, data->ret);
94
+ job_completed(job, data->ret, NULL);
95
96
g_free(data);
97
bdrv_drained_end(src);
98
diff --git a/block/stream.c b/block/stream.c
99
index XXXXXXX..XXXXXXX 100644
100
--- a/block/stream.c
101
+++ b/block/stream.c
102
@@ -XXX,XX +XXX,XX @@ out:
103
}
26
}
104
27
105
g_free(s->backing_file_str);
28
if (!libcurl_initialized) {
106
- job_completed(job, data->ret);
107
+ job_completed(job, data->ret, NULL);
108
g_free(data);
109
}
110
111
diff --git a/job-qmp.c b/job-qmp.c
112
index XXXXXXX..XXXXXXX 100644
113
--- a/job-qmp.c
114
+++ b/job-qmp.c
115
@@ -XXX,XX +XXX,XX @@ void qmp_job_dismiss(const char *id, Error **errp)
116
static JobInfo *job_query_single(Job *job, Error **errp)
117
{
118
JobInfo *info;
119
- const char *errmsg = NULL;
120
121
assert(!job_is_internal(job));
122
123
- if (job->ret < 0) {
124
- errmsg = strerror(-job->ret);
125
- }
126
-
127
info = g_new(JobInfo, 1);
128
*info = (JobInfo) {
129
.id = g_strdup(job->id),
130
@@ -XXX,XX +XXX,XX @@ static JobInfo *job_query_single(Job *job, Error **errp)
131
.status = job->status,
132
.current_progress = job->progress_current,
133
.total_progress = job->progress_total,
134
- .has_error = !!errmsg,
135
- .error = g_strdup(errmsg),
136
+ .has_error = !!job->error,
137
+ .error = g_strdup(job->error),
138
};
139
140
return info;
141
diff --git a/job.c b/job.c
142
index XXXXXXX..XXXXXXX 100644
143
--- a/job.c
144
+++ b/job.c
145
@@ -XXX,XX +XXX,XX @@ void job_unref(Job *job)
146
147
QLIST_REMOVE(job, job_list);
148
149
+ g_free(job->error);
150
g_free(job->id);
151
g_free(job);
152
}
153
@@ -XXX,XX +XXX,XX @@ static void job_update_rc(Job *job)
154
job->ret = -ECANCELED;
155
}
156
if (job->ret) {
157
+ if (!job->error) {
158
+ job->error = g_strdup(strerror(-job->ret));
159
+ }
160
job_state_transition(job, JOB_STATUS_ABORTING);
161
}
162
}
163
@@ -XXX,XX +XXX,XX @@ static int job_prepare(Job *job)
164
{
165
if (job->ret == 0 && job->driver->prepare) {
166
job->ret = job->driver->prepare(job);
167
+ job_update_rc(job);
168
}
169
return job->ret;
170
}
171
@@ -XXX,XX +XXX,XX @@ static void job_completed_txn_success(Job *job)
172
}
173
}
174
175
-void job_completed(Job *job, int ret)
176
+void job_completed(Job *job, int ret, Error *error)
177
{
178
assert(job && job->txn && !job_is_completed(job));
179
+
180
job->ret = ret;
181
+ if (error) {
182
+ assert(job->ret < 0);
183
+ job->error = g_strdup(error_get_pretty(error));
184
+ error_free(error);
185
+ }
186
+
187
job_update_rc(job);
188
trace_job_completed(job, ret, job->ret);
189
if (job->ret) {
190
@@ -XXX,XX +XXX,XX @@ void job_cancel(Job *job, bool force)
191
}
192
job_cancel_async(job, force);
193
if (!job_started(job)) {
194
- job_completed(job, -ECANCELED);
195
+ job_completed(job, -ECANCELED, NULL);
196
} else if (job->deferred_to_main_loop) {
197
job_completed_txn_abort(job);
198
} else {
199
diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c
200
index XXXXXXX..XXXXXXX 100644
201
--- a/tests/test-bdrv-drain.c
202
+++ b/tests/test-bdrv-drain.c
203
@@ -XXX,XX +XXX,XX @@ typedef struct TestBlockJob {
204
205
static void test_job_completed(Job *job, void *opaque)
206
{
207
- job_completed(job, 0);
208
+ job_completed(job, 0, NULL);
209
}
210
211
static void coroutine_fn test_job_start(void *opaque)
212
diff --git a/tests/test-blockjob-txn.c b/tests/test-blockjob-txn.c
213
index XXXXXXX..XXXXXXX 100644
214
--- a/tests/test-blockjob-txn.c
215
+++ b/tests/test-blockjob-txn.c
216
@@ -XXX,XX +XXX,XX @@ static void test_block_job_complete(Job *job, void *opaque)
217
rc = -ECANCELED;
218
}
219
220
- job_completed(job, rc);
221
+ job_completed(job, rc, NULL);
222
bdrv_unref(bs);
223
}
224
225
diff --git a/tests/test-blockjob.c b/tests/test-blockjob.c
226
index XXXXXXX..XXXXXXX 100644
227
--- a/tests/test-blockjob.c
228
+++ b/tests/test-blockjob.c
229
@@ -XXX,XX +XXX,XX @@ static void cancel_job_completed(Job *job, void *opaque)
230
{
231
CancelJob *s = opaque;
232
s->completed = true;
233
- job_completed(job, 0);
234
+ job_completed(job, 0, NULL);
235
}
236
237
static void cancel_job_complete(Job *job, Error **errp)
238
--
29
--
239
2.13.6
30
2.19.1
240
31
241
32
diff view generated by jsdifflib
1
This rewrites the test case 210 to work with the new x-blockdev-create
1
If read-only=off, but auto-read-only=on is given, open the file
2
job rather than the old synchronous version of the command.
2
read-write if we have the permissions, but instead of erroring out for
3
3
read-only files, just degrade to read-only.
4
All of the test cases stay the same as before, but in order to be able
5
to implement proper job handling, the test case is rewritten in Python.
6
4
7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
5
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
Reviewed-by: Max Reitz <mreitz@redhat.com>
6
Reviewed-by: Niels de Vos <ndevos@redhat.com>
9
Reviewed-by: Jeff Cody <jcody@redhat.com>
10
---
7
---
11
tests/qemu-iotests/210 | 393 ++++++++++++++++++------------------------
8
block/gluster.c | 12 ++++++++++--
12
tests/qemu-iotests/210.out | 197 ++++++++++++++-------
9
1 file changed, 10 insertions(+), 2 deletions(-)
13
tests/qemu-iotests/group | 2 +-
14
tests/qemu-iotests/iotests.py | 12 +-
15
4 files changed, 314 insertions(+), 290 deletions(-)
16
10
17
diff --git a/tests/qemu-iotests/210 b/tests/qemu-iotests/210
11
diff --git a/block/gluster.c b/block/gluster.c
18
index XXXXXXX..XXXXXXX 100755
12
index XXXXXXX..XXXXXXX 100644
19
--- a/tests/qemu-iotests/210
13
--- a/block/gluster.c
20
+++ b/tests/qemu-iotests/210
14
+++ b/block/gluster.c
21
@@ -XXX,XX +XXX,XX @@
15
@@ -XXX,XX +XXX,XX @@ static int qemu_gluster_open(BlockDriverState *bs, QDict *options,
22
-#!/bin/bash
16
qemu_gluster_parse_flags(bdrv_flags, &open_flags);
23
+#!/usr/bin/env python
17
24
#
18
s->fd = glfs_open(s->glfs, gconf->path, open_flags);
25
# Test luks and file image creation
19
- if (!s->fd) {
26
#
20
- ret = -errno;
27
# Copyright (C) 2018 Red Hat, Inc.
21
+ ret = s->fd ? 0 : -errno;
28
#
29
+# Creator/Owner: Kevin Wolf <kwolf@redhat.com>
30
+#
31
# This program is free software; you can redistribute it and/or modify
32
# it under the terms of the GNU General Public License as published by
33
# the Free Software Foundation; either version 2 of the License, or
34
@@ -XXX,XX +XXX,XX @@
35
# along with this program. If not, see <http://www.gnu.org/licenses/>.
36
#
37
38
-# creator
39
-owner=kwolf@redhat.com
40
-
41
-seq=`basename $0`
42
-echo "QA output created by $seq"
43
-
44
-here=`pwd`
45
-status=1    # failure is the default!
46
-
47
-# get standard environment, filters and checks
48
-. ./common.rc
49
-. ./common.filter
50
-
51
-_supported_fmt luks
52
-_supported_proto file
53
-_supported_os Linux
54
-
55
-function do_run_qemu()
56
-{
57
- echo Testing: "$@"
58
- $QEMU -nographic -qmp stdio -serial none "$@"
59
- echo
60
-}
61
-
62
-function run_qemu()
63
-{
64
- do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \
65
- | _filter_qemu | _filter_imgfmt \
66
- | _filter_actual_image_size
67
-}
68
-
69
-echo
70
-echo "=== Successful image creation (defaults) ==="
71
-echo
72
-
73
-size=$((128 * 1024 * 1024))
74
-
75
-run_qemu -object secret,id=keysec0,data="foo" <<EOF
76
-{ "execute": "qmp_capabilities" }
77
-{ "execute": "x-blockdev-create",
78
- "arguments": {
79
- "driver": "file",
80
- "filename": "$TEST_IMG_FILE",
81
- "size": 0
82
- }
83
-}
84
-{ "execute": "blockdev-add",
85
- "arguments": {
86
- "driver": "file",
87
- "node-name": "imgfile",
88
- "filename": "$TEST_IMG_FILE"
89
- }
90
-}
91
-{ "execute": "x-blockdev-create",
92
- "arguments": {
93
- "driver": "$IMGFMT",
94
- "file": "imgfile",
95
- "key-secret": "keysec0",
96
- "size": $size,
97
- "iter-time": 10
98
- }
99
-}
100
-{ "execute": "quit" }
101
-EOF
102
-
103
-_img_info --format-specific | _filter_img_info --format-specific
104
-
105
-echo
106
-echo "=== Successful image creation (with non-default options) ==="
107
-echo
108
-
109
-# Choose a different size to show that we got a new image
110
-size=$((64 * 1024 * 1024))
111
-
112
-run_qemu -object secret,id=keysec0,data="foo" <<EOF
113
-{ "execute": "qmp_capabilities" }
114
-{ "execute": "x-blockdev-create",
115
- "arguments": {
116
- "driver": "file",
117
- "filename": "$TEST_IMG_FILE",
118
- "size": 0
119
- }
120
-}
121
-{ "execute": "x-blockdev-create",
122
- "arguments": {
123
- "driver": "$IMGFMT",
124
- "file": {
125
- "driver": "file",
126
- "filename": "$TEST_IMG_FILE"
127
- },
128
- "size": $size,
129
- "key-secret": "keysec0",
130
- "cipher-alg": "twofish-128",
131
- "cipher-mode": "ctr",
132
- "ivgen-alg": "plain64",
133
- "ivgen-hash-alg": "md5",
134
- "hash-alg": "sha1",
135
- "iter-time": 10
136
- }
137
-}
138
-{ "execute": "quit" }
139
-EOF
140
-
141
-_img_info --format-specific | _filter_img_info --format-specific
142
-
143
-echo
144
-echo "=== Invalid BlockdevRef ==="
145
-echo
146
-
147
-run_qemu <<EOF
148
-{ "execute": "qmp_capabilities" }
149
-{ "execute": "x-blockdev-create",
150
- "arguments": {
151
- "driver": "$IMGFMT",
152
- "file": "this doesn't exist",
153
- "size": $size
154
- }
155
-}
156
-{ "execute": "quit" }
157
-EOF
158
-
159
-echo
160
-echo "=== Zero size ==="
161
-echo
162
-
163
-run_qemu -blockdev driver=file,filename="$TEST_IMG_FILE",node-name=node0 \
164
- -object secret,id=keysec0,data="foo" <<EOF
165
-{ "execute": "qmp_capabilities" }
166
-{ "execute": "x-blockdev-create",
167
- "arguments": {
168
- "driver": "$IMGFMT",
169
- "file": "node0",
170
- "key-secret": "keysec0",
171
- "size": 0,
172
- "iter-time": 10
173
- }
174
-}
175
-{ "execute": "quit" }
176
-EOF
177
-
178
-_img_info | _filter_img_info
179
-
180
-
181
-echo
182
-echo "=== Invalid sizes ==="
183
-echo
184
-
185
-# TODO Negative image sizes aren't handled correctly, but this is a problem
186
-# with QAPI's implementation of the 'size' type and affects other commands as
187
-# well. Once this is fixed, we may want to add a test case here.
188
-
189
-# 1. 2^64 - 512
190
-# 2. 2^63 = 8 EB (qemu-img enforces image sizes less than this)
191
-# 3. 2^63 - 512 (generally valid, but with the crypto header the file will
192
-# exceed 63 bits)
193
-
194
-run_qemu -blockdev driver=file,filename="$TEST_IMG_FILE",node-name=node0 \
195
- -object secret,id=keysec0,data="foo" <<EOF
196
-{ "execute": "qmp_capabilities" }
197
-{ "execute": "x-blockdev-create",
198
- "arguments": {
199
- "driver": "$IMGFMT",
200
- "file": "node0",
201
- "key-secret": "keysec0",
202
- "size": 18446744073709551104
203
- }
204
-}
205
-{ "execute": "x-blockdev-create",
206
- "arguments": {
207
- "driver": "$IMGFMT",
208
- "file": "node0",
209
- "key-secret": "keysec0",
210
- "size": 9223372036854775808
211
- }
212
-}
213
-{ "execute": "x-blockdev-create",
214
- "arguments": {
215
- "driver": "$IMGFMT",
216
- "file": "node0",
217
- "key-secret": "keysec0",
218
- "size": 9223372036854775296
219
- }
220
-}
221
-{ "execute": "quit" }
222
-EOF
223
-
224
-echo
225
-echo "=== Resize image with invalid sizes ==="
226
-echo
227
-
228
-run_qemu -blockdev driver=file,filename="$TEST_IMG_FILE",node-name=node0 \
229
- -blockdev driver=luks,file=node0,key-secret=keysec0,node-name=node1 \
230
- -object secret,id=keysec0,data="foo" <<EOF
231
-{ "execute": "qmp_capabilities" }
232
-{ "execute": "block_resize",
233
- "arguments": {
234
- "node-name": "node1",
235
- "size": 9223372036854775296
236
- }
237
-}
238
-{ "execute": "block_resize",
239
- "arguments": {
240
- "node-name": "node1",
241
- "size": 9223372036854775808
242
- }
243
-}
244
-{ "execute": "block_resize",
245
- "arguments": {
246
- "node-name": "node1",
247
- "size": 18446744073709551104
248
- }
249
-}
250
-{ "execute": "block_resize",
251
- "arguments": {
252
- "node-name": "node1",
253
- "size": -9223372036854775808
254
- }
255
-}
256
-{ "execute": "quit" }
257
-EOF
258
-
259
-_img_info | _filter_img_info
260
-
261
-# success, all done
262
-echo "*** done"
263
-rm -f $seq.full
264
-status=0
265
+import iotests
266
+from iotests import imgfmt
267
+
22
+
268
+iotests.verify_image_format(supported_fmts=['luks'])
23
+ if (ret == -EACCES || ret == -EROFS) {
269
+iotests.verify_protocol(supported=['file'])
24
+ /* Try to degrade to read-only, but if it doesn't work, still use the
270
+
25
+ * normal error message. */
271
+def blockdev_create(vm, options):
26
+ if (bdrv_apply_auto_read_only(bs, NULL, NULL) == 0) {
272
+ result = vm.qmp_log('x-blockdev-create', job_id='job0', options=options)
27
+ open_flags = (open_flags & ~O_RDWR) | O_RDONLY;
273
+
28
+ s->fd = glfs_open(s->glfs, gconf->path, open_flags);
274
+ if 'return' in result:
29
+ ret = s->fd ? 0 : -errno;
275
+ assert result['return'] == {}
30
+ }
276
+ vm.run_job('job0')
31
}
277
+ iotests.log("")
32
278
+
33
s->supports_seek_data = qemu_gluster_test_seek(s->fd);
279
+with iotests.FilePath('t.luks') as disk_path, \
280
+ iotests.VM() as vm:
281
+
282
+ vm.add_object('secret,id=keysec0,data=foo')
283
+
284
+ #
285
+ # Successful image creation (defaults)
286
+ #
287
+ iotests.log("=== Successful image creation (defaults) ===")
288
+ iotests.log("")
289
+
290
+ size = 128 * 1024 * 1024
291
+
292
+ vm.launch()
293
+ blockdev_create(vm, { 'driver': 'file',
294
+ 'filename': disk_path,
295
+ 'size': 0 })
296
+
297
+ vm.qmp_log('blockdev-add', driver='file', filename=disk_path,
298
+ node_name='imgfile')
299
+
300
+ blockdev_create(vm, { 'driver': imgfmt,
301
+ 'file': 'imgfile',
302
+ 'key-secret': 'keysec0',
303
+ 'size': size,
304
+ 'iter-time': 10 })
305
+ vm.shutdown()
306
+
307
+ # TODO Proper support for images to be used with imgopts and/or protocols
308
+ iotests.img_info_log(
309
+ 'driver=luks,file.driver=file,file.filename=%s,key-secret=keysec0' % (disk_path),
310
+ filter_path=disk_path,
311
+ extra_args=['--object', 'secret,id=keysec0,data=foo'],
312
+ imgopts=True)
313
+
314
+ #
315
+ # Successful image creation (with non-default options)
316
+ #
317
+ iotests.log("=== Successful image creation (with non-default options) ===")
318
+ iotests.log("")
319
+
320
+ size = 64 * 1024 * 1024
321
+
322
+ vm.launch()
323
+ blockdev_create(vm, { 'driver': 'file',
324
+ 'filename': disk_path,
325
+ 'size': 0 })
326
+ blockdev_create(vm, { 'driver': imgfmt,
327
+ 'file': {
328
+ 'driver': 'file',
329
+ 'filename': disk_path,
330
+ },
331
+ 'size': size,
332
+ 'key-secret': 'keysec0',
333
+ 'cipher-alg': 'twofish-128',
334
+ 'cipher-mode': 'ctr',
335
+ 'ivgen-alg': 'plain64',
336
+ 'ivgen-hash-alg': 'md5',
337
+ 'hash-alg': 'sha1',
338
+ 'iter-time': 10 })
339
+ vm.shutdown()
340
+
341
+ # TODO Proper support for images to be used with imgopts and/or protocols
342
+ iotests.img_info_log(
343
+ 'driver=luks,file.driver=file,file.filename=%s,key-secret=keysec0' % (disk_path),
344
+ filter_path=disk_path,
345
+ extra_args=['--object', 'secret,id=keysec0,data=foo'],
346
+ imgopts=True)
347
+
348
+ #
349
+ # Invalid BlockdevRef
350
+ #
351
+ iotests.log("=== Invalid BlockdevRef ===")
352
+ iotests.log("")
353
+
354
+ size = 64 * 1024 * 1024
355
+
356
+ vm.launch()
357
+ blockdev_create(vm, { 'driver': imgfmt,
358
+ 'file': "this doesn't exist",
359
+ 'size': size })
360
+ vm.shutdown()
361
+
362
+ #
363
+ # Zero size
364
+ #
365
+ iotests.log("=== Zero size ===")
366
+ iotests.log("")
367
+
368
+ vm.add_blockdev('driver=file,filename=%s,node-name=node0' % (disk_path))
369
+ vm.launch()
370
+ blockdev_create(vm, { 'driver': imgfmt,
371
+ 'file': 'node0',
372
+ 'key-secret': 'keysec0',
373
+ 'size': 0,
374
+ 'iter-time': 10 })
375
+ vm.shutdown()
376
+
377
+ # TODO Proper support for images to be used with imgopts and/or protocols
378
+ iotests.img_info_log(
379
+ 'driver=luks,file.driver=file,file.filename=%s,key-secret=keysec0' % (disk_path),
380
+ filter_path=disk_path,
381
+ extra_args=['--object', 'secret,id=keysec0,data=foo'],
382
+ imgopts=True)
383
+
384
+ #
385
+ # Invalid sizes
386
+ #
387
+
388
+ # TODO Negative image sizes aren't handled correctly, but this is a problem
389
+ # with QAPI's implementation of the 'size' type and affects other commands as
390
+ # well. Once this is fixed, we may want to add a test case here.
391
+
392
+ # 1. 2^64 - 512
393
+ # 2. 2^63 = 8 EB (qemu-img enforces image sizes less than this)
394
+ # 3. 2^63 - 512 (generally valid, but with the crypto header the file will
395
+ # exceed 63 bits)
396
+ iotests.log("=== Invalid sizes ===")
397
+ iotests.log("")
398
+
399
+ vm.launch()
400
+ for size in [ 18446744073709551104, 9223372036854775808, 9223372036854775296 ]:
401
+ blockdev_create(vm, { 'driver': imgfmt,
402
+ 'file': 'node0',
403
+ 'key-secret': 'keysec0',
404
+ 'size': size })
405
+ vm.shutdown()
406
+
407
+ #
408
+ # Resize image with invalid sizes
409
+ #
410
+ iotests.log("=== Resize image with invalid sizes ===")
411
+ iotests.log("")
412
+
413
+ vm.add_blockdev('driver=luks,file=node0,key-secret=keysec0,node-name=node1')
414
+ vm.launch()
415
+ vm.qmp_log('block_resize', node_name='node1', size=9223372036854775296)
416
+ vm.qmp_log('block_resize', node_name='node1', size=9223372036854775808)
417
+ vm.qmp_log('block_resize', node_name='node1', size=18446744073709551104)
418
+ vm.qmp_log('block_resize', node_name='node1', size=-9223372036854775808)
419
+ vm.shutdown()
420
+
421
+ # TODO Proper support for images to be used with imgopts and/or protocols
422
+ iotests.img_info_log(
423
+ 'driver=luks,file.driver=file,file.filename=%s,key-secret=keysec0' % (disk_path),
424
+ filter_path=disk_path,
425
+ extra_args=['--object', 'secret,id=keysec0,data=foo'],
426
+ imgopts=True)
427
diff --git a/tests/qemu-iotests/210.out b/tests/qemu-iotests/210.out
428
index XXXXXXX..XXXXXXX 100644
429
--- a/tests/qemu-iotests/210.out
430
+++ b/tests/qemu-iotests/210.out
431
@@ -XXX,XX +XXX,XX @@
432
-QA output created by 210
433
-
434
=== Successful image creation (defaults) ===
435
436
-Testing: -object secret,id=keysec0,data=foo
437
-QMP_VERSION
438
-{"return": {}}
439
-{"return": {}}
440
-{"return": {}}
441
-{"return": {}}
442
-{"return": {}}
443
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
444
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.luks'}}}
445
+{u'return': {}}
446
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
447
+{u'return': {}}
448
+
449
+{'execute': 'blockdev-add', 'arguments': {'node_name': 'imgfile', 'driver': 'file', 'filename': 'TEST_DIR/PID-t.luks'}}
450
+{u'return': {}}
451
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'key-secret': 'keysec0', 'iter-time': 10, 'driver': 'luks', 'file': 'imgfile', 'size': 134217728}}}
452
+{u'return': {}}
453
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
454
+{u'return': {}}
455
456
-image: json:{"driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "key-secret": "keysec0"}
457
+image: json:{"driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_IMG"}, "key-secret": "keysec0"}
458
file format: IMGFMT
459
virtual size: 128M (134217728 bytes)
460
+encrypted: yes
461
Format specific information:
462
ivgen alg: plain64
463
hash alg: sha256
464
cipher alg: aes-256
465
- uuid: 00000000-0000-0000-0000-000000000000
466
+ uuid: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
467
cipher mode: xts
468
slots:
469
[0]:
470
active: true
471
- iters: 1024
472
+ iters: XXX
473
key offset: 4096
474
stripes: 4000
475
[1]:
476
@@ -XXX,XX +XXX,XX @@ Format specific information:
477
active: false
478
key offset: 1810432
479
payload offset: 2068480
480
- master key iters: 1024
481
+ master key iters: XXX
482
483
=== Successful image creation (with non-default options) ===
484
485
-Testing: -object secret,id=keysec0,data=foo
486
-QMP_VERSION
487
-{"return": {}}
488
-{"return": {}}
489
-{"return": {}}
490
-{"return": {}}
491
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
492
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.luks'}}}
493
+{u'return': {}}
494
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
495
+{u'return': {}}
496
+
497
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'key-secret': 'keysec0', 'hash-alg': 'sha1', 'cipher-mode': 'ctr', 'cipher-alg': 'twofish-128', 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.luks'}, 'iter-time': 10, 'ivgen-alg': 'plain64', 'ivgen-hash-alg': 'md5', 'driver': 'luks', 'size': 67108864}}}
498
+{u'return': {}}
499
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
500
+{u'return': {}}
501
502
-image: json:{"driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "key-secret": "keysec0"}
503
+image: json:{"driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_IMG"}, "key-secret": "keysec0"}
504
file format: IMGFMT
505
virtual size: 64M (67108864 bytes)
506
+encrypted: yes
507
Format specific information:
508
ivgen alg: plain64
509
hash alg: sha1
510
cipher alg: twofish-128
511
- uuid: 00000000-0000-0000-0000-000000000000
512
+ uuid: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
513
cipher mode: ctr
514
slots:
515
[0]:
516
active: true
517
- iters: 1024
518
+ iters: XXX
519
key offset: 4096
520
stripes: 4000
521
[1]:
522
@@ -XXX,XX +XXX,XX @@ Format specific information:
523
active: false
524
key offset: 462848
525
payload offset: 528384
526
- master key iters: 1024
527
+ master key iters: XXX
528
529
=== Invalid BlockdevRef ===
530
531
-Testing:
532
-QMP_VERSION
533
-{"return": {}}
534
-{"error": {"class": "GenericError", "desc": "Cannot find device=this doesn't exist nor node_name=this doesn't exist"}}
535
-{"return": {}}
536
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
537
-
538
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'luks', 'file': "this doesn't exist", 'size': 67108864}}}
539
+{u'return': {}}
540
+Job failed: Cannot find device=this doesn't exist nor node_name=this doesn't exist
541
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
542
+{u'return': {}}
543
544
=== Zero size ===
545
546
-Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0 -object secret,id=keysec0,data=foo
547
-QMP_VERSION
548
-{"return": {}}
549
-{"return": {}}
550
-{"return": {}}
551
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
552
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'key-secret': 'keysec0', 'iter-time': 10, 'driver': 'luks', 'file': 'node0', 'size': 0}}}
553
+{u'return': {}}
554
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
555
+{u'return': {}}
556
557
-image: json:{"driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "key-secret": "keysec0"}
558
+image: json:{"driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_IMG"}, "key-secret": "keysec0"}
559
file format: IMGFMT
560
virtual size: 0 (0 bytes)
561
+encrypted: yes
562
+Format specific information:
563
+ ivgen alg: plain64
564
+ hash alg: sha256
565
+ cipher alg: aes-256
566
+ uuid: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
567
+ cipher mode: xts
568
+ slots:
569
+ [0]:
570
+ active: true
571
+ iters: XXX
572
+ key offset: 4096
573
+ stripes: 4000
574
+ [1]:
575
+ active: false
576
+ key offset: 262144
577
+ [2]:
578
+ active: false
579
+ key offset: 520192
580
+ [3]:
581
+ active: false
582
+ key offset: 778240
583
+ [4]:
584
+ active: false
585
+ key offset: 1036288
586
+ [5]:
587
+ active: false
588
+ key offset: 1294336
589
+ [6]:
590
+ active: false
591
+ key offset: 1552384
592
+ [7]:
593
+ active: false
594
+ key offset: 1810432
595
+ payload offset: 2068480
596
+ master key iters: XXX
597
598
=== Invalid sizes ===
599
600
-Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0 -object secret,id=keysec0,data=foo
601
-QMP_VERSION
602
-{"return": {}}
603
-{"error": {"class": "GenericError", "desc": "The requested file size is too large"}}
604
-{"error": {"class": "GenericError", "desc": "The requested file size is too large"}}
605
-{"error": {"class": "GenericError", "desc": "The requested file size is too large"}}
606
-{"return": {}}
607
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
608
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'key-secret': 'keysec0', 'driver': 'luks', 'file': 'node0', 'size': 18446744073709551104L}}}
609
+{u'return': {}}
610
+Job failed: The requested file size is too large
611
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
612
+{u'return': {}}
613
+
614
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'key-secret': 'keysec0', 'driver': 'luks', 'file': 'node0', 'size': 9223372036854775808L}}}
615
+{u'return': {}}
616
+Job failed: The requested file size is too large
617
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
618
+{u'return': {}}
619
620
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'key-secret': 'keysec0', 'driver': 'luks', 'file': 'node0', 'size': 9223372036854775296}}}
621
+{u'return': {}}
622
+Job failed: The requested file size is too large
623
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
624
+{u'return': {}}
625
626
=== Resize image with invalid sizes ===
627
628
-Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0 -blockdev driver=IMGFMT,file=node0,key-secret=keysec0,node-name=node1 -object secret,id=keysec0,data=foo
629
-QMP_VERSION
630
-{"return": {}}
631
-{"error": {"class": "GenericError", "desc": "The requested file size is too large"}}
632
-{"error": {"class": "GenericError", "desc": "Invalid parameter type for 'size', expected: integer"}}
633
-{"error": {"class": "GenericError", "desc": "Invalid parameter type for 'size', expected: integer"}}
634
-{"error": {"class": "GenericError", "desc": "Parameter 'size' expects a >0 size"}}
635
-{"return": {}}
636
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
637
-
638
-image: json:{"driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "key-secret": "keysec0"}
639
+{'execute': 'block_resize', 'arguments': {'size': 9223372036854775296, 'node_name': 'node1'}}
640
+{u'error': {u'class': u'GenericError', u'desc': u'The requested file size is too large'}}
641
+{'execute': 'block_resize', 'arguments': {'size': 9223372036854775808L, 'node_name': 'node1'}}
642
+{u'error': {u'class': u'GenericError', u'desc': u"Invalid parameter type for 'size', expected: integer"}}
643
+{'execute': 'block_resize', 'arguments': {'size': 18446744073709551104L, 'node_name': 'node1'}}
644
+{u'error': {u'class': u'GenericError', u'desc': u"Invalid parameter type for 'size', expected: integer"}}
645
+{'execute': 'block_resize', 'arguments': {'size': -9223372036854775808, 'node_name': 'node1'}}
646
+{u'error': {u'class': u'GenericError', u'desc': u"Parameter 'size' expects a >0 size"}}
647
+image: json:{"driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_IMG"}, "key-secret": "keysec0"}
648
file format: IMGFMT
649
virtual size: 0 (0 bytes)
650
-*** done
651
+encrypted: yes
652
+Format specific information:
653
+ ivgen alg: plain64
654
+ hash alg: sha256
655
+ cipher alg: aes-256
656
+ uuid: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
657
+ cipher mode: xts
658
+ slots:
659
+ [0]:
660
+ active: true
661
+ iters: XXX
662
+ key offset: 4096
663
+ stripes: 4000
664
+ [1]:
665
+ active: false
666
+ key offset: 262144
667
+ [2]:
668
+ active: false
669
+ key offset: 520192
670
+ [3]:
671
+ active: false
672
+ key offset: 778240
673
+ [4]:
674
+ active: false
675
+ key offset: 1036288
676
+ [5]:
677
+ active: false
678
+ key offset: 1294336
679
+ [6]:
680
+ active: false
681
+ key offset: 1552384
682
+ [7]:
683
+ active: false
684
+ key offset: 1810432
685
+ payload offset: 2068480
686
+ master key iters: XXX
687
+
688
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
689
index XXXXXXX..XXXXXXX 100644
690
--- a/tests/qemu-iotests/group
691
+++ b/tests/qemu-iotests/group
692
@@ -XXX,XX +XXX,XX @@
693
207 rw auto
694
208 rw auto quick
695
209 rw auto quick
696
+210 rw auto
697
# TODO The following commented out tests need to be reworked to work
698
# with the x-blockdev-create job
699
-#210 rw auto
700
#211 rw auto quick
701
#212 rw auto quick
702
#213 rw auto quick
703
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
704
index XXXXXXX..XXXXXXX 100644
705
--- a/tests/qemu-iotests/iotests.py
706
+++ b/tests/qemu-iotests/iotests.py
707
@@ -XXX,XX +XXX,XX @@ def qemu_img_pipe(*args):
708
sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' '.join(qemu_img_args + list(args))))
709
return subp.communicate()[0]
710
711
-def img_info_log(filename, filter_path=None):
712
- output = qemu_img_pipe('info', '-f', imgfmt, filename)
713
+def img_info_log(filename, filter_path=None, imgopts=False, extra_args=[]):
714
+ args = [ 'info' ]
715
+ if imgopts:
716
+ args.append('--image-opts')
717
+ else:
718
+ args += [ '-f', imgfmt ]
719
+ args += extra_args
720
+ args.append(filename)
721
+
722
+ output = qemu_img_pipe(*args)
723
if not filter_path:
724
filter_path = filename
725
log(filter_img_info(output, filter_path))
726
--
34
--
727
2.13.6
35
2.19.1
728
36
729
37
diff view generated by jsdifflib
1
This rewrites the test case 207 to work with the new x-blockdev-create
1
If read-only=off, but auto-read-only=on is given, open the volume
2
job rather than the old synchronous version of the command.
2
read-write if we have the permissions, but instead of erroring out for
3
3
read-only volumes, just degrade to read-only.
4
Most of the test cases stay the same as before (the exception being some
5
improved 'size' options that allow distinguishing which command created
6
the image), but in order to be able to implement proper job handling,
7
the test case is rewritten in Python.
8
4
9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
5
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10
Reviewed-by: Max Reitz <mreitz@redhat.com>
6
Reviewed-by: Eric Blake <eblake@redhat.com>
11
---
7
---
12
tests/qemu-iotests/207 | 440 ++++++++++++++++++++-------------------------
8
block/iscsi.c | 8 +++++---
13
tests/qemu-iotests/207.out | 107 +++++------
9
1 file changed, 5 insertions(+), 3 deletions(-)
14
tests/qemu-iotests/group | 6 +-
15
3 files changed, 257 insertions(+), 296 deletions(-)
16
10
17
diff --git a/tests/qemu-iotests/207 b/tests/qemu-iotests/207
11
diff --git a/block/iscsi.c b/block/iscsi.c
18
index XXXXXXX..XXXXXXX 100755
19
--- a/tests/qemu-iotests/207
20
+++ b/tests/qemu-iotests/207
21
@@ -XXX,XX +XXX,XX @@
22
-#!/bin/bash
23
+#!/usr/bin/env python
24
#
25
# Test ssh image creation
26
#
27
# Copyright (C) 2018 Red Hat, Inc.
28
#
29
+# Creator/Owner: Kevin Wolf <kwolf@redhat.com>
30
+#
31
# This program is free software; you can redistribute it and/or modify
32
# it under the terms of the GNU General Public License as published by
33
# the Free Software Foundation; either version 2 of the License, or
34
@@ -XXX,XX +XXX,XX @@
35
# along with this program. If not, see <http://www.gnu.org/licenses/>.
36
#
37
38
-# creator
39
-owner=kwolf@redhat.com
40
-
41
-seq=`basename $0`
42
-echo "QA output created by $seq"
43
-
44
-here=`pwd`
45
-status=1    # failure is the default!
46
-
47
-# get standard environment, filters and checks
48
-. ./common.rc
49
-. ./common.filter
50
-
51
-_supported_fmt raw
52
-_supported_proto ssh
53
-_supported_os Linux
54
-
55
-function do_run_qemu()
56
-{
57
- echo Testing: "$@"
58
- $QEMU -nographic -qmp stdio -serial none "$@"
59
- echo
60
-}
61
-
62
-function run_qemu()
63
-{
64
- do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \
65
- | _filter_qemu | _filter_imgfmt \
66
- | _filter_actual_image_size
67
-}
68
-
69
-echo
70
-echo "=== Successful image creation (defaults) ==="
71
-echo
72
-
73
-run_qemu <<EOF
74
-{ "execute": "qmp_capabilities" }
75
-{ "execute": "x-blockdev-create",
76
- "arguments": {
77
- "driver": "ssh",
78
- "location": {
79
- "path": "$TEST_IMG_FILE",
80
- "server": {
81
- "host": "127.0.0.1",
82
- "port": "22"
83
- }
84
- },
85
- "size": 4194304
86
- }
87
-}
88
-{ "execute": "quit" }
89
-EOF
90
-
91
-_img_info | _filter_img_info
92
-echo
93
-TEST_IMG=$TEST_IMG_FILE _img_info | _filter_img_info
94
-
95
-echo
96
-echo "=== Test host-key-check options ==="
97
-echo
98
-
99
-run_qemu <<EOF
100
-{ "execute": "qmp_capabilities" }
101
-{ "execute": "x-blockdev-create",
102
- "arguments": {
103
- "driver": "ssh",
104
- "location": {
105
- "path": "$TEST_IMG_FILE",
106
- "server": {
107
- "host": "127.0.0.1",
108
- "port": "22"
109
- },
110
- "host-key-check": {
111
- "mode": "none"
112
- }
113
- },
114
- "size": 8388608
115
- }
116
-}
117
-{ "execute": "quit" }
118
-EOF
119
-
120
-_img_info | _filter_img_info
121
-
122
-run_qemu <<EOF
123
-{ "execute": "qmp_capabilities" }
124
-{ "execute": "x-blockdev-create",
125
- "arguments": {
126
- "driver": "ssh",
127
- "location": {
128
- "path": "$TEST_IMG_FILE",
129
- "server": {
130
- "host": "127.0.0.1",
131
- "port": "22"
132
- },
133
- "host-key-check": {
134
- "mode": "known_hosts"
135
- }
136
- },
137
- "size": 4194304
138
- }
139
-}
140
-{ "execute": "quit" }
141
-EOF
142
-
143
-_img_info | _filter_img_info
144
-
145
-
146
-key=$(ssh-keyscan -t rsa 127.0.0.1 2>/dev/null | grep -v "\\^#" |
147
- cut -d" " -f3 | base64 -d | md5sum -b | cut -d" " -f1)
148
-
149
-run_qemu <<EOF
150
-{ "execute": "qmp_capabilities" }
151
-{ "execute": "x-blockdev-create",
152
- "arguments": {
153
- "driver": "ssh",
154
- "location": {
155
- "path": "$TEST_IMG_FILE",
156
- "server": {
157
- "host": "127.0.0.1",
158
- "port": "22"
159
- },
160
- "host-key-check": {
161
- "mode": "hash",
162
- "type": "md5",
163
- "hash": "wrong"
164
- }
165
- },
166
- "size": 8388608
167
- }
168
-}
169
-{ "execute": "x-blockdev-create",
170
- "arguments": {
171
- "driver": "ssh",
172
- "location": {
173
- "path": "$TEST_IMG_FILE",
174
- "server": {
175
- "host": "127.0.0.1",
176
- "port": "22"
177
- },
178
- "host-key-check": {
179
- "mode": "hash",
180
- "type": "md5",
181
- "hash": "$key"
182
- }
183
- },
184
- "size": 8388608
185
- }
186
-}
187
-{ "execute": "quit" }
188
-EOF
189
-
190
-_img_info | _filter_img_info
191
-
192
-
193
-key=$(ssh-keyscan -t rsa 127.0.0.1 2>/dev/null | grep -v "\\^#" |
194
- cut -d" " -f3 | base64 -d | sha1sum -b | cut -d" " -f1)
195
-
196
-run_qemu <<EOF
197
-{ "execute": "qmp_capabilities" }
198
-{ "execute": "x-blockdev-create",
199
- "arguments": {
200
- "driver": "ssh",
201
- "location": {
202
- "path": "$TEST_IMG_FILE",
203
- "server": {
204
- "host": "127.0.0.1",
205
- "port": "22"
206
- },
207
- "host-key-check": {
208
- "mode": "hash",
209
- "type": "sha1",
210
- "hash": "wrong"
211
- }
212
- },
213
- "size": 4194304
214
- }
215
-}
216
-{ "execute": "x-blockdev-create",
217
- "arguments": {
218
- "driver": "ssh",
219
- "location": {
220
- "path": "$TEST_IMG_FILE",
221
- "server": {
222
- "host": "127.0.0.1",
223
- "port": "22"
224
- },
225
- "host-key-check": {
226
- "mode": "hash",
227
- "type": "sha1",
228
- "hash": "$key"
229
- }
230
- },
231
- "size": 4194304
232
- }
233
-}
234
-{ "execute": "quit" }
235
-EOF
236
-
237
-_img_info | _filter_img_info
238
-
239
-echo
240
-echo "=== Invalid path and user ==="
241
-echo
242
-
243
-run_qemu <<EOF
244
-{ "execute": "qmp_capabilities" }
245
-{ "execute": "x-blockdev-create",
246
- "arguments": {
247
- "driver": "ssh",
248
- "location": {
249
- "path": "/this/is/not/an/existing/path",
250
- "server": {
251
- "host": "127.0.0.1",
252
- "port": "22"
253
- }
254
- },
255
- "size": 4194304
256
- }
257
-}
258
-{ "execute": "x-blockdev-create",
259
- "arguments": {
260
- "driver": "ssh",
261
- "location": {
262
- "path": "$TEST_IMG_FILE",
263
- "user": "invalid user",
264
- "server": {
265
- "host": "127.0.0.1",
266
- "port": "22"
267
- }
268
- },
269
- "size": 4194304
270
- }
271
-}
272
-{ "execute": "quit" }
273
-EOF
274
-
275
-# success, all done
276
-echo "*** done"
277
-rm -f $seq.full
278
-status=0
279
+import iotests
280
+import subprocess
281
+import re
282
+
283
+iotests.verify_image_format(supported_fmts=['raw'])
284
+iotests.verify_protocol(supported=['ssh'])
285
+
286
+def filter_hash(msg):
287
+ return re.sub("'hash': '[0-9a-f]+'", "'hash': HASH", msg)
288
+
289
+def blockdev_create(vm, options):
290
+ result = vm.qmp_log('x-blockdev-create', job_id='job0', options=options,
291
+ filters=[iotests.filter_testfiles, filter_hash])
292
+
293
+ if 'return' in result:
294
+ assert result['return'] == {}
295
+ vm.run_job('job0')
296
+ iotests.log("")
297
+
298
+with iotests.FilePath('t.img') as disk_path, \
299
+ iotests.VM() as vm:
300
+
301
+ remote_path = iotests.remote_filename(disk_path)
302
+
303
+ #
304
+ # Successful image creation (defaults)
305
+ #
306
+ iotests.log("=== Successful image creation (defaults) ===")
307
+ iotests.log("")
308
+
309
+ vm.launch()
310
+ blockdev_create(vm, { 'driver': 'ssh',
311
+ 'location': {
312
+ 'path': disk_path,
313
+ 'server': {
314
+ 'host': '127.0.0.1',
315
+ 'port': '22'
316
+ }
317
+ },
318
+ 'size': 4194304 })
319
+ vm.shutdown()
320
+
321
+ iotests.img_info_log(remote_path, filter_path=disk_path)
322
+ iotests.log("")
323
+ iotests.img_info_log(disk_path)
324
+
325
+ #
326
+ # Test host-key-check options
327
+ #
328
+ iotests.log("=== Test host-key-check options ===")
329
+ iotests.log("")
330
+
331
+ vm.launch()
332
+ blockdev_create(vm, { 'driver': 'ssh',
333
+ 'location': {
334
+ 'path': disk_path,
335
+ 'server': {
336
+ 'host': '127.0.0.1',
337
+ 'port': '22'
338
+ },
339
+ 'host-key-check': {
340
+ 'mode': 'none'
341
+ }
342
+ },
343
+ 'size': 8388608 })
344
+ vm.shutdown()
345
+
346
+ iotests.img_info_log(remote_path, filter_path=disk_path)
347
+
348
+ vm.launch()
349
+ blockdev_create(vm, { 'driver': 'ssh',
350
+ 'location': {
351
+ 'path': disk_path,
352
+ 'server': {
353
+ 'host': '127.0.0.1',
354
+ 'port': '22'
355
+ },
356
+ 'host-key-check': {
357
+ 'mode': 'known_hosts'
358
+ }
359
+ },
360
+ 'size': 4194304 })
361
+ vm.shutdown()
362
+
363
+ iotests.img_info_log(remote_path, filter_path=disk_path)
364
+
365
+ md5_key = subprocess.check_output(
366
+ 'ssh-keyscan -t rsa 127.0.0.1 2>/dev/null | grep -v "\\^#" | ' +
367
+ 'cut -d" " -f3 | base64 -d | md5sum -b | cut -d" " -f1',
368
+ shell=True).rstrip()
369
+
370
+ vm.launch()
371
+ blockdev_create(vm, { 'driver': 'ssh',
372
+ 'location': {
373
+ 'path': disk_path,
374
+ 'server': {
375
+ 'host': '127.0.0.1',
376
+ 'port': '22'
377
+ },
378
+ 'host-key-check': {
379
+ 'mode': 'hash',
380
+ 'type': 'md5',
381
+ 'hash': 'wrong',
382
+ }
383
+ },
384
+ 'size': 2097152 })
385
+ blockdev_create(vm, { 'driver': 'ssh',
386
+ 'location': {
387
+ 'path': disk_path,
388
+ 'server': {
389
+ 'host': '127.0.0.1',
390
+ 'port': '22'
391
+ },
392
+ 'host-key-check': {
393
+ 'mode': 'hash',
394
+ 'type': 'md5',
395
+ 'hash': md5_key,
396
+ }
397
+ },
398
+ 'size': 8388608 })
399
+ vm.shutdown()
400
+
401
+ iotests.img_info_log(remote_path, filter_path=disk_path)
402
+
403
+ sha1_key = subprocess.check_output(
404
+ 'ssh-keyscan -t rsa 127.0.0.1 2>/dev/null | grep -v "\\^#" | ' +
405
+ 'cut -d" " -f3 | base64 -d | sha1sum -b | cut -d" " -f1',
406
+ shell=True).rstrip()
407
+
408
+ vm.launch()
409
+ blockdev_create(vm, { 'driver': 'ssh',
410
+ 'location': {
411
+ 'path': disk_path,
412
+ 'server': {
413
+ 'host': '127.0.0.1',
414
+ 'port': '22'
415
+ },
416
+ 'host-key-check': {
417
+ 'mode': 'hash',
418
+ 'type': 'sha1',
419
+ 'hash': 'wrong',
420
+ }
421
+ },
422
+ 'size': 2097152 })
423
+ blockdev_create(vm, { 'driver': 'ssh',
424
+ 'location': {
425
+ 'path': disk_path,
426
+ 'server': {
427
+ 'host': '127.0.0.1',
428
+ 'port': '22'
429
+ },
430
+ 'host-key-check': {
431
+ 'mode': 'hash',
432
+ 'type': 'sha1',
433
+ 'hash': sha1_key,
434
+ }
435
+ },
436
+ 'size': 4194304 })
437
+ vm.shutdown()
438
+
439
+ iotests.img_info_log(remote_path, filter_path=disk_path)
440
+
441
+ #
442
+ # Invalid path and user
443
+ #
444
+ iotests.log("=== Invalid path and user ===")
445
+ iotests.log("")
446
+
447
+ vm.launch()
448
+ blockdev_create(vm, { 'driver': 'ssh',
449
+ 'location': {
450
+ 'path': '/this/is/not/an/existing/path',
451
+ 'server': {
452
+ 'host': '127.0.0.1',
453
+ 'port': '22'
454
+ },
455
+ 'host-key-check': {
456
+ 'mode': 'none'
457
+ }
458
+ },
459
+ 'size': 4194304 })
460
+ blockdev_create(vm, { 'driver': 'ssh',
461
+ 'location': {
462
+ 'path': disk_path,
463
+ 'user': 'invalid user',
464
+ 'server': {
465
+ 'host': '127.0.0.1',
466
+ 'port': '22'
467
+ },
468
+ 'host-key-check': {
469
+ 'mode': 'none'
470
+ }
471
+ },
472
+ 'size': 4194304 })
473
+ vm.shutdown()
474
diff --git a/tests/qemu-iotests/207.out b/tests/qemu-iotests/207.out
475
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
476
--- a/tests/qemu-iotests/207.out
13
--- a/block/iscsi.c
477
+++ b/tests/qemu-iotests/207.out
14
+++ b/block/iscsi.c
478
@@ -XXX,XX +XXX,XX @@
15
@@ -XXX,XX +XXX,XX @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
479
-QA output created by 207
16
/* Check the write protect flag of the LUN if we want to write */
480
-
17
if (iscsilun->type == TYPE_DISK && (flags & BDRV_O_RDWR) &&
481
=== Successful image creation (defaults) ===
18
iscsilun->write_protected) {
482
19
- error_setg(errp, "Cannot open a write protected LUN as read-write");
483
-Testing:
20
- ret = -EACCES;
484
-QMP_VERSION
21
- goto out;
485
-{"return": {}}
22
+ ret = bdrv_apply_auto_read_only(bs, "LUN is write protected", errp);
486
-{"return": {}}
23
+ if (ret < 0) {
487
-{"return": {}}
24
+ goto out;
488
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
25
+ }
489
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'ssh', 'location': {'path': 'TEST_DIR/PID-t.img', 'server': {'host': '127.0.0.1', 'port': '22'}}, 'size': 4194304}}}
26
+ flags &= ~BDRV_O_RDWR;
490
+{u'return': {}}
27
}
491
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
28
492
+{u'return': {}}
29
iscsi_readcapacity_sync(iscsilun, &local_err);
493
494
-image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "server.port": "22", "driver": "ssh", "path": "TEST_DIR/t.IMGFMT"}}
495
+image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "server.port": "22", "driver": "ssh", "path": "TEST_IMG"}}
496
file format: IMGFMT
497
virtual size: 4.0M (4194304 bytes)
498
499
-image: TEST_DIR/t.IMGFMT
500
+
501
+image: TEST_IMG
502
file format: IMGFMT
503
virtual size: 4.0M (4194304 bytes)
504
505
=== Test host-key-check options ===
506
507
-Testing:
508
-QMP_VERSION
509
-{"return": {}}
510
-{"return": {}}
511
-{"return": {}}
512
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
513
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'ssh', 'location': {'path': 'TEST_DIR/PID-t.img', 'host-key-check': {'mode': 'none'}, 'server': {'host': '127.0.0.1', 'port': '22'}}, 'size': 8388608}}}
514
+{u'return': {}}
515
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
516
+{u'return': {}}
517
518
-image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "server.port": "22", "driver": "ssh", "path": "TEST_DIR/t.IMGFMT"}}
519
+image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "server.port": "22", "driver": "ssh", "path": "TEST_IMG"}}
520
file format: IMGFMT
521
virtual size: 8.0M (8388608 bytes)
522
-Testing:
523
-QMP_VERSION
524
-{"return": {}}
525
-{"return": {}}
526
-{"return": {}}
527
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
528
-
529
-image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "server.port": "22", "driver": "ssh", "path": "TEST_DIR/t.IMGFMT"}}
530
+
531
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'ssh', 'location': {'path': 'TEST_DIR/PID-t.img', 'host-key-check': {'mode': 'known_hosts'}, 'server': {'host': '127.0.0.1', 'port': '22'}}, 'size': 4194304}}}
532
+{u'return': {}}
533
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
534
+{u'return': {}}
535
+
536
+image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "server.port": "22", "driver": "ssh", "path": "TEST_IMG"}}
537
file format: IMGFMT
538
virtual size: 4.0M (4194304 bytes)
539
-Testing:
540
-QMP_VERSION
541
-{"return": {}}
542
-{"error": {"class": "GenericError", "desc": "remote host key does not match host_key_check 'wrong'"}}
543
-{"return": {}}
544
-{"return": {}}
545
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
546
-
547
-image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "server.port": "22", "driver": "ssh", "path": "TEST_DIR/t.IMGFMT"}}
548
+
549
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'ssh', 'location': {'path': 'TEST_DIR/PID-t.img', 'host-key-check': {'hash': 'wrong', 'type': 'md5', 'mode': 'hash'}, 'server': {'host': '127.0.0.1', 'port': '22'}}, 'size': 2097152}}}
550
+{u'return': {}}
551
+Job failed: remote host key does not match host_key_check 'wrong'
552
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
553
+{u'return': {}}
554
+
555
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'ssh', 'location': {'path': 'TEST_DIR/PID-t.img', 'host-key-check': {'hash': HASH, 'type': 'md5', 'mode': 'hash'}, 'server': {'host': '127.0.0.1', 'port': '22'}}, 'size': 8388608}}}
556
+{u'return': {}}
557
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
558
+{u'return': {}}
559
+
560
+image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "server.port": "22", "driver": "ssh", "path": "TEST_IMG"}}
561
file format: IMGFMT
562
virtual size: 8.0M (8388608 bytes)
563
-Testing:
564
-QMP_VERSION
565
-{"return": {}}
566
-{"error": {"class": "GenericError", "desc": "remote host key does not match host_key_check 'wrong'"}}
567
-{"return": {}}
568
-{"return": {}}
569
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
570
-
571
-image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "server.port": "22", "driver": "ssh", "path": "TEST_DIR/t.IMGFMT"}}
572
+
573
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'ssh', 'location': {'path': 'TEST_DIR/PID-t.img', 'host-key-check': {'hash': 'wrong', 'type': 'sha1', 'mode': 'hash'}, 'server': {'host': '127.0.0.1', 'port': '22'}}, 'size': 2097152}}}
574
+{u'return': {}}
575
+Job failed: remote host key does not match host_key_check 'wrong'
576
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
577
+{u'return': {}}
578
+
579
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'ssh', 'location': {'path': 'TEST_DIR/PID-t.img', 'host-key-check': {'hash': HASH, 'type': 'sha1', 'mode': 'hash'}, 'server': {'host': '127.0.0.1', 'port': '22'}}, 'size': 4194304}}}
580
+{u'return': {}}
581
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
582
+{u'return': {}}
583
+
584
+image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "server.port": "22", "driver": "ssh", "path": "TEST_IMG"}}
585
file format: IMGFMT
586
virtual size: 4.0M (4194304 bytes)
587
588
=== Invalid path and user ===
589
590
-Testing:
591
-QMP_VERSION
592
-{"return": {}}
593
-{"error": {"class": "GenericError", "desc": "failed to open remote file '/this/is/not/an/existing/path': Failed opening remote file (libssh2 error code: -31)"}}
594
-{"error": {"class": "GenericError", "desc": "failed to authenticate using publickey authentication and the identities held by your ssh-agent"}}
595
-{"return": {}}
596
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
597
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'ssh', 'location': {'path': '/this/is/not/an/existing/path', 'host-key-check': {'mode': 'none'}, 'server': {'host': '127.0.0.1', 'port': '22'}}, 'size': 4194304}}}
598
+{u'return': {}}
599
+Job failed: failed to open remote file '/this/is/not/an/existing/path': Failed opening remote file (libssh2 error code: -31)
600
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
601
+{u'return': {}}
602
+
603
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'ssh', 'location': {'path': 'TEST_DIR/PID-t.img', 'host-key-check': {'mode': 'none'}, 'user': 'invalid user', 'server': {'host': '127.0.0.1', 'port': '22'}}, 'size': 4194304}}}
604
+{u'return': {}}
605
+Job failed: failed to authenticate using publickey authentication and the identities held by your ssh-agent
606
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
607
+{u'return': {}}
608
609
-*** done
610
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
611
index XXXXXXX..XXXXXXX 100644
612
--- a/tests/qemu-iotests/group
613
+++ b/tests/qemu-iotests/group
614
@@ -XXX,XX +XXX,XX @@
615
204 rw auto quick
616
205 rw auto quick
617
206 rw auto
618
-# TODO The following commented out tests need to be reworked to work
619
-# with the x-blockdev-create job
620
-#207 rw auto
621
+207 rw auto
622
208 rw auto quick
623
209 rw auto quick
624
+# TODO The following commented out tests need to be reworked to work
625
+# with the x-blockdev-create job
626
#210 rw auto
627
#211 rw auto quick
628
#212 rw auto quick
629
--
30
--
630
2.13.6
31
2.19.1
631
32
632
33
diff view generated by jsdifflib
1
This adds a helper function that returns a list of QMP events that are
1
While we want machine interfaces like -blockdev and QMP blockdev-add to
2
already filtered through filter_qmp_event().
2
add as little auto-detection as possible so that management tools are
3
explicit about their needs, -drive is a convenience option for human
4
users. Enabling auto-read-only=on by default there enables users to use
5
read-only images for read-only guest devices without having to specify
6
read-only=on explicitly. If they try to attach the image to a read-write
7
device, they will still get an error message.
3
8
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
5
Reviewed-by: Max Reitz <mreitz@redhat.com>
10
Reviewed-by: Eric Blake <eblake@redhat.com>
6
Reviewed-by: Jeff Cody <jcody@redhat.com>
7
---
11
---
8
tests/qemu-iotests/iotests.py | 5 +++++
12
blockdev.c | 1 +
9
1 file changed, 5 insertions(+)
13
1 file changed, 1 insertion(+)
10
14
11
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
15
diff --git a/blockdev.c b/blockdev.c
12
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
13
--- a/tests/qemu-iotests/iotests.py
17
--- a/blockdev.c
14
+++ b/tests/qemu-iotests/iotests.py
18
+++ b/blockdev.c
15
@@ -XXX,XX +XXX,XX @@ class VM(qtest.QEMUQtestMachine):
19
@@ -XXX,XX +XXX,XX @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
16
output_list += [key + '=' + obj[key]]
20
qdict_set_default_str(bs_opts, BDRV_OPT_CACHE_NO_FLUSH, "off");
17
return ','.join(output_list)
21
qdict_set_default_str(bs_opts, BDRV_OPT_READ_ONLY,
18
22
read_only ? "on" : "off");
19
+ def get_qmp_events_filtered(self, wait=True):
23
+ qdict_set_default_str(bs_opts, BDRV_OPT_AUTO_READ_ONLY, "on");
20
+ result = []
24
assert((bdrv_flags & BDRV_O_CACHE_MASK) == 0);
21
+ for ev in self.get_qmp_events(wait=wait):
25
22
+ result.append(filter_qmp_event(ev))
26
if (runstate_check(RUN_STATE_INMIGRATE)) {
23
+ return result
24
25
26
index_re = re.compile(r'([^\[]+)\[([^\]]+)\]')
27
--
27
--
28
2.13.6
28
2.19.1
29
29
30
30
diff view generated by jsdifflib
1
This rewrites the test case 206 to work with the new x-blockdev-create
1
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2
job rather than the old synchronous version of the command.
2
Reviewed-by: Eric Blake <eblake@redhat.com>
3
---
4
tests/qemu-iotests/232 | 147 +++++++++++++++++++++++++++++++++++++
5
tests/qemu-iotests/232.out | 59 +++++++++++++++
6
tests/qemu-iotests/group | 1 +
7
3 files changed, 207 insertions(+)
8
create mode 100755 tests/qemu-iotests/232
9
create mode 100644 tests/qemu-iotests/232.out
3
10
4
All of the test cases stay the same as before, but in order to be able
11
diff --git a/tests/qemu-iotests/232 b/tests/qemu-iotests/232
5
to implement proper job handling, the test case is rewritten in Python.
12
new file mode 100755
6
13
index XXXXXXX..XXXXXXX
7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14
--- /dev/null
8
Reviewed-by: Max Reitz <mreitz@redhat.com>
15
+++ b/tests/qemu-iotests/232
9
---
10
tests/qemu-iotests/206 | 680 ++++++++++++++++++---------------------------
11
tests/qemu-iotests/206.out | 253 ++++++++++-------
12
tests/qemu-iotests/group | 2 +-
13
3 files changed, 414 insertions(+), 521 deletions(-)
14
15
diff --git a/tests/qemu-iotests/206 b/tests/qemu-iotests/206
16
index XXXXXXX..XXXXXXX 100755
17
--- a/tests/qemu-iotests/206
18
+++ b/tests/qemu-iotests/206
19
@@ -XXX,XX +XXX,XX @@
16
@@ -XXX,XX +XXX,XX @@
20
-#!/bin/bash
17
+#!/bin/bash
21
+#!/usr/bin/env python
18
+#
22
#
19
+# Test for auto-read-only
23
# Test qcow2 and file image creation
20
+#
24
#
21
+# Copyright (C) 2018 Red Hat, Inc.
25
# Copyright (C) 2018 Red Hat, Inc.
22
+#
26
#
23
+# This program is free software; you can redistribute it and/or modify
27
+# Creator/Owner: Kevin Wolf <kwolf@redhat.com>
24
+# it under the terms of the GNU General Public License as published by
28
+#
25
+# the Free Software Foundation; either version 2 of the License, or
29
# This program is free software; you can redistribute it and/or modify
26
+# (at your option) any later version.
30
# it under the terms of the GNU General Public License as published by
27
+#
31
# the Free Software Foundation; either version 2 of the License, or
28
+# This program is distributed in the hope that it will be useful,
29
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
30
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31
+# GNU General Public License for more details.
32
+#
33
+# You should have received a copy of the GNU General Public License
34
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
35
+#
36
+
37
+# creator
38
+owner=kwolf@redhat.com
39
+
40
+seq=`basename $0`
41
+echo "QA output created by $seq"
42
+
43
+here=`pwd`
44
+status=1    # failure is the default!
45
+
46
+_cleanup()
47
+{
48
+ _cleanup_test_img
49
+ rm -f $TEST_IMG.snap
50
+}
51
+trap "_cleanup; exit \$status" 0 1 2 3 15
52
+
53
+# get standard environment, filters and checks
54
+. ./common.rc
55
+. ./common.filter
56
+
57
+_supported_fmt generic
58
+_supported_proto file
59
+_supported_os Linux
60
+
61
+function do_run_qemu()
62
+{
63
+ echo Testing: "$@"
64
+ (
65
+ if ! test -t 0; then
66
+ while read cmd; do
67
+ echo $cmd
68
+ done
69
+ fi
70
+ echo quit
71
+ ) | $QEMU -nographic -monitor stdio -nodefaults "$@"
72
+ echo
73
+}
74
+
75
+function run_qemu()
76
+{
77
+ do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_hmp |
78
+ _filter_generated_node_ids | _filter_imgfmt
79
+}
80
+
81
+function run_qemu_info_block()
82
+{
83
+ echo "info block -n" | run_qemu "$@" | grep -e "(file" -e "QEMU_PROG"
84
+}
85
+
86
+size=128M
87
+
88
+_make_test_img $size
89
+
90
+echo
91
+echo "=== -drive with read-write image: read-only/auto-read-only combinations ==="
92
+echo
93
+
94
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=off
95
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=on
96
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on
97
+echo
98
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=off
99
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=on
100
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off
101
+echo
102
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=off
103
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=on
104
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none
105
+
106
+echo
107
+echo "=== -drive with read-only image: read-only/auto-read-only combinations ==="
108
+echo
109
+
110
+chmod a-w $TEST_IMG
111
+
112
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=off
113
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=on
114
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on
115
+echo
116
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=off
117
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=on
118
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off
119
+echo
120
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=off
121
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=on
122
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none
123
+
124
+echo
125
+echo "=== -blockdev with read-write image: read-only/auto-read-only combinations ==="
126
+echo
127
+
128
+chmod a+w $TEST_IMG
129
+
130
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=off
131
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=on
132
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on
133
+echo
134
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=off
135
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=on
136
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off
137
+echo
138
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=off
139
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=on
140
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0
141
+
142
+echo
143
+echo "=== -blockdev with read-only image: read-only/auto-read-only combinations ==="
144
+echo
145
+
146
+chmod a-w $TEST_IMG
147
+
148
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=off
149
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=on
150
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on
151
+echo
152
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=off
153
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=on
154
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off
155
+echo
156
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=off
157
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=on
158
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0
159
+
160
+# success, all done
161
+echo "*** done"
162
+rm -f $seq.full
163
+status=0
164
diff --git a/tests/qemu-iotests/232.out b/tests/qemu-iotests/232.out
165
new file mode 100644
166
index XXXXXXX..XXXXXXX
167
--- /dev/null
168
+++ b/tests/qemu-iotests/232.out
32
@@ -XXX,XX +XXX,XX @@
169
@@ -XXX,XX +XXX,XX @@
33
# along with this program. If not, see <http://www.gnu.org/licenses/>.
170
+QA output created by 232
34
#
171
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
35
172
+
36
-# creator
173
+=== -drive with read-write image: read-only/auto-read-only combinations ===
37
-owner=kwolf@redhat.com
174
+
38
-
175
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
39
-seq=`basename $0`
176
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
40
-echo "QA output created by $seq"
177
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
41
-
178
+
42
-here=`pwd`
179
+NODE_NAME: TEST_DIR/t.IMGFMT (file)
43
-status=1    # failure is the default!
180
+NODE_NAME: TEST_DIR/t.IMGFMT (file)
44
-
181
+NODE_NAME: TEST_DIR/t.IMGFMT (file)
45
-# get standard environment, filters and checks
182
+
46
-. ./common.rc
183
+NODE_NAME: TEST_DIR/t.IMGFMT (file)
47
-. ./common.filter
184
+NODE_NAME: TEST_DIR/t.IMGFMT (file)
48
-
185
+NODE_NAME: TEST_DIR/t.IMGFMT (file)
49
-_supported_fmt qcow2
186
+
50
-_supported_proto file
187
+=== -drive with read-only image: read-only/auto-read-only combinations ===
51
-_supported_os Linux
188
+
52
-
189
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
53
-function do_run_qemu()
190
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
54
-{
191
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
55
- echo Testing: "$@"
192
+
56
- $QEMU -nographic -qmp stdio -serial none "$@"
193
+QEMU_PROG: -drive driver=file,file=TEST_DIR/t.IMGFMT,if=none,read-only=off,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
57
- echo
194
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
58
-}
195
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
59
-
196
+
60
-function run_qemu()
197
+QEMU_PROG: -drive driver=file,file=TEST_DIR/t.IMGFMT,if=none,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
61
-{
198
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
62
- do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \
199
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
63
- | _filter_qemu | _filter_imgfmt \
200
+
64
- | _filter_actual_image_size
201
+=== -blockdev with read-write image: read-only/auto-read-only combinations ===
65
-}
202
+
66
-
203
+node0: TEST_DIR/t.IMGFMT (file, read-only)
67
-echo
204
+node0: TEST_DIR/t.IMGFMT (file, read-only)
68
-echo "=== Successful image creation (defaults) ==="
205
+node0: TEST_DIR/t.IMGFMT (file, read-only)
69
-echo
206
+
70
-
207
+node0: TEST_DIR/t.IMGFMT (file)
71
-size=$((128 * 1024 * 1024))
208
+node0: TEST_DIR/t.IMGFMT (file)
72
-
209
+node0: TEST_DIR/t.IMGFMT (file)
73
-run_qemu <<EOF
210
+
74
-{ "execute": "qmp_capabilities" }
211
+node0: TEST_DIR/t.IMGFMT (file)
75
-{ "execute": "x-blockdev-create",
212
+node0: TEST_DIR/t.IMGFMT (file)
76
- "arguments": {
213
+node0: TEST_DIR/t.IMGFMT (file)
77
- "driver": "file",
214
+
78
- "filename": "$TEST_IMG",
215
+=== -blockdev with read-only image: read-only/auto-read-only combinations ===
79
- "size": 0
216
+
80
- }
217
+node0: TEST_DIR/t.IMGFMT (file, read-only)
81
-}
218
+node0: TEST_DIR/t.IMGFMT (file, read-only)
82
-{ "execute": "blockdev-add",
219
+node0: TEST_DIR/t.IMGFMT (file, read-only)
83
- "arguments": {
220
+
84
- "driver": "file",
221
+QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0,read-only=off,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
85
- "node-name": "imgfile",
222
+node0: TEST_DIR/t.IMGFMT (file, read-only)
86
- "filename": "$TEST_IMG"
223
+QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0,read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
87
- }
224
+
88
-}
225
+QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
89
-{ "execute": "x-blockdev-create",
226
+node0: TEST_DIR/t.IMGFMT (file, read-only)
90
- "arguments": {
227
+QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
91
- "driver": "$IMGFMT",
228
+*** done
92
- "file": "imgfile",
93
- "size": $size
94
- }
95
-}
96
-{ "execute": "quit" }
97
-EOF
98
-
99
-_img_info --format-specific
100
-
101
-echo
102
-echo "=== Successful image creation (inline blockdev-add, explicit defaults) ==="
103
-echo
104
-
105
-# Choose a different size to show that we got a new image
106
-size=$((64 * 1024 * 1024))
107
-
108
-run_qemu <<EOF
109
-{ "execute": "qmp_capabilities" }
110
-{ "execute": "x-blockdev-create",
111
- "arguments": {
112
- "driver": "file",
113
- "filename": "$TEST_IMG",
114
- "size": 0,
115
- "preallocation": "off",
116
- "nocow": false
117
- }
118
-}
119
-{ "execute": "x-blockdev-create",
120
- "arguments": {
121
- "driver": "$IMGFMT",
122
- "file": {
123
- "driver": "file",
124
- "filename": "$TEST_IMG"
125
- },
126
- "size": $size,
127
- "version": "v3",
128
- "cluster-size": 65536,
129
- "preallocation": "off",
130
- "lazy-refcounts": false,
131
- "refcount-bits": 16
132
- }
133
-}
134
-{ "execute": "quit" }
135
-EOF
136
-
137
-_img_info --format-specific
138
-
139
-echo
140
-echo "=== Successful image creation (v3 non-default options) ==="
141
-echo
142
-
143
-# Choose a different size to show that we got a new image
144
-size=$((32 * 1024 * 1024))
145
-
146
-run_qemu <<EOF
147
-{ "execute": "qmp_capabilities" }
148
-{ "execute": "x-blockdev-create",
149
- "arguments": {
150
- "driver": "file",
151
- "filename": "$TEST_IMG",
152
- "size": 0,
153
- "preallocation": "falloc",
154
- "nocow": true
155
- }
156
-}
157
-{ "execute": "x-blockdev-create",
158
- "arguments": {
159
- "driver": "$IMGFMT",
160
- "file": {
161
- "driver": "file",
162
- "filename": "$TEST_IMG"
163
- },
164
- "size": $size,
165
- "version": "v3",
166
- "cluster-size": 2097152,
167
- "preallocation": "metadata",
168
- "lazy-refcounts": true,
169
- "refcount-bits": 1
170
- }
171
-}
172
-{ "execute": "quit" }
173
-EOF
174
-
175
-_img_info --format-specific
176
-
177
-echo
178
-echo "=== Successful image creation (v2 non-default options) ==="
179
-echo
180
-
181
-mv $TEST_IMG $TEST_IMG.base
182
-
183
-run_qemu <<EOF
184
-{ "execute": "qmp_capabilities" }
185
-{ "execute": "x-blockdev-create",
186
- "arguments": {
187
- "driver": "file",
188
- "filename": "$TEST_IMG",
189
- "size": 0
190
- }
191
-}
192
-{ "execute": "x-blockdev-create",
193
- "arguments": {
194
- "driver": "$IMGFMT",
195
- "file": {
196
- "driver": "file",
197
- "filename": "$TEST_IMG"
198
- },
199
- "size": $size,
200
- "backing-file": "$TEST_IMG.base",
201
- "backing-fmt": "qcow2",
202
- "version": "v2",
203
- "cluster-size": 512
204
- }
205
-}
206
-{ "execute": "quit" }
207
-EOF
208
-
209
-_img_info --format-specific
210
-
211
-echo
212
-echo "=== Successful image creation (encrypted) ==="
213
-echo
214
-
215
-run_qemu -object secret,id=keysec0,data="foo" <<EOF
216
-{ "execute": "qmp_capabilities" }
217
-{ "execute": "x-blockdev-create",
218
- "arguments": {
219
- "driver": "$IMGFMT",
220
- "file": {
221
- "driver": "file",
222
- "filename": "$TEST_IMG"
223
- },
224
- "size": $size,
225
- "encrypt": {
226
- "format": "luks",
227
- "key-secret": "keysec0",
228
- "cipher-alg": "twofish-128",
229
- "cipher-mode": "ctr",
230
- "ivgen-alg": "plain64",
231
- "ivgen-hash-alg": "md5",
232
- "hash-alg": "sha1",
233
- "iter-time": 10
234
- }
235
- }
236
-}
237
-{ "execute": "quit" }
238
-EOF
239
-
240
-_img_info --format-specific | _filter_img_info --format-specific
241
-
242
-echo
243
-echo "=== Invalid BlockdevRef ==="
244
-echo
245
-
246
-run_qemu <<EOF
247
-{ "execute": "qmp_capabilities" }
248
-{ "execute": "x-blockdev-create",
249
- "arguments": {
250
- "driver": "$IMGFMT",
251
- "file": "this doesn't exist",
252
- "size": $size
253
- }
254
-}
255
-{ "execute": "quit" }
256
-EOF
257
-
258
-
259
-echo
260
-echo "=== Invalid sizes ==="
261
-echo
262
-
263
-# TODO Negative image sizes aren't handled correctly, but this is a problem
264
-# with QAPI's implementation of the 'size' type and affects other commands as
265
-# well. Once this is fixed, we may want to add a test case here.
266
-
267
-# 1. Misaligned image size
268
-# 2. 2^64 - 512
269
-# 3. 2^63 = 8 EB (qemu-img enforces image sizes less than this)
270
-# 4. 2^63 - 512 (generally valid, but qcow2 can't handle images this size)
271
-
272
-run_qemu -blockdev driver=file,filename="$TEST_IMG",node-name=node0 <<EOF
273
-{ "execute": "qmp_capabilities" }
274
-{ "execute": "x-blockdev-create",
275
- "arguments": {
276
- "driver": "$IMGFMT",
277
- "file": "node0",
278
- "size": 1234
279
- }
280
-}
281
-{ "execute": "x-blockdev-create",
282
- "arguments": {
283
- "driver": "$IMGFMT",
284
- "file": "node0",
285
- "size": 18446744073709551104
286
- }
287
-}
288
-{ "execute": "x-blockdev-create",
289
- "arguments": {
290
- "driver": "$IMGFMT",
291
- "file": "node0",
292
- "size": 9223372036854775808
293
- }
294
-}
295
-{ "execute": "x-blockdev-create",
296
- "arguments": {
297
- "driver": "$IMGFMT",
298
- "file": "node0",
299
- "size": 9223372036854775296
300
- }
301
-}
302
-{ "execute": "quit" }
303
-EOF
304
-
305
-echo
306
-echo "=== Invalid version ==="
307
-echo
308
-
309
-run_qemu -blockdev driver=file,filename="$TEST_IMG",node-name=node0 <<EOF
310
-{ "execute": "qmp_capabilities" }
311
-{ "execute": "x-blockdev-create",
312
- "arguments": {
313
- "driver": "$IMGFMT",
314
- "file": "node0",
315
- "size": 67108864,
316
- "version": "v1"
317
- }
318
-}
319
-{ "execute": "x-blockdev-create",
320
- "arguments": {
321
- "driver": "$IMGFMT",
322
- "file": "node0",
323
- "size": 67108864,
324
- "version": "v2",
325
- "lazy-refcounts": true
326
- }
327
-}
328
-{ "execute": "x-blockdev-create",
329
- "arguments": {
330
- "driver": "$IMGFMT",
331
- "file": "node0",
332
- "size": 67108864,
333
- "version": "v2",
334
- "refcount-bits": 8
335
- }
336
-}
337
-{ "execute": "quit" }
338
-EOF
339
-
340
-echo
341
-echo "=== Invalid backing file options ==="
342
-echo
343
-
344
-run_qemu -blockdev driver=file,filename="$TEST_IMG",node-name=node0 <<EOF
345
-{ "execute": "qmp_capabilities" }
346
-{ "execute": "x-blockdev-create",
347
- "arguments": {
348
- "driver": "$IMGFMT",
349
- "file": "node0",
350
- "size": 67108864,
351
- "backing-file": "/dev/null",
352
- "preallocation": "full"
353
- }
354
-}
355
-{ "execute": "x-blockdev-create",
356
- "arguments": {
357
- "driver": "$IMGFMT",
358
- "file": "node0",
359
- "size": 67108864,
360
- "backing-fmt": "$IMGFMT"
361
- }
362
-}
363
-{ "execute": "quit" }
364
-EOF
365
-
366
-echo
367
-echo "=== Invalid cluster size ==="
368
-echo
369
-
370
-run_qemu -blockdev driver=file,filename="$TEST_IMG",node-name=node0 <<EOF
371
-{ "execute": "qmp_capabilities" }
372
-{ "execute": "x-blockdev-create",
373
- "arguments": {
374
- "driver": "$IMGFMT",
375
- "file": "node0",
376
- "size": 67108864,
377
- "cluster-size": 1234
378
- }
379
-}
380
-{ "execute": "x-blockdev-create",
381
- "arguments": {
382
- "driver": "$IMGFMT",
383
- "file": "node0",
384
- "size": 67108864,
385
- "cluster-size": 128
386
- }
387
-}
388
-{ "execute": "x-blockdev-create",
389
- "arguments": {
390
- "driver": "$IMGFMT",
391
- "file": "node0",
392
- "size": 67108864,
393
- "cluster-size": 4194304
394
- }
395
-}
396
-{ "execute": "x-blockdev-create",
397
- "arguments": {
398
- "driver": "$IMGFMT",
399
- "file": "node0",
400
- "size": 67108864,
401
- "cluster-size": 0
402
- }
403
-}
404
-{ "execute": "x-blockdev-create",
405
- "arguments": {
406
- "driver": "$IMGFMT",
407
- "file": "node0",
408
- "size": 281474976710656,
409
- "cluster-size": 512
410
- }
411
-}
412
-{ "execute": "quit" }
413
-EOF
414
-
415
-echo
416
-echo "=== Invalid refcount width ==="
417
-echo
418
-
419
-run_qemu -blockdev driver=file,filename="$TEST_IMG",node-name=node0 <<EOF
420
-{ "execute": "qmp_capabilities" }
421
-{ "execute": "x-blockdev-create",
422
- "arguments": {
423
- "driver": "$IMGFMT",
424
- "file": "node0",
425
- "size": 67108864,
426
- "refcount-bits": 128
427
- }
428
-}
429
-{ "execute": "x-blockdev-create",
430
- "arguments": {
431
- "driver": "$IMGFMT",
432
- "file": "node0",
433
- "size": 67108864,
434
- "refcount-bits": 0
435
- }
436
-}
437
-{ "execute": "x-blockdev-create",
438
- "arguments": {
439
- "driver": "$IMGFMT",
440
- "file": "node0",
441
- "size": 67108864,
442
- "refcount-bits": 7
443
- }
444
-}
445
-{ "execute": "quit" }
446
-EOF
447
-
448
-# success, all done
449
-echo "*** done"
450
-rm -f $seq.full
451
-status=0
452
+import iotests
453
+from iotests import imgfmt
454
+
455
+iotests.verify_image_format(supported_fmts=['qcow2'])
456
+
457
+def blockdev_create(vm, options):
458
+ result = vm.qmp_log('x-blockdev-create', job_id='job0', options=options)
459
+
460
+ if 'return' in result:
461
+ assert result['return'] == {}
462
+ vm.run_job('job0')
463
+ iotests.log("")
464
+
465
+with iotests.FilePath('t.qcow2') as disk_path, \
466
+ iotests.FilePath('t.qcow2.base') as backing_path, \
467
+ iotests.VM() as vm:
468
+
469
+ vm.add_object('secret,id=keysec0,data=foo')
470
+
471
+ #
472
+ # Successful image creation (defaults)
473
+ #
474
+ iotests.log("=== Successful image creation (defaults) ===")
475
+ iotests.log("")
476
+
477
+ size = 128 * 1024 * 1024
478
+
479
+ vm.launch()
480
+ blockdev_create(vm, { 'driver': 'file',
481
+ 'filename': disk_path,
482
+ 'size': 0 })
483
+
484
+ vm.qmp_log('blockdev-add', driver='file', filename=disk_path,
485
+ node_name='imgfile')
486
+
487
+ blockdev_create(vm, { 'driver': imgfmt,
488
+ 'file': 'imgfile',
489
+ 'size': size })
490
+ vm.shutdown()
491
+
492
+ iotests.img_info_log(disk_path)
493
+
494
+ #
495
+ # Successful image creation (inline blockdev-add, explicit defaults)
496
+ #
497
+ iotests.log("=== Successful image creation (inline blockdev-add, explicit defaults) ===")
498
+ iotests.log("")
499
+
500
+ # Choose a different size to show that we got a new image
501
+ size = 64 * 1024 * 1024
502
+
503
+ vm.launch()
504
+ blockdev_create(vm, { 'driver': 'file',
505
+ 'filename': disk_path,
506
+ 'size': 0,
507
+ 'preallocation': 'off',
508
+ 'nocow': False })
509
+
510
+ blockdev_create(vm, { 'driver': imgfmt,
511
+ 'file': {
512
+ 'driver': 'file',
513
+ 'filename': disk_path,
514
+ },
515
+ 'size': size,
516
+ 'version': 'v3',
517
+ 'cluster-size': 65536,
518
+ 'preallocation': 'off',
519
+ 'lazy-refcounts': False,
520
+ 'refcount-bits': 16 })
521
+ vm.shutdown()
522
+
523
+ iotests.img_info_log(disk_path)
524
+
525
+ #
526
+ # Successful image creation (v3 non-default options)
527
+ #
528
+ iotests.log("=== Successful image creation (v3 non-default options) ===")
529
+ iotests.log("")
530
+
531
+ # Choose a different size to show that we got a new image
532
+ size = 32 * 1024 * 1024
533
+
534
+ vm.launch()
535
+ blockdev_create(vm, { 'driver': 'file',
536
+ 'filename': disk_path,
537
+ 'size': 0,
538
+ 'preallocation': 'falloc',
539
+ 'nocow': True })
540
+
541
+ blockdev_create(vm, { 'driver': imgfmt,
542
+ 'file': {
543
+ 'driver': 'file',
544
+ 'filename': disk_path,
545
+ },
546
+ 'size': size,
547
+ 'version': 'v3',
548
+ 'cluster-size': 2097152,
549
+ 'preallocation': 'metadata',
550
+ 'lazy-refcounts': True,
551
+ 'refcount-bits': 1 })
552
+ vm.shutdown()
553
+
554
+ iotests.img_info_log(disk_path)
555
+
556
+ #
557
+ # Successful image creation (v2 non-default options)
558
+ #
559
+ iotests.log("=== Successful image creation (v2 non-default options) ===")
560
+ iotests.log("")
561
+
562
+ vm.launch()
563
+ blockdev_create(vm, { 'driver': 'file',
564
+ 'filename': disk_path,
565
+ 'size': 0 })
566
+
567
+ blockdev_create(vm, { 'driver': imgfmt,
568
+ 'file': {
569
+ 'driver': 'file',
570
+ 'filename': disk_path,
571
+ },
572
+ 'size': size,
573
+ 'backing-file': backing_path,
574
+ 'backing-fmt': 'qcow2',
575
+ 'version': 'v2',
576
+ 'cluster-size': 512 })
577
+ vm.shutdown()
578
+
579
+ iotests.img_info_log(disk_path)
580
+
581
+ #
582
+ # Successful image creation (encrypted)
583
+ #
584
+ iotests.log("=== Successful image creation (encrypted) ===")
585
+ iotests.log("")
586
+
587
+ vm.launch()
588
+ blockdev_create(vm, { 'driver': imgfmt,
589
+ 'file': {
590
+ 'driver': 'file',
591
+ 'filename': disk_path,
592
+ },
593
+ 'size': size,
594
+ 'encrypt': {
595
+ 'format': 'luks',
596
+ 'key-secret': 'keysec0',
597
+ 'cipher-alg': 'twofish-128',
598
+ 'cipher-mode': 'ctr',
599
+ 'ivgen-alg': 'plain64',
600
+ 'ivgen-hash-alg': 'md5',
601
+ 'hash-alg': 'sha1',
602
+ 'iter-time': 10,
603
+ }})
604
+ vm.shutdown()
605
+
606
+ iotests.img_info_log(disk_path)
607
+
608
+ #
609
+ # Invalid BlockdevRef
610
+ #
611
+ iotests.log("=== Invalid BlockdevRef ===")
612
+ iotests.log("")
613
+
614
+ vm.launch()
615
+ blockdev_create(vm, { 'driver': imgfmt,
616
+ 'file': "this doesn't exist",
617
+ 'size': size })
618
+ vm.shutdown()
619
+
620
+ #
621
+ # Invalid sizes
622
+ #
623
+ iotests.log("=== Invalid sizes ===")
624
+
625
+ # TODO Negative image sizes aren't handled correctly, but this is a problem
626
+ # with QAPI's implementation of the 'size' type and affects other commands
627
+ # as well. Once this is fixed, we may want to add a test case here.
628
+ #
629
+ # 1. Misaligned image size
630
+ # 2. 2^64 - 512
631
+ # 3. 2^63 = 8 EB (qemu-img enforces image sizes less than this)
632
+ # 4. 2^63 - 512 (generally valid, but qcow2 can't handle images this size)
633
+
634
+ vm.add_blockdev('driver=file,filename=%s,node-name=node0' % (disk_path))
635
+
636
+ vm.launch()
637
+ for size in [ 1234, 18446744073709551104, 9223372036854775808,
638
+ 9223372036854775296 ]:
639
+ blockdev_create(vm, { 'driver': imgfmt,
640
+ 'file': 'node0',
641
+ 'size': size })
642
+ vm.shutdown()
643
+
644
+ #
645
+ # Invalid version
646
+ #
647
+ iotests.log("=== Invalid version ===")
648
+
649
+ vm.launch()
650
+ blockdev_create(vm, { 'driver': imgfmt,
651
+ 'file': 'node0',
652
+ 'size': 67108864,
653
+ 'version': 'v1' })
654
+ blockdev_create(vm, { 'driver': imgfmt,
655
+ 'file': 'node0',
656
+ 'size': 67108864,
657
+ 'version': 'v2',
658
+ 'lazy-refcounts': True })
659
+ blockdev_create(vm, { 'driver': imgfmt,
660
+ 'file': 'node0',
661
+ 'size': 67108864,
662
+ 'version': 'v2',
663
+ 'refcount-bits': 8 })
664
+ vm.shutdown()
665
+
666
+ #
667
+ # Invalid backing file options
668
+ #
669
+ iotests.log("=== Invalid backing file options ===")
670
+
671
+ vm.launch()
672
+ blockdev_create(vm, { 'driver': imgfmt,
673
+ 'file': 'node0',
674
+ 'size': 67108864,
675
+ 'backing-file': '/dev/null',
676
+ 'preallocation': 'full' })
677
+ blockdev_create(vm, { 'driver': imgfmt,
678
+ 'file': 'node0',
679
+ 'size': 67108864,
680
+ 'backing-fmt': imgfmt })
681
+ vm.shutdown()
682
+
683
+ #
684
+ # Invalid cluster size
685
+ #
686
+ iotests.log("=== Invalid cluster size ===")
687
+
688
+ vm.launch()
689
+ for csize in [ 1234, 128, 4194304, 0 ]:
690
+ blockdev_create(vm, { 'driver': imgfmt,
691
+ 'file': 'node0',
692
+ 'size': 67108864,
693
+ 'cluster-size': csize })
694
+ blockdev_create(vm, { 'driver': imgfmt,
695
+ 'file': 'node0',
696
+ 'size': 281474976710656,
697
+ 'cluster-size': 512 })
698
+ vm.shutdown()
699
+
700
+ #
701
+ # Invalid refcount width
702
+ #
703
+ iotests.log("=== Invalid refcount width ===")
704
+
705
+ vm.launch()
706
+ for refcount_bits in [ 128, 0, 7 ]:
707
+ blockdev_create(vm, { 'driver': imgfmt,
708
+ 'file': 'node0',
709
+ 'size': 67108864,
710
+ 'refcount-bits': refcount_bits })
711
+ vm.shutdown()
712
diff --git a/tests/qemu-iotests/206.out b/tests/qemu-iotests/206.out
713
index XXXXXXX..XXXXXXX 100644
714
--- a/tests/qemu-iotests/206.out
715
+++ b/tests/qemu-iotests/206.out
716
@@ -XXX,XX +XXX,XX @@
717
-QA output created by 206
718
-
719
=== Successful image creation (defaults) ===
720
721
-Testing:
722
-QMP_VERSION
723
-{"return": {}}
724
-{"return": {}}
725
-{"return": {}}
726
-{"return": {}}
727
-{"return": {}}
728
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
729
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}}}
730
+{u'return': {}}
731
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
732
+{u'return': {}}
733
+
734
+{'execute': 'blockdev-add', 'arguments': {'node_name': 'imgfile', 'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}}
735
+{u'return': {}}
736
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'qcow2', 'file': 'imgfile', 'size': 134217728}}}
737
+{u'return': {}}
738
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
739
+{u'return': {}}
740
741
-image: TEST_DIR/t.IMGFMT
742
+image: TEST_IMG
743
file format: IMGFMT
744
virtual size: 128M (134217728 bytes)
745
cluster_size: 65536
746
@@ -XXX,XX +XXX,XX @@ Format specific information:
747
748
=== Successful image creation (inline blockdev-add, explicit defaults) ===
749
750
-Testing:
751
-QMP_VERSION
752
-{"return": {}}
753
-{"return": {}}
754
-{"return": {}}
755
-{"return": {}}
756
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
757
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'nocow': False, 'preallocation': 'off', 'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}}}
758
+{u'return': {}}
759
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
760
+{u'return': {}}
761
762
-image: TEST_DIR/t.IMGFMT
763
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 65536, 'refcount-bits': 16, 'version': 'v3', 'preallocation': 'off', 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}, 'lazy-refcounts': False, 'driver': 'qcow2', 'size': 67108864}}}
764
+{u'return': {}}
765
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
766
+{u'return': {}}
767
+
768
+image: TEST_IMG
769
file format: IMGFMT
770
virtual size: 64M (67108864 bytes)
771
cluster_size: 65536
772
@@ -XXX,XX +XXX,XX @@ Format specific information:
773
774
=== Successful image creation (v3 non-default options) ===
775
776
-Testing:
777
-QMP_VERSION
778
-{"return": {}}
779
-{"return": {}}
780
-{"return": {}}
781
-{"return": {}}
782
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
783
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'nocow': True, 'preallocation': 'falloc', 'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}}}
784
+{u'return': {}}
785
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
786
+{u'return': {}}
787
+
788
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 2097152, 'refcount-bits': 1, 'version': 'v3', 'preallocation': 'metadata', 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}, 'lazy-refcounts': True, 'driver': 'qcow2', 'size': 33554432}}}
789
+{u'return': {}}
790
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
791
+{u'return': {}}
792
793
-image: TEST_DIR/t.IMGFMT
794
+image: TEST_IMG
795
file format: IMGFMT
796
virtual size: 32M (33554432 bytes)
797
cluster_size: 2097152
798
@@ -XXX,XX +XXX,XX @@ Format specific information:
799
800
=== Successful image creation (v2 non-default options) ===
801
802
-Testing:
803
-QMP_VERSION
804
-{"return": {}}
805
-{"return": {}}
806
-{"return": {}}
807
-{"return": {}}
808
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
809
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}}}
810
+{u'return': {}}
811
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
812
+{u'return': {}}
813
814
-image: TEST_DIR/t.IMGFMT
815
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 512, 'backing-fmt': 'qcow2', 'driver': 'qcow2', 'version': 'v2', 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}, 'backing-file': 'TEST_DIR/PID-t.qcow2.base', 'size': 33554432}}}
816
+{u'return': {}}
817
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
818
+{u'return': {}}
819
+
820
+image: TEST_IMG
821
file format: IMGFMT
822
virtual size: 32M (33554432 bytes)
823
cluster_size: 512
824
-backing file: TEST_DIR/t.IMGFMT.base
825
+backing file: TEST_IMG.base
826
backing file format: IMGFMT
827
Format specific information:
828
compat: 0.10
829
@@ -XXX,XX +XXX,XX @@ Format specific information:
830
831
=== Successful image creation (encrypted) ===
832
833
-Testing: -object secret,id=keysec0,data=foo
834
-QMP_VERSION
835
-{"return": {}}
836
-{"return": {}}
837
-{"return": {}}
838
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
839
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'encrypt': {'key-secret': 'keysec0', 'iter-time': 10, 'cipher-mode': 'ctr', 'ivgen-hash-alg': 'md5', 'cipher-alg': 'twofish-128', 'format': 'luks', 'ivgen-alg': 'plain64', 'hash-alg': 'sha1'}, 'driver': 'qcow2', 'file': {'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}, 'size': 33554432}}}
840
+{u'return': {}}
841
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
842
+{u'return': {}}
843
844
-image: TEST_DIR/t.IMGFMT
845
+image: TEST_IMG
846
file format: IMGFMT
847
virtual size: 32M (33554432 bytes)
848
+encrypted: yes
849
+cluster_size: 65536
850
Format specific information:
851
compat: 1.1
852
lazy refcounts: false
853
@@ -XXX,XX +XXX,XX @@ Format specific information:
854
ivgen alg: plain64
855
hash alg: sha1
856
cipher alg: twofish-128
857
- uuid: 00000000-0000-0000-0000-000000000000
858
+ uuid: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
859
format: luks
860
cipher mode: ctr
861
slots:
862
[0]:
863
active: true
864
- iters: 1024
865
+ iters: XXX
866
key offset: 4096
867
stripes: 4000
868
[1]:
869
@@ -XXX,XX +XXX,XX @@ Format specific information:
870
active: false
871
key offset: 462848
872
payload offset: 528384
873
- master key iters: 1024
874
+ master key iters: XXX
875
corrupt: false
876
877
=== Invalid BlockdevRef ===
878
879
-Testing:
880
-QMP_VERSION
881
-{"return": {}}
882
-{"error": {"class": "GenericError", "desc": "Cannot find device=this doesn't exist nor node_name=this doesn't exist"}}
883
-{"return": {}}
884
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
885
-
886
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'qcow2', 'file': "this doesn't exist", 'size': 33554432}}}
887
+{u'return': {}}
888
+Job failed: Cannot find device=this doesn't exist nor node_name=this doesn't exist
889
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
890
+{u'return': {}}
891
892
=== Invalid sizes ===
893
-
894
-Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0
895
-QMP_VERSION
896
-{"return": {}}
897
-{"error": {"class": "GenericError", "desc": "Image size must be a multiple of 512 bytes"}}
898
-{"error": {"class": "GenericError", "desc": "Could not resize image: Image size cannot be negative"}}
899
-{"error": {"class": "GenericError", "desc": "Could not resize image: Image size cannot be negative"}}
900
-{"error": {"class": "GenericError", "desc": "Could not resize image: Failed to grow the L1 table: File too large"}}
901
-{"return": {}}
902
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
903
-
904
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'qcow2', 'file': 'node0', 'size': 1234}}}
905
+{u'return': {}}
906
+Job failed: Image size must be a multiple of 512 bytes
907
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
908
+{u'return': {}}
909
+
910
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'qcow2', 'file': 'node0', 'size': 18446744073709551104L}}}
911
+{u'return': {}}
912
+Job failed: Could not resize image: Image size cannot be negative
913
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
914
+{u'return': {}}
915
+
916
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'qcow2', 'file': 'node0', 'size': 9223372036854775808L}}}
917
+{u'return': {}}
918
+Job failed: Could not resize image: Image size cannot be negative
919
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
920
+{u'return': {}}
921
+
922
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'qcow2', 'file': 'node0', 'size': 9223372036854775296}}}
923
+{u'return': {}}
924
+Job failed: Could not resize image: Failed to grow the L1 table: File too large
925
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
926
+{u'return': {}}
927
928
=== Invalid version ===
929
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'version': 'v1', 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
930
+{u'error': {u'class': u'GenericError', u'desc': u"Invalid parameter 'v1'"}}
931
932
-Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0
933
-QMP_VERSION
934
-{"return": {}}
935
-{"error": {"class": "GenericError", "desc": "Invalid parameter 'v1'"}}
936
-{"error": {"class": "GenericError", "desc": "Lazy refcounts only supported with compatibility level 1.1 and above (use version=v3 or greater)"}}
937
-{"error": {"class": "GenericError", "desc": "Different refcount widths than 16 bits require compatibility level 1.1 or above (use version=v3 or greater)"}}
938
-{"return": {}}
939
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
940
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'lazy-refcounts': True, 'version': 'v2', 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
941
+{u'return': {}}
942
+Job failed: Lazy refcounts only supported with compatibility level 1.1 and above (use version=v3 or greater)
943
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
944
+{u'return': {}}
945
946
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'refcount-bits': 8, 'version': 'v2', 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
947
+{u'return': {}}
948
+Job failed: Different refcount widths than 16 bits require compatibility level 1.1 or above (use version=v3 or greater)
949
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
950
+{u'return': {}}
951
952
=== Invalid backing file options ===
953
-
954
-Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0
955
-QMP_VERSION
956
-{"return": {}}
957
-{"error": {"class": "GenericError", "desc": "Backing file and preallocation cannot be used at the same time"}}
958
-{"error": {"class": "GenericError", "desc": "Backing format cannot be used without backing file"}}
959
-{"return": {}}
960
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
961
-
962
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'preallocation': 'full', 'driver': 'qcow2', 'backing-file': '/dev/null', 'file': 'node0', 'size': 67108864}}}
963
+{u'return': {}}
964
+Job failed: Backing file and preallocation cannot be used at the same time
965
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
966
+{u'return': {}}
967
+
968
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'backing-fmt': 'qcow2', 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
969
+{u'return': {}}
970
+Job failed: Backing format cannot be used without backing file
971
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
972
+{u'return': {}}
973
974
=== Invalid cluster size ===
975
-
976
-Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0
977
-QMP_VERSION
978
-{"return": {}}
979
-{"error": {"class": "GenericError", "desc": "Cluster size must be a power of two between 512 and 2048k"}}
980
-{"error": {"class": "GenericError", "desc": "Cluster size must be a power of two between 512 and 2048k"}}
981
-{"error": {"class": "GenericError", "desc": "Cluster size must be a power of two between 512 and 2048k"}}
982
-{"error": {"class": "GenericError", "desc": "Cluster size must be a power of two between 512 and 2048k"}}
983
-{"error": {"class": "GenericError", "desc": "Could not resize image: Failed to grow the L1 table: File too large"}}
984
-{"return": {}}
985
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
986
-
987
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 1234, 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
988
+{u'return': {}}
989
+Job failed: Cluster size must be a power of two between 512 and 2048k
990
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
991
+{u'return': {}}
992
+
993
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 128, 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
994
+{u'return': {}}
995
+Job failed: Cluster size must be a power of two between 512 and 2048k
996
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
997
+{u'return': {}}
998
+
999
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 4194304, 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
1000
+{u'return': {}}
1001
+Job failed: Cluster size must be a power of two between 512 and 2048k
1002
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
1003
+{u'return': {}}
1004
+
1005
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 0, 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
1006
+{u'return': {}}
1007
+Job failed: Cluster size must be a power of two between 512 and 2048k
1008
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
1009
+{u'return': {}}
1010
+
1011
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'cluster-size': 512, 'driver': 'qcow2', 'file': 'node0', 'size': 281474976710656}}}
1012
+{u'return': {}}
1013
+Job failed: Could not resize image: Failed to grow the L1 table: File too large
1014
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
1015
+{u'return': {}}
1016
1017
=== Invalid refcount width ===
1018
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'refcount-bits': 128, 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
1019
+{u'return': {}}
1020
+Job failed: Refcount width must be a power of two and may not exceed 64 bits
1021
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
1022
+{u'return': {}}
1023
+
1024
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'refcount-bits': 0, 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
1025
+{u'return': {}}
1026
+Job failed: Refcount width must be a power of two and may not exceed 64 bits
1027
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
1028
+{u'return': {}}
1029
+
1030
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'refcount-bits': 7, 'driver': 'qcow2', 'file': 'node0', 'size': 67108864}}}
1031
+{u'return': {}}
1032
+Job failed: Refcount width must be a power of two and may not exceed 64 bits
1033
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
1034
+{u'return': {}}
1035
1036
-Testing: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0
1037
-QMP_VERSION
1038
-{"return": {}}
1039
-{"error": {"class": "GenericError", "desc": "Refcount width must be a power of two and may not exceed 64 bits"}}
1040
-{"error": {"class": "GenericError", "desc": "Refcount width must be a power of two and may not exceed 64 bits"}}
1041
-{"error": {"class": "GenericError", "desc": "Refcount width must be a power of two and may not exceed 64 bits"}}
1042
-{"return": {}}
1043
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
1044
-
1045
-*** done
1046
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
229
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
1047
index XXXXXXX..XXXXXXX 100644
230
index XXXXXXX..XXXXXXX 100644
1048
--- a/tests/qemu-iotests/group
231
--- a/tests/qemu-iotests/group
1049
+++ b/tests/qemu-iotests/group
232
+++ b/tests/qemu-iotests/group
1050
@@ -XXX,XX +XXX,XX @@
233
@@ -XXX,XX +XXX,XX @@
1051
203 rw auto migration
234
227 auto quick
1052
204 rw auto quick
235
229 auto quick
1053
205 rw auto quick
236
231 auto quick
1054
+206 rw auto
237
+232 auto quick
1055
# TODO The following commented out tests need to be reworked to work
1056
# with the x-blockdev-create job
1057
-#206 rw auto
1058
#207 rw auto
1059
208 rw auto quick
1060
209 rw auto quick
1061
--
238
--
1062
2.13.6
239
2.19.1
1063
240
1064
241
diff view generated by jsdifflib
New patch
1
From: Max Reitz <mreitz@redhat.com>
1
2
3
This adds some whitespace into the option help (including indentation)
4
and puts angle brackets around the type names. Furthermore, the list
5
name is no longer printed as part of every line, but only once in
6
advance, and only if the caller did not print a caption already.
7
8
This patch also restores the description alignment we had before commit
9
9cbef9d68ee1d8d0, just at 24 instead of 16 characters like we used to.
10
This increase is because now we have the type and two spaces of
11
indentation before the description, and with a usual type name length of
12
three chracters, this sums up to eight additional characters -- which
13
means that we now need 24 characters to get the same amount of padding
14
for most options. Also, 24 is a third of 80, which makes it kind of a
15
round number in terminal terms.
16
17
Finally, this patch amends the reference output of iotest 082 to match
18
the changes (and thus makes it pass again).
19
20
Signed-off-by: Max Reitz <mreitz@redhat.com>
21
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
22
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
23
---
24
include/qemu/option.h | 2 +-
25
qemu-img.c | 4 +-
26
util/qemu-option.c | 32 +-
27
tests/qemu-iotests/082.out | 956 ++++++++++++++++++-------------------
28
4 files changed, 507 insertions(+), 487 deletions(-)
29
30
diff --git a/include/qemu/option.h b/include/qemu/option.h
31
index XXXXXXX..XXXXXXX 100644
32
--- a/include/qemu/option.h
33
+++ b/include/qemu/option.h
34
@@ -XXX,XX +XXX,XX @@ typedef int (*qemu_opts_loopfunc)(void *opaque, QemuOpts *opts, Error **errp);
35
int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func,
36
void *opaque, Error **errp);
37
void qemu_opts_print(QemuOpts *opts, const char *sep);
38
-void qemu_opts_print_help(QemuOptsList *list);
39
+void qemu_opts_print_help(QemuOptsList *list, bool print_caption);
40
void qemu_opts_free(QemuOptsList *list);
41
QemuOptsList *qemu_opts_append(QemuOptsList *dst, QemuOptsList *list);
42
43
diff --git a/qemu-img.c b/qemu-img.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/qemu-img.c
46
+++ b/qemu-img.c
47
@@ -XXX,XX +XXX,XX @@ static int print_block_option_help(const char *filename, const char *fmt)
48
}
49
50
printf("Supported options:\n");
51
- qemu_opts_print_help(create_opts);
52
+ qemu_opts_print_help(create_opts, false);
53
qemu_opts_free(create_opts);
54
return 0;
55
}
56
@@ -XXX,XX +XXX,XX @@ static int print_amend_option_help(const char *format)
57
assert(drv->create_opts);
58
59
printf("Creation options for '%s':\n", format);
60
- qemu_opts_print_help(drv->create_opts);
61
+ qemu_opts_print_help(drv->create_opts, false);
62
printf("\nNote that not all of these options may be amendable.\n");
63
return 0;
64
}
65
diff --git a/util/qemu-option.c b/util/qemu-option.c
66
index XXXXXXX..XXXXXXX 100644
67
--- a/util/qemu-option.c
68
+++ b/util/qemu-option.c
69
@@ -XXX,XX +XXX,XX @@ static const char *opt_type_to_string(enum QemuOptType type)
70
g_assert_not_reached();
71
}
72
73
-void qemu_opts_print_help(QemuOptsList *list)
74
+/**
75
+ * Print the list of options available in the given list. If
76
+ * @print_caption is true, a caption (including the list name, if it
77
+ * exists) is printed. The options itself will be indented, so
78
+ * @print_caption should only be set to false if the caller prints its
79
+ * own custom caption (so that the indentation makes sense).
80
+ */
81
+void qemu_opts_print_help(QemuOptsList *list, bool print_caption)
82
{
83
QemuOptDesc *desc;
84
int i;
85
@@ -XXX,XX +XXX,XX @@ void qemu_opts_print_help(QemuOptsList *list)
86
desc = list->desc;
87
while (desc && desc->name) {
88
GString *str = g_string_new(NULL);
89
- if (list->name) {
90
- g_string_append_printf(str, "%s.", list->name);
91
- }
92
- g_string_append_printf(str, "%s=%s", desc->name,
93
+ g_string_append_printf(str, " %s=<%s>", desc->name,
94
opt_type_to_string(desc->type));
95
if (desc->help) {
96
+ if (str->len < 24) {
97
+ g_string_append_printf(str, "%*s", 24 - (int)str->len, "");
98
+ }
99
g_string_append_printf(str, " - %s", desc->help);
100
}
101
g_ptr_array_add(array, g_string_free(str, false));
102
@@ -XXX,XX +XXX,XX @@ void qemu_opts_print_help(QemuOptsList *list)
103
}
104
105
g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0);
106
+ if (print_caption && array->len > 0) {
107
+ if (list->name) {
108
+ printf("%s options:\n", list->name);
109
+ } else {
110
+ printf("Options:\n");
111
+ }
112
+ } else if (array->len == 0) {
113
+ if (list->name) {
114
+ printf("There are no options for %s.\n", list->name);
115
+ } else {
116
+ printf("No options available.\n");
117
+ }
118
+ }
119
for (i = 0; i < array->len; i++) {
120
printf("%s\n", (char *)array->pdata[i]);
121
}
122
@@ -XXX,XX +XXX,XX @@ QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, const char *params,
123
opts = opts_parse(list, params, permit_abbrev, false, &invalidp, &err);
124
if (err) {
125
if (invalidp && has_help_option(params)) {
126
- qemu_opts_print_help(list);
127
+ qemu_opts_print_help(list, true);
128
error_free(err);
129
} else {
130
error_report_err(err);
131
diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out
132
index XXXXXXX..XXXXXXX 100644
133
--- a/tests/qemu-iotests/082.out
134
+++ b/tests/qemu-iotests/082.out
135
@@ -XXX,XX +XXX,XX @@ cluster_size: 8192
136
137
Testing: create -f qcow2 -o help TEST_DIR/t.qcow2 128M
138
Supported options:
139
-size Virtual disk size
140
-compat Compatibility level (0.10 or 1.1)
141
-backing_file File name of a base image
142
-backing_fmt Image format of the base image
143
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
144
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
145
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
146
-encrypt.cipher-alg Name of encryption cipher algorithm
147
-encrypt.cipher-mode Name of encryption cipher mode
148
-encrypt.ivgen-alg Name of IV generator algorithm
149
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
150
-encrypt.hash-alg Name of encryption hash algorithm
151
-encrypt.iter-time Time to spend in PBKDF in milliseconds
152
-cluster_size qcow2 cluster size
153
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
154
-lazy_refcounts Postpone refcount updates
155
-refcount_bits Width of a reference count entry in bits
156
-nocow Turn off copy-on-write (valid only on btrfs)
157
+ backing_file=<str> - File name of a base image
158
+ backing_fmt=<str> - Image format of the base image
159
+ cluster_size=<size> - qcow2 cluster size
160
+ compat=<str> - Compatibility level (0.10 or 1.1)
161
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
162
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
163
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
164
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
165
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
166
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
167
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
168
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
169
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
170
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
171
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
172
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
173
+ refcount_bits=<num> - Width of a reference count entry in bits
174
+ size=<size> - Virtual disk size
175
176
Testing: create -f qcow2 -o ? TEST_DIR/t.qcow2 128M
177
Supported options:
178
-size Virtual disk size
179
-compat Compatibility level (0.10 or 1.1)
180
-backing_file File name of a base image
181
-backing_fmt Image format of the base image
182
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
183
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
184
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
185
-encrypt.cipher-alg Name of encryption cipher algorithm
186
-encrypt.cipher-mode Name of encryption cipher mode
187
-encrypt.ivgen-alg Name of IV generator algorithm
188
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
189
-encrypt.hash-alg Name of encryption hash algorithm
190
-encrypt.iter-time Time to spend in PBKDF in milliseconds
191
-cluster_size qcow2 cluster size
192
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
193
-lazy_refcounts Postpone refcount updates
194
-refcount_bits Width of a reference count entry in bits
195
-nocow Turn off copy-on-write (valid only on btrfs)
196
+ backing_file=<str> - File name of a base image
197
+ backing_fmt=<str> - Image format of the base image
198
+ cluster_size=<size> - qcow2 cluster size
199
+ compat=<str> - Compatibility level (0.10 or 1.1)
200
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
201
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
202
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
203
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
204
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
205
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
206
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
207
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
208
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
209
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
210
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
211
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
212
+ refcount_bits=<num> - Width of a reference count entry in bits
213
+ size=<size> - Virtual disk size
214
215
Testing: create -f qcow2 -o cluster_size=4k,help TEST_DIR/t.qcow2 128M
216
Supported options:
217
-size Virtual disk size
218
-compat Compatibility level (0.10 or 1.1)
219
-backing_file File name of a base image
220
-backing_fmt Image format of the base image
221
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
222
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
223
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
224
-encrypt.cipher-alg Name of encryption cipher algorithm
225
-encrypt.cipher-mode Name of encryption cipher mode
226
-encrypt.ivgen-alg Name of IV generator algorithm
227
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
228
-encrypt.hash-alg Name of encryption hash algorithm
229
-encrypt.iter-time Time to spend in PBKDF in milliseconds
230
-cluster_size qcow2 cluster size
231
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
232
-lazy_refcounts Postpone refcount updates
233
-refcount_bits Width of a reference count entry in bits
234
-nocow Turn off copy-on-write (valid only on btrfs)
235
+ backing_file=<str> - File name of a base image
236
+ backing_fmt=<str> - Image format of the base image
237
+ cluster_size=<size> - qcow2 cluster size
238
+ compat=<str> - Compatibility level (0.10 or 1.1)
239
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
240
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
241
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
242
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
243
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
244
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
245
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
246
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
247
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
248
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
249
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
250
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
251
+ refcount_bits=<num> - Width of a reference count entry in bits
252
+ size=<size> - Virtual disk size
253
254
Testing: create -f qcow2 -o cluster_size=4k,? TEST_DIR/t.qcow2 128M
255
Supported options:
256
-size Virtual disk size
257
-compat Compatibility level (0.10 or 1.1)
258
-backing_file File name of a base image
259
-backing_fmt Image format of the base image
260
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
261
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
262
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
263
-encrypt.cipher-alg Name of encryption cipher algorithm
264
-encrypt.cipher-mode Name of encryption cipher mode
265
-encrypt.ivgen-alg Name of IV generator algorithm
266
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
267
-encrypt.hash-alg Name of encryption hash algorithm
268
-encrypt.iter-time Time to spend in PBKDF in milliseconds
269
-cluster_size qcow2 cluster size
270
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
271
-lazy_refcounts Postpone refcount updates
272
-refcount_bits Width of a reference count entry in bits
273
-nocow Turn off copy-on-write (valid only on btrfs)
274
+ backing_file=<str> - File name of a base image
275
+ backing_fmt=<str> - Image format of the base image
276
+ cluster_size=<size> - qcow2 cluster size
277
+ compat=<str> - Compatibility level (0.10 or 1.1)
278
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
279
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
280
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
281
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
282
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
283
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
284
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
285
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
286
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
287
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
288
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
289
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
290
+ refcount_bits=<num> - Width of a reference count entry in bits
291
+ size=<size> - Virtual disk size
292
293
Testing: create -f qcow2 -o help,cluster_size=4k TEST_DIR/t.qcow2 128M
294
Supported options:
295
-size Virtual disk size
296
-compat Compatibility level (0.10 or 1.1)
297
-backing_file File name of a base image
298
-backing_fmt Image format of the base image
299
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
300
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
301
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
302
-encrypt.cipher-alg Name of encryption cipher algorithm
303
-encrypt.cipher-mode Name of encryption cipher mode
304
-encrypt.ivgen-alg Name of IV generator algorithm
305
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
306
-encrypt.hash-alg Name of encryption hash algorithm
307
-encrypt.iter-time Time to spend in PBKDF in milliseconds
308
-cluster_size qcow2 cluster size
309
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
310
-lazy_refcounts Postpone refcount updates
311
-refcount_bits Width of a reference count entry in bits
312
-nocow Turn off copy-on-write (valid only on btrfs)
313
+ backing_file=<str> - File name of a base image
314
+ backing_fmt=<str> - Image format of the base image
315
+ cluster_size=<size> - qcow2 cluster size
316
+ compat=<str> - Compatibility level (0.10 or 1.1)
317
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
318
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
319
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
320
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
321
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
322
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
323
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
324
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
325
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
326
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
327
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
328
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
329
+ refcount_bits=<num> - Width of a reference count entry in bits
330
+ size=<size> - Virtual disk size
331
332
Testing: create -f qcow2 -o ?,cluster_size=4k TEST_DIR/t.qcow2 128M
333
Supported options:
334
-size Virtual disk size
335
-compat Compatibility level (0.10 or 1.1)
336
-backing_file File name of a base image
337
-backing_fmt Image format of the base image
338
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
339
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
340
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
341
-encrypt.cipher-alg Name of encryption cipher algorithm
342
-encrypt.cipher-mode Name of encryption cipher mode
343
-encrypt.ivgen-alg Name of IV generator algorithm
344
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
345
-encrypt.hash-alg Name of encryption hash algorithm
346
-encrypt.iter-time Time to spend in PBKDF in milliseconds
347
-cluster_size qcow2 cluster size
348
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
349
-lazy_refcounts Postpone refcount updates
350
-refcount_bits Width of a reference count entry in bits
351
-nocow Turn off copy-on-write (valid only on btrfs)
352
+ backing_file=<str> - File name of a base image
353
+ backing_fmt=<str> - Image format of the base image
354
+ cluster_size=<size> - qcow2 cluster size
355
+ compat=<str> - Compatibility level (0.10 or 1.1)
356
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
357
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
358
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
359
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
360
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
361
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
362
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
363
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
364
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
365
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
366
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
367
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
368
+ refcount_bits=<num> - Width of a reference count entry in bits
369
+ size=<size> - Virtual disk size
370
371
Testing: create -f qcow2 -o cluster_size=4k -o help TEST_DIR/t.qcow2 128M
372
Supported options:
373
-size Virtual disk size
374
-compat Compatibility level (0.10 or 1.1)
375
-backing_file File name of a base image
376
-backing_fmt Image format of the base image
377
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
378
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
379
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
380
-encrypt.cipher-alg Name of encryption cipher algorithm
381
-encrypt.cipher-mode Name of encryption cipher mode
382
-encrypt.ivgen-alg Name of IV generator algorithm
383
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
384
-encrypt.hash-alg Name of encryption hash algorithm
385
-encrypt.iter-time Time to spend in PBKDF in milliseconds
386
-cluster_size qcow2 cluster size
387
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
388
-lazy_refcounts Postpone refcount updates
389
-refcount_bits Width of a reference count entry in bits
390
-nocow Turn off copy-on-write (valid only on btrfs)
391
+ backing_file=<str> - File name of a base image
392
+ backing_fmt=<str> - Image format of the base image
393
+ cluster_size=<size> - qcow2 cluster size
394
+ compat=<str> - Compatibility level (0.10 or 1.1)
395
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
396
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
397
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
398
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
399
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
400
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
401
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
402
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
403
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
404
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
405
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
406
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
407
+ refcount_bits=<num> - Width of a reference count entry in bits
408
+ size=<size> - Virtual disk size
409
410
Testing: create -f qcow2 -o cluster_size=4k -o ? TEST_DIR/t.qcow2 128M
411
Supported options:
412
-size Virtual disk size
413
-compat Compatibility level (0.10 or 1.1)
414
-backing_file File name of a base image
415
-backing_fmt Image format of the base image
416
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
417
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
418
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
419
-encrypt.cipher-alg Name of encryption cipher algorithm
420
-encrypt.cipher-mode Name of encryption cipher mode
421
-encrypt.ivgen-alg Name of IV generator algorithm
422
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
423
-encrypt.hash-alg Name of encryption hash algorithm
424
-encrypt.iter-time Time to spend in PBKDF in milliseconds
425
-cluster_size qcow2 cluster size
426
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
427
-lazy_refcounts Postpone refcount updates
428
-refcount_bits Width of a reference count entry in bits
429
-nocow Turn off copy-on-write (valid only on btrfs)
430
+ backing_file=<str> - File name of a base image
431
+ backing_fmt=<str> - Image format of the base image
432
+ cluster_size=<size> - qcow2 cluster size
433
+ compat=<str> - Compatibility level (0.10 or 1.1)
434
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
435
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
436
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
437
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
438
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
439
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
440
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
441
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
442
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
443
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
444
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
445
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
446
+ refcount_bits=<num> - Width of a reference count entry in bits
447
+ size=<size> - Virtual disk size
448
449
Testing: create -f qcow2 -u -o backing_file=TEST_DIR/t.qcow2,,help TEST_DIR/t.qcow2 128M
450
Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/t.qcow2,,help cluster_size=65536 lazy_refcounts=off refcount_bits=16
451
@@ -XXX,XX +XXX,XX @@ qemu-img: Invalid option list: ,,
452
453
Testing: create -f qcow2 -o help
454
Supported options:
455
-size Virtual disk size
456
-compat Compatibility level (0.10 or 1.1)
457
-backing_file File name of a base image
458
-backing_fmt Image format of the base image
459
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
460
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
461
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
462
-encrypt.cipher-alg Name of encryption cipher algorithm
463
-encrypt.cipher-mode Name of encryption cipher mode
464
-encrypt.ivgen-alg Name of IV generator algorithm
465
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
466
-encrypt.hash-alg Name of encryption hash algorithm
467
-encrypt.iter-time Time to spend in PBKDF in milliseconds
468
-cluster_size qcow2 cluster size
469
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
470
-lazy_refcounts Postpone refcount updates
471
-refcount_bits Width of a reference count entry in bits
472
+ backing_file=<str> - File name of a base image
473
+ backing_fmt=<str> - Image format of the base image
474
+ cluster_size=<size> - qcow2 cluster size
475
+ compat=<str> - Compatibility level (0.10 or 1.1)
476
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
477
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
478
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
479
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
480
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
481
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
482
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
483
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
484
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
485
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
486
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
487
+ refcount_bits=<num> - Width of a reference count entry in bits
488
+ size=<size> - Virtual disk size
489
490
Testing: create -o help
491
Supported options:
492
-size Virtual disk size
493
+ size=<size> - Virtual disk size
494
495
Testing: create -f bochs -o help
496
qemu-img: Format driver 'bochs' does not support image creation
497
@@ -XXX,XX +XXX,XX @@ cluster_size: 8192
498
499
Testing: convert -O qcow2 -o help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
500
Supported options:
501
-size Virtual disk size
502
-compat Compatibility level (0.10 or 1.1)
503
-backing_file File name of a base image
504
-backing_fmt Image format of the base image
505
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
506
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
507
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
508
-encrypt.cipher-alg Name of encryption cipher algorithm
509
-encrypt.cipher-mode Name of encryption cipher mode
510
-encrypt.ivgen-alg Name of IV generator algorithm
511
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
512
-encrypt.hash-alg Name of encryption hash algorithm
513
-encrypt.iter-time Time to spend in PBKDF in milliseconds
514
-cluster_size qcow2 cluster size
515
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
516
-lazy_refcounts Postpone refcount updates
517
-refcount_bits Width of a reference count entry in bits
518
-nocow Turn off copy-on-write (valid only on btrfs)
519
+ backing_file=<str> - File name of a base image
520
+ backing_fmt=<str> - Image format of the base image
521
+ cluster_size=<size> - qcow2 cluster size
522
+ compat=<str> - Compatibility level (0.10 or 1.1)
523
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
524
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
525
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
526
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
527
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
528
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
529
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
530
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
531
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
532
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
533
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
534
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
535
+ refcount_bits=<num> - Width of a reference count entry in bits
536
+ size=<size> - Virtual disk size
537
538
Testing: convert -O qcow2 -o ? TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
539
Supported options:
540
-size Virtual disk size
541
-compat Compatibility level (0.10 or 1.1)
542
-backing_file File name of a base image
543
-backing_fmt Image format of the base image
544
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
545
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
546
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
547
-encrypt.cipher-alg Name of encryption cipher algorithm
548
-encrypt.cipher-mode Name of encryption cipher mode
549
-encrypt.ivgen-alg Name of IV generator algorithm
550
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
551
-encrypt.hash-alg Name of encryption hash algorithm
552
-encrypt.iter-time Time to spend in PBKDF in milliseconds
553
-cluster_size qcow2 cluster size
554
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
555
-lazy_refcounts Postpone refcount updates
556
-refcount_bits Width of a reference count entry in bits
557
-nocow Turn off copy-on-write (valid only on btrfs)
558
+ backing_file=<str> - File name of a base image
559
+ backing_fmt=<str> - Image format of the base image
560
+ cluster_size=<size> - qcow2 cluster size
561
+ compat=<str> - Compatibility level (0.10 or 1.1)
562
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
563
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
564
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
565
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
566
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
567
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
568
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
569
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
570
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
571
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
572
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
573
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
574
+ refcount_bits=<num> - Width of a reference count entry in bits
575
+ size=<size> - Virtual disk size
576
577
Testing: convert -O qcow2 -o cluster_size=4k,help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
578
Supported options:
579
-size Virtual disk size
580
-compat Compatibility level (0.10 or 1.1)
581
-backing_file File name of a base image
582
-backing_fmt Image format of the base image
583
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
584
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
585
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
586
-encrypt.cipher-alg Name of encryption cipher algorithm
587
-encrypt.cipher-mode Name of encryption cipher mode
588
-encrypt.ivgen-alg Name of IV generator algorithm
589
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
590
-encrypt.hash-alg Name of encryption hash algorithm
591
-encrypt.iter-time Time to spend in PBKDF in milliseconds
592
-cluster_size qcow2 cluster size
593
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
594
-lazy_refcounts Postpone refcount updates
595
-refcount_bits Width of a reference count entry in bits
596
-nocow Turn off copy-on-write (valid only on btrfs)
597
+ backing_file=<str> - File name of a base image
598
+ backing_fmt=<str> - Image format of the base image
599
+ cluster_size=<size> - qcow2 cluster size
600
+ compat=<str> - Compatibility level (0.10 or 1.1)
601
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
602
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
603
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
604
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
605
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
606
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
607
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
608
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
609
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
610
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
611
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
612
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
613
+ refcount_bits=<num> - Width of a reference count entry in bits
614
+ size=<size> - Virtual disk size
615
616
Testing: convert -O qcow2 -o cluster_size=4k,? TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
617
Supported options:
618
-size Virtual disk size
619
-compat Compatibility level (0.10 or 1.1)
620
-backing_file File name of a base image
621
-backing_fmt Image format of the base image
622
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
623
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
624
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
625
-encrypt.cipher-alg Name of encryption cipher algorithm
626
-encrypt.cipher-mode Name of encryption cipher mode
627
-encrypt.ivgen-alg Name of IV generator algorithm
628
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
629
-encrypt.hash-alg Name of encryption hash algorithm
630
-encrypt.iter-time Time to spend in PBKDF in milliseconds
631
-cluster_size qcow2 cluster size
632
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
633
-lazy_refcounts Postpone refcount updates
634
-refcount_bits Width of a reference count entry in bits
635
-nocow Turn off copy-on-write (valid only on btrfs)
636
+ backing_file=<str> - File name of a base image
637
+ backing_fmt=<str> - Image format of the base image
638
+ cluster_size=<size> - qcow2 cluster size
639
+ compat=<str> - Compatibility level (0.10 or 1.1)
640
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
641
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
642
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
643
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
644
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
645
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
646
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
647
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
648
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
649
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
650
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
651
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
652
+ refcount_bits=<num> - Width of a reference count entry in bits
653
+ size=<size> - Virtual disk size
654
655
Testing: convert -O qcow2 -o help,cluster_size=4k TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
656
Supported options:
657
-size Virtual disk size
658
-compat Compatibility level (0.10 or 1.1)
659
-backing_file File name of a base image
660
-backing_fmt Image format of the base image
661
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
662
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
663
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
664
-encrypt.cipher-alg Name of encryption cipher algorithm
665
-encrypt.cipher-mode Name of encryption cipher mode
666
-encrypt.ivgen-alg Name of IV generator algorithm
667
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
668
-encrypt.hash-alg Name of encryption hash algorithm
669
-encrypt.iter-time Time to spend in PBKDF in milliseconds
670
-cluster_size qcow2 cluster size
671
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
672
-lazy_refcounts Postpone refcount updates
673
-refcount_bits Width of a reference count entry in bits
674
-nocow Turn off copy-on-write (valid only on btrfs)
675
+ backing_file=<str> - File name of a base image
676
+ backing_fmt=<str> - Image format of the base image
677
+ cluster_size=<size> - qcow2 cluster size
678
+ compat=<str> - Compatibility level (0.10 or 1.1)
679
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
680
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
681
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
682
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
683
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
684
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
685
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
686
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
687
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
688
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
689
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
690
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
691
+ refcount_bits=<num> - Width of a reference count entry in bits
692
+ size=<size> - Virtual disk size
693
694
Testing: convert -O qcow2 -o ?,cluster_size=4k TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
695
Supported options:
696
-size Virtual disk size
697
-compat Compatibility level (0.10 or 1.1)
698
-backing_file File name of a base image
699
-backing_fmt Image format of the base image
700
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
701
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
702
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
703
-encrypt.cipher-alg Name of encryption cipher algorithm
704
-encrypt.cipher-mode Name of encryption cipher mode
705
-encrypt.ivgen-alg Name of IV generator algorithm
706
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
707
-encrypt.hash-alg Name of encryption hash algorithm
708
-encrypt.iter-time Time to spend in PBKDF in milliseconds
709
-cluster_size qcow2 cluster size
710
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
711
-lazy_refcounts Postpone refcount updates
712
-refcount_bits Width of a reference count entry in bits
713
-nocow Turn off copy-on-write (valid only on btrfs)
714
+ backing_file=<str> - File name of a base image
715
+ backing_fmt=<str> - Image format of the base image
716
+ cluster_size=<size> - qcow2 cluster size
717
+ compat=<str> - Compatibility level (0.10 or 1.1)
718
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
719
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
720
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
721
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
722
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
723
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
724
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
725
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
726
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
727
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
728
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
729
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
730
+ refcount_bits=<num> - Width of a reference count entry in bits
731
+ size=<size> - Virtual disk size
732
733
Testing: convert -O qcow2 -o cluster_size=4k -o help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
734
Supported options:
735
-size Virtual disk size
736
-compat Compatibility level (0.10 or 1.1)
737
-backing_file File name of a base image
738
-backing_fmt Image format of the base image
739
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
740
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
741
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
742
-encrypt.cipher-alg Name of encryption cipher algorithm
743
-encrypt.cipher-mode Name of encryption cipher mode
744
-encrypt.ivgen-alg Name of IV generator algorithm
745
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
746
-encrypt.hash-alg Name of encryption hash algorithm
747
-encrypt.iter-time Time to spend in PBKDF in milliseconds
748
-cluster_size qcow2 cluster size
749
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
750
-lazy_refcounts Postpone refcount updates
751
-refcount_bits Width of a reference count entry in bits
752
-nocow Turn off copy-on-write (valid only on btrfs)
753
+ backing_file=<str> - File name of a base image
754
+ backing_fmt=<str> - Image format of the base image
755
+ cluster_size=<size> - qcow2 cluster size
756
+ compat=<str> - Compatibility level (0.10 or 1.1)
757
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
758
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
759
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
760
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
761
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
762
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
763
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
764
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
765
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
766
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
767
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
768
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
769
+ refcount_bits=<num> - Width of a reference count entry in bits
770
+ size=<size> - Virtual disk size
771
772
Testing: convert -O qcow2 -o cluster_size=4k -o ? TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
773
Supported options:
774
-size Virtual disk size
775
-compat Compatibility level (0.10 or 1.1)
776
-backing_file File name of a base image
777
-backing_fmt Image format of the base image
778
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
779
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
780
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
781
-encrypt.cipher-alg Name of encryption cipher algorithm
782
-encrypt.cipher-mode Name of encryption cipher mode
783
-encrypt.ivgen-alg Name of IV generator algorithm
784
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
785
-encrypt.hash-alg Name of encryption hash algorithm
786
-encrypt.iter-time Time to spend in PBKDF in milliseconds
787
-cluster_size qcow2 cluster size
788
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
789
-lazy_refcounts Postpone refcount updates
790
-refcount_bits Width of a reference count entry in bits
791
-nocow Turn off copy-on-write (valid only on btrfs)
792
+ backing_file=<str> - File name of a base image
793
+ backing_fmt=<str> - Image format of the base image
794
+ cluster_size=<size> - qcow2 cluster size
795
+ compat=<str> - Compatibility level (0.10 or 1.1)
796
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
797
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
798
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
799
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
800
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
801
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
802
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
803
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
804
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
805
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
806
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
807
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
808
+ refcount_bits=<num> - Width of a reference count entry in bits
809
+ size=<size> - Virtual disk size
810
811
Testing: convert -O qcow2 -o backing_file=TEST_DIR/t.qcow2,,help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
812
qemu-img: Could not open 'TEST_DIR/t.qcow2.base': Could not open backing file: Could not open 'TEST_DIR/t.qcow2,help': No such file or directory
813
@@ -XXX,XX +XXX,XX @@ qemu-img: Invalid option list: ,,
814
815
Testing: convert -O qcow2 -o help
816
Supported options:
817
-size Virtual disk size
818
-compat Compatibility level (0.10 or 1.1)
819
-backing_file File name of a base image
820
-backing_fmt Image format of the base image
821
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
822
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
823
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
824
-encrypt.cipher-alg Name of encryption cipher algorithm
825
-encrypt.cipher-mode Name of encryption cipher mode
826
-encrypt.ivgen-alg Name of IV generator algorithm
827
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
828
-encrypt.hash-alg Name of encryption hash algorithm
829
-encrypt.iter-time Time to spend in PBKDF in milliseconds
830
-cluster_size qcow2 cluster size
831
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
832
-lazy_refcounts Postpone refcount updates
833
-refcount_bits Width of a reference count entry in bits
834
+ backing_file=<str> - File name of a base image
835
+ backing_fmt=<str> - Image format of the base image
836
+ cluster_size=<size> - qcow2 cluster size
837
+ compat=<str> - Compatibility level (0.10 or 1.1)
838
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
839
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
840
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
841
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
842
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
843
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
844
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
845
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
846
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
847
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
848
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
849
+ refcount_bits=<num> - Width of a reference count entry in bits
850
+ size=<size> - Virtual disk size
851
852
Testing: convert -o help
853
Supported options:
854
-size Virtual disk size
855
+ size=<size> - Virtual disk size
856
857
Testing: convert -O bochs -o help
858
qemu-img: Format driver 'bochs' does not support image creation
859
@@ -XXX,XX +XXX,XX @@ cluster_size: 65536
860
861
Testing: amend -f qcow2 -o help TEST_DIR/t.qcow2
862
Creation options for 'qcow2':
863
-size Virtual disk size
864
-compat Compatibility level (0.10 or 1.1)
865
-backing_file File name of a base image
866
-backing_fmt Image format of the base image
867
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
868
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
869
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
870
-encrypt.cipher-alg Name of encryption cipher algorithm
871
-encrypt.cipher-mode Name of encryption cipher mode
872
-encrypt.ivgen-alg Name of IV generator algorithm
873
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
874
-encrypt.hash-alg Name of encryption hash algorithm
875
-encrypt.iter-time Time to spend in PBKDF in milliseconds
876
-cluster_size qcow2 cluster size
877
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
878
-lazy_refcounts Postpone refcount updates
879
-refcount_bits Width of a reference count entry in bits
880
+ backing_file=<str> - File name of a base image
881
+ backing_fmt=<str> - Image format of the base image
882
+ cluster_size=<size> - qcow2 cluster size
883
+ compat=<str> - Compatibility level (0.10 or 1.1)
884
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
885
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
886
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
887
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
888
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
889
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
890
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
891
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
892
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
893
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
894
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
895
+ refcount_bits=<num> - Width of a reference count entry in bits
896
+ size=<size> - Virtual disk size
897
898
Note that not all of these options may be amendable.
899
900
Testing: amend -f qcow2 -o ? TEST_DIR/t.qcow2
901
Creation options for 'qcow2':
902
-size Virtual disk size
903
-compat Compatibility level (0.10 or 1.1)
904
-backing_file File name of a base image
905
-backing_fmt Image format of the base image
906
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
907
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
908
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
909
-encrypt.cipher-alg Name of encryption cipher algorithm
910
-encrypt.cipher-mode Name of encryption cipher mode
911
-encrypt.ivgen-alg Name of IV generator algorithm
912
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
913
-encrypt.hash-alg Name of encryption hash algorithm
914
-encrypt.iter-time Time to spend in PBKDF in milliseconds
915
-cluster_size qcow2 cluster size
916
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
917
-lazy_refcounts Postpone refcount updates
918
-refcount_bits Width of a reference count entry in bits
919
+ backing_file=<str> - File name of a base image
920
+ backing_fmt=<str> - Image format of the base image
921
+ cluster_size=<size> - qcow2 cluster size
922
+ compat=<str> - Compatibility level (0.10 or 1.1)
923
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
924
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
925
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
926
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
927
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
928
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
929
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
930
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
931
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
932
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
933
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
934
+ refcount_bits=<num> - Width of a reference count entry in bits
935
+ size=<size> - Virtual disk size
936
937
Note that not all of these options may be amendable.
938
939
Testing: amend -f qcow2 -o cluster_size=4k,help TEST_DIR/t.qcow2
940
Creation options for 'qcow2':
941
-size Virtual disk size
942
-compat Compatibility level (0.10 or 1.1)
943
-backing_file File name of a base image
944
-backing_fmt Image format of the base image
945
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
946
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
947
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
948
-encrypt.cipher-alg Name of encryption cipher algorithm
949
-encrypt.cipher-mode Name of encryption cipher mode
950
-encrypt.ivgen-alg Name of IV generator algorithm
951
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
952
-encrypt.hash-alg Name of encryption hash algorithm
953
-encrypt.iter-time Time to spend in PBKDF in milliseconds
954
-cluster_size qcow2 cluster size
955
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
956
-lazy_refcounts Postpone refcount updates
957
-refcount_bits Width of a reference count entry in bits
958
+ backing_file=<str> - File name of a base image
959
+ backing_fmt=<str> - Image format of the base image
960
+ cluster_size=<size> - qcow2 cluster size
961
+ compat=<str> - Compatibility level (0.10 or 1.1)
962
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
963
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
964
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
965
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
966
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
967
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
968
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
969
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
970
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
971
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
972
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
973
+ refcount_bits=<num> - Width of a reference count entry in bits
974
+ size=<size> - Virtual disk size
975
976
Note that not all of these options may be amendable.
977
978
Testing: amend -f qcow2 -o cluster_size=4k,? TEST_DIR/t.qcow2
979
Creation options for 'qcow2':
980
-size Virtual disk size
981
-compat Compatibility level (0.10 or 1.1)
982
-backing_file File name of a base image
983
-backing_fmt Image format of the base image
984
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
985
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
986
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
987
-encrypt.cipher-alg Name of encryption cipher algorithm
988
-encrypt.cipher-mode Name of encryption cipher mode
989
-encrypt.ivgen-alg Name of IV generator algorithm
990
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
991
-encrypt.hash-alg Name of encryption hash algorithm
992
-encrypt.iter-time Time to spend in PBKDF in milliseconds
993
-cluster_size qcow2 cluster size
994
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
995
-lazy_refcounts Postpone refcount updates
996
-refcount_bits Width of a reference count entry in bits
997
+ backing_file=<str> - File name of a base image
998
+ backing_fmt=<str> - Image format of the base image
999
+ cluster_size=<size> - qcow2 cluster size
1000
+ compat=<str> - Compatibility level (0.10 or 1.1)
1001
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
1002
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
1003
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
1004
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
1005
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
1006
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
1007
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
1008
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
1009
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
1010
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
1011
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
1012
+ refcount_bits=<num> - Width of a reference count entry in bits
1013
+ size=<size> - Virtual disk size
1014
1015
Note that not all of these options may be amendable.
1016
1017
Testing: amend -f qcow2 -o help,cluster_size=4k TEST_DIR/t.qcow2
1018
Creation options for 'qcow2':
1019
-size Virtual disk size
1020
-compat Compatibility level (0.10 or 1.1)
1021
-backing_file File name of a base image
1022
-backing_fmt Image format of the base image
1023
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
1024
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
1025
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
1026
-encrypt.cipher-alg Name of encryption cipher algorithm
1027
-encrypt.cipher-mode Name of encryption cipher mode
1028
-encrypt.ivgen-alg Name of IV generator algorithm
1029
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
1030
-encrypt.hash-alg Name of encryption hash algorithm
1031
-encrypt.iter-time Time to spend in PBKDF in milliseconds
1032
-cluster_size qcow2 cluster size
1033
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
1034
-lazy_refcounts Postpone refcount updates
1035
-refcount_bits Width of a reference count entry in bits
1036
+ backing_file=<str> - File name of a base image
1037
+ backing_fmt=<str> - Image format of the base image
1038
+ cluster_size=<size> - qcow2 cluster size
1039
+ compat=<str> - Compatibility level (0.10 or 1.1)
1040
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
1041
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
1042
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
1043
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
1044
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
1045
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
1046
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
1047
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
1048
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
1049
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
1050
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
1051
+ refcount_bits=<num> - Width of a reference count entry in bits
1052
+ size=<size> - Virtual disk size
1053
1054
Note that not all of these options may be amendable.
1055
1056
Testing: amend -f qcow2 -o ?,cluster_size=4k TEST_DIR/t.qcow2
1057
Creation options for 'qcow2':
1058
-size Virtual disk size
1059
-compat Compatibility level (0.10 or 1.1)
1060
-backing_file File name of a base image
1061
-backing_fmt Image format of the base image
1062
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
1063
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
1064
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
1065
-encrypt.cipher-alg Name of encryption cipher algorithm
1066
-encrypt.cipher-mode Name of encryption cipher mode
1067
-encrypt.ivgen-alg Name of IV generator algorithm
1068
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
1069
-encrypt.hash-alg Name of encryption hash algorithm
1070
-encrypt.iter-time Time to spend in PBKDF in milliseconds
1071
-cluster_size qcow2 cluster size
1072
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
1073
-lazy_refcounts Postpone refcount updates
1074
-refcount_bits Width of a reference count entry in bits
1075
+ backing_file=<str> - File name of a base image
1076
+ backing_fmt=<str> - Image format of the base image
1077
+ cluster_size=<size> - qcow2 cluster size
1078
+ compat=<str> - Compatibility level (0.10 or 1.1)
1079
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
1080
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
1081
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
1082
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
1083
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
1084
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
1085
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
1086
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
1087
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
1088
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
1089
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
1090
+ refcount_bits=<num> - Width of a reference count entry in bits
1091
+ size=<size> - Virtual disk size
1092
1093
Note that not all of these options may be amendable.
1094
1095
Testing: amend -f qcow2 -o cluster_size=4k -o help TEST_DIR/t.qcow2
1096
Creation options for 'qcow2':
1097
-size Virtual disk size
1098
-compat Compatibility level (0.10 or 1.1)
1099
-backing_file File name of a base image
1100
-backing_fmt Image format of the base image
1101
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
1102
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
1103
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
1104
-encrypt.cipher-alg Name of encryption cipher algorithm
1105
-encrypt.cipher-mode Name of encryption cipher mode
1106
-encrypt.ivgen-alg Name of IV generator algorithm
1107
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
1108
-encrypt.hash-alg Name of encryption hash algorithm
1109
-encrypt.iter-time Time to spend in PBKDF in milliseconds
1110
-cluster_size qcow2 cluster size
1111
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
1112
-lazy_refcounts Postpone refcount updates
1113
-refcount_bits Width of a reference count entry in bits
1114
+ backing_file=<str> - File name of a base image
1115
+ backing_fmt=<str> - Image format of the base image
1116
+ cluster_size=<size> - qcow2 cluster size
1117
+ compat=<str> - Compatibility level (0.10 or 1.1)
1118
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
1119
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
1120
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
1121
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
1122
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
1123
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
1124
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
1125
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
1126
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
1127
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
1128
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
1129
+ refcount_bits=<num> - Width of a reference count entry in bits
1130
+ size=<size> - Virtual disk size
1131
1132
Note that not all of these options may be amendable.
1133
1134
Testing: amend -f qcow2 -o cluster_size=4k -o ? TEST_DIR/t.qcow2
1135
Creation options for 'qcow2':
1136
-size Virtual disk size
1137
-compat Compatibility level (0.10 or 1.1)
1138
-backing_file File name of a base image
1139
-backing_fmt Image format of the base image
1140
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
1141
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
1142
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
1143
-encrypt.cipher-alg Name of encryption cipher algorithm
1144
-encrypt.cipher-mode Name of encryption cipher mode
1145
-encrypt.ivgen-alg Name of IV generator algorithm
1146
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
1147
-encrypt.hash-alg Name of encryption hash algorithm
1148
-encrypt.iter-time Time to spend in PBKDF in milliseconds
1149
-cluster_size qcow2 cluster size
1150
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
1151
-lazy_refcounts Postpone refcount updates
1152
-refcount_bits Width of a reference count entry in bits
1153
+ backing_file=<str> - File name of a base image
1154
+ backing_fmt=<str> - Image format of the base image
1155
+ cluster_size=<size> - qcow2 cluster size
1156
+ compat=<str> - Compatibility level (0.10 or 1.1)
1157
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
1158
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
1159
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
1160
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
1161
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
1162
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
1163
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
1164
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
1165
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
1166
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
1167
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
1168
+ refcount_bits=<num> - Width of a reference count entry in bits
1169
+ size=<size> - Virtual disk size
1170
1171
Note that not all of these options may be amendable.
1172
1173
@@ -XXX,XX +XXX,XX @@ qemu-img: Invalid option list: ,,
1174
1175
Testing: amend -f qcow2 -o help
1176
Creation options for 'qcow2':
1177
-size Virtual disk size
1178
-compat Compatibility level (0.10 or 1.1)
1179
-backing_file File name of a base image
1180
-backing_fmt Image format of the base image
1181
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
1182
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
1183
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
1184
-encrypt.cipher-alg Name of encryption cipher algorithm
1185
-encrypt.cipher-mode Name of encryption cipher mode
1186
-encrypt.ivgen-alg Name of IV generator algorithm
1187
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
1188
-encrypt.hash-alg Name of encryption hash algorithm
1189
-encrypt.iter-time Time to spend in PBKDF in milliseconds
1190
-cluster_size qcow2 cluster size
1191
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
1192
-lazy_refcounts Postpone refcount updates
1193
-refcount_bits Width of a reference count entry in bits
1194
+ backing_file=<str> - File name of a base image
1195
+ backing_fmt=<str> - Image format of the base image
1196
+ cluster_size=<size> - qcow2 cluster size
1197
+ compat=<str> - Compatibility level (0.10 or 1.1)
1198
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
1199
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
1200
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
1201
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
1202
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
1203
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
1204
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
1205
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
1206
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
1207
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
1208
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
1209
+ refcount_bits=<num> - Width of a reference count entry in bits
1210
+ size=<size> - Virtual disk size
1211
1212
Note that not all of these options may be amendable.
1213
1214
Testing: convert -o help
1215
Supported options:
1216
-size Virtual disk size
1217
+ size=<size> - Virtual disk size
1218
1219
Testing: amend -f bochs -o help
1220
qemu-img: Format driver 'bochs' does not support option amendment
1221
--
1222
2.19.1
1223
1224
diff view generated by jsdifflib
New patch
1
From: Max Reitz <mreitz@redhat.com>
1
2
3
Following the example of qemu_opts_print_help(), indent all entries in
4
the list of character devices.
5
6
Signed-off-by: Max Reitz <mreitz@redhat.com>
7
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9
---
10
chardev/char.c | 2 +-
11
1 file changed, 1 insertion(+), 1 deletion(-)
12
13
diff --git a/chardev/char.c b/chardev/char.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/chardev/char.c
16
+++ b/chardev/char.c
17
@@ -XXX,XX +XXX,XX @@ help_string_append(const char *name, void *opaque)
18
{
19
GString *str = opaque;
20
21
- g_string_append_printf(str, "\n%s", name);
22
+ g_string_append_printf(str, "\n %s", name);
23
}
24
25
static const char *chardev_alias_translate(const char *name)
26
--
27
2.19.1
28
29
diff view generated by jsdifflib
New patch
1
From: Max Reitz <mreitz@redhat.com>
1
2
3
Just like in qemu_opts_print_help(), print the device name as a caption
4
instead of on every single line, indent all options, add angle brackets
5
around types, and align the descriptions after 24 characters. Also,
6
separate the descriptions with " - " instead of putting them in
7
parentheses, because that is what we do everywhere else. This does look
8
a bit funny here because basically all bits have the description
9
"on/off", but funny does not mean it is less readable.
10
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
12
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
13
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14
---
15
qdev-monitor.c | 13 +++++++++++--
16
1 file changed, 11 insertions(+), 2 deletions(-)
17
18
diff --git a/qdev-monitor.c b/qdev-monitor.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/qdev-monitor.c
21
+++ b/qdev-monitor.c
22
@@ -XXX,XX +XXX,XX @@ int qdev_device_help(QemuOpts *opts)
23
goto error;
24
}
25
26
+ if (prop_list) {
27
+ out_printf("%s options:\n", driver);
28
+ } else {
29
+ out_printf("There are no options for %s.\n", driver);
30
+ }
31
for (prop = prop_list; prop; prop = prop->next) {
32
- out_printf("%s.%s=%s", driver, prop->value->name, prop->value->type);
33
+ int len;
34
+ out_printf(" %s=<%s>%n", prop->value->name, prop->value->type, &len);
35
if (prop->value->has_description) {
36
- out_printf(" (%s)\n", prop->value->description);
37
+ if (len < 24) {
38
+ out_printf("%*s", 24 - len, "");
39
+ }
40
+ out_printf(" - %s\n", prop->value->description);
41
} else {
42
out_printf("\n");
43
}
44
--
45
2.19.1
46
47
diff view generated by jsdifflib
New patch
1
From: Max Reitz <mreitz@redhat.com>
1
2
3
Just like in qemu_opts_print_help(), print the object name as a caption
4
instead of on every single line, indent all options, add angle brackets
5
around types, and align the descriptions after 24 characters.
6
7
Also, indent every object name in the list of available objects.
8
9
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
11
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12
---
13
vl.c | 13 ++++++++++---
14
1 file changed, 10 insertions(+), 3 deletions(-)
15
16
diff --git a/vl.c b/vl.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/vl.c
19
+++ b/vl.c
20
@@ -XXX,XX +XXX,XX @@ static bool object_create_initial(const char *type, QemuOpts *opts)
21
list = object_class_get_list_sorted(TYPE_USER_CREATABLE, false);
22
for (l = list; l != NULL; l = l->next) {
23
ObjectClass *oc = OBJECT_CLASS(l->data);
24
- printf("%s\n", object_class_get_name(oc));
25
+ printf(" %s\n", object_class_get_name(oc));
26
}
27
g_slist_free(list);
28
exit(0);
29
@@ -XXX,XX +XXX,XX @@ static bool object_create_initial(const char *type, QemuOpts *opts)
30
}
31
32
str = g_string_new(NULL);
33
- g_string_append_printf(str, "%s.%s=%s", type,
34
- prop->name, prop->type);
35
+ g_string_append_printf(str, " %s=<%s>", prop->name, prop->type);
36
if (prop->description) {
37
+ if (str->len < 24) {
38
+ g_string_append_printf(str, "%*s", 24 - (int)str->len, "");
39
+ }
40
g_string_append_printf(str, " - %s", prop->description);
41
}
42
g_ptr_array_add(array, g_string_free(str, false));
43
}
44
g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0);
45
+ if (array->len > 0) {
46
+ printf("%s options:\n", type);
47
+ } else {
48
+ printf("There are no options for %s.\n", type);
49
+ }
50
for (i = 0; i < array->len; i++) {
51
printf("%s\n", (char *)array->pdata[i]);
52
}
53
--
54
2.19.1
55
56
diff view generated by jsdifflib
New patch
1
From: Max Reitz <mreitz@redhat.com>
1
2
3
There is no good reason why there should be a newline in this
4
description, so remove it.
5
6
Signed-off-by: Max Reitz <mreitz@redhat.com>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10
---
11
vl.c | 2 +-
12
1 file changed, 1 insertion(+), 1 deletion(-)
13
14
diff --git a/vl.c b/vl.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/vl.c
17
+++ b/vl.c
18
@@ -XXX,XX +XXX,XX @@ static QemuOptsList qemu_fw_cfg_opts = {
19
}, {
20
.name = "file",
21
.type = QEMU_OPT_STRING,
22
- .help = "Sets the name of the file from which\n"
23
+ .help = "Sets the name of the file from which "
24
"the fw_cfg blob will be loaded",
25
}, {
26
.name = "string",
27
--
28
2.19.1
29
30
diff view generated by jsdifflib
1
.bdrv_co_create() is supposed to return 0 on success, but vdi could
1
From: Leonid Bloch <lbloch@janustech.com>
2
return a positive value instead. Fix this.
3
2
3
If an expression is used to define DEFAULT_CLUSTER_SIZE, when compiled,
4
it will be embedded as a literal expression in the binary (as the
5
default value) because it is stringified to mark the size of the default
6
value. Now this is fixed by using a defined number to define this value.
7
8
Signed-off-by: Leonid Bloch <lbloch@janustech.com>
9
Reviewed-by: Stefan Weil <sw@weilnetz.de>
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
5
Reviewed-by: Max Reitz <mreitz@redhat.com>
6
Reviewed-by: Jeff Cody <jcody@redhat.com>
7
---
11
---
8
block/vdi.c | 1 +
12
block/vdi.c | 4 ++--
9
1 file changed, 1 insertion(+)
13
1 file changed, 2 insertions(+), 2 deletions(-)
10
14
11
diff --git a/block/vdi.c b/block/vdi.c
15
diff --git a/block/vdi.c b/block/vdi.c
12
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
13
--- a/block/vdi.c
17
--- a/block/vdi.c
14
+++ b/block/vdi.c
18
+++ b/block/vdi.c
15
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn vdi_co_do_create(BlockdevCreateOptions *create_options,
19
@@ -XXX,XX +XXX,XX @@
16
}
20
#define BLOCK_OPT_STATIC "static"
17
}
21
18
22
#define SECTOR_SIZE 512
19
+ ret = 0;
23
-#define DEFAULT_CLUSTER_SIZE (1 * MiB)
20
exit:
24
+#define DEFAULT_CLUSTER_SIZE S_1MiB
21
blk_unref(blk);
25
22
bdrv_unref(bs_file);
26
#if defined(CONFIG_VDI_DEBUG)
27
#define VDI_DEBUG 1
28
@@ -XXX,XX +XXX,XX @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
29
goto fail;
30
} else if (header.block_size != DEFAULT_CLUSTER_SIZE) {
31
error_setg(errp, "unsupported VDI image (block size %" PRIu32
32
- " is not %" PRIu64 ")",
33
+ " is not %" PRIu32 ")",
34
header.block_size, DEFAULT_CLUSTER_SIZE);
35
ret = -ENOTSUP;
36
goto fail;
23
--
37
--
24
2.13.6
38
2.19.1
25
39
26
40
diff view generated by jsdifflib
1
This adds a filter function to postprocess 'qemu-img info' input
1
From: Leonid Bloch <lbloch@janustech.com>
2
(similar to what _img_info does), and an img_info_log() function that
3
calls 'qemu-img info' and logs the filtered output.
4
2
3
The lookup table for power-of-two sizes was added in commit 540b8492618eb
4
for the purpose of having convenient shortcuts for these sizes in cases
5
when the literal number has to be present at compile time, and
6
expressions as '(1 * KiB)' can not be used. One such case is the
7
stringification of sizes. Beyond that, it is convenient to use these
8
shortcuts for all power-of-two sizes, even if they don't have to be
9
literal numbers.
10
11
Despite its convenience, this table introduced 55 lines of "dumb" code,
12
the purpose and origin of which are obscure without reading the message
13
of the commit which introduced it. This patch fixes that by adding a
14
comment to the code itself with a brief explanation for the reasoning
15
behind this table. This comment includes the short AWK script that
16
generated the table, so that anyone who's interested could make sure
17
that the values in it are correct (otherwise these values look as if
18
they were typed manually).
19
20
Signed-off-by: Leonid Bloch <lbloch@janustech.com>
5
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
21
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
6
Reviewed-by: Max Reitz <mreitz@redhat.com>
7
Reviewed-by: Jeff Cody <jcody@redhat.com>
8
---
22
---
9
tests/qemu-iotests/iotests.py | 18 ++++++++++++++++++
23
include/qemu/units.h | 18 ++++++++++++++++++
10
1 file changed, 18 insertions(+)
24
1 file changed, 18 insertions(+)
11
25
12
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
26
diff --git a/include/qemu/units.h b/include/qemu/units.h
13
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
14
--- a/tests/qemu-iotests/iotests.py
28
--- a/include/qemu/units.h
15
+++ b/tests/qemu-iotests/iotests.py
29
+++ b/include/qemu/units.h
16
@@ -XXX,XX +XXX,XX @@ def qemu_img_pipe(*args):
30
@@ -XXX,XX +XXX,XX @@
17
sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' '.join(qemu_img_args + list(args))))
31
#define PiB (INT64_C(1) << 50)
18
return subp.communicate()[0]
32
#define EiB (INT64_C(1) << 60)
19
33
20
+def img_info_log(filename, filter_path=None):
34
+/*
21
+ output = qemu_img_pipe('info', '-f', imgfmt, filename)
35
+ * The following lookup table is intended to be used when a literal string of
22
+ if not filter_path:
36
+ * the number of bytes is required (for example if it needs to be stringified).
23
+ filter_path = filename
37
+ * It can also be used for generic shortcuts of power-of-two sizes.
24
+ log(filter_img_info(output, filter_path))
38
+ * This table is generated using the AWK script below:
39
+ *
40
+ * BEGIN {
41
+ * suffix="KMGTPE";
42
+ * for(i=10; i<64; i++) {
43
+ * val=2**i;
44
+ * s=substr(suffix, int(i/10), 1);
45
+ * n=2**(i%10);
46
+ * pad=21-int(log(n)/log(10));
47
+ * printf("#define S_%d%siB %*d\n", n, s, pad, val);
48
+ * }
49
+ * }
50
+ */
25
+
51
+
26
def qemu_io(*args):
52
#define S_1KiB 1024
27
'''Run qemu-io and return the stdout data'''
53
#define S_2KiB 2048
28
args = qemu_io_args + list(args)
54
#define S_4KiB 4096
29
@@ -XXX,XX +XXX,XX @@ def filter_testfiles(msg):
30
prefix = os.path.join(test_dir, "%s-" % (os.getpid()))
31
return msg.replace(prefix, 'TEST_DIR/PID-')
32
33
+def filter_img_info(output, filename):
34
+ lines = []
35
+ for line in output.split('\n'):
36
+ if 'disk size' in line or 'actual-size' in line:
37
+ continue
38
+ line = line.replace(filename, 'TEST_IMG') \
39
+ .replace(imgfmt, 'IMGFMT')
40
+ line = re.sub('iters: [0-9]+', 'iters: XXX', line)
41
+ line = re.sub('uuid: [-a-f0-9]+', 'uuid: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', line)
42
+ lines.append(line)
43
+ return '\n'.join(lines)
44
+
45
def log(msg, filters=[]):
46
for flt in filters:
47
msg = flt(msg)
48
--
55
--
49
2.13.6
56
2.19.1
50
57
51
58
diff view generated by jsdifflib