virBufferAddLit(buf, "dhcp-authoritative\n");
}
- if (ipdef->tftproot) {
- virBufferAddLit(buf, "enable-tftp\n");
- virBufferAsprintf(buf, "tftp-root=%s\n", ipdef->tftproot);
- }
-
if (ipdef->bootfile) {
if (VIR_SOCKET_ADDR_VALID(&ipdef->bootserver)) {
g_autofree char *bootserver = virSocketAddrFormat(&ipdef->bootserver);
}
+static void
+networkDnsmasqConfTFTP(virBuffer *buf,
+ virNetworkIPDef *ipdef,
+ bool *enableTFTP)
+{
+ if (!ipdef->tftproot)
+ return;
+
+ if (!*enableTFTP) {
+ virBufferAddLit(buf, "enable-tftp\n");
+ *enableTFTP = true;
+ }
+ virBufferAsprintf(buf, "tftp-root=%s\n", ipdef->tftproot);
+}
+
+
int
networkDnsmasqConfContents(virNetworkObj *obj,
const char *pidfile,
virNetworkIPDef *ipv4def = NULL;
virNetworkIPDef *ipv6def = NULL;
bool ipv6SLAAC = false;
+ bool enableTFTP = false;
*configstr = NULL;
ipv4def = ipdef;
}
}
+
+ networkDnsmasqConfTFTP(&configbuf, ipdef, &enableTFTP);
}
if (VIR_SOCKET_ADDR_IS_FAMILY(&ipdef->address, AF_INET6)) {
if (ipdef->nranges || ipdef->nhosts) {
i = 0;
while ((ipdef = virNetworkDefGetIPByIndex(def, AF_UNSPEC, i))) {
i++;
- if (ipdef->nranges || ipdef->nhosts)
+ if (ipdef->nranges || ipdef->nhosts || ipdef->tftproot)
needDnsmasq = true;
}
for (i = 0;
(ipdef = virNetworkDefGetIPByIndex(def, AF_INET, i));
i++) {
- if (ipdef->nranges || ipdef->nhosts) {
+ if (ipdef->nranges || ipdef->nhosts || ipdef->tftproot) {
oldDhcpActive = true;
break;
}
for (i = 0; (ipdef = virNetworkDefGetIPByIndex(def, AF_INET, i));
i++) {
- if (ipdef->nranges || ipdef->nhosts) {
+ if (ipdef->nranges || ipdef->nhosts || ipdef->tftproot) {
newDhcpActive = true;
break;
}
--- /dev/null
+##WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
+##OVERWRITTEN AND LOST. Changes to this configuration should be made using:
+## virsh net-edit tftp-only
+## or other application using the libvirt API.
+##
+## dnsmasq conf file created by libvirt
+strict-order
+except-interface=lo
+bind-dynamic
+interface=virbr0
+enable-tftp
+tftp-root=/var/lib/tftproot
+addn-hosts=/var/lib/libvirt/dnsmasq/tftp-only.addnhosts
DO_TEST("isolated-network", full);
DO_TEST("netboot-network", full);
DO_TEST("netboot-proxy-network", full);
+ DO_TEST("netboot-tftp", full);
DO_TEST("nat-network-dns-srv-record-minimal", full);
DO_TEST("nat-network-name-with-quotes", full);
DO_TEST("routed-network", full);