<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>8681</bug_id>
          
          <creation_ts>2015-11-11 18:10:44 +0000</creation_ts>
          <short_desc>qemu runs out of entropy, hangs on getrandom() syscall</short_desc>
          <delta_ts>2016-03-07 06:29:44 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>11</classification_id>
          <classification>Runtime</classification>
          <product>General Runtime</product>
          <component>General Runtime</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>2.1 M3</target_milestone>
          <dependson>8816</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Alejandro Hernandez">alejandro.hernandez</reporter>
          <assigned_to name="Saul Wold">sgw</assigned_to>
          <cc>alexandru.c.georgescu</cc>
    
    <cc>randy.macleod</cc>
          
          <qa_contact name="Francisco Pedraza">francisco.j.pedraza.gonzalez</qa_contact>
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>56394</commentid>
    <comment_count>0</comment_count>
    <who name="Alejandro Hernandez">alejandro.hernandez</who>
    <bug_when>2015-11-11 18:10:44 +0000</bug_when>
    <thetext>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=&quot;Linux&quot;, nodename=&quot;qemux86&quot;, ...}) = 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&apos;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 &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; 


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...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>58833</commentid>
    <comment_count>1</comment_count>
    <who name="Saul Wold">sgw</who>
    <bug_when>2016-02-10 16:58:01 +0000</bug_when>
    <thetext>Pushing to M3 due to change of resources</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>59038</commentid>
    <comment_count>2</comment_count>
    <who name="Saul Wold">sgw</who>
    <bug_when>2016-02-15 17:02:26 +0000</bug_when>
    <thetext>These two patches add rng-tools to the qemu images and increase the availablity 
of entropy bits

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=6740dd55798641a47744b891aa1d8fa5e04c2cdc
http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=ce3df21122d7fc4ede6fe36009afb297004672ef</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>