[PATCH 3/4] qemuBlockStorageSourceNeedsStorageSliceLayer: Deal with 'luks' files

Peter Krempa pkrempa at redhat.com
Thu Mar 19 16:35:40 UTC 2020


The 'luks' driver in qemu is as any other non-raw format driver and thus
doesn't support the properties for 'slice'. Since libvirt considers
luks files to be raw+encryption we need to special case them when
dealing with the slice.

https://bugzilla.redhat.com/show_bug.cgi?id=1814975

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/qemu/qemu_block.c                                 | 4 ++++
 tests/qemuxml2argvdata/disk-slices.x86_64-latest.args | 5 ++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index b5b34ab441..ee15167215 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -3324,5 +3324,9 @@ qemuBlockStorageSourceNeedsStorageSliceLayer(const virStorageSource *src)
     if (src->format != VIR_STORAGE_FILE_RAW)
         return true;

+    if (src->encryption &&
+        src->encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS)
+        return true;
+
     return false;
 }
diff --git a/tests/qemuxml2argvdata/disk-slices.x86_64-latest.args b/tests/qemuxml2argvdata/disk-slices.x86_64-latest.args
index 75485c17a7..63bdaa58be 100644
--- a/tests/qemuxml2argvdata/disk-slices.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/disk-slices.x86_64-latest.args
@@ -52,9 +52,12 @@ data=9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,\
 keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \
 -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/luks.img",\
 "node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \
+-blockdev '{"driver":"raw","node-name":"libvirt-1-slice-sto","offset":1234,\
+"size":321,"file":"libvirt-1-storage","auto-read-only":true,\
+"discard":"unmap"}' \
 -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"luks",\
 "key-secret":"libvirt-1-format-encryption-secret0","offset":1234,"size":321,\
-"file":"libvirt-1-storage"}' \
+"file":"libvirt-1-slice-sto"}' \
 -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=libvirt-1-format,\
 id=virtio-disk2 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 \
-- 
2.24.1




More information about the libvir-list mailing list