]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: block: fix error when blockcopy target is librbd encrypted
authorOr Ozeri <oro@il.ibm.com>
Thu, 12 Jan 2023 09:04:01 +0000 (03:04 -0600)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 26 Jan 2024 08:52:19 +0000 (09:52 +0100)
Encryption secrets are considered a format dependency, even
when being used by the storage node itself, as in the case of
using encryption engine=librbd.
Currently, the storage node is created (blockdev-add) before
creating the format dependencies (including encryption secrets).
As a result, when trying to perform a blockcopy when the target
disk uses librbd encryption, an error of this form is returned:

  "error: internal error: unable to execute QEMU command 'blockdev-add': No secret with id 'libvirt-5-format-encryption-secret0'"

To overcome this error, we change the order of commands so that
format dependencies are created BEFORE creating the storage node.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_block.c

index c9f5cbbf29682b9451d7ba54c5153a064bd4146a..b266f5743db12411136a11328e3635016c7fb89a 100644 (file)
@@ -1669,9 +1669,9 @@ qemuBlockStorageSourceAttachApply(qemuMonitor *mon,
                                   qemuBlockStorageSourceAttachData *data)
 {
     if (qemuBlockStorageSourceAttachApplyStorageDeps(mon, data) < 0 ||
+        qemuBlockStorageSourceAttachApplyFormatDeps(mon, data) < 0 ||
         qemuBlockStorageSourceAttachApplyStorage(mon, data) < 0 ||
         qemuBlockStorageSourceAttachApplyStorageSlice(mon, data) < 0 ||
-        qemuBlockStorageSourceAttachApplyFormatDeps(mon, data) < 0 ||
         qemuBlockStorageSourceAttachApplyFormat(mon, data) < 0)
         return -1;
 
@@ -2636,6 +2636,8 @@ qemuBlockStorageSourceCreate(virDomainObj *vm,
         goto cleanup;
 
     rc = qemuBlockStorageSourceAttachApplyStorageDeps(priv->mon, data);
+    if (rc == 0)
+        rc = qemuBlockStorageSourceAttachApplyFormatDeps(priv->mon, data);
 
     qemuDomainObjExitMonitor(vm);
     if (rc < 0)
@@ -2649,9 +2651,6 @@ qemuBlockStorageSourceCreate(virDomainObj *vm,
 
     rc = qemuBlockStorageSourceAttachApplyStorage(priv->mon, data);
 
-    if (rc == 0)
-        rc = qemuBlockStorageSourceAttachApplyFormatDeps(priv->mon, data);
-
     qemuDomainObjExitMonitor(vm);
     if (rc < 0)
         goto cleanup;