git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/scripted-networking: fix bridge setup when libvirtd uses socket activation
commit687aa06c70d75a5df9f9cccc1d77dcec75fdac2f authorvolth <volth@volth.com> dateMon 9 Mar 2020, 09:05 (7 years ago) parentd8664c7
1 file changed+12−6
nixos/modules/tasks/network-interfaces-scripted.nix+12−6
nixos/modules/tasks/network-interfaces-scripted.nix+12−6
@@ -291,13 +291,19 @@ let
291291
292292 ${optionalString config.virtualisation.libvirtd.enable ''
293293 # Enslave dynamically added interfaces which may be lost on nixos-rebuild
294− for uri in qemu:///system lxc:///; do
295− for dom in $(${pkgs.libvirt}/bin/virsh -c $uri list --name); do
296− ${pkgs.libvirt}/bin/virsh -c $uri dumpxml "$dom" | \
297− ${pkgs.xmlstarlet}/bin/xmlstarlet sel -t -m "//domain/devices/interface[@type='bridge'][source/@bridge='${n}'][target/@dev]" -v "concat('ip link set ',target/@dev,' master ',source/@bridge,';')" | \
298− ${pkgs.bash}/bin/bash
294+ #
295+ # if `libvirtd.service` is not running, do not use `virsh` which would try activate it via 'libvirtd.socket' and thus start it out-of-order.
296+ # `libvirtd.service` will set up bridge interfaces when it will start normally.
297+ #
298+ if ${pkgs.systemd}/bin/systemctl --quiet is-active 'libvirtd.service'; then
299+ for uri in qemu:///system lxc:///; do
300+ for dom in $(${pkgs.libvirt}/bin/virsh -c $uri list --name); do
301+ ${pkgs.libvirt}/bin/virsh -c $uri dumpxml "$dom" | \
302+ ${pkgs.xmlstarlet}/bin/xmlstarlet sel -t -m "//domain/devices/interface[@type='bridge'][source/@bridge='${n}'][target/@dev]" -v "concat('ip link set ',target/@dev,' master ',source/@bridge,';')" | \
303+ ${pkgs.bash}/bin/bash
304+ done
299305 done
300− done
306+ fi
301307 ''}
302308
303309 # Enable stp on the interface