diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index f15a7a6879393b5a4ff668810a875fc819b80f59..aa170d60acc0d4fde0c0b309ed8df6db891d8831 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -108,7 +108,7 @@ static void networkReloadIptablesRules(struct network_driver *driver); static struct network_driver *driverState = NULL; static char * -networkDnsmasqLeaseFileName(const char *netname) +networkDnsmasqLeaseFileNameDefault(const char *netname) { char *leasefile; @@ -117,6 +117,9 @@ networkDnsmasqLeaseFileName(const char *netname) return leasefile; } +networkDnsmasqLeaseFileNameFunc networkDnsmasqLeaseFileName = + networkDnsmasqLeaseFileNameDefault; + static char * networkRadvdPidfileBasename(const char *netname) { diff --git a/src/network/bridge_driver.h b/src/network/bridge_driver.h index 8d82b677132fd8505c9d63c0891468f891de279e..a106e3df571011a6cc165afbcc6a3e5ebc8c3694 100644 --- a/src/network/bridge_driver.h +++ b/src/network/bridge_driver.h @@ -34,4 +34,9 @@ int networkRegister(void); int networkBuildDhcpDaemonCommandLine(virNetworkObjPtr network, virCommandPtr *cmdout, char *pidfile); +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/networkxml2argvtest.c b/tests/networkxml2argvtest.c index 16d57a9c7a002082bdeaf451345ffd4381d77dda..62de191eeb3e6b468b69d65847ef85bef0bcf574 100644 --- a/tests/networkxml2argvtest.c +++ b/tests/networkxml2argvtest.c @@ -85,11 +85,24 @@ cleanup: return result; } +static char * +testDnsmasqLeaseFileName(const char *netname) +{ + char *leasefile; + + virAsprintf(&leasefile, "/var/lib/libvirt/dnsmasq/%s.leases", + netname); + + return leasefile; +} + static int mymain(void) { int ret = 0; + networkDnsmasqLeaseFileName = testDnsmasqLeaseFileName; + #define DO_TEST(name) \ if (virtTestRun("Network XML-2-Argv " name, \ 1, testCompareXMLToArgvHelper, (name)) < 0) \