networking tests
This commit is contained in:
1 parent
f1622fae84
commit
5b2621acbc
4 files changed
+134
-3
No files matched your search
@@ -1,5 +1,6 @@
|
||||
# Static evaluation check for the host module's two networking modes (NAT
|
||||
# and bridged) and the guest's mode-agnostic NIC configuration.
|
||||
# and bridged), its QEMU command line and unit sandbox, and the guest's
|
||||
# mode-agnostic NIC configuration.
|
||||
#
|
||||
# Nothing here is built or booted: the check evaluates services.hermenix
|
||||
# (modules/host.nix) in both modes plus guest/common.nix, and asserts on the
|
||||
@@ -142,6 +143,8 @@ let
|
||||
brInput = br.config.networking.firewall.extraInputRules;
|
||||
brForward = br.config.networking.firewall.extraForwardRules;
|
||||
|
||||
vm = nat.config.systemd.services."hermes-vm".serviceConfig;
|
||||
|
||||
hostResults = {
|
||||
# --- NAT mode: the original behaviour has to be unchanged ----------
|
||||
"nat: no bridged-mode bridge table" = !(natNft ? "hermenix-bridge");
|
||||
@@ -209,6 +212,33 @@ let
|
||||
brNetworks."11-vm-hermes".networkConfig.Bridge == "hermes-br";
|
||||
};
|
||||
|
||||
# The QEMU command line and the unit's sandbox, which the host VM test
|
||||
# (tests/host-vm-test.nix) cannot exercise without nested virtualization.
|
||||
vmResults = {
|
||||
"vm: qemu runs under kvm with smm" = has "-machine q35,accel=kvm,smm=on" vm.ExecStart;
|
||||
"vm: tap netdev wired to the guest NIC" =
|
||||
has "-netdev tap,id=net0,ifname=vm-hermes" vm.ExecStart
|
||||
&& has "-device virtio-net-pci,netdev=net0,mac=02:00:00:7e:00:01" vm.ExecStart;
|
||||
"vm: system and state disks attached" =
|
||||
has "id=system,format=raw" vm.ExecStart && has "id=state,format=raw" vm.ExecStart;
|
||||
"vm: qmp socket exposed for hermenix vm control" =
|
||||
has "qmp unix:/run/hermes-vm/qmp.sock" vm.ExecStart;
|
||||
"vm: default devices (rng, vsock, qga) present" =
|
||||
has "-device virtio-rng-pci" vm.ExecStart
|
||||
&& has "-device vhost-vsock-pci,guest-cid=77" vm.ExecStart
|
||||
&& has "name=org.qemu.guest_agent.0" vm.ExecStart;
|
||||
"vm: optional devices off by default" =
|
||||
!(has "-vga" vm.ExecStart) && !(has "virtio-balloon" vm.ExecStart);
|
||||
"vm: sandbox hardening intact" =
|
||||
vm.ProtectSystem == "strict" && vm.NoNewPrivileges == true && vm.DevicePolicy == "closed";
|
||||
"vm: device allowlist covers kvm, tun, vsock" =
|
||||
vm.DeviceAllow == [
|
||||
"/dev/kvm rw"
|
||||
"/dev/net/tun rw"
|
||||
"/dev/vhost-vsock rw"
|
||||
];
|
||||
};
|
||||
|
||||
# Guest module: must produce one NIC config that works in both modes. #
|
||||
# Evaluated against the full NixOS option set. #
|
||||
guest = lib.evalModules {
|
||||
@@ -239,7 +269,7 @@ let
|
||||
];
|
||||
};
|
||||
|
||||
results = hostResults // guestResults;
|
||||
results = hostResults // vmResults // guestResults;
|
||||
|
||||
failing = builtins.filter (n: !results.${n}) (builtins.attrNames results);
|
||||
in
|
||||
|
||||
Reference in new issue
Block a user