[libvirt] [PATCHv5 0/3] leaseshelper: Couple of improvements

Nehal J Wani (1): leaseshelper: improvements to support all events Peter Krempa (2): leaseshelper: Refactor control flow network: dnsmasq: Don't format lease file path src/network/bridge_driver.c | 16 +- src/network/bridge_driver.h | 3 - src/network/leaseshelper.c | 246 +++++++++++++++------ 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 - 13 files changed, 181 insertions(+), 105 deletions(-) -- 2.1.0

From: Nehal J Wani <nehaljw.kkd1@gmail.com> This patch enables the helper program to detect event(s) triggered when there is a change in lease length or expiry and client-id. This transfers complete control of leases database to libvirt and obsoletes use of the lease database file (<network-name>.leases). That file will not be created, read, or written. This is achieved by adding the option --leasefile-ro to dnsmasq and passing a custom env var to leaseshelper, which helps us map events related to leases with their corresponding network bridges, no matter what the event be. Also, this requires the addition of a new non-lease entry in our custom lease database: "server-duid". It is required to identify a DHCPv6 server. Now that dnsmasq doesn't maintain its own leases database, it relies on our helper program to tell it about previous leases and server duid. Thus, this patch makes our leases program honor an extra action: "init", in which it sends the known info in a particular format to dnsmasq by printing it to stdout. The drawback of this change is that upgrade to this new approach does not transfer the existing leases for the network if the leaseshelper wasn't already used. --- Notes: Version 5: - fixed crash in the "init" operation - mentioned the loss of previous records in the commit message src/network/bridge_driver.c | 3 + src/network/leaseshelper.c | 160 ++++++++++++++++++++++++++++++++++---------- 2 files changed, 128 insertions(+), 35 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 6cb421c..6ecbc37 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -1280,7 +1280,10 @@ networkBuildDhcpDaemonCommandLine(virNetworkObjPtr network, cmd = virCommandNew(dnsmasqCapsGetBinaryPath(caps)); virCommandAddArgFormat(cmd, "--conf-file=%s", configfile); + /* Libvirt gains full control of leases database */ + virCommandAddArgFormat(cmd, "--leasefile-ro"); virCommandAddArgFormat(cmd, "--dhcp-script=%s", leaseshelper_path); + virCommandAddEnvPair(cmd, "VIR_BRIDGE_NAME", network->def->bridge); *cmdout = cmd; ret = 0; diff --git a/src/network/leaseshelper.c b/src/network/leaseshelper.c index 5b3c9c3..806e82d 100644 --- a/src/network/leaseshelper.c +++ b/src/network/leaseshelper.c @@ -50,6 +50,12 @@ */ #define VIR_NETWORK_DHCP_LEASE_FILE_SIZE_MAX (32 * 1024 * 1024) +/* + * Use this when passing possibly-NULL strings to printf-a-likes. + * Required for unknown parameters during init call. + */ +#define EMPTY_STR(s) ((s) ? (s) : "*") + static const char *program_name; /* Display version information. */ @@ -65,7 +71,7 @@ usage(int status) if (status) { fprintf(stderr, _("%s: try --help for more details\n"), program_name); } else { - printf(_("Usage: %s add|old|del mac|clientid ip [hostname]\n" + printf(_("Usage: %s add|old|del|init mac|clientid ip [hostname]\n" "Designed for use with 'dnsmasq --dhcp-script'\n" "Refer to man page of dnsmasq for more details'\n"), program_name); @@ -89,6 +95,7 @@ enum virLeaseActionFlags { VIR_LEASE_ACTION_ADD, /* Create new lease */ VIR_LEASE_ACTION_OLD, /* Lease already exists, renew it */ VIR_LEASE_ACTION_DEL, /* Delete the lease */ + VIR_LEASE_ACTION_INIT, /* Tell dnsmasq of existing leases on restart */ VIR_LEASE_ACTION_LAST }; @@ -96,7 +103,7 @@ enum virLeaseActionFlags { VIR_ENUM_DECL(virLeaseAction); VIR_ENUM_IMPL(virLeaseAction, VIR_LEASE_ACTION_LAST, - "add", "old", "del"); + "add", "old", "del", "init"); int main(int argc, char **argv) @@ -107,12 +114,15 @@ main(int argc, char **argv) char *custom_lease_file = NULL; const char *ip = NULL; const char *mac = NULL; + const char *ip_tmp = NULL; + const char *leases_str = NULL; + const char *server_duid_tmp = NULL; const char *iaid = virGetEnvAllowSUID("DNSMASQ_IAID"); const char *clientid = virGetEnvAllowSUID("DNSMASQ_CLIENT_ID"); const char *interface = virGetEnvAllowSUID("DNSMASQ_INTERFACE"); const char *exptime_tmp = virGetEnvAllowSUID("DNSMASQ_LEASE_EXPIRES"); const char *hostname = virGetEnvAllowSUID("DNSMASQ_SUPPLIED_HOSTNAME"); - const char *leases_str = NULL; + const char *server_duid = virGetEnvAllowSUID("DNSMASQ_SERVER_DUID"); long long currtime = 0; long long expirytime = 0; size_t i = 0; @@ -120,7 +130,6 @@ main(int argc, char **argv) int pid_file_fd = -1; int rv = EXIT_FAILURE; int custom_lease_file_len = 0; - bool add = false; bool delete = false; virJSONValuePtr lease_new = NULL; virJSONValuePtr lease_tmp = NULL; @@ -156,16 +165,17 @@ main(int argc, char **argv) } } - if (argc != 4 && argc != 5) { + if (argc != 4 && argc != 5 && argc != 2) { /* Refer man page of dnsmasq --dhcp-script for more details */ usage(EXIT_FAILURE); } /* Make sure dnsmasq knows the interface. The interface name is not known - * when dnsmasq (re)starts and throws 'del' events for expired leases. - * So, if any old lease has expired, it will be automatically removed the - * next time this program is invoked */ - if (!interface) + * via env variable set by dnsmasq when dnsmasq (re)starts and throws 'del' + * events for expired leases. So, libvirtd sets another env var for this + * purpose */ + if (!interface && + !(interface = virGetEnvAllowSUID("VIR_BRIDGE_NAME"))) goto cleanup; ip = argv[3]; @@ -176,15 +186,22 @@ main(int argc, char **argv) if (argc == 5) hostname = argv[4]; - if (VIR_STRDUP(exptime, exptime_tmp) < 0) - goto cleanup; + /* In case hostname is still unknown, use the last known one */ + if (!hostname) + hostname = virGetEnvAllowSUID("DNSMASQ_OLD_HOSTNAME"); - /* Removed extraneous trailing space in DNSMASQ_LEASE_EXPIRES (dnsmasq < 2.52) */ - if (exptime[strlen(exptime) - 1] == ' ') - exptime[strlen(exptime) - 1] = '\0'; + if (exptime_tmp) { + if (VIR_STRDUP(exptime, exptime_tmp) < 0) + goto cleanup; + + /* Removed extraneous trailing space in DNSMASQ_LEASE_EXPIRES + * (dnsmasq < 2.52) */ + if (exptime[strlen(exptime) - 1] == ' ') + exptime[strlen(exptime) - 1] = '\0'; + } /* Check if it is an IPv6 lease */ - if (virGetEnvAllowSUID("DNSMASQ_IAID")) { + if (iaid) { mac = virGetEnvAllowSUID("DNSMASQ_MAC"); clientid = argv[2]; } @@ -234,7 +251,6 @@ main(int argc, char **argv) delete = true; if (action == VIR_LEASE_ACTION_ADD || action == VIR_LEASE_ACTION_OLD) { - add = true; /* Create new lease */ if (!(lease_new = virJSONValueNewObject())) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -242,10 +258,11 @@ main(int argc, char **argv) goto cleanup; } - if (virStrToLong_ll(exptime, NULL, 10, &expirytime) < 0) { + if (!exptime || + virStrToLong_ll(exptime, NULL, 10, &expirytime) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to convert lease expiry time to long long: %s"), - exptime); + NULLSTR(exptime)); goto cleanup; } @@ -259,11 +276,13 @@ main(int argc, char **argv) goto cleanup; if (clientid && virJSONValueObjectAppendString(lease_new, "client-id", clientid) < 0) goto cleanup; + if (server_duid && virJSONValueObjectAppendString(lease_new, "server-duid", server_duid) < 0) + goto cleanup; if (expirytime && virJSONValueObjectAppendNumberLong(lease_new, "expiry-time", expirytime) < 0) goto cleanup; } } - } else { + } else if (action != VIR_LEASE_ACTION_INIT) { fprintf(stderr, _("Unsupported action: %s\n"), virLeaseActionTypeToString(action)); exit(EXIT_FAILURE); @@ -292,8 +311,6 @@ main(int argc, char **argv) i = 0; while (i < virJSONValueArraySize(leases_array)) { - const char *ip_tmp = NULL; - long long expirytime_tmp = -1; if (!(lease_tmp = virJSONValueArrayGet(leases_array, i))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -302,14 +319,13 @@ main(int argc, char **argv) } if (!(ip_tmp = virJSONValueObjectGetString(lease_tmp, "ip-address")) || - (virJSONValueObjectGetNumberLong(lease_tmp, "expiry-time", &expirytime_tmp) < 0)) { + (virJSONValueObjectGetNumberLong(lease_tmp, "expiry-time", &expirytime) < 0)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to parse json")); goto cleanup; } - /* Check whether lease has expired or not */ - if (expirytime_tmp < currtime) { + if (expirytime < currtime) { i++; continue; } @@ -320,6 +336,25 @@ main(int argc, char **argv) continue; } + if (strchr(ip_tmp, ':')) { + /* This is an ipv6 lease */ + if ((server_duid_tmp + = virJSONValueObjectGetString(lease_tmp, "server-duid"))) { + if (!server_duid) { + /* Control reaches here when the 'action' is not for an + * ipv6 lease or, for some weird reason the env var + * DNSMASQ_SERVER_DUID wasn't set*/ + server_duid = server_duid_tmp; + } + } else { + /* Inject server-duid into those ipv6 leases which + * didn't have it previously, for example, those + * created by leaseshelper from libvirt 1.2.6 */ + if (virJSONValueObjectAppendString(lease_tmp, "server-duid", server_duid) < 0) + goto cleanup; + } + } + /* Move old lease to new array */ if (virJSONValueArrayAppend(leases_array_new, lease_tmp) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -332,25 +367,80 @@ main(int argc, char **argv) } } - if (add) { + switch ((enum virLeaseActionFlags) action) { + case VIR_LEASE_ACTION_INIT: + /* Man page of dnsmasq says: the script (helper program, in our case) + * should write the saved state of the lease database, in dnsmasq + * leasefile format, to stdout and exit with zero exit code, when + * called with argument init. Format: + * $expirytime $mac $ip $hostname $clientid # For all ipv4 leases + * duid $server-duid # If DHCPv6 is present + * $expirytime $iaid $ip $hostname $clientduid # For all ipv6 leases */ + + /* Traversing the ipv4 leases */ + for (i = 0; i < virJSONValueArraySize(leases_array_new); i++) { + lease_tmp = virJSONValueArrayGet(leases_array_new, i); + if (!(ip_tmp = virJSONValueObjectGetString(lease_tmp, "ip-address"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("failed to parse json")); + goto cleanup; + } + if (!strchr(ip_tmp, ':')) { + virJSONValueObjectGetNumberLong(lease_tmp, "expiry-time", &expirytime); + printf("%lld %s %s %s %s\n", + expirytime, + virJSONValueObjectGetString(lease_tmp, "mac-address"), + virJSONValueObjectGetString(lease_tmp, "ip-address"), + EMPTY_STR(virJSONValueObjectGetString(lease_tmp, "hostname")), + EMPTY_STR(virJSONValueObjectGetString(lease_tmp, "client-id"))); + } + } + + /* Traversing the ipv6 leases */ + if (server_duid) { + printf("duid %s\n", server_duid); + for (i = 0; i < virJSONValueArraySize(leases_array_new); i++) { + lease_tmp = virJSONValueArrayGet(leases_array_new, i); + if (!(ip_tmp = virJSONValueObjectGetString(lease_tmp, "ip-address"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("failed to parse json")); + goto cleanup; + } + if (strchr(ip_tmp, ':')) { + virJSONValueObjectGetNumberLong(lease_tmp, "expiry-time", &expirytime); + printf("%lld %s %s %s %s\n", + expirytime, + virJSONValueObjectGetString(lease_tmp, "iaid"), + virJSONValueObjectGetString(lease_tmp, "ip-address"), + EMPTY_STR(virJSONValueObjectGetString(lease_tmp, "hostname")), + EMPTY_STR(virJSONValueObjectGetString(lease_tmp, "client-id"))); + } + } + } + + break; + + case VIR_LEASE_ACTION_OLD: + case VIR_LEASE_ACTION_ADD: if (virJSONValueArrayAppend(leases_array_new, lease_new) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to create json")); goto cleanup; } lease_new = NULL; - } - if (!(leases_str = virJSONValueToString(leases_array_new, true))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("empty json array")); - goto cleanup; - } + default: + if (!(leases_str = virJSONValueToString(leases_array_new, true))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("empty json array")); + goto cleanup; + } - /* Write to file */ - if (virFileRewrite(custom_lease_file, 0644, - customLeaseRewriteFile, &leases_str) < 0) - goto cleanup; + /* Write to file */ + if (virFileRewrite(custom_lease_file, 0644, + customLeaseRewriteFile, &leases_str) < 0) + goto cleanup; + } rv = EXIT_SUCCESS; -- 2.1.0

Untangle a few conditions into a case statement and improve reporting of invaid commands. --- src/network/leaseshelper.c | 100 ++++++++++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 42 deletions(-) diff --git a/src/network/leaseshelper.c b/src/network/leaseshelper.c index 806e82d..96a1de2 100644 --- a/src/network/leaseshelper.c +++ b/src/network/leaseshelper.c @@ -180,7 +180,11 @@ main(int argc, char **argv) ip = argv[3]; mac = argv[2]; - action = virLeaseActionTypeFromString(argv[1]); + + if ((action = virLeaseActionTypeFromString(argv[1])) < 0) { + fprintf(stderr, _("Unsupported action: %s\n"), argv[1]); + exit(EXIT_FAILURE); + } /* In case hostname is known, it is the 5th argument */ if (argc == 5) @@ -230,9 +234,47 @@ main(int argc, char **argv) goto cleanup; } - if (action == VIR_LEASE_ACTION_ADD || - action == VIR_LEASE_ACTION_OLD || - action == VIR_LEASE_ACTION_DEL) { + switch ((enum virLeaseActionFlags) action) { + case VIR_LEASE_ACTION_ADD: + case VIR_LEASE_ACTION_OLD: + if (!mac) + break; + delete = true; + + /* Create new lease */ + if (!(lease_new = virJSONValueNewObject())) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("failed to create json")); + goto cleanup; + } + + if (!exptime || + virStrToLong_ll(exptime, NULL, 10, &expirytime) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to convert lease expiry time to long long: %s"), + NULLSTR(exptime)); + goto cleanup; + } + + if (iaid && virJSONValueObjectAppendString(lease_new, "iaid", iaid) < 0) + goto cleanup; + if (ip && virJSONValueObjectAppendString(lease_new, "ip-address", ip) < 0) + goto cleanup; + if (mac && virJSONValueObjectAppendString(lease_new, "mac-address", mac) < 0) + goto cleanup; + if (hostname && virJSONValueObjectAppendString(lease_new, "hostname", hostname) < 0) + goto cleanup; + if (clientid && virJSONValueObjectAppendString(lease_new, "client-id", clientid) < 0) + goto cleanup; + if (server_duid && virJSONValueObjectAppendString(lease_new, "server-duid", server_duid) < 0) + goto cleanup; + if (expirytime && virJSONValueObjectAppendNumberLong(lease_new, "expiry-time", expirytime) < 0) + goto cleanup; + + break; + + case VIR_LEASE_ACTION_DEL: + delete = true; /* Custom ipv6 leases *will not* be created if the env-var DNSMASQ_MAC * is not set. In the special case, when the $(interface).status file * is not already present and dnsmasq is (re)started, the corresponding @@ -246,46 +288,15 @@ main(int argc, char **argv) * the new lease will be created irrespective of whether the MACID is * known or not. */ - if (mac || action == VIR_LEASE_ACTION_DEL) { + if (mac) { /* Delete the corresponding lease, if it already exists */ delete = true; - if (action == VIR_LEASE_ACTION_ADD || - action == VIR_LEASE_ACTION_OLD) { - /* Create new lease */ - if (!(lease_new = virJSONValueNewObject())) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("failed to create json")); - goto cleanup; - } - - if (!exptime || - virStrToLong_ll(exptime, NULL, 10, &expirytime) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to convert lease expiry time to long long: %s"), - NULLSTR(exptime)); - goto cleanup; - } - - if (iaid && virJSONValueObjectAppendString(lease_new, "iaid", iaid) < 0) - goto cleanup; - if (ip && virJSONValueObjectAppendString(lease_new, "ip-address", ip) < 0) - goto cleanup; - if (mac && virJSONValueObjectAppendString(lease_new, "mac-address", mac) < 0) - goto cleanup; - if (hostname && virJSONValueObjectAppendString(lease_new, "hostname", hostname) < 0) - goto cleanup; - if (clientid && virJSONValueObjectAppendString(lease_new, "client-id", clientid) < 0) - goto cleanup; - if (server_duid && virJSONValueObjectAppendString(lease_new, "server-duid", server_duid) < 0) - goto cleanup; - if (expirytime && virJSONValueObjectAppendNumberLong(lease_new, "expiry-time", expirytime) < 0) - goto cleanup; - } } - } else if (action != VIR_LEASE_ACTION_INIT) { - fprintf(stderr, _("Unsupported action: %s\n"), - virLeaseActionTypeToString(action)); - exit(EXIT_FAILURE); + break; + + case VIR_LEASE_ACTION_INIT: + case VIR_LEASE_ACTION_LAST: + break; } if (!(leases_array_new = virJSONValueNewArray())) { @@ -429,7 +440,8 @@ main(int argc, char **argv) } lease_new = NULL; - default: + /* fallthrough */ + case VIR_LEASE_ACTION_DEL: if (!(leases_str = virJSONValueToString(leases_array_new, true))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("empty json array")); @@ -440,6 +452,10 @@ main(int argc, char **argv) if (virFileRewrite(custom_lease_file, 0644, customLeaseRewriteFile, &leases_str) < 0) goto cleanup; + break; + + case VIR_LEASE_ACTION_LAST: + break; } rv = EXIT_SUCCESS; -- 2.1.0

