]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuHotplugRemoveManagedPR: Integrate check whether removal is needed
authorPeter Krempa <pkrempa@redhat.com>
Mon, 17 Mar 2025 17:18:37 +0000 (18:18 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 20 Mar 2025 05:42:43 +0000 (06:42 +0100)
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>
src/qemu/qemu_blockjob.c
src/qemu/qemu_driver.c
src/qemu/qemu_hotplug.c
src/qemu/qemu_hotplug.h

index c1b29f2fde8d1cb2b96a3a3595477b3b1db4a602..c7462e28385c2a2ac88b8e4af6997c6b67b7a7dd 100644 (file)
@@ -709,7 +709,7 @@ qemuBlockJobEventProcessConcludedRemoveChain(virQEMUDriver *driver,
 
     qemuDomainStorageSourceChainAccessRevoke(driver, vm, chain);
 
-    qemuHotplugRemoveManagedPR(vm, asyncJob);
+    qemuHotplugRemoveManagedPR(vm, chain, asyncJob);
 }
 
 
index fb6d4e9bff3f5d582fd20c910a5476ba2c6d04a2..d87d38c4b9afbf57efac2e1f2b8a38785d8696de 100644 (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"));
index a8aed9c56e99dec34458839b30d6ab515ec38f97..87bccd5057eaac6d312c6f6ab73fd6ef18b9f79f 100644 (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);
 
index 63ed7bbafdd198576bad94c24e792e1adf896025..8e3a8f769e757e87a3a6de121a55566cb744dc04 100644 (file)
@@ -133,4 +133,5 @@ qemuHotplugAttachManagedPR(virDomainObj *vm,
                            virDomainAsyncJob asyncJob);
 void
 qemuHotplugRemoveManagedPR(virDomainObj *vm,
+                           virStorageSource *src,
                            virDomainAsyncJob asyncJob);