From: Peter Krempa <pkrempa@xxxxxxxxxx> Calls to 'qemuHotplugRemoveManagedPR' needed to be guarded by a check if the removed elements actually caused us to add the manager in the first place. The two new calls added in commit 1697323bfe6000c2f5a2519c06f0ba81 were not guarded by such check and thus would spam the debug log with: [{"id": "libvirt-59", "error": {"class": "GenericError", "desc": "object 'pr-helper0' not found"}}] Luckily 'qemuHotplugRemoveManagedPR' didn't request the error to be reported as a proper error. Don't attempt the removal unless needed. Fixes: 1697323bfe6000c2f5a2519c06f0ba81f7b792eb Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_blockjob.c | 2 +- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_hotplug.c | 18 +++++++++--------- src/qemu/qemu_hotplug.h | 1 + 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index c1b29f2fde..c7462e2838 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -709,7 +709,7 @@ qemuBlockJobEventProcessConcludedRemoveChain(virQEMUDriver *driver, qemuDomainStorageSourceChainAccessRevoke(driver, vm, chain); - qemuHotplugRemoveManagedPR(vm, asyncJob); + qemuHotplugRemoveManagedPR(vm, chain, asyncJob); } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 37cd3a8b7b..4594a201c0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14396,7 +14396,7 @@ qemuDomainBlockCopyCommon(virDomainObj *vm, if (need_revoke) qemuDomainStorageSourceChainAccessRevoke(driver, vm, mirror); - qemuHotplugRemoveManagedPR(vm, VIR_ASYNC_JOB_NONE); + qemuHotplugRemoveManagedPR(vm, mirror, VIR_ASYNC_JOB_NONE); } if (need_unlink && virStorageSourceUnlink(mirror) < 0) VIR_WARN("%s", _("unable to remove just-created copy target")); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index d6de9afccd..db0d888194 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -462,8 +462,8 @@ qemuHotplugAttachManagedPR(virDomainObj *vm, /** * qemuHotplugRemoveManagedPR: - * @driver: QEMU driver object * @vm: domain object + * @src: storage source that is being removed * @asyncJob: asynchronous job identifier * * Removes the managed PR object from @vm if the configuration does not require @@ -471,11 +471,15 @@ qemuHotplugAttachManagedPR(virDomainObj *vm, */ void qemuHotplugRemoveManagedPR(virDomainObj *vm, + virStorageSource *src, virDomainAsyncJob asyncJob) { qemuDomainObjPrivate *priv = vm->privateData; virErrorPtr orig_err; + if (!virStorageSourceChainHasManagedPR(src)) + return; + if (qemuDomainDefHasManagedPR(vm)) return; @@ -647,8 +651,7 @@ qemuDomainChangeEjectableMedia(virQEMUDriver *driver, ignore_value(qemuDomainStorageSourceChainAccessRevoke(driver, vm, oldsrc)); - if (virStorageSourceChainHasManagedPR(oldsrc)) - qemuHotplugRemoveManagedPR(vm, VIR_ASYNC_JOB_NONE); + qemuHotplugRemoveManagedPR(vm, oldsrc, VIR_ASYNC_JOB_NONE); /* media was changed, so we can remove the old media definition now */ g_clear_pointer(&oldsrc, virObjectUnref); @@ -657,8 +660,7 @@ qemuDomainChangeEjectableMedia(virQEMUDriver *driver, rollback: ignore_value(qemuDomainStorageSourceChainAccessRevoke(driver, vm, newsrc)); - if (virStorageSourceChainHasManagedPR(newsrc)) - qemuHotplugRemoveManagedPR(vm, VIR_ASYNC_JOB_NONE); + qemuHotplugRemoveManagedPR(vm, newsrc, VIR_ASYNC_JOB_NONE); /* revert old image do the disk definition */ disk->src = oldsrc; @@ -1089,8 +1091,7 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver, if (releaseSeclabel) ignore_value(qemuDomainStorageSourceChainAccessRevoke(driver, vm, disk->src)); - if (virStorageSourceChainHasManagedPR(disk->src)) - qemuHotplugRemoveManagedPR(vm, VIR_ASYNC_JOB_NONE); + qemuHotplugRemoveManagedPR(vm, disk->src, VIR_ASYNC_JOB_NONE); } qemuDomainSecretDiskDestroy(disk); qemuDomainCleanupStorageSourceFD(disk->src); @@ -4730,8 +4731,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriver *driver, if (diskBackend) qemuDomainStorageSourceChainAccessRevoke(driver, vm, disk->src); - if (virStorageSourceChainHasManagedPR(disk->src)) - qemuHotplugRemoveManagedPR(vm, VIR_ASYNC_JOB_NONE); + qemuHotplugRemoveManagedPR(vm, disk->src, VIR_ASYNC_JOB_NONE); qemuNbdkitStopStorageSource(disk->src, vm, true); diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h index 6a94dbd0cb..d3c0b45a5f 100644 --- a/src/qemu/qemu_hotplug.h +++ b/src/qemu/qemu_hotplug.h @@ -132,4 +132,5 @@ qemuHotplugAttachManagedPR(virDomainObj *vm, virDomainAsyncJob asyncJob); void qemuHotplugRemoveManagedPR(virDomainObj *vm, + virStorageSource *src, virDomainAsyncJob asyncJob); -- 2.48.1