1

I'd like to pass the host's /dev/urandom device through to a qemu/kvm virtual machine.

Note that /dev/urandom is not seekable, so it's not possible to pass it through as a block device using -hda, -fda, or -sda.

I would expect that I should be able to pass it through as a serial device, but I can't see to get that working. The guest needs to be able to read random data from some device in /dev where that random data is served by the host.

I am well aware of virtio-rng in modern versions of qemu/kvm and that's not quite what I'm looking for.

2
  • 4
    Why do you want to do this? The guest OS should have its own random number generator... Commented Oct 12, 2012 at 15:50
  • 1
    I can see a way to do what you are asking but it seems terribly kludgy: cron script pulls a buffers worth of data on host OS into a file (cat), copy it into a file which has a filesystem (dd mke2fs cp), which is loop mounted and shared into kvm to its guest ... yuck. Commented Oct 12, 2012 at 22:08

1 Answer 1

5

For /dev/urandom you don't need to do anything.

For /dev/random KVM provides a paravirtualized random number generator to its (Linux) guests. This allows guests to use the host's entropy pool. To use it, make sure that HW_RANDOM_VIRTIO is set in your guest kernel configuration.

7
  • Read the first paragraph, then. Commented Oct 12, 2012 at 20:29
  • Okay, so virtio-rng is a module. It loads via modprobe. Now what? Should that create a new device, or just populate /dev/random? Commented Oct 12, 2012 at 20:50
  • 1
    Sorry, but when you ask for something that sounds like a very bad idea here, you are going to be asked about it, and should be prepared to justify it. We have a very strong culture of "do it right or not at all" here. Commented Oct 16, 2012 at 18:42
  • 2
    The question asks, "Is it possible..." to do something very specific. I've read the documentation. I've contacted the QEMU upstream developers. I haven't found the answer I'm looking for, and so I turned to StackExchange. If the answer to my question is "no", and that can be justified, I'm perfectly fine with that. I'll gladly +1 that, and select as the correct answer. Commented Oct 17, 2012 at 2:09
  • 3
    Again, that's because you're almost certainly asking the wrong question and need to rethink what you're doing. Commented Oct 17, 2012 at 11:16

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.