From de44c89d768f02f957ad038d1bf83dc36ce074fb Mon Sep 17 00:00:00 2001 From: Astro Date: Sun, 13 Oct 2024 03:22:12 +0200 Subject: [PATCH] lib/runner: add macvtap config checks --- lib/runner.nix | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/runner.nix b/lib/runner.nix index 20999c8a..a7182886 100644 --- a/lib/runner.nix +++ b/lib/runner.nix @@ -82,17 +82,21 @@ pkgs.buildPackages.runCommand "microvm-${microvmConfig.hypervisor}-${microvmConf ${lib.concatMapStringsSep " " (interface: lib.optionalString ( interface.type == "macvtap" && - interface ? id && - (interface.macvtap.link or null) != null && - (interface.macvtap.mode or null) != null - ) '' - echo "${builtins.concatStringsSep " " [ - interface.id - interface.mac - interface.macvtap.link - (builtins.toString interface.macvtap.mode) - ]}" >> $out/share/microvm/macvtap-interfaces - '') microvmConfig.interfaces} + interface ? id + ) ( + if interface.macvtap.link or null == null + then throw "microvm.interface's macvtap.link must be specified for id=${interface.id}" + else if interface.macvtap.mode or null == null + then throw "microvm.interface's macvtap.mode must be specified for id=${interface.id}" + else '' + echo "${builtins.concatStringsSep " " [ + interface.id + interface.mac + interface.macvtap.link + (builtins.toString interface.macvtap.mode) + ]}" >> $out/share/microvm/macvtap-interfaces + '' + )) microvmConfig.interfaces} ${lib.concatMapStrings ({ tag, socket, source, proto, ... }: