[PATCH] qemuDomainPrepareStorageSourceBlockdev: Set default encryption engine also when preparing virStorageSource

Peter Krempa posted 1 patch 2 years, 5 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/d6ff24efb156778ee1e958c316d5b916070df140.1637078080.git.pkrempa@redhat.com
src/qemu/qemu_domain.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] qemuDomainPrepareStorageSourceBlockdev: Set default encryption engine also when preparing virStorageSource
Posted by Peter Krempa 2 years, 5 months ago
Originally the default encryption engine is populated in the disk
post-parse callback code. This works for disks but for any additional
images introduced either via the block copy API or via the backup API we
don't populate the default.

In case when the backup or block copy is requested on an encrypted image
this would then lead to an error:

 error: internal error: Unexpected enum value 0 for virStorageEncryptionEngine

This patch adds another point where we populate the default which is
when setting up a virStorageSource for actual usage.

We keep the original setting in the post-parse callback as that's the
only point that is recorded in the XML file after definition.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2023674
Fixes: ab1d46d6128
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_domain.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index fb203bc830..5aad321e36 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -10651,6 +10651,9 @@ qemuDomainPrepareStorageSourceBlockdev(virDomainDiskDef *disk,
     if (qemuBlockStorageSourceNeedsStorageSliceLayer(src))
         src->sliceStorage->nodename = g_strdup_printf("libvirt-%u-slice-sto", src->id);

+    if (src->encryption && src->encryption->engine == VIR_STORAGE_ENCRYPTION_ENGINE_DEFAULT)
+        src->encryption->engine = VIR_STORAGE_ENCRYPTION_ENGINE_QEMU;
+
     if (qemuDomainValidateStorageSource(src, priv->qemuCaps, false) < 0)
         return -1;

-- 
2.31.1

Re: [PATCH] qemuDomainPrepareStorageSourceBlockdev: Set default encryption engine also when preparing virStorageSource
Posted by Ján Tomko 2 years, 5 months ago
On a Tuesday in 2021, Peter Krempa wrote:
>Originally the default encryption engine is populated in the disk
>post-parse callback code. This works for disks but for any additional
>images introduced either via the block copy API or via the backup API we
>don't populate the default.
>
>In case when the backup or block copy is requested on an encrypted image
>this would then lead to an error:
>
> error: internal error: Unexpected enum value 0 for virStorageEncryptionEngine
>
>This patch adds another point where we populate the default which is
>when setting up a virStorageSource for actual usage.
>
>We keep the original setting in the post-parse callback as that's the
>only point that is recorded in the XML file after definition.
>
>Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2023674
>Fixes: ab1d46d6128
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/qemu/qemu_domain.c | 3 +++
> 1 file changed, 3 insertions(+)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano