windows tests: forward ports

This commit is contained in:
Astro 2019-04-18 17:34:09 +02:00
parent 82dcdaeec8
commit e5125a85e8
3 changed files with 19 additions and 5 deletions

View File

@ -52,7 +52,7 @@ stdenv.mkDerivation {
set -e -m set -e -m
${qemu.qemu-img} create -f qcow2 c.img ${diskImageSize} ${qemu.qemu-img} create -f qcow2 c.img ${diskImageSize}
${qemu.runQemu false [ ${qemu.runQemu false [] [
"-boot" "order=d" "-boot" "order=d"
"-drive" "file=c.img,index=0,media=disk,cache=unsafe" "-drive" "file=c.img,index=0,media=disk,cache=unsafe"
"-drive" "file=$out/data/windows.iso,index=1,media=cdrom,cache=unsafe" "-drive" "file=$out/data/windows.iso,index=1,media=cdrom,cache=unsafe"
@ -65,7 +65,7 @@ stdenv.mkDerivation {
#!/usr/bin/env bash #!/usr/bin/env bash
set -e -m set -e -m
${qemu.runQemu false [ ${qemu.runQemu false [] [
"-boot" "order=c" "-boot" "order=c"
"-drive" "file=c.img,index=0,media=disk" "-drive" "file=c.img,index=0,media=disk"
]} & ]} &

View File

@ -9,17 +9,24 @@ with pkgs;
let let
qemu-img = "${qemu_kvm}/bin/qemu-img"; qemu-img = "${qemu_kvm}/bin/qemu-img";
runQemu = isolateNetwork: extraArgs: runQemu = isolateNetwork: forwardedPorts: extraArgs:
let let
restrict = restrict =
if isolateNetwork if isolateNetwork
then "on" then "on"
else "off"; 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 = [ args = [
"-enable-kvm" "-enable-kvm"
"-m" qemuMem "-m" qemuMem
"-bios" "${OVMF.fd}/FV/OVMF.fd" "-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" "-device" "e1000,netdev=n1"
]; ];
argStr = builtins.concatStringsSep " " (args ++ extraArgs); argStr = builtins.concatStringsSep " " (args ++ extraArgs);

View File

@ -18,6 +18,13 @@ let
ssh = cmd: qemu.ssh (escape cmd); ssh = cmd: qemu.ssh (escape cmd);
scp = qemu.scp; scp = qemu.scp;
condaEnv = "artiq-env"; 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 in
stdenv.mkDerivation { stdenv.mkDerivation {
@ -31,7 +38,7 @@ stdenv.mkDerivation {
cat > $out/bin/run.sh << EOF cat > $out/bin/run.sh << EOF
# +1 day from last modification of the disk image # +1 day from last modification of the disk image
CLOCK=$(date -Is -d @$(expr $(stat -c %Y ${diskImage}) + 86400)) CLOCK=$(date -Is -d @$(expr $(stat -c %Y ${diskImage}) + 86400))
${qemu.runQemu true [ ${qemu.runQemu true forwardedPorts [
"-boot" "order=c" "-boot" "order=c"
"-snapshot" "-snapshot"
"-drive" "file=${diskImage},index=0,media=disk,cache=unsafe" "-drive" "file=${diskImage},index=0,media=disk,cache=unsafe"