qemu/qapi
Hyman Huang 9ad5c4e7ee crypto: Support LUKS volume with detached header
By enhancing the LUKS driver, it is possible to implement
the LUKS volume with a detached header.

Normally a LUKS volume has a layout:
  disk:  | header | key material | disk payload data |

With a detached LUKS header, you need 2 disks so getting:
  disk1:  | header | key material |
  disk2:  | disk payload data |

There are a variety of benefits to doing this:
 * Secrecy - the disk2 cannot be identified as containing LUKS
             volume since there's no header
 * Control - if access to the disk1 is restricted, then even
             if someone has access to disk2 they can't unlock
             it. Might be useful if you have disks on NFS but
             want to restrict which host can launch a VM
             instance from it, by dynamically providing access
             to the header to a designated host
 * Flexibility - your application data volume may be a given
                 size and it is inconvenient to resize it to
                 add encryption.You can store the LUKS header
                 separately and use the existing storage
                 volume for payload
 * Recovery - corruption of a bit in the header may make the
              entire payload inaccessible. It might be
              convenient to take backups of the header. If
              your primary disk header becomes corrupt, you
              can unlock the data still by pointing to the
              backup detached header

Take the raw-format image as an example to introduce the usage
of the LUKS volume with a detached header:

1. prepare detached LUKS header images
$ dd if=/dev/zero of=test-header.img bs=1M count=32
$ dd if=/dev/zero of=test-payload.img bs=1M count=1000
$ cryptsetup luksFormat --header test-header.img test-payload.img
> --force-password --type luks1

2. block-add a protocol blockdev node of payload image
$ virsh qemu-monitor-command vm '{"execute":"blockdev-add",
> "arguments":{"node-name":"libvirt-1-storage", "driver":"file",
> "filename":"test-payload.img"}}'

3. block-add a protocol blockdev node of LUKS header as above.
$ virsh qemu-monitor-command vm '{"execute":"blockdev-add",
> "arguments":{"node-name":"libvirt-2-storage", "driver":"file",
> "filename": "test-header.img" }}'

4. object-add the secret for decrypting the cipher stored in
   LUKS header above
$ virsh qemu-monitor-command vm '{"execute":"object-add",
> "arguments":{"qom-type":"secret", "id":
> "libvirt-2-storage-secret0", "data":"abc123"}}'

5. block-add the raw-drived blockdev format node
$ virsh qemu-monitor-command vm '{"execute":"blockdev-add",
> "arguments":{"node-name":"libvirt-1-format", "driver":"raw",
> "file":"libvirt-1-storage"}}'

6. block-add the luks-drived blockdev to link the raw disk
   with the LUKS header by specifying the field "header"
$ virsh qemu-monitor-command vm '{"execute":"blockdev-add",
> "arguments":{"node-name":"libvirt-2-format", "driver":"luks",
> "file":"libvirt-1-format", "header":"libvirt-2-storage",
> "key-secret":"libvirt-2-format-secret0"}}'

7. hot-plug the virtio-blk device finally
$ virsh qemu-monitor-command vm '{"execute":"device_add",
> "arguments": {"num-queues":"1", "driver":"virtio-blk-pci",
> "drive": "libvirt-2-format", "id":"virtio-disk2"}}'

Starting a VM with a LUKS volume with detached header is
somewhat similar to hot-plug in that both maintaining the
same json command while the starting VM changes the
"blockdev-add/device_add" parameters to "blockdev/device".

