]> git.ipfire.org Git - thirdparty/libvirt.git/commit
qemu: Use virEventThreadStop() in qemuProcessStop()
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 25 Jul 2024 07:51:45 +0000 (09:51 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 22 Aug 2024 11:33:09 +0000 (13:33 +0200)
commit0888784f38704718592c88ad149c426f3943298c
tree317a7ceba85a54bb73d0dc1fe85e8190d59cd4e4
parent7aca235d8dad72fbf3ab2ba3b2940c847e503848
qemu: Use virEventThreadStop() in qemuProcessStop()

Currently, qemuProcessStop() unlocks given domain object right in
the middle of cleanup process. This is dangerous because there
might be another thread which is executing virDomainObjListAdd().
And since the domain object is on the list of domain objects AND
by the time qemuProcessStop() unlocks it the object is also
marked as inactive, the other thread acquires the lock and
switches vm->def pointer.

The unlocking of domain object is needed though, to allow even
processing thread finish its queue. Well, the processing can be
done before any cleanup is attempted.

Therefore, use freshly introduced virEventThreadStop() to join
the event thread and drop lock/unlock from the middle of
qemuProcessStop().

Now, there's a comment being removed that mentions
qemuDomainObjStopWorker() and why it has to be called only after
the domain is marked as dead. This comment is no longed
applicable because call to qemuDomainObjStopWorker() is removed
also. Moreover, priv->beingDestroyed is set to true before
unlocking the domain object, thus any event processing callback
is going to see the domain being destroyed and can chose to
either exit early or finish processing event.

Fixes: 3865410e7f67ca4ec66e9a905e75f452762a97f0
Resolves: https://issues.redhat.com/browse/RHEL-49607
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_process.c