]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: blockjob: Clean out disk mirror data after concluding the job
authorPeter Krempa <pkrempa@redhat.com>
Fri, 27 Sep 2024 07:07:22 +0000 (09:07 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 1 Oct 2024 10:54:40 +0000 (12:54 +0200)
The 'disk->mirrorJob' and 'disk->mirrorState' fields need to be cleared
after a blockjob, but should be kept around while 'disk->mirror' is
still in place. As 'disk->mirror' is cleared only after conclusion of
the job in 'qemuBlockJobEventProcessConcluded()' we should be resetting
them only afterwards.

Move the code later, but since the job is unregistered from the disk we
need to store the pointer to the disk before concluding the job.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/qemu/qemu_blockjob.c

index 9c56d5cb9549116f090cf092f7f69df6174789fa..652b25540a9551eda2942291c32b909f9d9720ed 100644 (file)
@@ -1561,12 +1561,18 @@ qemuBlockJobEventProcess(virQEMUDriver *driver,
     case QEMU_BLOCKJOB_STATE_COMPLETED:
     case QEMU_BLOCKJOB_STATE_FAILED:
     case QEMU_BLOCKJOB_STATE_CANCELLED:
-    case QEMU_BLOCKJOB_STATE_CONCLUDED:
-        if (job->disk) {
-            job->disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_NONE;
-            job->disk->mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN;
-        }
+    case QEMU_BLOCKJOB_STATE_CONCLUDED: {
+        virDomainDiskDef *disk = job->disk;
+
         qemuBlockJobEventProcessConcluded(job, driver, vm, asyncJob);
+
+        /* Job was unregistered from the disk but we must ensure that the
+         * data is cleared */
+        if (disk) {
+            disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_NONE;
+            disk->mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN;
+        }
+    }
         break;
 
     case QEMU_BLOCKJOB_STATE_READY: