1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-30 18:50:18 +03:00

qemuHotplugRemoveManagedPR: Integrate check whether removal is needed

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@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Peter Krempa 2025-03-17 18:18:37 +01:00
parent ad94d8fb19
commit f48fb17d72
4 changed files with 12 additions and 11 deletions

View File

@ -709,7 +709,7 @@ qemuBlockJobEventProcessConcludedRemoveChain(virQEMUDriver *driver,
qemuDomainStorageSourceChainAccessRevoke(driver, vm, chain);
qemuHotplugRemoveManagedPR(vm, asyncJob);
qemuHotplugRemoveManagedPR(vm, chain, asyncJob);
}

View File

@ -14416,7 +14416,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"));

View File

@ -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);
@ -4779,8 +4780,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);

View File

@ -133,4 +133,5 @@ qemuHotplugAttachManagedPR(virDomainObj *vm,
virDomainAsyncJob asyncJob);
void
qemuHotplugRemoveManagedPR(virDomainObj *vm,
virStorageSource *src,
virDomainAsyncJob asyncJob);