From 5241bb1d5e088ec3906cbc32afcdeb68953badef Mon Sep 17 00:00:00 2001 From: aszlig Date: Sun, 16 Feb 2014 16:53:02 +0100 Subject: [PATCH] vm/windows: Avoid shadowing the Nix store. This is done by putting the non-initrd /nix/store into a subdirectory, which we then chroot to and pass along the SSH command. Also, we now collect the exit code after the chroot command and power off the VM thereafter, because the store is no longer shadowed and we have still access to the busybox inside the initrd. Signed-off-by: aszlig --- .../vm/windows/controller/default.nix | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/pkgs/build-support/vm/windows/controller/default.nix b/pkgs/build-support/vm/windows/controller/default.nix index 3d763468113..60ec1d4783a 100644 --- a/pkgs/build-support/vm/windows/controller/default.nix +++ b/pkgs/build-support/vm/windows/controller/default.nix @@ -8,8 +8,7 @@ let inherit (import {}) lib stdenv writeScript vmTools makeInitrd; - inherit (import {}) samba vde2 busybox openssh; - inherit (import {}) socat netcat coreutils gzip; + inherit (import {}) samba vde2 openssh socat netcat coreutils gzip; preInitScript = writeScript "preinit.sh" '' #!${vmTools.initrdUtils}/bin/ash -e @@ -26,7 +25,9 @@ let insmod $i done - mkdir -p /tmp /dev + mkdir -p /dev /fs + + mount -t tmpfs none /dev mknod /dev/null c 1 3 mknod /dev/zero c 1 5 mknod /dev/random c 1 8 @@ -36,22 +37,31 @@ let ifconfig lo up ifconfig eth0 up 192.168.0.2 - mkdir -p /xchg /nix/store /etc /var/run /var/log + mount -t tmpfs none /fs + mkdir -p /fs/nix/store /fs/xchg /fs/dev /fs/sys /fs/proc /fs/etc /fs/tmp - cat > /etc/passwd < /fs/etc/passwd < /fs/xchg/in-vm-exit - mount -t 9p \ - -o trans=virtio,version=9p2000.L,msize=262144,cache=loose \ - store /nix/store - - exec "$command" + poweroff -f ''; initrd = makeInitrd { @@ -80,7 +90,8 @@ let # Loop forever, because this VM is going to be killed. ${loopForever} '' else '' - ${coreutils}/bin/mkdir -p /etc/samba /etc/samba/private /var/lib/samba + ${coreutils}/bin/mkdir -p /etc/samba /etc/samba/private \ + /var/lib/samba /var/log /var/run ${coreutils}/bin/cat > /etc/samba/smb.conf <