[libvirt] [PATCH] wrong if-condition in bridge_driver.c, networkBuildDnsmasqArgv, dhcp host definition

I added a host definition to a network definition: <network> <name>Lokal</name> <uuid>2074f379-b82c-423f-9ada-305d8088daaa</uuid> <bridge name='virbr1' stp='on' delay='0' /> <ip address='192.168.180.1' netmask='255.255.255.0'> <dhcp> <range start='192.168.180.128' end='192.168.180.254' /> <host mac='23:74:00:03:42:02' name='somevm' ip='192.168.180.10' /> </dhcp> </ip> </network> But due to the wrong if-statement the argument --dhcp-hostsfile doesn't get added to the dnsmasq command. The patch below fixes it for me. diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 7d43ef5..4c64a74 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -524,7 +524,7 @@ networkBuildDnsmasqArgv(virNetworkObjPtr network, goto cleanup; } - if (networkSaveDnsmasqHostsfile(ipdef, dctx, false) < 0) { + if (networkSaveDnsmasqHostsfile(ipdef, dctx, false) == 0) { virCommandAddArgPair(cmd, "--dhcp-hostsfile", dctx->hostsfile->path); }

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 7d43ef5..4c64a74 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -524,7 +524,7 @@ networkBuildDnsmasqArgv(virNetworkObjPtr network, goto cleanup; }
- if (networkSaveDnsmasqHostsfile(ipdef, dctx, false) < 0) { + if (networkSaveDnsmasqHostsfile(ipdef, dctx, false) == 0) { virCommandAddArgPair(cmd, "--dhcp-hostsfile", dctx->hostsfile->path); }
Ouch. That was introduced by an oversight in 6e3e6db14fe80830cea3f427d8ff3fda7cc3f853 which changed return values of networkSaveDnsmasqHostsfile from 1 to 0 on success and from 0 to -1 on error. Thanks for the patch. ACK and pushed. Jirka

On 01/06/2011 10:05 AM, Jiri Denemark wrote:
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 7d43ef5..4c64a74 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -524,7 +524,7 @@ networkBuildDnsmasqArgv(virNetworkObjPtr network, goto cleanup; }
- if (networkSaveDnsmasqHostsfile(ipdef, dctx, false)< 0) { + if (networkSaveDnsmasqHostsfile(ipdef, dctx, false) == 0) { virCommandAddArgPair(cmd, "--dhcp-hostsfile", dctx->hostsfile->path); } Ouch. That was introduced by an oversight in 6e3e6db14fe80830cea3f427d8ff3fda7cc3f853 which changed return values of networkSaveDnsmasqHostsfile from 1 to 0 on success and from 0 to -1 on error.
Thanks for the patch.
ACK and pushed.
Dang! I just checked through the rest of the original commit again to make sure the sense of the other conditionals was changed correctly. Thanks to both of you for cleaning up my mess! :-/
participants (3)
-
Jiri Denemark
-
Kay Schubert
-
Laine Stump