bridge_driver: Set @dnsmasqStarted only after successful dnsmasq spawn

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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Michal Privoznik 2022-08-09 13:48:34 +02:00
parent 684fa309ae
commit 42880776d8

View File

@ -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;