[PATCH 1/2] docs: Clarify 'burst' units for QoS

Michal Privoznik mprivozn at redhat.com
Tue Jan 4 12:53:05 UTC 2022


The burst attribute for bandwidth specifies how much bytes can be
transmitted in a single burst. Therefore, the unit is in
multiples of 1024 (thus kibibytes) not SI-like 1000. It always
has been like that.

The 'tc' output is still confusing though, for instance:

  # tc class add dev $DEV parent 1: classid 1:1 htb rate 1000kbps burst 2097152
  # tc class show dev vnet2
  class htb 1:1 root rate 8Mbit ceil 8Mbit burst 2Mb cburst 1600b

Please note that 2097152 = 2*1024*1024. Even the man page is
confusing. From tc(8):

  kb or k        Kilobytes
  mb or m        Megabytes

But I guess this is because 'tc' predates IEC standardisation of
binary multiples and thus can't change without breaking scripts
parsing its output.

And while at it, adjust _virNetDevBandwidthRate struct member
description, to make it obvious which members use SI/IEC units.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 docs/formatnetwork.html.in    | 2 +-
 src/util/virnetdevbandwidth.h | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/docs/formatnetwork.html.in b/docs/formatnetwork.html.in
index b1b2391f43..fad43f77ea 100644
--- a/docs/formatnetwork.html.in
+++ b/docs/formatnetwork.html.in
@@ -634,7 +634,7 @@
           </dd>
           <dt><code>burst</code></dt>
           <dd>
-          Optional attribute which specifies the amount of kilobytes that
+          Optional attribute which specifies the amount of kibibytes that
           can be transmitted in a single burst at <code>peak</code> speed.
           </dd>
           <dt><code>floor</code></dt>
diff --git a/src/util/virnetdevbandwidth.h b/src/util/virnetdevbandwidth.h
index 3d520721f6..c82029fc0f 100644
--- a/src/util/virnetdevbandwidth.h
+++ b/src/util/virnetdevbandwidth.h
@@ -23,10 +23,10 @@
 
 typedef struct _virNetDevBandwidthRate virNetDevBandwidthRate;
 struct _virNetDevBandwidthRate {
-    unsigned long long average;  /* kbytes/s */
-    unsigned long long peak;     /* kbytes/s */
-    unsigned long long floor;    /* kbytes/s */
-    unsigned long long burst;    /* kbytes */
+    unsigned long long average;  /* kilobytes/s */
+    unsigned long long peak;     /* kilobytes/s */
+    unsigned long long floor;    /* kilobytes/s */
+    unsigned long long burst;    /* kibibytes */
 };
 
 typedef struct _virNetDevBandwidth virNetDevBandwidth;
-- 
2.34.1




More information about the libvir-list mailing list