From 421406808abaf7eb66abd27d71c21ae5b783a380 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 20 Nov 2014 13:56:39 +0100 Subject: [PATCH] network: dnsmasq: Don't format lease file path Now that we don't use the leases file at all for leases just don't format it into the config and use the leaseshelper to do all the lifting. --- src/network/bridge_driver.c | 13 ++----------- src/network/bridge_driver.h | 3 --- tests/networkxml2confdata/dhcp6-nat-network.conf | 1 - tests/networkxml2confdata/dhcp6-network.conf | 1 - tests/networkxml2confdata/isolated-network.conf | 1 - .../nat-network-dns-srv-record-minimal.conf | 1 - .../nat-network-dns-srv-record.conf | 1 - .../nat-network-dns-txt-record.conf | 1 - tests/networkxml2confdata/nat-network.conf | 1 - tests/networkxml2confdata/netboot-network.conf | 1 - .../networkxml2confdata/netboot-proxy-network.conf | 1 - tests/networkxml2conftest.c | 12 ------------ 12 files changed, 2 insertions(+), 35 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 70e3f270a4..9ccc9f8f8d 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -209,9 +209,6 @@ networkDnsmasqLeaseFileNameDefault(const char *netname) return leasefile; } -networkDnsmasqLeaseFileNameFunc networkDnsmasqLeaseFileName = - networkDnsmasqLeaseFileNameDefault; - static char * networkDnsmasqLeaseFileNameCustom(const char *bridge) { @@ -273,7 +270,7 @@ networkRemoveInactive(virNetworkObjPtr net) goto cleanup; } - if (!(leasefile = networkDnsmasqLeaseFileName(def->name))) + if (!(leasefile = networkDnsmasqLeaseFileNameDefault(def->name))) goto cleanup; if (!(customleasefile = networkDnsmasqLeaseFileNameCustom(def->bridge))) @@ -1202,14 +1199,8 @@ networkDnsmasqConfContents(virNetworkObjPtr network, ipdef = (ipdef == ipv6def) ? NULL : ipv6def; } - if (nbleases > 0) { - char *leasefile = networkDnsmasqLeaseFileName(network->def->name); - if (!leasefile) - goto cleanup; - virBufferAsprintf(&configbuf, "dhcp-leasefile=%s\n", leasefile); - VIR_FREE(leasefile); + if (nbleases > 0) virBufferAsprintf(&configbuf, "dhcp-lease-max=%d\n", nbleases); - } /* this is done once per interface */ if (networkBuildDnsmasqHostsList(dctx, dns) < 0) diff --git a/src/network/bridge_driver.h b/src/network/bridge_driver.h index decc08f77d..2f801ee514 100644 --- a/src/network/bridge_driver.h +++ b/src/network/bridge_driver.h @@ -64,7 +64,4 @@ int networkDnsmasqConfContents(virNetworkObjPtr network, typedef char *(*networkDnsmasqLeaseFileNameFunc)(const char *netname); -/* this allows the testsuite to replace the lease filename resolver function */ -extern networkDnsmasqLeaseFileNameFunc networkDnsmasqLeaseFileName; - #endif /* __VIR_NETWORK__DRIVER_H */ diff --git a/tests/networkxml2confdata/dhcp6-nat-network.conf b/tests/networkxml2confdata/dhcp6-nat-network.conf index f270a4372d..922eb7a32c 100644 --- a/tests/networkxml2confdata/dhcp6-nat-network.conf +++ b/tests/networkxml2confdata/dhcp6-nat-network.conf @@ -11,7 +11,6 @@ interface=virbr0 dhcp-range=192.168.122.2,192.168.122.254 dhcp-no-override dhcp-range=2001:db8:ac10:fd01::1:10,2001:db8:ac10:fd01::1:ff -dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases dhcp-lease-max=493 dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts diff --git a/tests/networkxml2confdata/dhcp6-network.conf b/tests/networkxml2confdata/dhcp6-network.conf index f0a9660975..064515f816 100644 --- a/tests/networkxml2confdata/dhcp6-network.conf +++ b/tests/networkxml2confdata/dhcp6-network.conf @@ -11,7 +11,6 @@ except-interface=lo bind-dynamic interface=virbr0 dhcp-range=2001:db8:ac10:fd01::1:10,2001:db8:ac10:fd01::1:ff -dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases dhcp-lease-max=240 dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts diff --git a/tests/networkxml2confdata/isolated-network.conf b/tests/networkxml2confdata/isolated-network.conf index 6ba34ae56e..fbdf75a7de 100644 --- a/tests/networkxml2confdata/isolated-network.conf +++ b/tests/networkxml2confdata/isolated-network.conf @@ -12,7 +12,6 @@ dhcp-option=3 no-resolv dhcp-range=192.168.152.2,192.168.152.254 dhcp-no-override -dhcp-leasefile=/var/lib/libvirt/dnsmasq/private.leases dhcp-lease-max=253 dhcp-hostsfile=/var/lib/libvirt/dnsmasq/private.hostsfile addn-hosts=/var/lib/libvirt/dnsmasq/private.addnhosts diff --git a/tests/networkxml2confdata/nat-network-dns-srv-record-minimal.conf b/tests/networkxml2confdata/nat-network-dns-srv-record-minimal.conf index e60411ba25..08ed67204b 100644 --- a/tests/networkxml2confdata/nat-network-dns-srv-record-minimal.conf +++ b/tests/networkxml2confdata/nat-network-dns-srv-record-minimal.conf @@ -15,7 +15,6 @@ listen-address=10.24.10.1 srv-host=_name._tcp dhcp-range=192.168.122.2,192.168.122.254 dhcp-no-override -dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases dhcp-lease-max=253 dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts diff --git a/tests/networkxml2confdata/nat-network-dns-srv-record.conf b/tests/networkxml2confdata/nat-network-dns-srv-record.conf index 16e7dca506..d7de422c71 100644 --- a/tests/networkxml2confdata/nat-network-dns-srv-record.conf +++ b/tests/networkxml2confdata/nat-network-dns-srv-record.conf @@ -17,7 +17,6 @@ srv-host=_name6._tcp.test6.com,test6.example.com,6666,0,666 srv-host=_name7._tcp.test7.com,test7.example.com,1,0,777 dhcp-range=192.168.122.2,192.168.122.254 dhcp-no-override -dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases dhcp-lease-max=253 dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts diff --git a/tests/networkxml2confdata/nat-network-dns-txt-record.conf b/tests/networkxml2confdata/nat-network-dns-txt-record.conf index ff53f4e4f7..44ed6bd189 100644 --- a/tests/networkxml2confdata/nat-network-dns-txt-record.conf +++ b/tests/networkxml2confdata/nat-network-dns-txt-record.conf @@ -11,7 +11,6 @@ interface=virbr0 txt-record=example,example value dhcp-range=192.168.122.2,192.168.122.254 dhcp-no-override -dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases dhcp-lease-max=253 dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts diff --git a/tests/networkxml2confdata/nat-network.conf b/tests/networkxml2confdata/nat-network.conf index ced4123a96..34d5b17d8a 100644 --- a/tests/networkxml2confdata/nat-network.conf +++ b/tests/networkxml2confdata/nat-network.conf @@ -10,7 +10,6 @@ bind-dynamic interface=virbr0 dhcp-range=192.168.122.2,192.168.122.254 dhcp-no-override -dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases dhcp-lease-max=253 dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts diff --git a/tests/networkxml2confdata/netboot-network.conf b/tests/networkxml2confdata/netboot-network.conf index 8ea1f67de9..4b8f0cc457 100644 --- a/tests/networkxml2confdata/netboot-network.conf +++ b/tests/networkxml2confdata/netboot-network.conf @@ -15,7 +15,6 @@ dhcp-no-override enable-tftp tftp-root=/var/lib/tftproot dhcp-boot=pxeboot.img -dhcp-leasefile=/var/lib/libvirt/dnsmasq/netboot.leases dhcp-lease-max=253 dhcp-hostsfile=/var/lib/libvirt/dnsmasq/netboot.hostsfile addn-hosts=/var/lib/libvirt/dnsmasq/netboot.addnhosts diff --git a/tests/networkxml2confdata/netboot-proxy-network.conf b/tests/networkxml2confdata/netboot-proxy-network.conf index 4774a92dd6..61a025c3e2 100644 --- a/tests/networkxml2confdata/netboot-proxy-network.conf +++ b/tests/networkxml2confdata/netboot-proxy-network.conf @@ -13,7 +13,6 @@ listen-address=192.168.122.1 dhcp-range=192.168.122.2,192.168.122.254 dhcp-no-override dhcp-boot=pxeboot.img,,10.20.30.40 -dhcp-leasefile=/var/lib/libvirt/dnsmasq/netboot.leases dhcp-lease-max=253 dhcp-hostsfile=/var/lib/libvirt/dnsmasq/netboot.hostsfile addn-hosts=/var/lib/libvirt/dnsmasq/netboot.addnhosts diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c index 4f1d9345ff..267513f637 100644 --- a/tests/networkxml2conftest.c +++ b/tests/networkxml2conftest.c @@ -100,16 +100,6 @@ testCompareXMLToConfHelper(const void *data) return result; } -static char * -testDnsmasqLeaseFileName(const char *netname) -{ - char *leasefile; - - ignore_value(virAsprintf(&leasefile, "/var/lib/libvirt/dnsmasq/%s.leases", - netname)); - return leasefile; -} - static int mymain(void) { @@ -121,8 +111,6 @@ mymain(void) dnsmasqCapsPtr dhcpv6 = dnsmasqCapsNewFromBuffer("Dnsmasq version 2.64\n--bind-dynamic", DNSMASQ); - networkDnsmasqLeaseFileName = testDnsmasqLeaseFileName; - #define DO_TEST(xname, xcaps) \ do { \ static testInfo info; \