[libvirt] [PATCH 06/13] Make virtual network netmasks optional

Eric Blake eblake at redhat.com
Tue Dec 21 00:13:00 UTC 2010


On 12/20/2010 01:03 AM, Laine Stump wrote:
> When a netmask isn't specified for an IPv4 address, one can be implied
> based on what network class range the address is in. The
> virNetworkDefPrefix function does this for us, so netmask isn't
> required.
> ---
>  src/conf/network_conf.c |   30 ++++++++++++++++--------------
>  1 files changed, 16 insertions(+), 14 deletions(-)
> 
> diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
> index b6ac4e3..09566ca 100644
> --- a/src/conf/network_conf.c
> +++ b/src/conf/network_conf.c
> @@ -461,19 +461,14 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
>          def->delay = 0;
>  
>      ipAddress = virXPathString("string(./ip[1]/@address)", ctxt);
> -    netmask = virXPathString("string(./ip[1]/@netmask)", ctxt);
> -    if (ipAddress &&
> -        netmask) {
> +    if (ipAddress) {

Before this patch, if you specified one but not the other, then neither
was recognized.  Now, if you specify ipAddress but not netmask,
ipAddress is still recognized (good), but if you specify netmask but not
ipAddress, you've caused the def file to be in a state that wasn't
possible before (potentially bad).  Should you also add a sanity check
that declares the configuration invalid if netmask is specified without
ipAddress, so you don't have to worry about it in the rest of the code base?

If the answer to that question is that netmask without ipAddress doesn't
hurt, then conditional ACK.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20101220/484e2faa/attachment-0001.sig>


More information about the libvir-list mailing list