]> git.ipfire.org Git - thirdparty/libvirt.git/commit
nodedev: Wait for device initialization in all public API callbacks
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 13 Apr 2021 09:18:23 +0000 (11:18 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 14 Apr 2021 08:16:48 +0000 (10:16 +0200)
commit77a13eb9ac3ac054bde3dafb0bcbedb77f07a135
treeae1342cf254d475b2ec678170747476db6fc2dc5
parent5b56a288cab097896832dc9d4acb7f23dfca377c
nodedev: Wait for device initialization in all public API callbacks

Although I have not experienced this in real life, there is a
possible race condition when creating new device, getting its XML
or parent or listing its capabilities.  If the nodedev driver is
still enumerating devices (in a separate thread) and one of
virNodeDeviceGetXMLDesc(), virNodeDeviceGetParent(),
virNodeDeviceNumOfCaps(), virNodeDeviceListCaps() or
virNodeDeviceCreate() is called then it can lead to spurious
results because the device enumeration thread is removing devices
from or adding them to the internal list of devices (among with
their states).

Therefore, wait for things to settle down before proceeding with
any of the APIs.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
src/node_device/node_device_driver.c