On 11/20/2014 06:58 AM, Peter Krempa wrote:
Untangle a few conditions into a case statement and improve reporting of invaid commands.
s/invaid/invalid/ (I may be too late in reporting this, though) -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 11/20/2014 06:58 AM, Peter Krempa wrote:
Untangle a few conditions into a case statement and improve reporting of invaid commands. --- src/network/leaseshelper.c | 100 ++++++++++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 42 deletions(-)
+ switch ((enum virLeaseActionFlags) action) { + case VIR_LEASE_ACTION_ADD: + case VIR_LEASE_ACTION_OLD:
Spacing looks odd. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

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 - tests/networkxml2confdata/nat-network-dns-srv-record.conf | 1 - tests/networkxml2confdata/nat-network-dns-txt-record.conf | 1 - tests/networkxml2confdata/nat-network.conf | 1 - tests/networkxml2confdata/netboot-network.conf | 1 - tests/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 6ecbc37..9355003 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))) @@ -1183,14 +1180,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 decc08f..2f801ee 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 f270a43..922eb7a 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 f0a9660..064515f 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 6ba34ae..fbdf75a 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 e60411b..08ed672 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 16e7dca..d7de422 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 ff53f4e..44ed6bd 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 ced4123..34d5b17 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 8ea1f67..4b8f0cc 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 4774a92..61a025c 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 4f1d934..267513f 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; \ -- 2.1.0

On Thu, Nov 20, 2014 at 7:28 PM, Peter Krempa <pkrempa@redhat.com> wrote:
Nehal J Wani (1): leaseshelper: improvements to support all events
Peter Krempa (2): leaseshelper: Refactor control flow network: dnsmasq: Don't format lease file path
src/network/bridge_driver.c | 16 +- src/network/bridge_driver.h | 3 - src/network/leaseshelper.c | 246 +++++++++++++++------ 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 - 13 files changed, 181 insertions(+), 105 deletions(-)
-- 2.1.0
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Ping! -- Nehal J Wani

On 20.11.2014 14:58, Peter Krempa wrote:
Nehal J Wani (1): leaseshelper: improvements to support all events
Peter Krempa (2): leaseshelper: Refactor control flow network: dnsmasq: Don't format lease file path
src/network/bridge_driver.c | 16 +- src/network/bridge_driver.h | 3 - src/network/leaseshelper.c | 246 +++++++++++++++------ 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 - 13 files changed, 181 insertions(+), 105 deletions(-)
ACK series. Michal

On 12/03/14 14:13, Michal Privoznik wrote:
On 20.11.2014 14:58, Peter Krempa wrote:
Nehal J Wani (1): leaseshelper: improvements to support all events
Peter Krempa (2): leaseshelper: Refactor control flow network: dnsmasq: Don't format lease file path
src/network/bridge_driver.c | 16 +- src/network/bridge_driver.h | 3 - src/network/leaseshelper.c | 246 +++++++++++++++------ 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 - 13 files changed, 181 insertions(+), 105 deletions(-)
ACK series.
Pushed; Thanks. Peter
participants (4)
-
Eric Blake
-
Michal Privoznik
-
Nehal J Wani
-
Peter Krempa