Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
3  
Why do you want to do this? The guest OS should have its own random number generator... – voretaq7 Oct 12 '12 at 15:50
    
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. – adric Oct 12 '12 at 22:08

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.

share|improve this answer
    
Read the first paragraph, then. – Michael Hampton Oct 12 '12 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? – Dustin Kirkland Oct 12 '12 at 20:50
    
Now you edit your question to clarify it. – Michael Hampton Oct 12 '12 at 20:55
    
Yes, I am well aware of virtio-rng. And I'm well aware that a guest has its own /dev/urandom. What I want, however, as my question asks, is to literally pass the host's /dev/urandom to the guest and have it readable as a serial device. – Dustin Kirkland Oct 15 '12 at 14:05
1  
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. – Dustin Kirkland Oct 17 '12 at 2:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.