[PATCH 1/5] bridge_driver: Set @dnsmasqStarted only after successful dnsmasq spawn

Michal Privoznik mprivozn at redhat.com
Tue Aug 9 13:13:53 UTC 2022


The networkStartNetworkVirtual() function handles starting of
networks of different forward types (none, nat, route, open).
And as a part of startup process dnsmasq might be spawned but
doesn't have to be (depending on the network configuration). The
@dnsmasqStarted variable is supposed to track whether dnsmasq was
started or not (so that it can be killed when starting network
fails after it was started). But the variable is set even when
the code decided not to start it.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/network/bridge_driver.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 11696a9459..7ad9f278a2 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -2052,11 +2052,12 @@ networkStartNetworkVirtual(virNetworkDriverState *driver,
 
 
     /* start dnsmasq if there are any IP addresses (v4 or v6) */
-    if ((v4present || v6present) &&
-        networkStartDhcpDaemon(driver, obj) < 0)
-        goto error;
+    if (v4present || v6present) {
+        if (networkStartDhcpDaemon(driver, obj) < 0)
+            goto error;
 
-    dnsmasqStarted = true;
+        dnsmasqStarted = true;
+    }
 
     if (virNetDevBandwidthSet(def->bridge, def->bandwidth, true, true) < 0)
         goto error;
-- 
2.35.1



More information about the libvir-list mailing list