mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
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:
parent
b0aaed65ea
commit
5679c844de
@ -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");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user