Signed-off-by: Hyman Huang <yong.huang@smartx.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2024-02-09 12:50:33 +00:00
..
acpi.json qapi: Reformat doc comments to conform to current conventions 2023-05-10 10:01:01 +02:00
audio.json audio/pw: Pipewire->PipeWire case fix for user-visible text 2023-07-17 15:22:56 +04:00
authz.json qapi: Reformat doc comments to conform to current conventions 2023-05-10 10:01:01 +02:00
block-core.json crypto: Support LUKS volume with detached header 2024-02-09 12:50:33 +00:00
block-export.json qapi: Elide "Potential additional modes" from generated docs 2024-02-03 09:20:01 +01:00
block.json qapi: Reformat recent doc comments to conform to current conventions 2023-07-26 14:51:36 +02:00
char.json qapi: Indent tagged doc comment sections properly 2024-01-26 07:04:53 +01:00
common.json qapi: Reformat doc comments to conform to current conventions 2023-05-10 10:01:01 +02:00
compat.json qapi: Belatedly update CompatPolicy documentation for unstable 2023-10-19 07:02:29 +02:00
control.json docs/interop: Convert qmp-spec.txt to rST 2023-05-22 10:21:01 +02:00
crypto.json crypto: Introduce SM4 symmetric cipher algorithm 2024-02-09 12:47:55 +00:00
cryptodev.json spelling: information 2023-06-09 23:38:16 +03:00
cxl.json qapi: Reformat recent doc comments to conform to current conventions 2023-07-26 14:51:36 +02:00
dump.json dump: Add command interface for kdump-raw formats 2023-11-02 18:40:37 +04:00
error.json qapi: Reformat doc comments to conform to current conventions 2023-05-10 10:01:01 +02:00
introspect.json qapi: Drop redundant documentation of inherited members 2024-02-03 09:19:25 +01:00
job.json blockjob: introduce block-job-change QMP command 2023-10-31 18:20:25 +01:00
machine-common.json CPU topology: extend with s390 specifics 2023-10-20 07:16:53 +02:00
machine-target.json qapi,risc-v: add query-cpu-model-expansion 2023-11-07 11:06:01 +10:00
machine.json qapi: Indent tagged doc comment sections properly 2024-01-26 07:04:53 +01:00
meson.build CPU topology: extend with s390 specifics 2023-10-20 07:16:53 +02:00
migration.json qapi/migration.json: Fix the member name for MigrationCapability 2024-01-30 21:20:20 +03:00
misc-target.json qapi: Drop redundant documentation of conditional 2024-02-03 09:19:55 +01:00
misc.json qapi: Indent tagged doc comment sections properly 2024-01-26 07:04:53 +01:00
net.json qapi: Fix mangled "Returns" sections in documentation 2024-01-26 07:04:53 +01:00
opts-visitor.c cutils: Adjust signature of parse_uint[_full] 2023-06-02 12:27:19 -05:00
pci.json qapi: Reformat doc comments to conform to current conventions 2023-05-10 10:01:01 +02:00
pragma.json qapi/pragma.json: Improve the comment about the lists of QAPI rule exceptions 2023-11-15 11:09:17 +03:00
qapi-clone-visitor.c
qapi-dealloc-visitor.c
qapi-forward-visitor.c qapi: remove needless include 2022-03-22 14:46:18 +04:00
qapi-schema.json CPU topology: extend with s390 specifics 2023-10-20 07:16:53 +02:00
qapi-type-helpers.c
qapi-util.c qapi: Fix dangling references to docs/devel/qapi-code-gen.txt 2024-01-26 07:04:53 +01:00
qapi-visit-core.c
qdev.json qapi: Fix mangled "Returns" sections in documentation 2024-01-26 07:04:53 +01:00
qmp-dispatch.c monitor: only run coroutine commands in qemu_aio_context 2024-01-26 11:16:58 +01:00
qmp-event.c Replace qemu_gettimeofday() with g_get_real_time() 2022-04-06 10:50:37 +02:00
qmp-registry.c
qobject-input-visitor.c include: add qemu/keyval.h 2022-04-21 17:03:51 +04:00
qobject-output-visitor.c
qom.json qapi: Fix mangled "Returns" sections in documentation 2024-01-26 07:04:53 +01:00
rdma.json qapi: Reformat doc comments to conform to current conventions 2023-05-10 10:01:01 +02:00
replay.json qapi: Reformat doc comments to conform to current conventions 2023-05-10 10:01:01 +02:00
rocker.json qapi: Reformat doc comments to conform to current conventions 2023-05-10 10:01:01 +02:00
run-state.json qapi: Remove deprecated 'singlestep' member of StatusInfo 2024-01-19 11:38:32 +01:00
sockets.json qapi: Reformat doc comments to conform to current conventions 2023-05-10 10:01:01 +02:00
stats.json qapi: Reformat doc comments to conform to current conventions 2023-05-10 10:01:01 +02:00
string-input-visitor.c
string-output-visitor.c string-output-visitor: Fix (pseudo) struct handling 2024-01-26 11:16:58 +01:00
tpm.json qapi: Reformat doc comments to conform to current conventions 2023-05-10 10:01:01 +02:00
trace-events
trace.h
trace.json qapi: Reformat recent doc comments to conform to current conventions 2023-07-26 14:51:36 +02:00
transaction.json qapi: Reformat doc comments to conform to current conventions 2023-05-10 10:01:01 +02:00
ui.json Make Pixman an optional dependency 2023-11-07 19:00:03 +08:00
virtio.json qdev: add IOThreadVirtQueueMappingList property type 2023-12-21 22:49:28 +01:00
yank.json qapi: Indent tagged doc comment sections properly 2024-01-26 07:04:53 +01:00