RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1119206 - RFE: Multiple virtio-rng devices support
Summary: RFE: Multiple virtio-rng devices support
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.0
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Peter Krempa
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On: 915335 VirtIORNG
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-07-14 09:20 UTC by Peter Krempa
Modified: 2015-03-05 07:41 UTC (History)
15 users (show)

Fixed In Version: libvirt-1.2.7-1.el7
Doc Type: Enhancement
Doc Text:
Feature: Both kernel and qemu support multiple virtio-rng devices to be specified for a VM. Libvirt supported only one. Reason: Original implementation of the driver in the kernel was flawed and it was considered dropping the multiple rng support at first. Libvirt thus didn't implement support for more than one device. Result: Libvirt is now able to specify multiple virtio-rng devices to be used with a VM.
Clone Of: 915335
Environment:
Last Closed: 2015-03-05 07:41:02 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2015:0323 0 normal SHIPPED_LIVE Low: libvirt security, bug fix, and enhancement update 2015-03-05 12:10:54 UTC

Description Peter Krempa 2014-07-14 09:20:05 UTC
+++ This bug was initially created as a clone of Bug #915335 +++

Both qemu-kvm and the kernel support now multiple virtio-rng devices. Libvirt's support was crippled to support just one device as the original intent was not to support multiple RNGs.

This bug will track adding support for multiple RNGs in a domain.

There was already an attempt to add this:
http://www.redhat.com/archives/libvir-list/2013-February/msg01423.html

Kernel commits adding the support:

commit a17597d3b418ca5a394d14724ccfc295cb3186c8
Author: Sasha Levin <sasha.levin>
Date:   Fri May 16 11:42:43 2014 +0930

    virtio-rng: fixes for device registration/unregistration
    
    There are several fixes in this patch (mostly because it's hard
    splitting them up):
    
     - Revert the name field in struct hwrng back to 'const'. Also, don't
    do an extra kmalloc for the name - just wasteful.
     - Deal with allocation failures properly.
     - Use IDA to allocate device number instead of brute forcing one.
    
    Signed-off-by: Sasha Levin <sasha.levin>
    Signed-off-by: Rusty Russell <rusty.au>


commit e5d23a8cc38c555f9f3a40dcc5d14030105df9a8
Author: Sasha Levin <sasha.levin>
Date:   Fri May 16 11:41:57 2014 +0930

    virtio-rng: fix boot with virtio-rng device
    
    Commit "virtio-rng: support multiple virtio-rng devices" has broken
    boot with a virtio-rng device because the 'init' callback of the
    virtio-rng device was left unitialized to garbage, and got called
    by the hwrng infrastructure, killing the guest on boot.
    
    Signed-off-by: Sasha Levin <sasha.levin>
    Signed-off-by: Rusty Russell <rusty.au>
    Fixes: 08e53fbdb85c0f6f45c0f7c1ea3defc1752a95ce

commit 08e53fbdb85c0f6f45c0f7c1ea3defc1752a95ce
Author: Amos Kong <akong>
Date:   Wed May 14 10:33:46 2014 +0930

    virtio-rng: support multiple virtio-rng devices
    
    Current hwrng core supports to register multiple hwrng devices,
    and there is only one device really works in the same time.
    QEMU alsu supports to have multiple virtio-rng backends.
    
    This patch changes virtio-rng driver to support multiple
    virtio-rng devices.
    
    ]# cat /sys/class/misc/hw_random/rng_available
    virtio_rng.0 virtio_rng.1
    ]# cat /sys/class/misc/hw_random/rng_current
    virtio_rng.0
    ]# echo -n virtio_rng.1 > /sys/class/misc/hw_random/rng_current
    ]# dd if=/dev/hwrng of=/dev/null
    
    Signed-off-by: Amos Kong <akong>
    Signed-off-by: Rusty Russell <rusty.au>

