]> git.ipfire.org Git - thirdparty/libvirt.git/commit
qemu: Add missing lock of virDomainObj before calling virDomainUnref
authorLaine Stump <laine@laine.org>
Thu, 3 Mar 2011 16:54:08 +0000 (11:54 -0500)
committerLaine Stump <laine@laine.org>
Fri, 4 Mar 2011 13:12:58 +0000 (08:12 -0500)
commite570ca1246667a72517357be7e8f75d217065880
tree11df4eca420e45ad7cbf4f9f928ca1a0bf0fc4a8
parent65fca8feba6ae5282d408bf9430df93a9607f493
qemu: Add missing lock of virDomainObj before calling virDomainUnref

This was found while researching the root cause of:

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

virDomainUnref should only be called with the lock held for the
virDomainObj in question. However, when a transient qemu domain gets
EOF on its monitor socket, it queues an event which frees the monitor,
which unref's the virDomainObj without first locking it. If another
thread has already locked the virDomainObj, the modification of the
refcount could potentially be corrupted. In an extreme case, it could
also be potentially unlocked by virDomainObjFree, thus left open to
modification by anyone else who would have otherwise waited for the
lock (not to mention the fact that they would be accessing freed
data!).

The solution is to have qemuMonitorFree lock the domain object right
before unrefing it. Since the caller to qemuMonitorFree doesn't expect
this lock to be held, if the refcount doesn't go all the way to 0,
qemuMonitorFree must unlock it after the unref.
src/qemu/qemu_process.c