pci: Give an explicit error if device not found

v2: Use intended F_OK. Drop devdir param, just check dev->path for device
existence.

v3: Use virReportSystemError, include dev->path in error message.
This commit is contained in:
Cole Robinson 2010-04-30 11:44:19 -04:00
parent b0aaed65ea
commit 5679c844de

View File

@ -1046,6 +1046,14 @@ pciGetDevice(unsigned domain,
snprintf(dev->path, sizeof(dev->path),
PCI_SYSFS "devices/%s/config", dev->name);
if (access(dev->path, F_OK) != 0) {
virReportSystemError(errno,
_("Device %s not found: could not access %s"),
dev->name, dev->path);
pciFreeDevice(dev);
return NULL;
}
vendor = pciReadDeviceID(dev, "vendor");
product = pciReadDeviceID(dev, "device");