2 * QEMU block full disk encryption
4 * Copyright (c) 2015-2016 Red Hat, Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
21 #include "qemu/osdep.h"
23 #include "block/block_int.h"
24 #include "block/qdict.h"
25 #include "sysemu/block-backend.h"
26 #include "crypto/block.h"
27 #include "qapi/opts-visitor.h"
28 #include "qapi/qapi-visit-crypto.h"
29 #include "qapi/qobject-input-visitor.h"
30 #include "qapi/error.h"
31 #include "qemu/module.h"
32 #include "qemu/option.h"
33 #include "qemu/cutils.h"
36 typedef struct BlockCrypto BlockCrypto
;
44 static int block_crypto_probe_generic(QCryptoBlockFormat format
,
49 if (qcrypto_block_has_format(format
, buf
, buf_size
)) {
57 static ssize_t
block_crypto_read_func(QCryptoBlock
*block
,
64 BlockDriverState
*bs
= opaque
;
67 ret
= bdrv_pread(bs
->file
, offset
, buf
, buflen
);
69 error_setg_errno(errp
, -ret
, "Could not read encryption header");
75 static ssize_t
block_crypto_write_func(QCryptoBlock
*block
,
82 BlockDriverState
*bs
= opaque
;
85 ret
= bdrv_pwrite(bs
->file
, offset
, buf
, buflen
);
87 error_setg_errno(errp
, -ret
, "Could not write encryption header");
94 struct BlockCryptoCreateData
{
97 PreallocMode prealloc
;
101 static ssize_t
block_crypto_create_write_func(QCryptoBlock
*block
,
108 struct BlockCryptoCreateData
*data
= opaque
;
111 ret
= blk_pwrite(data
->blk
, offset
, buf
, buflen
, 0);
113 error_setg_errno(errp
, -ret
, "Could not write encryption header");
119 static ssize_t
block_crypto_create_init_func(QCryptoBlock
*block
,
124 struct BlockCryptoCreateData
*data
= opaque
;
125 Error
*local_error
= NULL
;
128 if (data
->size
> INT64_MAX
|| headerlen
> INT64_MAX
- data
->size
) {
133 /* User provided size should reflect amount of space made
134 * available to the guest, so we must take account of that
135 * which will be used by the crypto header
137 ret
= blk_truncate(data
->blk
, data
->size
+ headerlen
, false,
138 data
->prealloc
, 0, &local_error
);
146 /* Replace the error message with a better one */
147 error_free(local_error
);
148 error_setg(errp
, "The requested file size is too large");
150 error_propagate(errp
, local_error
);
157 static QemuOptsList block_crypto_runtime_opts_luks
= {
159 .head
= QTAILQ_HEAD_INITIALIZER(block_crypto_runtime_opts_luks
.head
),
161 BLOCK_CRYPTO_OPT_DEF_LUKS_KEY_SECRET(""),
162 { /* end of list */ }
167 static QemuOptsList block_crypto_create_opts_luks
= {
169 .head
= QTAILQ_HEAD_INITIALIZER(block_crypto_create_opts_luks
.head
),
172 .name
= BLOCK_OPT_SIZE
,
173 .type
= QEMU_OPT_SIZE
,
174 .help
= "Virtual disk size"
176 BLOCK_CRYPTO_OPT_DEF_LUKS_KEY_SECRET(""),
177 BLOCK_CRYPTO_OPT_DEF_LUKS_CIPHER_ALG(""),
178 BLOCK_CRYPTO_OPT_DEF_LUKS_CIPHER_MODE(""),
179 BLOCK_CRYPTO_OPT_DEF_LUKS_IVGEN_ALG(""),
180 BLOCK_CRYPTO_OPT_DEF_LUKS_IVGEN_HASH_ALG(""),
181 BLOCK_CRYPTO_OPT_DEF_LUKS_HASH_ALG(""),
182 BLOCK_CRYPTO_OPT_DEF_LUKS_ITER_TIME(""),
183 { /* end of list */ }
188 static QemuOptsList block_crypto_amend_opts_luks
= {
190 .head
= QTAILQ_HEAD_INITIALIZER(block_crypto_create_opts_luks
.head
),
192 BLOCK_CRYPTO_OPT_DEF_LUKS_STATE(""),
193 BLOCK_CRYPTO_OPT_DEF_LUKS_KEYSLOT(""),
194 BLOCK_CRYPTO_OPT_DEF_LUKS_OLD_SECRET(""),
195 BLOCK_CRYPTO_OPT_DEF_LUKS_NEW_SECRET(""),
196 BLOCK_CRYPTO_OPT_DEF_LUKS_ITER_TIME(""),
197 { /* end of list */ }
201 QCryptoBlockOpenOptions
*
202 block_crypto_open_opts_init(QDict
*opts
, Error
**errp
)
205 QCryptoBlockOpenOptions
*ret
;
207 v
= qobject_input_visitor_new_flat_confused(opts
, errp
);
212 visit_type_QCryptoBlockOpenOptions(v
, NULL
, &ret
, errp
);
219 QCryptoBlockCreateOptions
*
220 block_crypto_create_opts_init(QDict
*opts
, Error
**errp
)
223 QCryptoBlockCreateOptions
*ret
;
225 v
= qobject_input_visitor_new_flat_confused(opts
, errp
);
230 visit_type_QCryptoBlockCreateOptions(v
, NULL
, &ret
, errp
);
236 QCryptoBlockAmendOptions
*
237 block_crypto_amend_opts_init(QDict
*opts
, Error
**errp
)
240 QCryptoBlockAmendOptions
*ret
;
242 v
= qobject_input_visitor_new_flat_confused(opts
, errp
);
247 visit_type_QCryptoBlockAmendOptions(v
, NULL
, &ret
, errp
);
254 static int block_crypto_open_generic(QCryptoBlockFormat format
,
255 QemuOptsList
*opts_spec
,
256 BlockDriverState
*bs
,
261 BlockCrypto
*crypto
= bs
->opaque
;
262 QemuOpts
*opts
= NULL
;
264 QCryptoBlockOpenOptions
*open_opts
= NULL
;
265 unsigned int cflags
= 0;
266 QDict
*cryptoopts
= NULL
;
268 bs
->file
= bdrv_open_child(NULL
, options
, "file", bs
, &child_of_bds
,
269 BDRV_CHILD_IMAGE
, false, errp
);
274 bs
->supported_write_flags
= BDRV_REQ_FUA
&
275 bs
->file
->bs
->supported_write_flags
;
277 opts
= qemu_opts_create(opts_spec
, NULL
, 0, &error_abort
);
278 if (!qemu_opts_absorb_qdict(opts
, options
, errp
)) {
282 cryptoopts
= qemu_opts_to_qdict(opts
, NULL
);
283 qdict_put_str(cryptoopts
, "format", QCryptoBlockFormat_str(format
));
285 open_opts
= block_crypto_open_opts_init(cryptoopts
, errp
);
290 if (flags
& BDRV_O_NO_IO
) {
291 cflags
|= QCRYPTO_BLOCK_OPEN_NO_IO
;
293 crypto
->block
= qcrypto_block_open(open_opts
, NULL
,
294 block_crypto_read_func
,
300 if (!crypto
->block
) {
305 bs
->encrypted
= true;
309 qobject_unref(cryptoopts
);
310 qapi_free_QCryptoBlockOpenOptions(open_opts
);
315 static int block_crypto_co_create_generic(BlockDriverState
*bs
,
317 QCryptoBlockCreateOptions
*opts
,
318 PreallocMode prealloc
,
323 QCryptoBlock
*crypto
= NULL
;
324 struct BlockCryptoCreateData data
;
326 blk
= blk_new_with_bs(bs
, BLK_PERM_WRITE
| BLK_PERM_RESIZE
, BLK_PERM_ALL
,
333 if (prealloc
== PREALLOC_MODE_METADATA
) {
334 prealloc
= PREALLOC_MODE_OFF
;
337 data
= (struct BlockCryptoCreateData
) {
340 .prealloc
= prealloc
,
343 crypto
= qcrypto_block_create(opts
, NULL
,
344 block_crypto_create_init_func
,
345 block_crypto_create_write_func
,
356 qcrypto_block_free(crypto
);
361 static int coroutine_fn
362 block_crypto_co_truncate(BlockDriverState
*bs
, int64_t offset
, bool exact
,
363 PreallocMode prealloc
, BdrvRequestFlags flags
,
366 BlockCrypto
*crypto
= bs
->opaque
;
367 uint64_t payload_offset
=
368 qcrypto_block_get_payload_offset(crypto
->block
);
370 if (payload_offset
> INT64_MAX
- offset
) {
371 error_setg(errp
, "The requested file size is too large");
375 offset
+= payload_offset
;
377 return bdrv_co_truncate(bs
->file
, offset
, exact
, prealloc
, 0, errp
);
380 static void block_crypto_close(BlockDriverState
*bs
)
382 BlockCrypto
*crypto
= bs
->opaque
;
383 qcrypto_block_free(crypto
->block
);
386 static int block_crypto_reopen_prepare(BDRVReopenState
*state
,
387 BlockReopenQueue
*queue
, Error
**errp
)
389 /* nothing needs checking */
394 * 1 MB bounce buffer gives good performance / memory tradeoff
395 * when using cache=none|directsync.
397 #define BLOCK_CRYPTO_MAX_IO_SIZE (1024 * 1024)
399 static coroutine_fn
int
400 block_crypto_co_preadv(BlockDriverState
*bs
, uint64_t offset
, uint64_t bytes
,
401 QEMUIOVector
*qiov
, int flags
)
403 BlockCrypto
*crypto
= bs
->opaque
;
404 uint64_t cur_bytes
; /* number of bytes in current iteration */
405 uint64_t bytes_done
= 0;
406 uint8_t *cipher_data
= NULL
;
407 QEMUIOVector hd_qiov
;
409 uint64_t sector_size
= qcrypto_block_get_sector_size(crypto
->block
);
410 uint64_t payload_offset
= qcrypto_block_get_payload_offset(crypto
->block
);
413 assert(payload_offset
< INT64_MAX
);
414 assert(QEMU_IS_ALIGNED(offset
, sector_size
));
415 assert(QEMU_IS_ALIGNED(bytes
, sector_size
));
417 qemu_iovec_init(&hd_qiov
, qiov
->niov
);
419 /* Bounce buffer because we don't wish to expose cipher text
420 * in qiov which points to guest memory.
423 qemu_try_blockalign(bs
->file
->bs
, MIN(BLOCK_CRYPTO_MAX_IO_SIZE
,
425 if (cipher_data
== NULL
) {
431 cur_bytes
= MIN(bytes
, BLOCK_CRYPTO_MAX_IO_SIZE
);
433 qemu_iovec_reset(&hd_qiov
);
434 qemu_iovec_add(&hd_qiov
, cipher_data
, cur_bytes
);
436 ret
= bdrv_co_preadv(bs
->file
, payload_offset
+ offset
+ bytes_done
,
437 cur_bytes
, &hd_qiov
, 0);
442 if (qcrypto_block_decrypt(crypto
->block
, offset
+ bytes_done
,
443 cipher_data
, cur_bytes
, NULL
) < 0) {
448 qemu_iovec_from_buf(qiov
, bytes_done
, cipher_data
, cur_bytes
);
451 bytes_done
+= cur_bytes
;
455 qemu_iovec_destroy(&hd_qiov
);
456 qemu_vfree(cipher_data
);
462 static coroutine_fn
int
463 block_crypto_co_pwritev(BlockDriverState
*bs
, uint64_t offset
, uint64_t bytes
,
464 QEMUIOVector
*qiov
, int flags
)
466 BlockCrypto
*crypto
= bs
->opaque
;
467 uint64_t cur_bytes
; /* number of bytes in current iteration */
468 uint64_t bytes_done
= 0;
469 uint8_t *cipher_data
= NULL
;
470 QEMUIOVector hd_qiov
;
472 uint64_t sector_size
= qcrypto_block_get_sector_size(crypto
->block
);
473 uint64_t payload_offset
= qcrypto_block_get_payload_offset(crypto
->block
);
475 assert(!(flags
& ~BDRV_REQ_FUA
));
476 assert(payload_offset
< INT64_MAX
);
477 assert(QEMU_IS_ALIGNED(offset
, sector_size
));
478 assert(QEMU_IS_ALIGNED(bytes
, sector_size
));
480 qemu_iovec_init(&hd_qiov
, qiov
->niov
);
482 /* Bounce buffer because we're not permitted to touch
483 * contents of qiov - it points to guest memory.
486 qemu_try_blockalign(bs
->file
->bs
, MIN(BLOCK_CRYPTO_MAX_IO_SIZE
,
488 if (cipher_data
== NULL
) {
494 cur_bytes
= MIN(bytes
, BLOCK_CRYPTO_MAX_IO_SIZE
);
496 qemu_iovec_to_buf(qiov
, bytes_done
, cipher_data
, cur_bytes
);
498 if (qcrypto_block_encrypt(crypto
->block
, offset
+ bytes_done
,
499 cipher_data
, cur_bytes
, NULL
) < 0) {
504 qemu_iovec_reset(&hd_qiov
);
505 qemu_iovec_add(&hd_qiov
, cipher_data
, cur_bytes
);
507 ret
= bdrv_co_pwritev(bs
->file
, payload_offset
+ offset
+ bytes_done
,
508 cur_bytes
, &hd_qiov
, flags
);
514 bytes_done
+= cur_bytes
;
518 qemu_iovec_destroy(&hd_qiov
);
519 qemu_vfree(cipher_data
);
524 static void block_crypto_refresh_limits(BlockDriverState
*bs
, Error
**errp
)
526 BlockCrypto
*crypto
= bs
->opaque
;
527 uint64_t sector_size
= qcrypto_block_get_sector_size(crypto
->block
);
528 bs
->bl
.request_alignment
= sector_size
; /* No sub-sector I/O */
532 static int64_t block_crypto_getlength(BlockDriverState
*bs
)
534 BlockCrypto
*crypto
= bs
->opaque
;
535 int64_t len
= bdrv_getlength(bs
->file
->bs
);
537 uint64_t offset
= qcrypto_block_get_payload_offset(crypto
->block
);
538 assert(offset
< INT64_MAX
);
550 static BlockMeasureInfo
*block_crypto_measure(QemuOpts
*opts
,
551 BlockDriverState
*in_bs
,
554 g_autoptr(QCryptoBlockCreateOptions
) create_opts
= NULL
;
555 Error
*local_err
= NULL
;
556 BlockMeasureInfo
*info
;
558 size_t luks_payload_size
;
562 * Preallocation mode doesn't affect size requirements but we must consume
565 g_free(qemu_opt_get_del(opts
, BLOCK_OPT_PREALLOC
));
567 size
= qemu_opt_get_size_del(opts
, BLOCK_OPT_SIZE
, 0);
570 int64_t ssize
= bdrv_getlength(in_bs
);
573 error_setg_errno(&local_err
, -ssize
,
574 "Unable to get image virtual_size");
581 cryptoopts
= qemu_opts_to_qdict_filtered(opts
, NULL
,
582 &block_crypto_create_opts_luks
, true);
583 qdict_put_str(cryptoopts
, "format", "luks");
584 create_opts
= block_crypto_create_opts_init(cryptoopts
, &local_err
);
585 qobject_unref(cryptoopts
);
590 if (!qcrypto_block_calculate_payload_offset(create_opts
, NULL
,
597 * Unallocated blocks are still encrypted so allocation status makes no
598 * difference to the file size.
600 info
= g_new0(BlockMeasureInfo
, 1);
601 info
->fully_allocated
= luks_payload_size
+ size
;
602 info
->required
= luks_payload_size
+ size
;
606 error_propagate(errp
, local_err
);
611 static int block_crypto_probe_luks(const uint8_t *buf
,
613 const char *filename
) {
614 return block_crypto_probe_generic(Q_CRYPTO_BLOCK_FORMAT_LUKS
,
615 buf
, buf_size
, filename
);
618 static int block_crypto_open_luks(BlockDriverState
*bs
,
623 return block_crypto_open_generic(Q_CRYPTO_BLOCK_FORMAT_LUKS
,
624 &block_crypto_runtime_opts_luks
,
625 bs
, options
, flags
, errp
);
628 static int coroutine_fn
629 block_crypto_co_create_luks(BlockdevCreateOptions
*create_options
, Error
**errp
)
631 BlockdevCreateOptionsLUKS
*luks_opts
;
632 BlockDriverState
*bs
= NULL
;
633 QCryptoBlockCreateOptions create_opts
;
634 PreallocMode preallocation
= PREALLOC_MODE_OFF
;
637 assert(create_options
->driver
== BLOCKDEV_DRIVER_LUKS
);
638 luks_opts
= &create_options
->u
.luks
;
640 bs
= bdrv_open_blockdev_ref(luks_opts
->file
, errp
);
645 create_opts
= (QCryptoBlockCreateOptions
) {
646 .format
= Q_CRYPTO_BLOCK_FORMAT_LUKS
,
647 .u
.luks
= *qapi_BlockdevCreateOptionsLUKS_base(luks_opts
),
650 if (luks_opts
->has_preallocation
) {
651 preallocation
= luks_opts
->preallocation
;
654 ret
= block_crypto_co_create_generic(bs
, luks_opts
->size
, &create_opts
,
655 preallocation
, errp
);
666 static int coroutine_fn
block_crypto_co_create_opts_luks(BlockDriver
*drv
,
667 const char *filename
,
671 QCryptoBlockCreateOptions
*create_opts
= NULL
;
672 BlockDriverState
*bs
= NULL
;
674 PreallocMode prealloc
;
678 Error
*local_err
= NULL
;
681 size
= qemu_opt_get_size_del(opts
, BLOCK_OPT_SIZE
, 0);
683 buf
= qemu_opt_get_del(opts
, BLOCK_OPT_PREALLOC
);
684 prealloc
= qapi_enum_parse(&PreallocMode_lookup
, buf
,
685 PREALLOC_MODE_OFF
, &local_err
);
688 error_propagate(errp
, local_err
);
692 cryptoopts
= qemu_opts_to_qdict_filtered(opts
, NULL
,
693 &block_crypto_create_opts_luks
,
696 qdict_put_str(cryptoopts
, "format", "luks");
697 create_opts
= block_crypto_create_opts_init(cryptoopts
, errp
);
703 /* Create protocol layer */
704 ret
= bdrv_create_file(filename
, opts
, errp
);
709 bs
= bdrv_open(filename
, NULL
, NULL
,
710 BDRV_O_RDWR
| BDRV_O_RESIZE
| BDRV_O_PROTOCOL
, errp
);
716 /* Create format layer */
717 ret
= block_crypto_co_create_generic(bs
, size
, create_opts
, prealloc
, errp
);
725 * If an error occurred, delete 'filename'. Even if the file existed
726 * beforehand, it has been truncated and corrupted in the process.
729 Error
*local_delete_err
= NULL
;
730 int r_del
= bdrv_co_delete_file(bs
, &local_delete_err
);
732 * ENOTSUP will happen if the block driver doesn't support
733 * the 'bdrv_co_delete_file' interface. This is a predictable
734 * scenario and shouldn't be reported back to the user.
736 if ((r_del
< 0) && (r_del
!= -ENOTSUP
)) {
737 error_report_err(local_delete_err
);
742 qapi_free_QCryptoBlockCreateOptions(create_opts
);
743 qobject_unref(cryptoopts
);
747 static int block_crypto_get_info_luks(BlockDriverState
*bs
,
748 BlockDriverInfo
*bdi
)
750 BlockDriverInfo subbdi
;
753 ret
= bdrv_get_info(bs
->file
->bs
, &subbdi
);
758 bdi
->cluster_size
= subbdi
.cluster_size
;
763 static ImageInfoSpecific
*
764 block_crypto_get_specific_info_luks(BlockDriverState
*bs
, Error
**errp
)
766 BlockCrypto
*crypto
= bs
->opaque
;
767 ImageInfoSpecific
*spec_info
;
768 QCryptoBlockInfo
*info
;
770 info
= qcrypto_block_get_info(crypto
->block
, errp
);
774 assert(info
->format
== Q_CRYPTO_BLOCK_FORMAT_LUKS
);
776 spec_info
= g_new(ImageInfoSpecific
, 1);
777 spec_info
->type
= IMAGE_INFO_SPECIFIC_KIND_LUKS
;
778 spec_info
->u
.luks
.data
= g_new(QCryptoBlockInfoLUKS
, 1);
779 *spec_info
->u
.luks
.data
= info
->u
.luks
;
781 /* Blank out pointers we've just stolen to avoid double free */
782 memset(&info
->u
.luks
, 0, sizeof(info
->u
.luks
));
784 qapi_free_QCryptoBlockInfo(info
);
790 block_crypto_amend_options_generic_luks(BlockDriverState
*bs
,
791 QCryptoBlockAmendOptions
*amend_options
,
795 BlockCrypto
*crypto
= bs
->opaque
;
799 assert(crypto
->block
);
801 /* apply for exclusive read/write permissions to the underlying file*/
802 crypto
->updating_keys
= true;
803 ret
= bdrv_child_refresh_perms(bs
, bs
->file
, errp
);
808 ret
= qcrypto_block_amend_options(crypto
->block
,
809 block_crypto_read_func
,
810 block_crypto_write_func
,
816 /* release exclusive read/write permissions to the underlying file*/
817 crypto
->updating_keys
= false;
818 bdrv_child_refresh_perms(bs
, bs
->file
, errp
);
823 block_crypto_amend_options_luks(BlockDriverState
*bs
,
825 BlockDriverAmendStatusCB
*status_cb
,
830 BlockCrypto
*crypto
= bs
->opaque
;
831 QDict
*cryptoopts
= NULL
;
832 QCryptoBlockAmendOptions
*amend_options
= NULL
;
836 assert(crypto
->block
);
838 cryptoopts
= qemu_opts_to_qdict(opts
, NULL
);
839 qdict_put_str(cryptoopts
, "format", "luks");
840 amend_options
= block_crypto_amend_opts_init(cryptoopts
, errp
);
841 qobject_unref(cryptoopts
);
842 if (!amend_options
) {
845 ret
= block_crypto_amend_options_generic_luks(bs
, amend_options
,
848 qapi_free_QCryptoBlockAmendOptions(amend_options
);
853 coroutine_fn
block_crypto_co_amend_luks(BlockDriverState
*bs
,
854 BlockdevAmendOptions
*opts
,
858 QCryptoBlockAmendOptions amend_opts
;
860 amend_opts
= (QCryptoBlockAmendOptions
) {
861 .format
= Q_CRYPTO_BLOCK_FORMAT_LUKS
,
862 .u
.luks
= *qapi_BlockdevAmendOptionsLUKS_base(&opts
->u
.luks
),
864 return block_crypto_amend_options_generic_luks(bs
, &amend_opts
,
869 block_crypto_child_perms(BlockDriverState
*bs
, BdrvChild
*c
,
870 const BdrvChildRole role
,
871 BlockReopenQueue
*reopen_queue
,
872 uint64_t perm
, uint64_t shared
,
873 uint64_t *nperm
, uint64_t *nshared
)
876 BlockCrypto
*crypto
= bs
->opaque
;
878 bdrv_default_perms(bs
, c
, role
, reopen_queue
, perm
, shared
, nperm
, nshared
);
881 * For backward compatibility, manually share the write
882 * and resize permission
884 *nshared
|= shared
& (BLK_PERM_WRITE
| BLK_PERM_RESIZE
);
886 * Since we are not fully a format driver, don't always request
887 * the read/resize permission but only when explicitly
890 *nperm
&= ~(BLK_PERM_WRITE
| BLK_PERM_RESIZE
);
891 *nperm
|= perm
& (BLK_PERM_WRITE
| BLK_PERM_RESIZE
);
894 * This driver doesn't modify LUKS metadata except
895 * when updating the encryption slots.
896 * Thus unlike a proper format driver we don't ask for
897 * shared write/read permission. However we need it
898 * when we are updating the keys, to ensure that only we
899 * have access to the device.
901 * Encryption update will set the crypto->updating_keys
902 * during that period and refresh permissions
905 if (crypto
->updating_keys
) {
906 /* need exclusive write access for header update */
907 *nperm
|= BLK_PERM_WRITE
;
908 /* unshare read and write permission */
909 *nshared
&= ~(BLK_PERM_CONSISTENT_READ
| BLK_PERM_WRITE
);
914 static const char *const block_crypto_strong_runtime_opts
[] = {
915 BLOCK_CRYPTO_OPT_LUKS_KEY_SECRET
,
920 static BlockDriver bdrv_crypto_luks
= {
921 .format_name
= "luks",
922 .instance_size
= sizeof(BlockCrypto
),
923 .bdrv_probe
= block_crypto_probe_luks
,
924 .bdrv_open
= block_crypto_open_luks
,
925 .bdrv_close
= block_crypto_close
,
926 .bdrv_child_perm
= block_crypto_child_perms
,
927 .bdrv_co_create
= block_crypto_co_create_luks
,
928 .bdrv_co_create_opts
= block_crypto_co_create_opts_luks
,
929 .bdrv_co_truncate
= block_crypto_co_truncate
,
930 .create_opts
= &block_crypto_create_opts_luks
,
931 .amend_opts
= &block_crypto_amend_opts_luks
,
933 .bdrv_reopen_prepare
= block_crypto_reopen_prepare
,
934 .bdrv_refresh_limits
= block_crypto_refresh_limits
,
935 .bdrv_co_preadv
= block_crypto_co_preadv
,
936 .bdrv_co_pwritev
= block_crypto_co_pwritev
,
937 .bdrv_getlength
= block_crypto_getlength
,
938 .bdrv_measure
= block_crypto_measure
,
939 .bdrv_get_info
= block_crypto_get_info_luks
,
940 .bdrv_get_specific_info
= block_crypto_get_specific_info_luks
,
941 .bdrv_amend_options
= block_crypto_amend_options_luks
,
942 .bdrv_co_amend
= block_crypto_co_amend_luks
,
946 .strong_runtime_opts
= block_crypto_strong_runtime_opts
,
949 static void block_crypto_init(void)
951 bdrv_register(&bdrv_crypto_luks
);
954 block_init(block_crypto_init
);