Comment 1 Peter Krempa 2014-07-25 07:40:35 UTC
Libvirt added this feature in v1.2.6-261-g7214d5d:

commit 7214d5da28c90fcdb62345190e34c76a345f9f70
Author: Peter Krempa <pkrempa>
Date:   Thu Jul 24 15:15:20 2014 +0200

    test: qemu: Add tests for multiple virtio-rng devices

commit bbddbefa2f8a8ef72287077d7d4b7190f3bf2609
Author: Peter Krempa <pkrempa>
Date:   Mon Feb 25 23:31:11 2013 +0100

    virtio-rng: allow multiple RNG devices
    
    qemu supports adding multiple RNG devices. This patch allows libvirt to
    support this.

Comment 3 Luyao Huang 2014-12-08 01:49:23 UTC
Verify this bug with libvirt-1.2.8-10.el7.x86_64 :

1.Start a guest with multiple virtio-rng devices
# virsh list 
 Id    Name                           State
----------------------------------------------------
 42    r7                             running


# virsh dumpxml r7
    <rng model='virtio'>
      <backend model='random'>/dev/random</backend>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </rng>
    <rng model='virtio'>
      <backend model='random'>/dev/random</backend>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
    </rng>
    <rng model='virtio'>
      <backend model='egd' type='udp'>
        <source mode='connect' host='localhost' service='1234'/>
      </backend>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
    </rng>
  </devices>

2.check qemu cmd line:
# ps aux|grep qemu
-object rng-random,id=rng0,filename=/dev/random -device virtio-rng-pci,rng=rng0,bus=pci.0,addr=0x9 -object rng-random,id=rng1,filename=/dev/random -device virtio-rng-pci,rng=rng1,bus=pci.0,addr=0xa -chardev udp,id=charrng2,host=localhost,port=1234,localaddr=,localport=0 -object rng-egd,chardev=charrng2,id=rng2 -device virtio-rng-pci,rng=rng2,bus=pci.0,addr=0xb

 
2.login guest to check if virtio_rng work well

IN GUEST:
# time cat /sys/devices/virtual/misc/hw_random/rng_current
virtio_rng.0

real	0m39.333s
user	0m0.002s
sys	0m0.000s

# time cat /sys/devices/virtual/misc/hw_random/rng_available 
virtio_rng.0 virtio_rng.1 virtio_rng.2 

real	0m24.679s
user	0m0.000s
sys	0m0.002s

# echo -n virtio_rng.1 > /sys/class/misc/hw_random/rng_current
# dd if=/dev/hwrng of=/tmp/random
^C^C5+1 records in
5+0 records out
2560 bytes (2.6 kB) copied, 495.8 s, 0.0 kB/s

It is very slow and this issue seems because bug 1008860.

Comment 4 Luyao Huang 2014-12-08 02:08:05 UTC
Hi peter,

I found this bug depends on bug 917953, but bug 917953 is a bug tracker of qemu-kvm, can i verify this bug now?

Thanks in advance for your answer.

Comment 5 Peter Krempa 2014-12-08 10:19:28 UTC
(In reply to Luyao Huang from comment #4)
> Hi peter,
> 
> I found this bug depends on bug 917953, but bug 917953 is a bug tracker of
> qemu-kvm, can i verify this bug now?

That bug dependency is probably wrong. As you were able to checked that it works then it's okay to set it to VERIFIED.

Comment 6 Luyao Huang 2014-12-08 12:17:37 UTC
(In reply to Peter Krempa from comment #5)
> (In reply to Luyao Huang from comment #4)
> > Hi peter,
> > 
> > I found this bug depends on bug 917953, but bug 917953 is a bug tracker of
> > qemu-kvm, can i verify this bug now?
> 
> That bug dependency is probably wrong. As you were able to checked that it
> works then it's okay to set it to VERIFIED.

Thanks for your reply and verify this bug

Comment 8 errata-xmlrpc 2015-03-05 07:41:02 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHSA-2015-0323.html


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