[libvirt] [PATCH v4 02/17] Domain conf: allow more than one IP address for net devices

Laine Stump laine at laine.org
Thu Dec 11 18:51:45 UTC 2014


On 11/13/2014 04:33 AM, Cédric Bosdonnat wrote:
> @@ -4667,6 +4671,58 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
>      return ret;
>  }
>  
> +static virDomainNetIpDefPtr
> +virDomainNetIpParseXML(xmlNodePtr node)
> +{
> +    /* Parse the prefix in every case */
> +    virDomainNetIpDefPtr ip = NULL;
> +    char *prefixStr = NULL;
> +    unsigned int prefixValue = 0;
> +    char *familyStr = NULL;
> +    int family = AF_UNSPEC;
> +    char *address = NULL;
> +
> +    if (!(prefixStr = virXMLPropString(node, "prefix")) ||
> +        (virStrToLong_ui(prefixStr, NULL, 10, &prefixValue) < 0)) {
> +        // Don't shout, just warn as some old config may not have a prefix
> +        VIR_WARN("Missing or invalid network prefix");

This warning is unnecessary. IPv6 address default to a prefix of 64 if
none is specified, and ipv4 addresses to 8, 16, or 24 depending on the
range of address you're in (this is specified in an RFC somewhere,
basically class A, B, and C networks), and it's quite common for the
default prefix to be the correct one. See the function
virSocketAddrGetIpPrefix() for details/example.


> -      <ip address='172.14.5.6'/>
> +      <ip address='172.14.5.6' family='ipv4'/>

Do we really want to automatically add the "ipv4" in there if it's not
there? That seems like unnecessary churn and verbosity in the config.




More information about the libvir-list mailing list