Bug 1007664 - real rng device(QNG PQ4000KU) can not work properly in guest
real rng device(QNG PQ4000KU) can not work properly in guest
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm (Show other bugs)
7.0
x86_64 Linux
urgent Severity high
: rc
: ---
Assigned To: Amos Kong
Virtualization Bugs
:
Depends On:
Blocks: 1008263
  Show dependency treegraph
 
Reported: 2013-09-13 01:03 EDT by Xu Han
Modified: 2017-09-07 14:38 EDT (History)
10 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1008263 (view as bug list)
Environment:
Last Closed: 2013-09-13 05:41:41 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Read random data from rng device by libqwqng API (data will be sent to remote socket) (1.54 KB, text/x-c++src)
2013-09-13 05:41 EDT, Amos Kong
no flags Details

  None (edit)
Description Xu Han 2013-09-13 01:03:06 EDT
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:
Comment 4 Amit Shah 2013-09-13 01:24:54 EDT
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.
Comment 6 Amos Kong 2013-09-13 05:00:57 EDT
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
Comment 7 Amos Kong 2013-09-13 05:41:16 EDT
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

Note You need to log in before you can comment on or make changes to this bug.