[PATCH 08/30] qemuDomainDeviceDiskDefPostParseRestoreSecAlias: Hardcode restored aliases

Peter Krempa posted 30 patches 5 years, 11 months ago
[PATCH 08/30] qemuDomainDeviceDiskDefPostParseRestoreSecAlias: Hardcode restored aliases
Posted by Peter Krempa 5 years, 11 months ago
In order to be able to change the function generating the alias and thus
also the aliases itself, we must hardcode the old format for the case of
upgrading form libvirt which didn't record them in the status XML yet.

Note that this code path is tested by
'tests/qemustatusxml2xmldata/disk-secinfo-upgrade-in.xml'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_domain.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 70b1b5c4f2..72e651ecee 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -8993,16 +8993,14 @@ qemuDomainDeviceDiskDefPostParseRestoreSecAlias(virDomainDiskDefPtr disk,
     }

     if (restoreAuthSecret) {
-        if (!(authalias = qemuDomainGetSecretAESAlias(disk->info.alias, false)))
-            return -1;
+        authalias = g_strdup_printf("%s-secret0", disk->info.alias);

         if (qemuStorageSourcePrivateDataAssignSecinfo(&priv->secinfo, &authalias) < 0)
             return -1;
     }

     if (restoreEncSecret) {
-        if (!(encalias = qemuDomainGetSecretAESAlias(disk->info.alias, true)))
-            return -1;
+        encalias = g_strdup_printf("%s-luks-secret0", disk->info.alias);

         if (qemuStorageSourcePrivateDataAssignSecinfo(&priv->encinfo, &encalias) < 0)
             return -1;
-- 
2.24.1

Re: [PATCH 08/30] qemuDomainDeviceDiskDefPostParseRestoreSecAlias: Hardcode restored aliases
Posted by Ján Tomko 5 years, 11 months ago
On a Monday in 2020, Peter Krempa wrote:
>In order to be able to change the function generating the alias and thus
>also the aliases itself, we must hardcode the old format for the case of
>upgrading form libvirt which didn't record them in the status XML yet.
>
>Note that this code path is tested by
>'tests/qemustatusxml2xmldata/disk-secinfo-upgrade-in.xml'
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/qemu/qemu_domain.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>

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

Jano