[libvirt] [PATCH v2 2/3] xenconfig: add support for multiple IP addresses

Jim Fehlig jfehlig at suse.com
Fri Dec 8 21:19:32 UTC 2017


On 12/06/2017 07:27 PM, Marek Marczykowski-Górecki wrote:
> ---
> new patch in v2
> ---

Sorry for being neurotic when it comes to empty commit messages. I added some 
useless text before pushing. Same for 3/3.

>   src/xenconfig/xen_common.c | 32 +++++++++++++++++---------------
>   1 file changed, 17 insertions(+), 15 deletions(-)

Reviewed-by: Jim Fehlig <jfehlig at suse.com>

I've pushed all 3. Thanks!

Regards,
Jim

> 
> diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
> index 7f838b6..40b1483 100644
> --- a/src/xenconfig/xen_common.c
> +++ b/src/xenconfig/xen_common.c
> @@ -847,7 +847,7 @@ xenParseVif(virConfPtr conf, virDomainDefPtr def, const char *vif_typename)
>           while (list) {
>               char model[10];
>               char type[10];
> -            char ip[16];
> +            char ip[128];
>               char mac[18];
>               char bridge[50];
>               char vifname[50];
> @@ -964,8 +964,18 @@ xenParseVif(virConfPtr conf, virDomainDefPtr def, const char *vif_typename)
>                   if (bridge[0] && VIR_STRDUP(net->data.bridge.brname, bridge) < 0)
>                       goto cleanup;
>               }
> -            if (ip[0] && virDomainNetAppendIPAddress(net, ip, AF_INET, 0) < 0)
> -                goto cleanup;
> +            if (ip[0]) {
> +                char **ip_list = virStringSplit(ip, " ", 0);
> +                size_t i;
> +
> +                for (i = 0; ip_list[i]; i++) {
> +                    if (virDomainNetAppendIPAddress(net, ip_list[i], 0, 0) < 0) {
> +                        virStringListFree(ip_list);
> +                        goto cleanup;
> +                    }
> +                }
> +                virStringListFree(ip_list);
> +            }
>   
>               if (script && script[0] &&
>                   VIR_STRDUP(net->script, script) < 0)
> @@ -1207,14 +1217,10 @@ xenFormatNet(virConnectPtr conn,
>       switch (net->type) {
>       case VIR_DOMAIN_NET_TYPE_BRIDGE:
>           virBufferAsprintf(&buf, ",bridge=%s", net->data.bridge.brname);
> -        if (net->guestIP.nips == 1) {
> -            char *ipStr = virSocketAddrFormat(&net->guestIP.ips[0]->address);
> +        if (net->guestIP.nips > 0) {
> +            char *ipStr = xenMakeIPList(&net->guestIP);
>               virBufferAsprintf(&buf, ",ip=%s", ipStr);
>               VIR_FREE(ipStr);
> -        } else if (net->guestIP.nips > 1) {
> -            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> -                           _("Driver does not support setting multiple IP addresses"));
> -            goto cleanup;
>           }
>           virBufferAsprintf(&buf, ",script=%s", DEFAULT_VIF_SCRIPT);
>           break;
> @@ -1222,14 +1228,10 @@ xenFormatNet(virConnectPtr conn,
>       case VIR_DOMAIN_NET_TYPE_ETHERNET:
>           if (net->script)
>               virBufferAsprintf(&buf, ",script=%s", net->script);
> -        if (net->guestIP.nips == 1) {
> -            char *ipStr = virSocketAddrFormat(&net->guestIP.ips[0]->address);
> +        if (net->guestIP.nips > 0) {
> +            char *ipStr = xenMakeIPList(&net->guestIP);
>               virBufferAsprintf(&buf, ",ip=%s", ipStr);
>               VIR_FREE(ipStr);
> -        } else if (net->guestIP.nips > 1) {
> -            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> -                           _("Driver does not support setting multiple IP addresses"));
> -            goto cleanup;
>           }
>           break;
>   
> 




More information about the libvir-list mailing list