Bug 1007664 - real rng device(QNG PQ4000KU) can not work properly in guest
Summary: real rng device(QNG PQ4000KU) can not work properly in guest
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm
Version: 7.0
Hardware: x86_64
OS: Linux
urgent
high
Target Milestone: rc
: ---
Assignee: Amos Kong
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks: 1008263
TreeView+ depends on / blocked
 
Reported: 2013-09-13 05:03 UTC by Xu Han
Modified: 2017-09-07 18:38 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1008263 (view as bug list)
Environment:
Last Closed: 2013-09-13 09:41:41 UTC
Target Upstream Version:


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 09:41 UTC, Amos Kong
no flags Details

Description Xu Han 2013-09-13 05:03:06 UTC
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 05:24:54 UTC
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 09:00:57 UTC
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 09:41:16 UTC
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.