Bug 1034780

Summary: virtio-rng: default rate limit isn't 2TB/s as described in document (it's actually 128,000 TB/s)
Product: Red Hat Enterprise Linux 7 Reporter: Amos Kong <akong>
Component: qemu-kvmAssignee: Amos Kong <akong>
Status: CLOSED WONTFIX QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: acathrow, ailan, juzhang, rhod, virt-maint, xuhan, yunzheng
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-12-02 09:45:47 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Amos Kong 2013-11-26 13:50:35 UTC
qemu-version: qemu-kvm-1.5.3-19.el7
bug exists in qemu upstream
-------------------------------------

    We have the following comment about the default limit rate:
    
    /* Set a default rate limit of 2^47 bytes per minute or roughly 2TB/s.  If
     * you have an entropy source capable of generating more entropy than this
     * and you can pass it through via virtio-rng, then hats off to you.  Until
     * then, this is unlimited for all practical purposes.
     */
    
#define DEFINE_VIRTIO_RNG_PROPERTIES(_state, _conf_field)                    \
        DEFINE_PROP_UINT64("max-bytes", _state, _conf_field.max_bytes,       \
                           INT64_MAX),                                       \
        DEFINE_PROP_UINT32("period", _state, _conf_field.period_ms, 1 << 16)

--------------

    But the current rate is (INT64_MAX) bytes per (1 << 16) ms, it's 128,000 TB/s
    
    2TB/s is a reasonable rate, so this patch fixes the code, not update the document.
    
    * change the default period to 60,000 ms --> 1 mins
    * change the default max-bytes to 2^47 bytes --> INT64_MAX >> 16
    
     INT64_MAX  =  0x 8000 0000 0000 0000 - 1 = 2 ^ 63 - 1
     INT64_MAX >> 16 =  0x 8000 0000 0000 - 1 = 2 ^ 47


===========================================================================
diff --git a/include/hw/virtio/virtio-rng.h b/include/hw/virtio/virtio-rng.h
index debaa15..d64e804 100644
--- a/include/hw/virtio/virtio-rng.h
+++ b/include/hw/virtio/virtio-rng.h
@@ -53,7 +53,7 @@ typedef struct VirtIORNG {
 */
 #define DEFINE_VIRTIO_RNG_PROPERTIES(_state, _conf_field)                    \
         DEFINE_PROP_UINT64("max-bytes", _state, _conf_field.max_bytes,       \
-                           INT64_MAX),                                       \
-        DEFINE_PROP_UINT32("period", _state, _conf_field.period_ms, 1 << 16)
+                           INT64_MAX >> 16),                                 \
+        DEFINE_PROP_UINT32("period", _state, _conf_field.period_ms, 60000)
 
 #endif

Comment 1 Ronen Hod 2013-12-02 09:45:47 UTC
The issue is minor, not worth backporting. Closing this bug. Will be rebased sometime in the future.