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>
virCheckFlags(0, NULL);
+ if (nodeDeviceInitWait() < 0)
+ return NULL;
+
if (!(obj = nodeDeviceObjFindByName(device->name)))
return NULL;
def = virNodeDeviceObjGetDef(obj);
virNodeDeviceDef *def;
char *ret = NULL;
+ if (nodeDeviceInitWait() < 0)
+ return NULL;
+
if (!(obj = nodeDeviceObjFindByName(device->name)))
return NULL;
def = virNodeDeviceObjGetDef(obj);
virNodeDeviceDef *def;
int ret = -1;
+ if (nodeDeviceInitWait() < 0)
+ return -1;
+
if (!(obj = nodeDeviceObjFindByName(device->name)))
return -1;
def = virNodeDeviceObjGetDef(obj);
int ret = -1;
size_t i = 0;
+ if (nodeDeviceInitWait() < 0)
+ return -1;
+
if (!(obj = nodeDeviceObjFindByName(device->name)))
return -1;
def = virNodeDeviceObjGetDef(obj);
virCheckFlags(0, -1);
+ if (nodeDeviceInitWait() < 0)
+ return -1;
+
if (!(obj = nodeDeviceObjFindByName(device->name)))
return -1;