On 09/11/2012 09:05 PM, Osier Yang wrote:
>> +
>> + if (VIR_ALLOC_N(names, count)< 0) {
>> + virReportOOMError();
>> + return -1;
>> + }
>
>
> If you want to check for a race here, you could allocate count+1 items
> in the array, then do an ncf_list_interfaces telling it the maxcount is
> "count+1" and check to see that you really only got count items back.
No want I think, :-)
Since I will adopt your below suggestion to igore the no found interface
by "ncf_lookup_by_name", that means we should either ignore the race, or
raise up error earlier here.
I think ignoring is better, any objections?
If we want to use the count+1 trick to ensure things didn't grow in the
meantime, then we should do it for ALL the fallbacks when vir*ListAll is
missing, not just the network listing. I'm okay with not checking for
truncation, as it's simpler, and as it will only affect the fallback
code which we already documented in virsh.pod as being racy.
--
Eric Blake eblake(a)redhat.com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org