From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, mreitz@redhat.com, berrange@redhat.com,
eblake@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v2 3/6] luks: Support .bdrv_co_create
Date: Mon, 12 Mar 2018 16:02:15 +0100 [thread overview]
Message-ID: <20180312150218.1314-4-kwolf@redhat.com> (raw)
In-Reply-To: <20180312150218.1314-1-kwolf@redhat.com>
This adds the .bdrv_co_create driver callback to luks, which enables
image creation over QMP.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
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 524d51567a..751adf89f4 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -3452,6 +3452,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.
@@ -3643,7 +3658,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
next prev parent reply other threads:[~2018-03-12 15:02 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-12 15:02 [Qemu-devel] [PATCH v2 0/6] luks: Implement .bdrv_co_create Kevin Wolf
2018-03-12 15:02 ` [Qemu-devel] [PATCH v2 1/6] luks: Separate image file creation from formatting Kevin Wolf
2018-03-12 15:02 ` [Qemu-devel] [PATCH v2 2/6] luks: Create block_crypto_co_create_generic() Kevin Wolf
2019-05-14 11:13 ` Daniel P. Berrangé
2019-05-14 17:53 ` Kevin Wolf
2018-03-12 15:02 ` Kevin Wolf [this message]
2018-03-12 16:03 ` [Qemu-devel] [PATCH v2 3/6] luks: Support .bdrv_co_create Daniel P. Berrangé
2018-03-12 15:02 ` [Qemu-devel] [PATCH v2 4/6] luks: Turn invalid assertion into check Kevin Wolf
2018-03-12 16:03 ` Daniel P. Berrangé
2018-03-12 15:02 ` [Qemu-devel] [PATCH v2 5/6] luks: Catch integer overflow for huge sizes Kevin Wolf
2018-03-12 15:02 ` [Qemu-devel] [PATCH v2 6/6] qemu-iotests: Test luks QMP image creation Kevin Wolf
2018-03-12 16:06 ` Daniel P. Berrangé
2018-03-12 16:34 ` [Qemu-devel] [PATCH v2 0/6] luks: Implement .bdrv_co_create Kevin Wolf
2018-03-12 17:59 ` no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180312150218.1314-4-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=berrange@redhat.com \
--cc=eblake@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.