[Nix-dev] vmTools.runInLinuxImage with ubuntu 1204 image blocks on getrandom()

Maarten Hoogendoorn maarten at moretea.nl
Tue Jul 26 15:43:33 CEST 2016


OK, fixed this problem by adding the virtio_rng device to the kernel and
qemu opts, see below.

Would a PR to make these additions the default in
build-support/vm/default.nix be appreciated?

with import <nixpkgs> {}; with pkgs;
let
 script = ''
   # /dev/urandom works fine
   dd if=/dev/urandom of=/dev/null bs=1M count=1

   # /dev/random only works if virtio_rng is enabled.
   dd if=/dev/random of=/dev/null bs=1M count=1
 '';
  img = runCommand "nix-binary-tarball-test" {
    diskImage = vmTools.diskImages.ubuntu1204x86_64;
    QEMU_OPTS = "-device virtio-rng-pci";
   } script;
   runCustomInImage = vmTools.override {
     rootModules = [ "virtio_rng" "virtio_pci" "virtio_blk"
"virtio_balloon" "ext4" "unix" "9p" "9pnet_virtio" "rtc_cmos" ];
   };
in
   runCustomInImage.runInLinuxImage img #<- does work
#  vmTools.runInLinuxImage img # < - does not work

2016-07-16 15:39 GMT+02:00 Maarten Hoogendoorn <maarten at moretea.nl>:

> Hi there,
>
> I'm trying to run some tests on a binary program on ubuntu 1204 using
> vmTools.runInLinuxImage. It just blocks on getrandom().
>
> I've created a minimal reproducible example:
>
> with import <nixpkgs> {}; with pkgs;
> let
>  script = ''
>    # /dev/urandom works fine
>    dd if=/dev/urandom of=/dev/null bs=1M count=1
>
>   # /dev/random does not work!
>    ${pkgs.strace}/bin/strace \
>      dd if=/dev/random of=/dev/null bs=1M count=1
>  '';
>   img = runCommand "nix-binary-tarball-test" {
>     diskImage = vmTools.diskImages.ubuntu1204x86_64;
> #    QEMU_OPTS = "-device virtio-rng-pci";
>    } script;
> in
>   vmTools.runInLinuxImage img
>
> I read somewhere that adding a virtio-rng-pci device could solve this,
> but it made no difference.
>
> Could someone confirm this behavior? And maybe one of you has an idea on
> how to fix this.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.science.uu.nl/pipermail/nix-dev/attachments/20160726/a7da2541/attachment.html>


More information about the nix-dev mailing list