diff --git a/pkgs/build-support/vm/default.nix b/pkgs/build-support/vm/default.nix index 18d13fd9ad4..54046ee1894 100644 --- a/pkgs/build-support/vm/default.nix +++ b/pkgs/build-support/vm/default.nix @@ -211,9 +211,11 @@ rec { qemuCommandLinux = '' - qemu-system-x86_64 \ + ${kvm}/bin/qemu-system-x86_64 \ -nographic -no-reboot \ - -net nic,model=virtio -chardev socket,id=samba,path=./samba -net user,guestfwd=tcp:10.0.2.4:139-chardev:samba \ + -net nic,model=virtio \ + -chardev socket,id=samba,path=./samba \ + -net user,guestfwd=tcp:10.0.2.4:139-chardev:samba \ -drive file=$diskImage,if=virtio,boot=on,cache=writeback,werror=report \ -kernel ${kernel}/bzImage \ -initrd ${initrd}/initrd \ @@ -222,31 +224,39 @@ rec { ''; + startSamba = + let sambaScript = writeScript "run-smbd" "while ${samba}/sbin/smbd -s $TMPDIR/smb.conf; do true; done"; in + '' + cat > $TMPDIR/smb.conf < /dev/null 2>&1 & + while [ ! -e ./samba ]; do sleep 0.1; done # ugly + ''; + + vmRunCommand = qemuCommand: writeText "vm-run" '' export > saved-env - PATH=${coreutils}/bin:${kvm}/bin + PATH=${coreutils}/bin diskImage=''${diskImage:-/dev/null} eval "$preVM" - cat > smb.conf < /dev/null 2>&1 & - while [ ! -e ./samba ]; do sleep 0.1; done # ugly + ${startSamba} ${qemuCommand} EOF @@ -330,7 +339,7 @@ rec { qemuCommandGeneric = '' - qemu-system-x86_64 \ + ${kvm}/bin/qemu-system-x86_64 \ -nographic -no-reboot \ -smb $(pwd) -hda $diskImage \ $QEMU_OPTS