diff mbox series

[RFC,4/8] Gluks: Introduce Gluks options

Message ID b11dab3ce45427d8beb8ddf5afd60a3419965aab.1701705003.git.yong.huang@smartx.com
State New
Headers show
Series Support generic Luks encryption | expand

Commit Message

Yong Huang Dec. 4, 2023, 4:06 p.m. UTC
Similar to Luks, the Gluks format primarily recycles the
Luks choices with the exception of the "size" option.

Signed-off-by: Hyman Huang <yong.huang@smartx.com>
---
 block/crypto.c       |  4 ++--
 block/generic-luks.c | 18 ++++++++++++++++++
 block/generic-luks.h |  3 +++
 3 files changed, 23 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/block/crypto.c b/block/crypto.c
index 6afae1de2e..6f8528dccc 100644
--- a/block/crypto.c
+++ b/block/crypto.c
@@ -150,7 +150,7 @@  error:
 }
 
 
-static QemuOptsList block_crypto_runtime_opts_luks = {
+QemuOptsList block_crypto_runtime_opts_luks = {
     .name = "crypto",
     .head = QTAILQ_HEAD_INITIALIZER(block_crypto_runtime_opts_luks.head),
     .desc = {
@@ -181,7 +181,7 @@  static QemuOptsList block_crypto_create_opts_luks = {
 };
 
 
-static QemuOptsList block_crypto_amend_opts_luks = {
+QemuOptsList block_crypto_amend_opts_luks = {
     .name = "crypto",
     .head = QTAILQ_HEAD_INITIALIZER(block_crypto_create_opts_luks.head),
     .desc = {
diff --git a/block/generic-luks.c b/block/generic-luks.c
index f23e202991..ebc0365d40 100644
--- a/block/generic-luks.c
+++ b/block/generic-luks.c
@@ -35,6 +35,21 @@  typedef struct BDRVGLUKSState {
     uint64_t header_size;   /* In bytes */
 } BDRVGLUKSState;
 
+static QemuOptsList gluks_create_opts_luks = {
+    .name = "crypto",
+    .head = QTAILQ_HEAD_INITIALIZER(gluks_create_opts_luks.head),
+    .desc = {
+        BLOCK_CRYPTO_OPT_DEF_LUKS_KEY_SECRET(""),
+        BLOCK_CRYPTO_OPT_DEF_LUKS_CIPHER_ALG(""),
+        BLOCK_CRYPTO_OPT_DEF_LUKS_CIPHER_MODE(""),
+        BLOCK_CRYPTO_OPT_DEF_LUKS_IVGEN_ALG(""),
+        BLOCK_CRYPTO_OPT_DEF_LUKS_IVGEN_HASH_ALG(""),
+        BLOCK_CRYPTO_OPT_DEF_LUKS_HASH_ALG(""),
+        BLOCK_CRYPTO_OPT_DEF_LUKS_ITER_TIME(""),
+        { /* end of list */ }
+    },
+};
+
 static int gluks_open(BlockDriverState *bs, QDict *options, int flags,
                       Error **errp)
 {
@@ -71,6 +86,9 @@  static BlockDriver bdrv_generic_luks = {
     .bdrv_co_create_opts    = gluks_co_create_opts,
     .bdrv_child_perm        = gluks_child_perms,
     .bdrv_co_getlength      = gluks_co_getlength,
+
+    .create_opts            = &gluks_create_opts_luks,
+    .amend_opts             = &block_crypto_amend_opts_luks,
 };
 
 static void block_generic_luks_init(void)
diff --git a/block/generic-luks.h b/block/generic-luks.h
index 2aae866fa4..f18adf41ea 100644
--- a/block/generic-luks.h
+++ b/block/generic-luks.h
@@ -23,4 +23,7 @@ 
 #ifndef GENERIC_LUKS_H
 #define GENERIC_LUKS_H
 
+extern QemuOptsList block_crypto_runtime_opts_luks;
+extern QemuOptsList block_crypto_amend_opts_luks;
+
 #endif /* GENERIC_LUKS_H */