qemu: block: fix error when blockcopy target is librbd encrypted

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>
This commit is contained in:
Or Ozeri 2023-01-12 03:04:01 -06:00 committed by Peter Krempa
parent ccfc5c1e16
commit 66aee6e5c2
1 changed files with 3 additions and 4 deletions

View 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;