]> git.ipfire.org Git - thirdparty/libvirt.git/commit
qemu: don't 'remove' hostdev objects from domain if operation fails
authorLaine Stump <laine@laine.org>
Wed, 7 Mar 2012 01:43:22 +0000 (20:43 -0500)
committerLaine Stump <laine@laine.org>
Thu, 8 Mar 2012 21:58:22 +0000 (16:58 -0500)
commitb59e59845f4ba59c68e17cbd0e41954bec75d333
treed0dfa8ad83908f3e681f07e8073c1564759e9462
parent8845d293757ff0deff17f65d555222ad6d462bfd
qemu: don't 'remove' hostdev objects from domain if operation fails

There were certain paths through the hostdev detach code that could
lead to the lower level function failing (and not removing the object
from the domain's hostdevs list), but the higher level function
free'ing the hostdev object anyway. This would leave a stale
hostdevdef pointer in the list, which would surely cause a problem
eventually.

This patch relocates virDomainHostdevRemove from the lower level
functions qemuDomainDetachThisHostDevice and
qemuDomainDetachHostPciDevice, to their caller
qemuDomainDetachThisHostDevice, placing it just before the call to
virDomainHostdevDefFree. This makes it easy to verify that either both
operations are done, or neither.

NB: The "dangling pointer" part of this problem was introduced in
commit 13d5a6, so it is not present in libvirt versions prior to
0.9.9. Earlier versions would return failure in certain cases even
though the the device object was removed/deleted, but the removal and
deletion operations would always both happen or neither.
src/qemu/qemu_hotplug.c