On 02/27/2013 09:57 PM, TJ wrote: > From: TJ <linux@xxxxxx> > > To avoid iterating all virNetworkIpDef entries when determining > DHCP state keep track of the first enabled DHCP stanza in the > network definition itself, for both IPv4 and IPv6. > > A by-product of this change is it allows the XML to contain more > than one IP->DHCP stanza. The active DHCP stanza is the first enabled > DHCP stanza. Hmm. This is an interesting idea, but I can't think of any other place in libvirt config where we allow putting the config in place and setting it disabled, and wouldn't want to set that precedent if it didn't already exist. Any other opinions about that? > All other stanzas are retained which adds flexibility when multiple > interfaces and routes might come and go since an alternative DHCP > stanza can be selected and a refresh operation performed without > needing to destroy/edit/start the network. Well, the network would still need to be updated (virNetworkUpdateFlags), and that operation. > > Signed-off-by: TJ <linux@xxxxxx> > --- > src/conf/network_conf.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c > index 259de0a..c5eab01 100644 > --- a/src/conf/network_conf.c > +++ b/src/conf/network_conf.c > @@ -1882,6 +1882,13 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt) > if (ret < 0) > goto error; > def->nips++; > + /* use only the first enabled DHCP definition */ > + if (!def->ipv4_dhcp && def->ips[ii].dhcp_enabled && > + VIR_SOCKET_ADDR_IS_FAMILY(&def->ips[ii].address, AF_INET)) > + def->ipv4_dhcp = &def->ips[ii]; > + if (!def->ipv6_dhcp && def->ips[ii].dhcp_enabled && > + VIR_SOCKET_ADDR_IS_FAMILY(&def->ips[ii].address, AF_INET6)) > + def->ipv6_dhcp = &def->ips[ii]; > } > } > VIR_FREE(ipNodes); -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list