[libvirt] [PATCH 05/13] conf: utility to return alias of a controller based on type/index

Laine Stump laine at laine.org
Fri May 8 18:04:19 UTC 2015


On 05/08/2015 01:44 PM, John Ferlan wrote:
>
> On 05/05/2015 02:03 PM, Laine Stump wrote:
>
>
>> +
>> +    contIndex = virDomainControllerFind(def, type, idx);
>> +    if (contIndex < 0) {
>> +        virReportError(VIR_ERR_INTERNAL_ERROR,
>> +                       _("Could not find %s controller with index %d "
>> +                         "required for device"),
>> +                       contTypeStr, idx);
>> +        return NULL;
>> +    }
>> +    if (!def->controllers[contIndex]->info.alias) {
>> +        virReportError(VIR_ERR_INTERNAL_ERROR,
>> +                       _("Device alias was not set for %s controller "
>> +                         "with index %d "),
>> +                       contTypeStr, idx);
>> +        return NULL;
> So if the alias wasn't set for some reason we're going to start seeing
> errors. Is there a reason the alias wouldn't be set... (just trying to
> think/type outloud later in the day at the end of the week as my brain
> is beginning to check out).

If the alias hasn't been set at the time that we're calling this
function, that would be an error that should be remedied. Currently the
only place it is going to be called is during commandline generation,
after all devices have had their aliases assigned, and during hotplug
(also by definition after all other devices have had their aliases
assigned). So for current usage we are fine. In the future if someone
tries to use this function when they shouldn't, they will get the
internal error and learn their lesson.




More information about the libvir-list mailing list