Bug 8681

Summary: qemu runs out of entropy, hangs on getrandom() syscall
Product: [Runtime] General Runtime Reporter: Alejandro Hernandez <alejandro.hernandez>
Component: General RuntimeAssignee: Saul Wold <sgw>
Status: RESOLVED FIXED QA Contact: Francisco Pedraza <francisco.j.pedraza.gonzalez>
Severity: normal    
Priority: Medium+ CC: alexandru.c.georgescu, randy.macleod
Version: unspecified   
Target Milestone: 2.1 M3   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)
Bug Depends on: 8816    
Bug Blocks:    

Description Alejandro Hernandez 2015-11-11 18:10:44 UTC
After running qemu on a certain headless host, trying to run python3 (and likely others) hangs, after doing an strace I can see that its hanging when trying to get a random number:

...
set_thread_area({entry_number:-1, base_addr:0xb7742700, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0 (entry_number:6)
mprotect(0x464dc000, 8192, PROT_READ)   = 0
mprotect(0x46568000, 4096, PROT_READ)   = 0
mprotect(0x464e7000, 4096, PROT_READ)   = 0
mprotect(0x46506000, 4096, PROT_READ)   = 0
mprotect(0x4668d000, 4096, PROT_READ)   = 0
mprotect(0x46362000, 4096, PROT_READ)   = 0
munmap(0xb7745000, 5836)                = 0
set_tid_address(0xb7742768)             = 255
set_robust_list(0xb7742770, 12)         = 0
rt_sigaction(SIGRTMIN, {0x46553920, [], SA_SIGINFO}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0x465539b0, [], SA_RESTART|SA_SIGINFO}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
ugetrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0
uname({sysname="Linux", nodename="qemux86", ...}) = 0
brk(0)                                  = 0x804b000
brk(0x806c000)                          = 0x806c000
getrandom(

...

Checking available entropy on qemu shows:
# sysctl  kernel.random.entropy_avail
kernel.random.entropy_avail = 0

Checking available entropy on the host shows:
kernel.random.entropy_avail = 185


Cristian Iorga suggested using:
http://wiki.qemu-project.org/Features/VirtIORNG

nonetheless, neither the qemu machine or the host contain the file /dev/hwrng, so this didn't solve it.

Ross Burton suggested doing a find /
# sysctl  kernel.random.entropy_avail
kernel.random.entropy_avail = 0
# find /
.
* Lots of output *
.
#  sysctl  kernel.random.entropy_avail
kernel.random.entropy_avail = 848
# python3
Python 3.5.0 (default, Nov 11 2015, 00:30:30) 
[GCC 5.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 


So generating output to the terminal, generates entropy and solves the issue, although we still don;t know what caused the problem in the first place.

After rebooting qemu, the issue shows up again...
Comment 1 Saul Wold 2016-02-10 16:58:01 UTC
Pushing to M3 due to change of resources