[libvirt] [PATCH v2] pci: Give an explicit error if device not found

Cole Robinson crobinso at redhat.com
Mon May 17 18:25:37 UTC 2010


On 05/17/2010 01:16 PM, Daniel P. Berrange wrote:
> On Mon, May 17, 2010 at 01:06:23PM -0400, Cole Robinson wrote:
>> v2: Use intended F_OK. Drop devdir param, just check dev->path for device
>> existence.
>>
>> Signed-off-by: Cole Robinson <crobinso at redhat.com>
>> ---
>>  src/util/pci.c |    7 +++++++
>>  1 files changed, 7 insertions(+), 0 deletions(-)
>>
>> diff --git a/src/util/pci.c b/src/util/pci.c
>> index 81193b7..3fcc658 100644
>> --- a/src/util/pci.c
>> +++ b/src/util/pci.c
>> @@ -1046,6 +1046,13 @@ pciGetDevice(unsigned domain,
>>      snprintf(dev->path, sizeof(dev->path),
>>               PCI_SYSFS "devices/%s/config", dev->name);
>>  
>> +    if (access(dev->path, F_OK) != 0) {
>> +        pciReportError(VIR_ERR_INTERNAL_ERROR,
>> +                       _("Device %s not found"), dev->name);
> 
> This should do
> 
>   virReportSystemError(errno,
>                        _("unable to access PCI device %s at %s"),
>                        dev->name, dev->path)
> 
> so that it lets us see the different types of problem access() 
> can return & reminds us what path we're complaining about.
> 

Thanks, sent an updated patch. I kept 'device not found' as part of the
error message, since that is likely to be what a failed access really means.

- Cole

>> +        pciFreeDevice(dev);
>> +        return NULL;
>> +    }
>> +
>>      vendor  = pciReadDeviceID(dev, "vendor");
>>      product = pciReadDeviceID(dev, "device");
>>  
> 
> Daniel




More information about the libvir-list mailing list