From e22dc636a8d5c4cd1c0fc06356049bcde50c793a Mon Sep 17 00:00:00 2001 From: David Fairbrother Date: Fri, 20 Dec 2024 14:09:48 +0000 Subject: [PATCH] Wait for network config before activating libvirt socket Wait for the network configuration to complete before trying to activate the libvirt socket. This prevents systemd binding to the specified IP, then having the interface either come up or reconfigure. Due to the race-y nature of the network config (at least with NetworkManager) and the socket activation this would mean <50% of the machines rebooting would be affected. After this point the socket is "up" from systemd's POV however anything (including telnet) trying to open the port will find it closed until an administrator restarts the socket unit --- templates/socket.j2 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/templates/socket.j2 b/templates/socket.j2 index 04f7476..bfbc2f5 100644 --- a/templates/socket.j2 +++ b/templates/socket.j2 @@ -5,3 +5,9 @@ ListenStream={{ _libvirt_listen_stream }} # FreeBind is recommended when listening on a specific address: # https://www.freedesktop.org/software/systemd/man/systemd.socket.html#FreeBind= FreeBind=true + +[Unit] +# Wait for network to be configured so we can bind to a specific address +# without it changing underneath us if it gets reconfigured +Wants=network-online.target +After=network-online.target