]> xenbits.xensource.com Git - libvirt.git/commitdiff
virnetdevopenvswitch: Fix 'burst' value passed to ovs-vsctl
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 3 Jan 2022 15:24:58 +0000 (16:24 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 4 Jan 2022 15:40:10 +0000 (16:40 +0100)
As described in the previous commit, the units for 'burst' are
kibibytes and not kilobytes, i.e. multiples of 1024 not 1000.
Therefore, when constructing ovs-vsctl command the burst value
must be multiplied by 1024 and not just 1000. And because ovs
expects this size in bits the value has to be multiplied again by
8.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1510237#c26
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/util/virnetdevopenvswitch.c

index 5dab545037605599c6f9d13585b09daf6d38d1d5..ba886dfb7d558858ff0cd93622be23fffa749034 100644 (file)
@@ -638,11 +638,13 @@ virNetDevOpenvswitchFindUUID(const char *table,
 }
 
 /*
- * Average, peak, floor and burst in virNetDevBandwidth are in kbytes.
- * However other_config in ovs qos is in bit.
- * ingress_policing_rate in ovs interface is in kbit.
+ * In virNetDevBandwidthRate, average, peak, floor are in kilobyes and burst in
+ * kibibytes. However other_config in ovs qos is in bits and
+ * ingress_policing_rate in ovs interface is in kilobit and
+ * ingress_policing_burst is in kibibits.
  */
-#define VIR_NETDEV_TX_TO_OVS 8000
+#define KBYTE_TO_BITS(x) (x * 8000ULL)
+#define KIBIBYTE_TO_BITS(x) (x * 8192ULL)
 #define VIR_NETDEV_RX_TO_OVS 8
 
 /**
@@ -717,11 +719,11 @@ virNetDevOpenvswitchInterfaceSetQos(const char *ifname,
         g_autofree char *qos_uuid = NULL;
         g_autofree char *queue_uuid = NULL;
 
-        average = g_strdup_printf("%llu", tx->average * VIR_NETDEV_TX_TO_OVS);
+        average = g_strdup_printf("%llu", KBYTE_TO_BITS(tx->average));
         if (tx->burst)
-            burst = g_strdup_printf("%llu", tx->burst * VIR_NETDEV_TX_TO_OVS);
+            burst = g_strdup_printf("%llu", KIBIBYTE_TO_BITS(tx->burst));
         if (tx->peak)
-            peak = g_strdup_printf("%llu", tx->peak * VIR_NETDEV_TX_TO_OVS);
+            peak = g_strdup_printf("%llu", KBYTE_TO_BITS(tx->peak));
 
         virUUIDFormat(vmuuid, vmuuidstr);
         vmid_ex_id = g_strdup_printf("external-ids:vm-id=\"%s\"", vmuuidstr);