From: Jinsheng Zhang <zhangjl02(a)inspur.com>
Signed-off-by: zhangjl02 <zhangjl02(a)inspur.com>
---
src/util/virnetdevopenvswitch.c | 12 +++++++-----
src/util/virnetdevopenvswitch.h | 7 +++++++
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
index d86ad0eafd..dfbebf8535 100644
--- a/src/util/virnetdevopenvswitch.c
+++ b/src/util/virnetdevopenvswitch.c
@@ -692,11 +692,11 @@ virNetDevOpenvswitchInterfaceSetQos(const char *ifname,
g_autofree char *qos_uuid = NULL;
g_autofree char *queue_uuid = NULL;
- average = g_strdup_printf("%llu", tx->average * 8192);
+ average = g_strdup_printf("%llu", tx->average *
VIR_NETDEV_TX_TO_OVS);
if (tx->burst)
- burst = g_strdup_printf("%llu", tx->burst * 8192);
+ burst = g_strdup_printf("%llu", tx->burst *
VIR_NETDEV_TX_TO_OVS);
if (tx->peak)
- peak = g_strdup_printf("%llu", tx->peak * 8192);
+ peak = g_strdup_printf("%llu", tx->peak *
VIR_NETDEV_TX_TO_OVS);
/* find queue */
cmd = virNetDevOpenvswitchCreateCmd();
@@ -786,9 +786,11 @@ virNetDevOpenvswitchInterfaceSetQos(const char *ifname,
cmd = virNetDevOpenvswitchCreateCmd();
virCommandAddArgList(cmd, "set", "Interface", ifname, NULL);
- virCommandAddArgFormat(cmd, "ingress_policing_rate=%llu",
rx->average * 8);
+ virCommandAddArgFormat(cmd, "ingress_policing_rate=%llu",
+ rx->average * VIR_NETDEV_RX_TO_OVS);
if (rx->burst)
- virCommandAddArgFormat(cmd, "ingress_policing_burst=%llu",
rx->burst * 8);
+ virCommandAddArgFormat(cmd, "ingress_policing_burst=%llu",
+ rx->burst * VIR_NETDEV_RX_TO_OVS);
if (virCommandRun(cmd, NULL) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
diff --git a/src/util/virnetdevopenvswitch.h b/src/util/virnetdevopenvswitch.h
index 2dcd1aec6b..33e52f57c7 100644
--- a/src/util/virnetdevopenvswitch.h
+++ b/src/util/virnetdevopenvswitch.h
@@ -26,6 +26,13 @@
#include "virnetdevvlan.h"
#define VIR_NETDEV_OVS_DEFAULT_TIMEOUT 5
+/*
+ * 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.
+ */
+#define VIR_NETDEV_TX_TO_OVS 8192
+#define VIR_NETDEV_RX_TO_OVS 8
void virNetDevOpenvswitchSetTimeout(unsigned int timeout);
--
2.30.2.windows.1