From 66aee6e5c2b37314df29a611ccf0453f6770d1e1 Mon Sep 17 00:00:00 2001 From: Or Ozeri Date: Thu, 12 Jan 2023 03:04:01 -0600 Subject: [PATCH] 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 Signed-off-by: Peter Krempa --- src/qemu/qemu_block.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index c9f5cbbf29..b266f5743d 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -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;