[libvirt] [PATCHv2 1/4] util: add an ifaceGetIPAddress to the interface utilies
Laine Stump
laine at laine.org
Thu Jul 21 23:52:27 UTC 2011
On 07/21/2011 07:16 PM, Eric Blake wrote:
> On 07/20/2011 02:11 AM, Laine Stump wrote:
>
> In the subject:
>
> s/utilies/utilities/
>
>> This function uses ioctl(SIOCGIFADDR), which limits it to returning
>> the first IPv4 address of an interface, but that's what we want right
>> now (the place we're going to use the address only accepts one).
>> ---
>> src/libvirt_private.syms | 1 +
>> src/util/interface.c | 60
>> ++++++++++++++++++++++++++++++++++++++++++++++
>> src/util/interface.h | 3 ++
>> 3 files changed, 64 insertions(+), 0 deletions(-)
>
>>
>> @@ -511,6 +512,65 @@ ifaceSetMacAddress(const char *ifname
>> ATTRIBUTE_UNUSED,
>>
>>
>> /**
>> + * ifaceGetIPAddress:
>> + * @ifname: name of the interface whose IP address we want
>> + * @macaddr: MAC address (VIR_MAC_BUFLEN in size)
>> + *
>> + * This function gets the @macaddr for a given interface @ifname.
>> + *
>> + * Returns 0 in case of success or an errno code in case of failure.
>
> Positive on error? Should we instead be returing -errno, so callers
> can check < 0, per our typical usage?
>
> Conditional ACK, depending on the answer to that question (the code
> looks correct, and converting to negative return on failure seems
> trivial enough if we decide to go that way).
>
On one hand I would like to be consistent with most of the rest of
libvirt in returning < 0 on error. On the other hand, most of the other
functions in this file return errno on error.
Maybe the proper thing to do is first post a patch that changes the
existing functions to return -errno, then my patches.
Yeah, I'll do that.
More information about the libvir-list
mailing list