Re: [PATCHv2] libxl: set IP address when creating NIC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Feb 07, 2015 at 04:53:46PM +0900, Jihoon Kim wrote:
> From: Ji-hoon Kim <relip@xxxxxx>
> 
> Currently libxlMakeNic() does not set ip address when creating NIC,
> this patch makes it to set ip address.
> 
> Signed-off-by: Ji-hoon Kim <relip@xxxxxx>
> ---
>  src/libxl/libxl_conf.c |   14 ++++++++++++++
>  1 files changed, 14 insertions(+), 0 deletions(-)
> 

I'm not that familiar with libxl, but...

> diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
> index 0555b91..e49715d 100644
> --- a/src/libxl/libxl_conf.c
> +++ b/src/libxl/libxl_conf.c
> @@ -1042,6 +1042,20 @@ libxlMakeNic(virDomainDefPtr def,
>      if (VIR_STRDUP(x_nic->ifname, l_nic->ifname) < 0)
>          return -1;
>  
> +    if (l_nic->nips == 1) {
> +        char *ipStr = virSocketAddrFormat(&l_nic->ips[0]->address);
> +        if (VIR_STRDUP(x_nic->ip, ipStr) < 0) {
> +            VIR_FREE(ipStr);
> +            return -1;
> +        }
> +        VIR_FREE(ipStr);

This does not check the return value of virSocketAddrFormat (VIR_STRDUP
returns 0 when the source string is NULL).

The VIR_STRDUP is also redundant, the string allocated by
virSocketAddrFormat can be just assigned to x_nic->ip.

Jan

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]