[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 30/41] vdi: Implement .bdrv_co_create
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 30/41] vdi: Implement .bdrv_co_create |
Date: |
Tue, 13 Mar 2018 17:17:52 +0100 |
From: Max Reitz <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
qapi/block-core.json | 2 +-
block/vdi.c | 24 +++++++++++++++++++-----
2 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/qapi/block-core.json b/qapi/block-core.json
index c69d70d7a8..6211b8222c 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -3837,7 +3837,7 @@
'sheepdog': 'BlockdevCreateOptionsSheepdog',
'ssh': 'BlockdevCreateOptionsSsh',
'throttle': 'BlockdevCreateNotSupported',
- 'vdi': 'BlockdevCreateNotSupported',
+ 'vdi': 'BlockdevCreateOptionsVdi',
'vhdx': 'BlockdevCreateNotSupported',
'vmdk': 'BlockdevCreateNotSupported',
'vpc': 'BlockdevCreateNotSupported',
diff --git a/block/vdi.c b/block/vdi.c
index 2a39b0ac98..8132e3adfe 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -721,9 +721,10 @@ nonallocating_write:
return ret;
}
-static int coroutine_fn vdi_co_do_create(BlockdevCreateOptionsVdi *vdi_opts,
+static int coroutine_fn vdi_co_do_create(BlockdevCreateOptions *create_options,
size_t block_size, Error **errp)
{
+ BlockdevCreateOptionsVdi *vdi_opts;
int ret = 0;
uint64_t bytes = 0;
uint32_t blocks;
@@ -736,6 +737,9 @@ static int coroutine_fn
vdi_co_do_create(BlockdevCreateOptionsVdi *vdi_opts,
BlockBackend *blk = NULL;
uint32_t *bmap = NULL;
+ assert(create_options->driver == BLOCKDEV_DRIVER_VDI);
+ vdi_opts = &create_options->u.vdi;
+
logout("\n");
/* Read out options. */
@@ -856,11 +860,17 @@ exit:
return ret;
}
+static int coroutine_fn vdi_co_create(BlockdevCreateOptions *create_options,
+ Error **errp)
+{
+ return vdi_co_do_create(create_options, DEFAULT_CLUSTER_SIZE, errp);
+}
+
static int coroutine_fn vdi_co_create_opts(const char *filename, QemuOpts
*opts,
Error **errp)
{
QDict *qdict = NULL;
- BlockdevCreateOptionsVdi *create_options = NULL;
+ BlockdevCreateOptions *create_options = NULL;
BlockDriverState *bs_file = NULL;
uint64_t block_size = DEFAULT_CLUSTER_SIZE;
Visitor *v;
@@ -897,11 +907,12 @@ static int coroutine_fn vdi_co_create_opts(const char
*filename, QemuOpts *opts,
goto done;
}
+ qdict_put_str(qdict, "driver", "vdi");
qdict_put_str(qdict, "file", bs_file->node_name);
/* Get the QAPI object */
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
- visit_type_BlockdevCreateOptionsVdi(v, NULL, &create_options, &local_err);
+ visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
visit_free(v);
if (local_err) {
@@ -910,12 +921,14 @@ static int coroutine_fn vdi_co_create_opts(const char
*filename, QemuOpts *opts,
goto done;
}
- create_options->size = ROUND_UP(create_options->size, BDRV_SECTOR_SIZE);
+ assert(create_options->driver == BLOCKDEV_DRIVER_VDI);
+ create_options->u.vdi.size = ROUND_UP(create_options->u.vdi.size,
+ BDRV_SECTOR_SIZE);
ret = vdi_co_do_create(create_options, block_size, errp);
done:
QDECREF(qdict);
- qapi_free_BlockdevCreateOptionsVdi(create_options);
+ qapi_free_BlockdevCreateOptions(create_options);
bdrv_unref(bs_file);
return ret;
}
@@ -969,6 +982,7 @@ static BlockDriver bdrv_vdi = {
.bdrv_reopen_prepare = vdi_reopen_prepare,
.bdrv_child_perm = bdrv_format_default_perms,
.bdrv_co_create_opts = vdi_co_create_opts,
+ .bdrv_co_create = vdi_co_create,
.bdrv_has_zero_init = bdrv_has_zero_init_1,
.bdrv_co_block_status = vdi_co_block_status,
.bdrv_make_empty = vdi_make_empty,
--
2.13.6
- [Qemu-block] [PULL 22/41] luks: Separate image file creation from formatting, (continued)
- [Qemu-block] [PULL 22/41] luks: Separate image file creation from formatting, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 29/41] vdi: Move file creation to vdi_co_create_opts, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 27/41] qemu-iotests: Test luks QMP image creation, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 26/41] luks: Catch integer overflow for huge sizes, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 19/41] blockjobs: Expose manual property, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 21/41] tests/test-blockjob: test cancellations, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 25/41] luks: Turn invalid assertion into check, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 34/41] qemu-iotests: Enable write tests for parallels, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 28/41] vdi: Pull option parsing from vdi_co_create, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 38/41] vhdx: Support .bdrv_co_create, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 30/41] vdi: Implement .bdrv_co_create,
Kevin Wolf <=
- [Qemu-block] [PULL 31/41] block: Fix flags in reopen queue, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 32/41] iotests: Add regression test for commit base locking, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 33/41] parallels: Support .bdrv_co_create, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 37/41] vdi: Make comments consistent with other drivers, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 35/41] qcow: Support .bdrv_co_create, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 36/41] qed: Support .bdrv_co_create, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 40/41] vpc: Require aligned size in .bdrv_co_create, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 39/41] vpc: Support .bdrv_co_create, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 41/41] block/mirror: change the semantic of 'force' of block-job-cancel, Kevin Wolf, 2018/03/13
- Re: [Qemu-block] [Qemu-devel] [PULL 00/41] Block layer patches, no-reply, 2018/03/13