]> git.ipfire.org Git - thirdparty/libvirt.git/commit
qemu: avoid rare race when undefining domain
authorMartin Kletzander <mkletzan@redhat.com>
Thu, 30 Oct 2014 13:38:35 +0000 (14:38 +0100)
committerMartin Kletzander <mkletzan@redhat.com>
Mon, 3 Nov 2014 15:43:23 +0000 (16:43 +0100)
commitb629c64e5e0a32ef439b8eeb3a697e2cd76f3248
tree0d5272860c26190cc65806036471ff1ebf7a7be8
parent1eb53f05bc82a72e30d3efc594f0a7ca4a3c60c3
qemu: avoid rare race when undefining domain

When one domain is being undefined and at the same time started, for
example, there is a possibility of a rare problem occuring.

 - Thread 1 does virDomainUndefine(), has the lock, checks that the
   domain is active and because it's not, calls
   virDomainObjListRemove().

 - Thread 2 does virDomainCreate() and tries to lock the domain.

 - Thread 1 needs to lock domain list in order to remove the domain from
   it, but must unlock domain first (proper order is to lock domain list
   first and the domain itself second).

 - Thread 2 grabs the lock, starts the domain and releases the lock.

 - Thread 1 grabs the lock and removes the domain from list.

With this patch:

 - qemuDomainRemoveInactive() creates a QEMU_JOB_MODIFY if that's
   possible, but since it must remove the domain from list either way,
   it continues even when starting the job failed.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1150505

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
src/qemu/qemu_domain.c