@@ -212,6 +212,7 @@ static QemuOptsList block_crypto_runtime_opts_luks = {
.head = QTAILQ_HEAD_INITIALIZER(block_crypto_runtime_opts_luks.head),
.desc = {
BLOCK_CRYPTO_OPT_DEF_LUKS_KEY_SECRET(""),
+ BLOCK_CRYPTO_OPT_DEF_LUKS_ENCRYPT_IN_PARALLEL(""),
{ /* end of list */ }
},
};
@@ -347,6 +348,13 @@ static int block_crypto_open_generic(QCryptoBlockFormat format,
}
cryptoopts = qemu_opts_to_qdict(opts, NULL);
+
+ if (!g_strcmp0(qdict_get_try_str(cryptoopts,
+ BLOCK_CRYPTO_OPT_LUKS_ENCRYPT_IN_PARALLEL), "on") ||
+ qdict_get_try_bool(cryptoopts,
+ BLOCK_CRYPTO_OPT_LUKS_ENCRYPT_IN_PARALLEL, false)) {
+ crypto->encrypt_in_parallel = true;
+ }
qdict_put_str(cryptoopts, "format", QCryptoBlockFormat_str(format));
open_opts = block_crypto_open_opts_init(cryptoopts, errp);
@@ -46,6 +46,7 @@
#define BLOCK_CRYPTO_OPT_LUKS_STATE "state"
#define BLOCK_CRYPTO_OPT_LUKS_OLD_SECRET "old-secret"
#define BLOCK_CRYPTO_OPT_LUKS_NEW_SECRET "new-secret"
+#define BLOCK_CRYPTO_OPT_LUKS_ENCRYPT_IN_PARALLEL "encrypt-in-parallel"
#define BLOCK_CRYPTO_OPT_DEF_LUKS_KEY_SECRET(prefix) \
@@ -130,6 +131,14 @@
"Empty string to erase", \
}
+#define BLOCK_CRYPTO_OPT_DEF_LUKS_ENCRYPT_IN_PARALLEL(prefix) \
+ { \
+ .name = prefix BLOCK_CRYPTO_OPT_LUKS_ENCRYPT_IN_PARALLEL, \
+ .type = QEMU_OPT_BOOL, \
+ .help = "perform encryption and decryption through " \
+ "thread pool", \
+ }
+
QCryptoBlockCreateOptions *
block_crypto_create_opts_init(QDict *opts, Error **errp);
@@ -3365,12 +3365,16 @@
#
# @header: block device holding a detached LUKS header. (since 9.0)
#
+# @encrypt-in-parallel: perform encryption and decryption through
+# thread pool
+#
# Since: 2.9
##
{ 'struct': 'BlockdevOptionsLUKS',
'base': 'BlockdevOptionsGenericFormat',
'data': { '*key-secret': 'str',
- '*header': 'BlockdevRef'} }
+ '*header': 'BlockdevRef',
+ '*encrypt-in-parallel': 'bool'} }
##
# @BlockdevOptionsGenericCOWFormat:
@@ -192,10 +192,14 @@
# decryption key. Mandatory except when probing image for
# metadata only.
#
+# @encrypt-in-parallel: perform encryption and decryption through
+# thread pool
+#
# Since: 2.6
##
{ 'struct': 'QCryptoBlockOptionsLUKS',
- 'data': { '*key-secret': 'str' }}
+ 'data': { '*key-secret': 'str',
+ '*encrypt-in-parallel': 'bool' }}
##
# @QCryptoBlockCreateOptionsLUKS: