]> git.ipfire.org Git - thirdparty/libvirt.git/commit
util: Allow removing hash entries in virHashForEach
authorJiri Denemark <jdenemar@redhat.com>
Thu, 3 Mar 2011 13:10:51 +0000 (14:10 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Thu, 3 Mar 2011 14:22:16 +0000 (15:22 +0100)
commit9677cd33eea4c65d78ba463b46b8b45ed2da1709
tree6c78a970390d1f1e54b2fdcf5a0518ba8999d013
parentd6d30cd4aedd3a65d7e4518ca253d1ba0f67a7a8
util: Allow removing hash entries in virHashForEach

This fixes a possible crash of libvirtd during its startup. When qemu
driver reconnects to running domains, it iterates over all domain
objects in a hash. When reconnecting to an associated qemu monitor
fails and the domain is transient, it's immediately removed from the
hash. Despite the fact that it's explicitly forbidden to do so. If
libvirtd is lucky enough, virHashForEach will access random memory when
the callback finishes and the deamon will crash.

Since it's trivial to fix virHashForEach to allow removal of hash
entries while iterating through them, I went this way instead of fixing
qemuReconnectDomain callback (and possibly others) to avoid deleting the
entries.
src/util/hash.c