[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 24/41] luks: Support .bdrv_co_create
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 24/41] luks: Support .bdrv_co_create |
Date: |
Tue, 13 Mar 2018 17:17:46 +0100 |
This adds the .bdrv_co_create driver callback to luks, which enables
image creation over QMP.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Daniel P. Berrangé <address@hidden>
---
qapi/block-core.json | 17 ++++++++++++++++-
block/crypto.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+), 1 deletion(-)
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 3e52d248eb..ba2d10d13a 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -3596,6 +3596,21 @@
'*preallocation': 'PreallocMode' } }
##
+# @BlockdevCreateOptionsLUKS:
+#
+# Driver specific image creation options for LUKS.
+#
+# @file Node to create the image format on
+# @size Size of the virtual disk in bytes
+#
+# Since: 2.12
+##
+{ 'struct': 'BlockdevCreateOptionsLUKS',
+ 'base': 'QCryptoBlockCreateOptionsLUKS',
+ 'data': { 'file': 'BlockdevRef',
+ 'size': 'size' } }
+
+##
# @BlockdevCreateOptionsNfs:
#
# Driver specific image creation options for NFS.
@@ -3787,7 +3802,7 @@
'http': 'BlockdevCreateNotSupported',
'https': 'BlockdevCreateNotSupported',
'iscsi': 'BlockdevCreateNotSupported',
- 'luks': 'BlockdevCreateNotSupported',
+ 'luks': 'BlockdevCreateOptionsLUKS',
'nbd': 'BlockdevCreateNotSupported',
'nfs': 'BlockdevCreateOptionsNfs',
'null-aio': 'BlockdevCreateNotSupported',
diff --git a/block/crypto.c b/block/crypto.c
index b0a4cb3388..a1139b6f09 100644
--- a/block/crypto.c
+++ b/block/crypto.c
@@ -543,6 +543,39 @@ static int block_crypto_open_luks(BlockDriverState *bs,
bs, options, flags, errp);
}
+static int coroutine_fn
+block_crypto_co_create_luks(BlockdevCreateOptions *create_options, Error
**errp)
+{
+ BlockdevCreateOptionsLUKS *luks_opts;
+ BlockDriverState *bs = NULL;
+ QCryptoBlockCreateOptions create_opts;
+ int ret;
+
+ assert(create_options->driver == BLOCKDEV_DRIVER_LUKS);
+ luks_opts = &create_options->u.luks;
+
+ bs = bdrv_open_blockdev_ref(luks_opts->file, errp);
+ if (bs == NULL) {
+ return -EIO;
+ }
+
+ create_opts = (QCryptoBlockCreateOptions) {
+ .format = Q_CRYPTO_BLOCK_FORMAT_LUKS,
+ .u.luks = *qapi_BlockdevCreateOptionsLUKS_base(luks_opts),
+ };
+
+ ret = block_crypto_co_create_generic(bs, luks_opts->size, &create_opts,
+ errp);
+ if (ret < 0) {
+ goto fail;
+ }
+
+ ret = 0;
+fail:
+ bdrv_unref(bs);
+ return ret;
+}
+
static int coroutine_fn block_crypto_co_create_opts_luks(const char *filename,
QemuOpts *opts,
Error **errp)
@@ -647,6 +680,7 @@ BlockDriver bdrv_crypto_luks = {
.bdrv_open = block_crypto_open_luks,
.bdrv_close = block_crypto_close,
.bdrv_child_perm = bdrv_format_default_perms,
+ .bdrv_co_create = block_crypto_co_create_luks,
.bdrv_co_create_opts = block_crypto_co_create_opts_luks,
.bdrv_truncate = block_crypto_truncate,
.create_opts = &block_crypto_create_opts_luks,
--
2.13.6
- [Qemu-devel] [PULL 23/41] luks: Create block_crypto_co_create_generic(), (continued)
- [Qemu-devel] [PULL 23/41] luks: Create block_crypto_co_create_generic(), Kevin Wolf, 2018/03/13
- [Qemu-devel] [PULL 17/41] blockjobs: add PENDING status and event, Kevin Wolf, 2018/03/13
- [Qemu-devel] [PULL 25/41] luks: Turn invalid assertion into check, Kevin Wolf, 2018/03/13
- [Qemu-devel] [PULL 20/41] iotests: test manual job dismissal, Kevin Wolf, 2018/03/13
- [Qemu-devel] [PULL 05/41] blockjobs: add state transition table, Kevin Wolf, 2018/03/13
- [Qemu-devel] [PULL 09/41] blockjobs: add CONCLUDED state, Kevin Wolf, 2018/03/13
- [Qemu-devel] [PULL 14/41] blockjobs: add block_job_txn_apply function, Kevin Wolf, 2018/03/13
- [Qemu-devel] [PULL 32/41] iotests: Add regression test for commit base locking, Kevin Wolf, 2018/03/13
- [Qemu-devel] [PULL 21/41] tests/test-blockjob: test cancellations, Kevin Wolf, 2018/03/13
- [Qemu-devel] [PULL 19/41] blockjobs: Expose manual property, Kevin Wolf, 2018/03/13
- [Qemu-devel] [PULL 24/41] luks: Support .bdrv_co_create,
Kevin Wolf <=
- [Qemu-devel] [PULL 22/41] luks: Separate image file creation from formatting, Kevin Wolf, 2018/03/13
- [Qemu-devel] [PULL 30/41] vdi: Implement .bdrv_co_create, Kevin Wolf, 2018/03/13
- [Qemu-devel] [PULL 29/41] vdi: Move file creation to vdi_co_create_opts, Kevin Wolf, 2018/03/13
- [Qemu-devel] [PULL 27/41] qemu-iotests: Test luks QMP image creation, Kevin Wolf, 2018/03/13
- [Qemu-devel] [PULL 28/41] vdi: Pull option parsing from vdi_co_create, Kevin Wolf, 2018/03/13
- [Qemu-devel] [PULL 31/41] block: Fix flags in reopen queue, Kevin Wolf, 2018/03/13
- [Qemu-devel] [PULL 26/41] luks: Catch integer overflow for huge sizes, Kevin Wolf, 2018/03/13
- [Qemu-devel] [PULL 34/41] qemu-iotests: Enable write tests for parallels, Kevin Wolf, 2018/03/13
- [Qemu-devel] [PULL 37/41] vdi: Make comments consistent with other drivers, Kevin Wolf, 2018/03/13
- [Qemu-devel] [PULL 33/41] parallels: Support .bdrv_co_create, Kevin Wolf, 2018/03/13