When concluding a job with a 'mirror' we first unplugged the appropriate
no-longer used images from qemu and then updated the definition.
Normally this wouldn't be a problem because for any other thread this is
done under the VM lock thus atomic. Unfortunately though, the AppArmor
security backend is using a VM XML to pass data to the helper process
and the state of the definition at that point was unsuitable to format a
valid XML thus making 'virt-aa-helper' report parsing failure.
Since we're removing the images the proper state of the VM definition
indeed should not include the mirror element any more at the point when
the images are removed.
Closes:
https://gitlab.com/libvirt/libvirt/-/issues/601
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_blockjob.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index 42856df6d4..9c56d5cb95 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -1218,6 +1218,8 @@ qemuBlockJobProcessEventConcludedCopyPivot(virQEMUDriver *driver,
virDomainAsyncJob asyncJob)
{
qemuDomainObjPrivate *priv = vm->privateData;
+ g_autoptr(virStorageSource) src = NULL;
+
VIR_DEBUG("copy job '%s' on VM '%s' pivoted", job->name,
vm->def->name);
/* mirror may be NULL for copy job corresponding to migration */
@@ -1241,9 +1243,11 @@ qemuBlockJobProcessEventConcludedCopyPivot(virQEMUDriver *driver,
qemuBlockJobRewriteConfigDiskSource(vm, job->disk, job->disk->mirror);
- qemuBlockJobEventProcessConcludedRemoveChain(driver, vm, asyncJob,
job->disk->src);
- virObjectUnref(job->disk->src);
+ src = g_steal_pointer(&job->disk->src);
+
job->disk->src = g_steal_pointer(&job->disk->mirror);
+
+ qemuBlockJobEventProcessConcludedRemoveChain(driver, vm, asyncJob, src);
}
@@ -1254,6 +1258,7 @@ qemuBlockJobProcessEventConcludedCopyAbort(virQEMUDriver *driver,
virDomainAsyncJob asyncJob)
{
qemuDomainObjPrivate *priv = vm->privateData;
+ g_autoptr(virStorageSource) mirror = NULL;
VIR_DEBUG("copy job '%s' on VM '%s' aborted", job->name,
vm->def->name);
@@ -1277,9 +1282,10 @@ qemuBlockJobProcessEventConcludedCopyAbort(virQEMUDriver *driver,
g_clear_pointer(&job->disk->mirror->backingStore,
virObjectUnref);
}
+ mirror = g_steal_pointer(&job->disk->mirror);
+
/* activeWrite bitmap is removed automatically here */
- qemuBlockJobEventProcessConcludedRemoveChain(driver, vm, asyncJob,
job->disk->mirror);
- g_clear_pointer(&job->disk->mirror, virObjectUnref);
+ qemuBlockJobEventProcessConcludedRemoveChain(driver, vm, asyncJob, mirror);
}
--
2.46.0