Hide Forgot
Description of problem: real rng device(QNG PQ4000KU) can not work properly in guest Version-Release number of selected component (if applicable): kernel: 3.10.0-18.el7.x86_64 qemu: qemu-kvm-1.5.3-2.el7.x86_64 How reproducible: 100% Steps to Reproduce: 1.boot guest #/usr/libexec/qemu-kvm ...\ -object rng-random,filename=/dev/ttyUSB0,id=rng0 \ -device virtio-rng-pci,rng=rng0 2.check rng device in guest #cat /sys/devices/virtual/misc/hw_random/rng_available #cat /sys/devices/virtual/misc/hw_random/rng_current #cat /dev/hwrng 3. Actual results: 2.has no output Expected results: real rng device can work properly in guest. Additional info:
As discussed on irc, even 'cat /dev/ttyUSB1' on the host doesn't give any output, so it's something that's lacking on this particular rng model, rather than on qemu. For this model of rng, a program will have to be written that reads from the rng's interface and pushes that data somewhere. This 'somewhere' can be a socket, for qemu to pick up the data, or to the kernel, to feed into the kernel's entropy pool. For testing, both methods should be available, and we'll use this bug to track the writing of a program that reads from the rng and writes to a socket. The best solution, of course, is to feed to the kernel's entropy pool, so that the qemu default of sending the host's /dev/random data to the guest doesn't have to change, and remains the most secure option. I don't agree this should be a TestBlocker - the real test should be whether the guest receives data from the host. The source of the data should not matter so much to hold up testing / builds.
We can use example programs to read random data from device, what we need to do is writing a program to read data by API, then write the data to a socket. ./read-data // create socket1, listen 1024 port of 10.66.4.212 // launch qemu, it will connect the socket1 // accept the connection // read random data and send to remote ./x86_64-softmmu/qemu-system-x86_64 -vnc :0 -snapshot /images/RHEL-Server-6.4-64-virtio.qcow2 -monitor stdio --enable-kvm -m 2000 -chardev socket,host=10.66.4.212,port=1024,id=chr0 -object rng-egd,chardev=chr0,id=rng0 -device virtio-rng-pci,rng=rng0
Created attachment 797225 [details] Read random data from rng device by libqwqng API (data will be sent to remote socket) (RandBytes.cpp should be added to libqwqng-1.3.5/examples/ to compile) localhost) # ./randbytes remote-host)# ./x86_64-softmmu/qemu-system-x86_64 -vnc :0 -snapshot /images/RHEL-Server-6.4-64-virtio.qcow2 -monitor stdio --enable-kvm -m 2000 -chardev socket,host=10.66.4.212,port=1024,id=chr0 -object rng-egd,chardev=chr0,id=rng0 -device virtio-rng-pci,rng=rng0 guest) # dd if=/dev/hwrng of=/dev/stdout tested: works well