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 60205b71421cbc529ca60b12c79e0eeace007319:
2
2
3
are available in the git repository at:
3
Merge tag 'pull-aspeed-20220801' of https://github.com/legoater/qemu into staging (2022-08-01 13:55:11 -0700)
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 21b1d974595b3986c68fe80a1f7e9b87886d4bae:
8
10
9
block/create: Mark blockdev-create stable (2018-05-30 13:31:18 +0200)
11
main loop: add missing documentation links to GS/IO macros (2022-08-02 12:02:17 +0200)
10
12
11
----------------------------------------------------------------
13
----------------------------------------------------------------
12
Block layer patches:
14
Block layer patches
13
15
14
- Add blockdev-create job
16
- libvduse: Coverity fixes
15
- qcow2: Silence Coverity false positive
17
- hd-geometry: Fix ignored bios-chs-trans setting
18
- io_uring: Fix compiler warning (missing #include)
19
- main loop: add missing documentation links to GS/IO macros
20
- qemu-iotests: Discard stderr when probing devices
16
21
17
----------------------------------------------------------------
22
----------------------------------------------------------------
18
Alberto Garcia (1):
23
Cole Robinson (1):
19
qcow2: Fix Coverity warning when calculating the refcount cache size
24
qemu-iotests: Discard stderr when probing devices
20
25
21
Kevin Wolf (16):
26
Emanuele Giuseppe Esposito (1):
22
vdi: Fix vdi_co_do_create() return value
27
main loop: add missing documentation links to GS/IO macros
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
28
39
qapi/block-core.json | 18 +-
29
Jinhao Fan (1):
40
qapi/job.json | 4 +-
30
block/io_uring: add missing include file
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
31
32
Lev Kujawski (1):
33
hw/block/hd-geometry: Do not override specified bios-chs-trans
34
35
Xie Yongji (3):
36
libvduse: Fix the incorrect function name
37
libvduse: Replace strcpy() with strncpy()
38
libvduse: Pass positive value to strerror()
39
40
include/qemu/main-loop.h | 18 +++++++++++++++---
41
block/io_uring.c | 1 +
42
hw/block/hd-geometry.c | 7 ++++++-
43
subprojects/libvduse/libvduse.c | 13 +++++++------
44
tests/qemu-iotests/common.rc | 4 ++--
45
5 files changed, 31 insertions(+), 12 deletions(-)
diff view generated by jsdifflib
1
.bdrv_co_create() is supposed to return 0 on success, but vdi could
1
From: Jinhao Fan <fanjinhao21s@ict.ac.cn>
2
return a positive value instead. Fix this.
3
2
3
The commit "Use io_uring_register_ring_fd() to skip fd operations" uses
4
warn_report but did not include the header file "qemu/error-report.h".
5
This causes "error: implicit declaration of function ‘warn_report’".
6
Include this header file.
7
8
Fixes: e2848bc574 ("Use io_uring_register_ring_fd() to skip fd operations")
9
Signed-off-by: Jinhao Fan <fanjinhao21s@ict.ac.cn>
10
Message-Id: <20220721065645.577404-1-fanjinhao21s@ict.ac.cn>
11
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12
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
---
13
---
8
block/vdi.c | 1 +
14
block/io_uring.c | 1 +
9
1 file changed, 1 insertion(+)
15
1 file changed, 1 insertion(+)
10
16
11
diff --git a/block/vdi.c b/block/vdi.c
17
diff --git a/block/io_uring.c b/block/io_uring.c
12
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
13
--- a/block/vdi.c
19
--- a/block/io_uring.c
14
+++ b/block/vdi.c
20
+++ b/block/io_uring.c
15
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn vdi_co_do_create(BlockdevCreateOptions *create_options,
21
@@ -XXX,XX +XXX,XX @@
16
}
22
#include "qemu/osdep.h"
17
}
23
#include <liburing.h>
18
24
#include "block/aio.h"
19
+ ret = 0;
25
+#include "qemu/error-report.h"
20
exit:
26
#include "qemu/queue.h"
21
blk_unref(blk);
27
#include "block/block.h"
22
bdrv_unref(bs_file);
28
#include "block/raw-aio.h"
23
--
29
--
24
2.13.6
30
2.35.3
25
31
26
32
diff view generated by jsdifflib
1
So far we relied on job->ret and strerror() to produce an error message
1
From: Xie Yongji <xieyongji@bytedance.com>
2
for failed jobs. Not surprisingly, this tends to result in completely
3
useless messages.
4
2
5
This adds a Job.error field that can contain an error string for a
3
In vduse_name_is_valid(), we actually check whether
6
failing job, and a parameter to job_completed() that sets the field. As
4
the name is invalid or not. So let's change the
7
a default, if NULL is passed, we continue to use strerror(job->ret).
5
function name to vduse_name_is_invalid() to match
6
the behavior.
8
7
9
All existing callers are changed to pass NULL. They can be improved in
8
Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
10
separate patches.
9
Reviewed-by: Markus Armbruster <armbru@redhat.com>
10
Message-Id: <20220706095624.328-2-xieyongji@bytedance.com>
11
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12
---
13
subprojects/libvduse/libvduse.c | 6 +++---
14
1 file changed, 3 insertions(+), 3 deletions(-)
11
15
12
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
16
diff --git a/subprojects/libvduse/libvduse.c b/subprojects/libvduse/libvduse.c
13
Reviewed-by: Max Reitz <mreitz@redhat.com>
14
Reviewed-by: Jeff Cody <jcody@redhat.com>
15
---
16
include/qemu/job.h | 7 ++++++-
17
block/backup.c | 2 +-
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
28
diff --git a/include/qemu/job.h b/include/qemu/job.h
29
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
30
--- a/include/qemu/job.h
18
--- a/subprojects/libvduse/libvduse.c
31
+++ b/include/qemu/job.h
19
+++ b/subprojects/libvduse/libvduse.c
32
@@ -XXX,XX +XXX,XX @@ typedef struct Job {
20
@@ -XXX,XX +XXX,XX @@ static int vduse_dev_init(VduseDev *dev, const char *name,
33
/** Estimated progress_current value at the completion of the job */
21
return 0;
34
int64_t progress_total;
22
}
35
23
36
+ /** Error string for a failed job (NULL if, and only if, job->ret == 0) */
24
-static inline bool vduse_name_is_valid(const char *name)
37
+ char *error;
25
+static inline bool vduse_name_is_invalid(const char *name)
38
+
26
{
39
/** ret code passed to job_completed. */
27
return strlen(name) >= VDUSE_NAME_MAX || strstr(name, "..");
28
}
29
@@ -XXX,XX +XXX,XX @@ VduseDev *vduse_dev_create_by_name(const char *name, uint16_t num_queues,
30
VduseDev *dev;
40
int ret;
31
int ret;
41
32
42
@@ -XXX,XX +XXX,XX @@ void job_transition_to_ready(Job *job);
33
- if (!name || vduse_name_is_valid(name) || !ops ||
43
/**
34
+ if (!name || vduse_name_is_invalid(name) || !ops ||
44
* @job: The job being completed.
35
!ops->enable_queue || !ops->disable_queue) {
45
* @ret: The status code.
36
fprintf(stderr, "Invalid parameter for vduse\n");
46
+ * @error: The error message for a failing job (only with @ret < 0). If @ret is
37
return NULL;
47
+ * negative, but NULL is given for @error, strerror() is used.
38
@@ -XXX,XX +XXX,XX @@ VduseDev *vduse_dev_create(const char *name, uint32_t device_id,
48
*
39
struct vduse_dev_config *dev_config;
49
* Marks @job as completed. If @ret is non-zero, the job transaction it is part
40
size_t size = offsetof(struct vduse_dev_config, config);
50
* of is aborted. If @ret is zero, the job moves into the WAITING state. If it
41
51
* is the last job to complete in its transaction, all jobs in the transaction
42
- if (!name || vduse_name_is_valid(name) ||
52
* move from WAITING to PENDING.
43
+ if (!name || vduse_name_is_invalid(name) ||
53
*/
44
!has_feature(features, VIRTIO_F_VERSION_1) || !config ||
54
-void job_completed(Job *job, int ret);
45
!config_size || !ops || !ops->enable_queue || !ops->disable_queue) {
55
+void job_completed(Job *job, int ret, Error *error);
46
fprintf(stderr, "Invalid parameter for vduse\n");
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
}
104
105
g_free(s->backing_file_str);
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
--
47
--
239
2.13.6
48
2.35.3
240
241
diff view generated by jsdifflib
1
.bdrv_co_create() is supposed to return 0 on success, but vhdx could
1
From: Xie Yongji <xieyongji@bytedance.com>
2
return a positive value instead. Fix this.
3
2
3
Coverity reported a string overflow issue since we copied
4
"name" to "dev_config->name" without checking the length.
5
This should be a false positive since we already checked
6
the length of "name" in vduse_name_is_invalid(). But anyway,
7
let's replace strcpy() with strncpy() (as a general library,
8
we'd like to minimize dependencies on other libraries, so we
9
didn't use g_strlcpy() here) to fix the coverity complaint.
10
11
Fixes: Coverity CID 1490224
12
Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
13
Reviewed-by: Markus Armbruster <armbru@redhat.com>
14
Message-Id: <20220706095624.328-3-xieyongji@bytedance.com>
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
15
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
---
16
---
8
block/vhdx.c | 2 +-
17
subprojects/libvduse/libvduse.c | 3 ++-
9
1 file changed, 1 insertion(+), 1 deletion(-)
18
1 file changed, 2 insertions(+), 1 deletion(-)
10
19
11
diff --git a/block/vhdx.c b/block/vhdx.c
20
diff --git a/subprojects/libvduse/libvduse.c b/subprojects/libvduse/libvduse.c
12
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
13
--- a/block/vhdx.c
22
--- a/subprojects/libvduse/libvduse.c
14
+++ b/block/vhdx.c
23
+++ b/subprojects/libvduse/libvduse.c
15
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn vhdx_co_create(BlockdevCreateOptions *opts,
24
@@ -XXX,XX +XXX,XX @@ VduseDev *vduse_dev_create(const char *name, uint32_t device_id,
16
goto delete_and_exit;
25
goto err_dev;
17
}
26
}
18
27
19
-
28
- strcpy(dev_config->name, name);
20
+ ret = 0;
29
+ strncpy(dev_config->name, name, VDUSE_NAME_MAX);
21
delete_and_exit:
30
+ dev_config->name[VDUSE_NAME_MAX - 1] = '\0';
22
blk_unref(blk);
31
dev_config->device_id = device_id;
23
bdrv_unref(bs);
32
dev_config->vendor_id = vendor_id;
33
dev_config->features = features;
24
--
34
--
25
2.13.6
35
2.35.3
26
27
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Xie Yongji <xieyongji@bytedance.com>
2
2
3
MIN_REFCOUNT_CACHE_SIZE is 4 and the cluster size is guaranteed to be
3
The value passed to strerror() should be positive.
4
at most 2MB, so the minimum refcount cache size (in bytes) is always
4
So let's fix it.
5
going to fit in a 32-bit integer.
6
5
7
Coverity doesn't know that, and since we're storing the result in a
6
Fixes: Coverity CID 1490226, 1490223
8
uint64_t (*refcount_cache_size) it thinks that we need the 64 bits and
7
Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
9
that we probably want to do a 64-bit multiplication to prevent the
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
result from being truncated.
9
Reviewed-by: Markus Armbruster <armbru@redhat.com>
11
10
Message-Id: <20220706095624.328-4-xieyongji@bytedance.com>
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>
19
Reviewed-by: Eric Blake <eblake@redhat.com>
20
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
21
---
12
---
22
block/qcow2.c | 5 ++---
13
subprojects/libvduse/libvduse.c | 4 ++--
23
1 file changed, 2 insertions(+), 3 deletions(-)
14
1 file changed, 2 insertions(+), 2 deletions(-)
24
15
25
diff --git a/block/qcow2.c b/block/qcow2.c
16
diff --git a/subprojects/libvduse/libvduse.c b/subprojects/libvduse/libvduse.c
26
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
27
--- a/block/qcow2.c
18
--- a/subprojects/libvduse/libvduse.c
28
+++ b/block/qcow2.c
19
+++ b/subprojects/libvduse/libvduse.c
29
@@ -XXX,XX +XXX,XX @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts,
20
@@ -XXX,XX +XXX,XX @@ VduseDev *vduse_dev_create_by_name(const char *name, uint16_t num_queues,
30
BDRVQcow2State *s = bs->opaque;
21
ret = vduse_dev_init(dev, name, num_queues, ops, priv);
31
uint64_t combined_cache_size;
22
if (ret < 0) {
32
bool l2_cache_size_set, refcount_cache_size_set, combined_cache_size_set;
23
fprintf(stderr, "Failed to init vduse device %s: %s\n",
33
+ int min_refcount_cache = MIN_REFCOUNT_CACHE_SIZE * s->cluster_size;
24
- name, strerror(ret));
34
25
+ name, strerror(-ret));
35
combined_cache_size_set = qemu_opt_get(opts, QCOW2_OPT_CACHE_SIZE);
26
free(dev);
36
l2_cache_size_set = qemu_opt_get(opts, QCOW2_OPT_L2_CACHE_SIZE);
27
return NULL;
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
}
28
}
29
@@ -XXX,XX +XXX,XX @@ VduseDev *vduse_dev_create(const char *name, uint32_t device_id,
30
ret = vduse_dev_init(dev, name, num_queues, ops, priv);
31
if (ret < 0) {
32
fprintf(stderr, "Failed to init vduse device %s: %s\n",
33
- name, strerror(ret));
34
+ name, strerror(-ret));
35
goto err;
36
}
54
37
55
--
38
--
56
2.13.6
39
2.35.3
57
58
diff view generated by jsdifflib
Deleted patch
1
This changes the x-blockdev-create QMP command so that it doesn't block
2
the monitor and the main loop any more, but starts a background job that
3
performs the image creation.
4
1
5
The basic job as implemented here is all that is necessary to make image
6
creation asynchronous and to provide a QMP interface that can be marked
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
13
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
---
17
qapi/block-core.json | 14 ++++++----
18
qapi/job.json | 4 ++-
19
block/create.c | 67 +++++++++++++++++++++++++++++++++---------------
20
tests/qemu-iotests/group | 14 +++++-----
21
4 files changed, 66 insertions(+), 33 deletions(-)
22
23
diff --git a/qapi/block-core.json b/qapi/block-core.json
24
index XXXXXXX..XXXXXXX 100644
25
--- a/qapi/block-core.json
26
+++ b/qapi/block-core.json
27
@@ -XXX,XX +XXX,XX @@
28
##
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;
89
- Error **errp;
90
-} BlockdevCreateCo;
91
+ Error *err;
92
+} BlockdevCreateJob;
93
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
+
101
+ job_completed(job, s->ret, s->err);
102
}
103
104
-void qmp_x_blockdev_create(BlockdevCreateOptions *options, Error **errp)
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;
136
}
137
138
- /* Call callback if it exists */
139
+ /* Error out if the driver doesn't support .bdrv_co_create */
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
+
166
+ s->drv = drv,
167
+ s->opts = QAPI_CLONE(BlockdevCreateOptions, options),
168
+
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
--
199
2.13.6
200
201
diff view generated by jsdifflib
Deleted patch
1
This adds a helper function that returns a list of QMP events that are
2
already filtered through filter_qmp_event().
3
1
4
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
---
8
tests/qemu-iotests/iotests.py | 5 +++++
9
1 file changed, 5 insertions(+)
10
11
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
12
index XXXXXXX..XXXXXXX 100644
13
--- a/tests/qemu-iotests/iotests.py
14
+++ b/tests/qemu-iotests/iotests.py
15
@@ -XXX,XX +XXX,XX @@ class VM(qtest.QEMUQtestMachine):
16
output_list += [key + '=' + obj[key]]
17
return ','.join(output_list)
18
19
+ def get_qmp_events_filtered(self, wait=True):
20
+ result = []
21
+ for ev in self.get_qmp_events(wait=wait):
22
+ result.append(filter_qmp_event(ev))
23
+ return result
24
25
26
index_re = re.compile(r'([^\[]+)\[([^\]]+)\]')
27
--
28
2.13.6
29
30
diff view generated by jsdifflib
Deleted patch
1
This adds a helper function that logs both the QMP request and the
2
received response before returning it.
3
1
4
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
---
8
tests/qemu-iotests/iotests.py | 11 +++++++++++
9
1 file changed, 11 insertions(+)
10
11
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
12
index XXXXXXX..XXXXXXX 100644
13
--- a/tests/qemu-iotests/iotests.py
14
+++ b/tests/qemu-iotests/iotests.py
15
@@ -XXX,XX +XXX,XX @@ def filter_qmp_event(event):
16
event['timestamp']['microseconds'] = 'USECS'
17
return event
18
19
+def filter_testfiles(msg):
20
+ prefix = os.path.join(test_dir, "%s-" % (os.getpid()))
21
+ return msg.replace(prefix, 'TEST_DIR/PID-')
22
+
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
40
--
41
2.13.6
42
43
diff view generated by jsdifflib
Deleted patch
1
This adds a filter function to postprocess 'qemu-img info' input
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
1
5
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
---
9
tests/qemu-iotests/iotests.py | 18 ++++++++++++++++++
10
1 file changed, 18 insertions(+)
11
12
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
13
index XXXXXXX..XXXXXXX 100644
14
--- a/tests/qemu-iotests/iotests.py
15
+++ b/tests/qemu-iotests/iotests.py
16
@@ -XXX,XX +XXX,XX @@ def qemu_img_pipe(*args):
17
sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' '.join(qemu_img_args + list(args))))
18
return subp.communicate()[0]
19
20
+def img_info_log(filename, filter_path=None):
21
+ output = qemu_img_pipe('info', '-f', imgfmt, filename)
22
+ if not filter_path:
23
+ filter_path = filename
24
+ log(filter_img_info(output, filter_path))
25
+
26
def qemu_io(*args):
27
'''Run qemu-io and return the stdout data'''
28
args = qemu_io_args + list(args)
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
--
49
2.13.6
50
51
diff view generated by jsdifflib
Deleted patch
1
Add an iotests.py function that runs a job and only returns when it is
2
destroyed. An error is logged when the job failed and job-finalize and
3
job-dismiss commands are issued if necessary.
4
1
5
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
---
9
tests/qemu-iotests/iotests.py | 19 +++++++++++++++++++
10
1 file changed, 19 insertions(+)
11
12
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
13
index XXXXXXX..XXXXXXX 100644
14
--- a/tests/qemu-iotests/iotests.py
15
+++ b/tests/qemu-iotests/iotests.py
16
@@ -XXX,XX +XXX,XX @@ class VM(qtest.QEMUQtestMachine):
17
log(str(result), filters)
18
return result
19
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
+
39
40
index_re = re.compile(r'([^\[]+)\[([^\]]+)\]')
41
42
--
43
2.13.6
44
45
diff view generated by jsdifflib
Deleted patch
1
This adds two helper functions that are useful for test cases that make
2
use of a non-file protocol (specifically ssh).
3
1
4
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
---
8
tests/qemu-iotests/iotests.py | 17 +++++++++++++++++
9
1 file changed, 17 insertions(+)
10
11
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
12
index XXXXXXX..XXXXXXX 100644
13
--- a/tests/qemu-iotests/iotests.py
14
+++ b/tests/qemu-iotests/iotests.py
15
@@ -XXX,XX +XXX,XX @@ def file_path(*names):
16
17
return paths[0] if len(paths) == 1 else paths
18
19
+def remote_filename(path):
20
+ if imgproto == 'file':
21
+ return path
22
+ elif imgproto == 'ssh':
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
--
47
2.13.6
48
49
diff view generated by jsdifflib
Deleted patch
1
This rewrites the test case 206 to work with the new x-blockdev-create
2
job rather than the old synchronous version of the command.
3
1
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
7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
Reviewed-by: Max Reitz <mreitz@redhat.com>
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 @@
20
-#!/bin/bash
21
+#!/usr/bin/env python
22
#
23
# Test qcow2 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 qcow2
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
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
1047
index XXXXXXX..XXXXXXX 100644
1048
--- a/tests/qemu-iotests/group
1049
+++ b/tests/qemu-iotests/group
1050
@@ -XXX,XX +XXX,XX @@
1051
203 rw auto migration
1052
204 rw auto quick
1053
205 rw auto quick
1054
+206 rw auto
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
--
1062
2.13.6
1063
1064
diff view generated by jsdifflib
Deleted patch
1
This rewrites the test case 207 to work with the new x-blockdev-create
2
job rather than the old synchronous version of the command.
3
1
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
9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10
Reviewed-by: Max Reitz <mreitz@redhat.com>
11
---
12
tests/qemu-iotests/207 | 440 ++++++++++++++++++++-------------------------
13
tests/qemu-iotests/207.out | 107 +++++------
14
tests/qemu-iotests/group | 6 +-
15
3 files changed, 257 insertions(+), 296 deletions(-)
16
17
diff --git a/tests/qemu-iotests/207 b/tests/qemu-iotests/207
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
476
--- a/tests/qemu-iotests/207.out
477
+++ b/tests/qemu-iotests/207.out
478
@@ -XXX,XX +XXX,XX @@
479
-QA output created by 207
480
-
481
=== Successful image creation (defaults) ===
482
483
-Testing:
484
-QMP_VERSION
485
-{"return": {}}
486
-{"return": {}}
487
-{"return": {}}
488
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
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}}}
490
+{u'return': {}}
491
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
492
+{u'return': {}}
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
--
630
2.13.6
631
632
diff view generated by jsdifflib
Deleted patch
1
This rewrites the test case 210 to work with the new x-blockdev-create
2
job rather than the old synchronous version of the command.
3
1
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
7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
Reviewed-by: Max Reitz <mreitz@redhat.com>
9
Reviewed-by: Jeff Cody <jcody@redhat.com>
10
---
11
tests/qemu-iotests/210 | 393 ++++++++++++++++++------------------------
12
tests/qemu-iotests/210.out | 197 ++++++++++++++-------
13
tests/qemu-iotests/group | 2 +-
14
tests/qemu-iotests/iotests.py | 12 +-
15
4 files changed, 314 insertions(+), 290 deletions(-)
16
17
diff --git a/tests/qemu-iotests/210 b/tests/qemu-iotests/210
18
index XXXXXXX..XXXXXXX 100755
19
--- a/tests/qemu-iotests/210
20
+++ b/tests/qemu-iotests/210
21
@@ -XXX,XX +XXX,XX @@
22
-#!/bin/bash
23
+#!/usr/bin/env python
24
#
25
# Test luks and file 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 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
+
268
+iotests.verify_image_format(supported_fmts=['luks'])
269
+iotests.verify_protocol(supported=['file'])
270
+
271
+def blockdev_create(vm, options):
272
+ result = vm.qmp_log('x-blockdev-create', job_id='job0', options=options)
273
+
274
+ if 'return' in result:
275
+ assert result['return'] == {}
276
+ vm.run_job('job0')
277
+ iotests.log("")
278
+
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
--
727
2.13.6
728
729
diff view generated by jsdifflib
Deleted patch
1
This rewrites the test case 211 to work with the new x-blockdev-create
2
job rather than the old synchronous version of the command.
3
1
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
7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
Reviewed-by: Max Reitz <mreitz@redhat.com>
9
---
10
tests/qemu-iotests/211 | 381 ++++++++++++++++++---------------------------
11
tests/qemu-iotests/211.out | 133 +++++++++-------
12
tests/qemu-iotests/group | 2 +-
13
3 files changed, 229 insertions(+), 287 deletions(-)
14
15
diff --git a/tests/qemu-iotests/211 b/tests/qemu-iotests/211
16
index XXXXXXX..XXXXXXX 100755
17
--- a/tests/qemu-iotests/211
18
+++ b/tests/qemu-iotests/211
19
@@ -XXX,XX +XXX,XX @@
20
-#!/bin/bash
21
+#!/usr/bin/env python
22
#
23
# Test VDI 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 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
+
265
+iotests.verify_image_format(supported_fmts=['vdi'])
266
+iotests.verify_protocol(supported=['file'])
267
+
268
+def blockdev_create(vm, options):
269
+ result = vm.qmp_log('x-blockdev-create', job_id='job0', options=options)
270
+
271
+ if 'return' in result:
272
+ assert result['return'] == {}
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
--
605
2.13.6
606
607
diff view generated by jsdifflib
1
We're ready to declare the blockdev-create job stable. This renames the
1
From: Lev Kujawski <lkujaw@member.fsf.org>
2
corresponding QMP command from x-blockdev-create to blockdev-create.
3
2
3
For small disk images (<4 GiB), QEMU and SeaBIOS default to the
4
LARGE/ECHS disk translation method, but it is not uncommon for other
5
BIOS software to use LBA in these cases as well. Some operating
6
system boot loaders (e.g., NT 4) do not handle LARGE translations
7
outside of fixed configurations. See, e.g., Q154052:
8
9
"When starting an x86 based computer, Ntdetect.com retrieves and
10
stores Interrupt 13 information. . . If the disk controller is using a
11
32 sector/64 head translation scheme, this boundary will be 1 GB. If
12
the controller uses 63 sector/255 head translation [AUTHOR: i.e.,
13
LBA], the limit will be 4 GB."
14
15
To accommodate these situations, hd_geometry_guess() now follows the
16
disk translation specified by the user even when the ATA disk geometry
17
is guessed.
18
19
hd_geometry_guess():
20
* Only set the disk translation when translation is AUTO.
21
* Show the soon-to-be active translation (*ptrans) in the trace rather
22
than what was guessed.
23
24
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/56
25
Buglink: https://bugs.launchpad.net/qemu/+bug/1745312
26
27
Signed-off-by: Lev Kujawski <lkujaw@member.fsf.org>
28
Message-Id: <20220707204045.999544-1-lkujaw@member.fsf.org>
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
29
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
---
30
---
8
qapi/block-core.json | 4 ++--
31
hw/block/hd-geometry.c | 7 ++++++-
9
qapi/job.json | 2 +-
32
1 file changed, 6 insertions(+), 1 deletion(-)
10
block/create.c | 4 ++--
11
tests/qemu-iotests/206 | 2 +-
12
tests/qemu-iotests/206.out | 54 +++++++++++++++++++++++-----------------------
13
tests/qemu-iotests/207 | 2 +-
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
33
25
diff --git a/qapi/block-core.json b/qapi/block-core.json
34
diff --git a/hw/block/hd-geometry.c b/hw/block/hd-geometry.c
26
index XXXXXXX..XXXXXXX 100644
35
index XXXXXXX..XXXXXXX 100644
27
--- a/qapi/block-core.json
36
--- a/hw/block/hd-geometry.c
28
+++ b/qapi/block-core.json
37
+++ b/hw/block/hd-geometry.c
29
@@ -XXX,XX +XXX,XX @@
38
@@ -XXX,XX +XXX,XX @@ void hd_geometry_guess(BlockBackend *blk,
30
} }
39
translation = BIOS_ATA_TRANSLATION_NONE;
31
40
}
32
##
41
if (ptrans) {
33
-# @x-blockdev-create:
42
- *ptrans = translation;
34
+# @blockdev-create:
43
+ if (*ptrans == BIOS_ATA_TRANSLATION_AUTO) {
35
#
44
+ *ptrans = translation;
36
# Starts a job to create an image format on a given node. The job is
45
+ } else {
37
# automatically finalized, but a manual job-dismiss is required.
46
+ /* Defer to the translation specified by the user. */
38
@@ -XXX,XX +XXX,XX @@
47
+ translation = *ptrans;
39
#
48
+ }
40
# Since: 3.0
49
}
41
##
50
trace_hd_geometry_guess(blk, *pcyls, *pheads, *psecs, translation);
42
-{ 'command': 'x-blockdev-create',
51
}
43
+{ 'command': 'blockdev-create',
44
'data': { 'job-id': 'str',
45
'options': 'BlockdevCreateOptions' } }
46
47
diff --git a/qapi/job.json b/qapi/job.json
48
index XXXXXXX..XXXXXXX 100644
49
--- a/qapi/job.json
50
+++ b/qapi/job.json
51
@@ -XXX,XX +XXX,XX @@
52
#
53
# @backup: drive backup job type, see "drive-backup"
54
#
55
-# @create: image creation job type, see "x-blockdev-create" (since 3.0)
56
+# @create: image creation job type, see "blockdev-create" (since 3.0)
57
#
58
# Since: 1.7
59
##
60
diff --git a/block/create.c b/block/create.c
61
index XXXXXXX..XXXXXXX 100644
62
--- a/block/create.c
63
+++ b/block/create.c
64
@@ -XXX,XX +XXX,XX @@ static const JobDriver blockdev_create_job_driver = {
65
.start = blockdev_create_run,
66
};
67
68
-void qmp_x_blockdev_create(const char *job_id, BlockdevCreateOptions *options,
69
- Error **errp)
70
+void qmp_blockdev_create(const char *job_id, BlockdevCreateOptions *options,
71
+ Error **errp)
72
{
73
BlockdevCreateJob *s;
74
const char *fmt = BlockdevDriver_str(options->driver);
75
diff --git a/tests/qemu-iotests/206 b/tests/qemu-iotests/206
76
index XXXXXXX..XXXXXXX 100755
77
--- a/tests/qemu-iotests/206
78
+++ b/tests/qemu-iotests/206
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
90
--- a/tests/qemu-iotests/206.out
91
+++ b/tests/qemu-iotests/206.out
92
@@ -XXX,XX +XXX,XX @@
93
=== Successful image creation (defaults) ===
94
95
-{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}}}
96
+{'execute': 'blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.qcow2'}}}
97
{u'return': {}}
98
{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
99
{u'return': {}}
100
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
--
52
--
951
2.13.6
53
2.35.3
952
953
diff view generated by jsdifflib
1
This rewrites the test case 213 to work with the new x-blockdev-create
1
From: Cole Robinson <crobinso@redhat.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
qemu-iotests fails in the following setup:
5
to implement proper job handling, the test case is rewritten in Python.
6
4
5
./configure --enable-modules --enable-smartcard \
6
--target-list=x86_64-softmmu,s390x-softmmu
7
make
8
cd build
9
QEMU_PROG=`pwd`/s390x-softmmu/qemu-system-s390x \
10
../tests/check-block.sh qcow2
11
...
12
--- /home/crobinso/src/qemu/tests/qemu-iotests/127.out
13
+++ /home/crobinso/src/qemu/build/tests/qemu-iotests/scratch/127.out.bad
14
@@ -1,4 +1,18 @@
15
QA output created by 127
16
+Failed to open module: /home/crobinso/src/qemu/build/hw-usb-smartcard.so: undefined symbol: ccid_card_ccid_attach
17
...
18
--- /home/crobinso/src/qemu/tests/qemu-iotests/267.out
19
+++ /home/crobinso/src/qemu/build/tests/qemu-iotests/scratch/267.out.bad
20
@@ -1,4 +1,11 @@
21
QA output created by 267
22
+Failed to open module: /home/crobinso/src/qemu/build/hw-usb-smartcard.so: undefined symbol: ccid_card_ccid_attach
23
24
The stderr spew is its own known issue, but seems like iotests should
25
be discarding stderr in this case.
26
27
Signed-off-by: Cole Robinson <crobinso@redhat.com>
28
Reviewed-by: Thomas Huth <thuth@redhat.com>
7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
29
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
Reviewed-by: Max Reitz <mreitz@redhat.com>
9
---
30
---
10
tests/qemu-iotests/213 | 520 +++++++++++++++++----------------------------
31
tests/qemu-iotests/common.rc | 4 ++--
11
tests/qemu-iotests/213.out | 208 +++++++++++-------
32
1 file changed, 2 insertions(+), 2 deletions(-)
12
tests/qemu-iotests/group | 4 +-
13
3 files changed, 319 insertions(+), 413 deletions(-)
14
33
15
diff --git a/tests/qemu-iotests/213 b/tests/qemu-iotests/213
34
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
16
index XXXXXXX..XXXXXXX 100755
35
index XXXXXXX..XXXXXXX 100644
17
--- a/tests/qemu-iotests/213
36
--- a/tests/qemu-iotests/common.rc
18
+++ b/tests/qemu-iotests/213
37
+++ b/tests/qemu-iotests/common.rc
19
@@ -XXX,XX +XXX,XX @@
38
@@ -XXX,XX +XXX,XX @@ _require_large_file()
20
-#!/bin/bash
21
+#!/usr/bin/env python
22
#
39
#
23
# Test vhdx and file image creation
40
_require_devices()
24
#
41
{
25
# Copyright (C) 2018 Red Hat, Inc.
42
- available=$($QEMU -M none -device help | \
26
#
43
+ available=$($QEMU -M none -device help 2> /dev/null | \
27
+# Creator/Owner: Kevin Wolf <kwolf@redhat.com>
44
grep ^name | sed -e 's/^name "//' -e 's/".*$//')
28
+#
45
for device
29
# This program is free software; you can redistribute it and/or modify
46
do
30
# it under the terms of the GNU General Public License as published by
47
@@ -XXX,XX +XXX,XX @@ _require_devices()
31
# the Free Software Foundation; either version 2 of the License, or
48
32
@@ -XXX,XX +XXX,XX @@
49
_require_one_device_of()
33
# along with this program. If not, see <http://www.gnu.org/licenses/>.
50
{
34
#
51
- available=$($QEMU -M none -device help | \
35
52
+ available=$($QEMU -M none -device help 2> /dev/null | \
36
-# creator
53
grep ^name | sed -e 's/^name "//' -e 's/".*$//')
37
-owner=kwolf@redhat.com
54
for device
38
-
55
do
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 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
-}
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
- "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
--
56
--
822
2.13.6
57
2.35.3
823
824
diff view generated by jsdifflib
1
This rewrites the test case 212 to work with the new x-blockdev-create
1
From: Emanuele Giuseppe Esposito <eesposit@redhat.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
If we go directly to GLOBAL_STATE_CODE, IO_CODE or IO_OR_GS_CODE
5
to implement proper job handling, the test case is rewritten in Python.
4
definition, we just find that they "mark and check that the function
5
is part of the {category} API".
6
However, ther is no definition on what {category} API is, they are
7
in include/block/block-*.h
8
Therefore, add a comment that refers to such documentation.
6
9
10
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
11
Message-Id: <20220609122206.1016936-1-eesposit@redhat.com>
12
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
Reviewed-by: Max Reitz <mreitz@redhat.com>
9
---
14
---
10
tests/qemu-iotests/212 | 483 +++++++++++++++++----------------------------
15
include/qemu/main-loop.h | 18 +++++++++++++++---
11
tests/qemu-iotests/212.out | 191 +++++++++++-------
16
1 file changed, 15 insertions(+), 3 deletions(-)
12
tests/qemu-iotests/group | 2 +-
13
3 files changed, 295 insertions(+), 381 deletions(-)
14
17
15
diff --git a/tests/qemu-iotests/212 b/tests/qemu-iotests/212
18
diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h
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
19
index XXXXXXX..XXXXXXX 100644
517
--- a/tests/qemu-iotests/212.out
20
--- a/include/qemu/main-loop.h
518
+++ b/tests/qemu-iotests/212.out
21
+++ b/include/qemu/main-loop.h
519
@@ -XXX,XX +XXX,XX @@
22
@@ -XXX,XX +XXX,XX @@ bool qemu_mutex_iothread_locked(void);
520
-QA output created by 212
23
*/
521
-
24
bool qemu_in_main_thread(void);
522
=== Successful image creation (defaults) ===
25
523
26
-/* Mark and check that the function is part of the global state API. */
524
-Testing:
27
+/*
525
-QMP_VERSION
28
+ * Mark and check that the function is part of the Global State API.
526
-{"return": {}}
29
+ * Please refer to include/block/block-global-state.h for more
527
-{"return": {}}
30
+ * information about GS API.
528
-{"return": {}}
31
+ */
529
-{"return": {}}
32
#ifdef CONFIG_COCOA
530
-{"return": {}}
33
/*
531
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
34
* When using the Cocoa UI, addRemovableDevicesMenuItems() is called from
532
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'size': 0, 'driver': 'file', 'filename': 'TEST_DIR/PID-t.parallels'}}}
35
@@ -XXX,XX +XXX,XX @@ bool qemu_in_main_thread(void);
533
+{u'return': {}}
36
} while (0)
534
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
37
#endif /* CONFIG_COCOA */
535
+{u'return': {}}
38
536
+
39
-/* Mark and check that the function is part of the I/O API. */
537
+{'execute': 'blockdev-add', 'arguments': {'node_name': 'imgfile', 'driver': 'file', 'filename': 'TEST_DIR/PID-t.parallels'}}
40
+/*
538
+{u'return': {}}
41
+ * Mark and check that the function is part of the I/O API.
539
+{'execute': 'x-blockdev-create', 'arguments': {'job_id': 'job0', 'options': {'driver': 'parallels', 'file': 'imgfile', 'size': 134217728}}}
42
+ * Please refer to include/block/block-io.h for more
540
+{u'return': {}}
43
+ * information about IO API.
541
+{'execute': 'job-dismiss', 'arguments': {'id': 'job0'}}
44
+ */
542
+{u'return': {}}
45
#define IO_CODE() \
543
46
do { \
544
-image: TEST_DIR/t.IMGFMT
47
/* nop */ \
545
+image: TEST_IMG
48
} while (0)
546
file format: IMGFMT
49
547
virtual size: 128M (134217728 bytes)
50
-/* Mark and check that the function is part of the "I/O OR GS" API. */
548
51
+/*
549
=== Successful image creation (explicit defaults) ===
52
+ * Mark and check that the function is part of the "I/O OR GS" API.
550
53
+ * Please refer to include/block/block-io.h for more
551
-Testing:
54
+ * information about "IO or GS" API.
552
-QMP_VERSION
55
+ */
553
-{"return": {}}
56
#define IO_OR_GS_CODE() \
554
-{"return": {}}
57
do { \
555
-{"return": {}}
58
/* nop */ \
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
--
59
--
765
2.13.6
60
2.35.3
766
767
diff view generated by jsdifflib