diff --git a/artiq/windows/install.nix b/artiq/windows/install.nix index cdf3955..22c5ae0 100644 --- a/artiq/windows/install.nix +++ b/artiq/windows/install.nix @@ -52,7 +52,7 @@ stdenv.mkDerivation { set -e -m ${qemu.qemu-img} create -f qcow2 c.img ${diskImageSize} - ${qemu.runQemu false [ + ${qemu.runQemu false [] [ "-boot" "order=d" "-drive" "file=c.img,index=0,media=disk,cache=unsafe" "-drive" "file=$out/data/windows.iso,index=1,media=cdrom,cache=unsafe" @@ -65,7 +65,7 @@ stdenv.mkDerivation { #!/usr/bin/env bash set -e -m - ${qemu.runQemu false [ + ${qemu.runQemu false [] [ "-boot" "order=c" "-drive" "file=c.img,index=0,media=disk" ]} & diff --git a/artiq/windows/qemu.nix b/artiq/windows/qemu.nix index 5601160..0cd52c4 100644 --- a/artiq/windows/qemu.nix +++ b/artiq/windows/qemu.nix @@ -9,17 +9,24 @@ with pkgs; let qemu-img = "${qemu_kvm}/bin/qemu-img"; - runQemu = isolateNetwork: extraArgs: + runQemu = isolateNetwork: forwardedPorts: extraArgs: let restrict = if isolateNetwork then "on" else "off"; + nc = "${netcat}/bin/nc"; + # use netcat instead of `tcp:…` to allow multiple connections + guestfwds = + builtins.concatStringsSep "" + (map ({ listenAddr, targetAddr, port }: + ",guestfwd=tcp:${listenAddr}:${toString port}-cmd:${nc}\\ ${targetAddr}\\ ${toString port}" + ) forwardedPorts); args = [ "-enable-kvm" "-m" qemuMem "-bios" "${OVMF.fd}/FV/OVMF.fd" - "-netdev" "user,id=n1,restrict=${restrict},hostfwd=tcp::2022-:22" + "-netdev" "user,id=n1,net=192.168.1.0/24,restrict=${restrict},hostfwd=tcp::2022-:22${guestfwds}" "-device" "e1000,netdev=n1" ]; argStr = builtins.concatStringsSep " " (args ++ extraArgs); diff --git a/artiq/windows/run-test.nix b/artiq/windows/run-test.nix index 266b5af..3c58f52 100644 --- a/artiq/windows/run-test.nix +++ b/artiq/windows/run-test.nix @@ -18,6 +18,13 @@ let ssh = cmd: qemu.ssh (escape cmd); scp = qemu.scp; condaEnv = "artiq-env"; + tcpPorts = [ 1380 1381 1382 1383 ]; + forwardedPorts = + map (port: { + listenAddr = "192.168.1.50"; + targetAddr = "192.168.1.50"; + inherit port; + }) tcpPorts; in stdenv.mkDerivation { @@ -31,7 +38,7 @@ stdenv.mkDerivation { cat > $out/bin/run.sh << EOF # +1 day from last modification of the disk image CLOCK=$(date -Is -d @$(expr $(stat -c %Y ${diskImage}) + 86400)) - ${qemu.runQemu true [ + ${qemu.runQemu true forwardedPorts [ "-boot" "order=c" "-snapshot" "-drive" "file=${diskImage},index=0,media=disk,cache=unsafe"