util: Allow removing hash entries in virHashForEach
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.
(cherry picked from commit 9677cd33eea4c65d78ba463b46b8b45ed2da1709)

Signed-off-by: Steve Hodgson <eb20a6615749cf04ff61aa37e18f749ed6d01446@solarflare.com>

sshah-solarflare/Libvirt-PCI-passthrough-,sshah-solarflare/Libvirt-PCI-passthrough-,sshah-solarflare/Libvirt-PCI-passthrough-,sshah-solarflare/Libvirt-PCI-passthrough-,sshah-solarflare/Libvirt-PCI-passthrough-