summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiklas Hambüchen <mail@nh2.me>2023-11-10 18:46:54 +0100
committerJörg Thalheim <Mic92@users.noreply.github.com>2023-11-10 22:29:12 +0100
commitdcceeb9868245a792622c7fb4157bf676677c497 (patch)
treedf4cc1ec8cb7c379f43164125756ee0f08d667a2
parent5d73d954cdec0a507b2d93b9dedd1aef890e3f2a (diff)
downloadnixpkgs-dcceeb9868245a792622c7fb4157bf676677c497.tar
nixpkgs-dcceeb9868245a792622c7fb4157bf676677c497.tar.gz
nixpkgs-dcceeb9868245a792622c7fb4157bf676677c497.tar.bz2
nixpkgs-dcceeb9868245a792622c7fb4157bf676677c497.tar.lz
nixpkgs-dcceeb9868245a792622c7fb4157bf676677c497.tar.xz
nixpkgs-dcceeb9868245a792622c7fb4157bf676677c497.tar.zst
nixpkgs-dcceeb9868245a792622c7fb4157bf676677c497.zip
manual: tests: Describe how to port-forward into test VMs
-rw-r--r--nixos/doc/manual/development/running-nixos-tests-interactively.section.md16
1 files changed, 16 insertions, 0 deletions
diff --git a/nixos/doc/manual/development/running-nixos-tests-interactively.section.md b/nixos/doc/manual/development/running-nixos-tests-interactively.section.md
index 54002941d63..a816213f37d 100644
--- a/nixos/doc/manual/development/running-nixos-tests-interactively.section.md
+++ b/nixos/doc/manual/development/running-nixos-tests-interactively.section.md
@@ -57,6 +57,22 @@ using:
 Once the connection is established, you can enter commands in the socat terminal
 where socat is running.
 
+## Port forwarding to NixOS test VMs {#sec-nixos-test-port-forwarding}
+
+If your test has only a single VM, you may use e.g.
+
+```ShellSession
+$ QEMU_NET_OPTS="hostfwd=tcp:127.0.0.1:2222-127.0.0.1:22" ./result/bin/nixos-test-driver
+```
+
+to port-forward a port in the VM (here `22`) to the host machine (here port `2222`).
+
+This naturally does not work when multiple machines are involved,
+since a single port on the host cannot forward to multiple VMs.
+
+If the test defines multiple machines, you may opt to _temporarily_ set
+`virtualisation.forwardPorts` in the test definition for debugging.
+
 ## Reuse VM state {#sec-nixos-test-reuse-vm-state}
 
 You can re-use the VM states coming from a previous run by setting the