[PATCH 04/10] conf: Network - keep track of active DHCP stanza in virNetworkDef

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

 



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.
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.

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);
-- 
1.8.1.2.433.g9808ce0.dirty

--
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]