[libvirt] [PATCH v3 3/3] Honor blacklist for modprobe command

Ján Tomko jtomko at redhat.com
Tue Feb 4 15:10:42 UTC 2014


On 02/04/2014 03:29 PM, John Ferlan wrote:
> 
> 
> On 02/04/2014 06:06 AM, Ján Tomko wrote:
>> On 01/30/2014 06:50 PM, John Ferlan wrote:
>>> +            VIR_FREE(errbuf);
>>> +            goto cleanup;
>>>          }
>>>  
>>>          goto recheck;
>>>      }
>>>  
>>> +    /* If we know failure was because of blacklist, let's report that */
>>> +    if (virKModIsBlacklisted(driver)) {
>>> +        virReportError(VIR_ERR_INTERNAL_ERROR,
>>> +                       _("Failed to load PCI stub module %s: "
>>> +                         "administratively prohibited"),
>>> +                       driver);
>>> +    }
>>> +
>>> +cleanup:
>>>      return -1;
>>>  }
>>>  
>>> @@ -1313,9 +1322,10 @@ virPCIDeviceDetach(virPCIDevicePtr dev,
>>>                     virPCIDeviceList *inactiveDevs)
>>>  {
>>>      if (virPCIProbeStubDriver(dev->stubDriver) < 0) {
>>> -        virReportError(VIR_ERR_INTERNAL_ERROR,
>>> -                       _("Failed to load PCI stub module %s"),
>>> -                       dev->stubDriver);
>>> +        if (virGetLastError() == NULL)
>>
>> This seems to be the only caller of virPCIProbeStubDriver.
>> You could just report the error unconditionally inside it.
>>
> 
> Attempting to make the differentiation between load failed load failed
> because of administratively prohibited means an additional check or two
> in the caller.

I meant that right now virPCIProbeStubDriver is only called from here and if
it did not report an error, we will report one here.

It seemed cleaner not to report an error here and make virPCIProbeStubDriver
report an error in all cases (not just when the module is blacklisted and/or
on OOM in virPCIDriverDir).

> 
> Furthermore if something that virPCIProbeStubDriver() called provided
> some other error wouldn't it be better to not overwrite the message? If
> the virAsprintf() called by virPCIDriverDir() failed because of memory
> allocation, then which error message would be displayed without the
> virGetLastError() check? I guess I'm not 100% clear in my mind which
> error message would get displayed...

Only the last reported error gets displayed, but both will get logged.

Jan


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140204/96f0a141/attachment-0001.sig>


More information about the libvir-list mailing list