Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

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
    
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. –  Michael Hampton Oct 16 '12 at 18:42

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.