The virNetDevOpenvswitchInterfaceSetQos function is uneven
because setting the Rx Qos is open-coded, while clearing it
is sepearated in another function.
Separate the setting too.
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
src/util/virnetdevopenvswitch.c | 38 +++++++++++++++++++++------------
1 file changed, 24 insertions(+), 14 deletions(-)
diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
index 71bd961b5a..32f423ef04 100644
--- a/src/util/virnetdevopenvswitch.c
+++ b/src/util/virnetdevopenvswitch.c
@@ -836,6 +836,29 @@ virNetDevOpenvswitchInterfaceSetTxQos(const char *ifname,
return 0;
}
+static int
+virNetDevOpenvswitchInterfaceSetRxQos(const char *ifname,
+ const virNetDevBandwidthRate *rx)
+{
+ g_autoptr(virCommand) cmd = NULL;
+
+ cmd = virNetDevOpenvswitchCreateCmd();
+ virCommandAddArgList(cmd, "set", "Interface", ifname, NULL);
+ virCommandAddArgFormat(cmd, "ingress_policing_rate=%llu",
+ rx->average * VIR_NETDEV_RX_TO_OVS);
+ if (rx->burst)
+ virCommandAddArgFormat(cmd, "ingress_policing_burst=%llu",
+ rx->burst * VIR_NETDEV_RX_TO_OVS);
+
+ if (virCommandRun(cmd, NULL) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unable to set vlan configuration on port %s"),
ifname);
+ return -1;
+ }
+
+ return 0;
+}
+
/**
* virNetDevOpenvswitchInterfaceSetQos:
* @ifname: on which interface
@@ -907,21 +930,8 @@ virNetDevOpenvswitchInterfaceSetQos(const char *ifname,
}
if (rx) {
- g_autoptr(virCommand) cmd = NULL;
-
- cmd = virNetDevOpenvswitchCreateCmd();
- virCommandAddArgList(cmd, "set", "Interface", ifname, NULL);
- virCommandAddArgFormat(cmd, "ingress_policing_rate=%llu",
- rx->average * VIR_NETDEV_RX_TO_OVS);
- if (rx->burst)
- virCommandAddArgFormat(cmd, "ingress_policing_burst=%llu",
- rx->burst * VIR_NETDEV_RX_TO_OVS);
-
- if (virCommandRun(cmd, NULL) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unable to set vlan configuration on port %s"),
ifname);
+ if (virNetDevOpenvswitchInterfaceSetRxQos(ifname, rx) < 0)
return -1;
- }
} else {
if (virNetDevOpenvswitchInterfaceClearRxQos(ifname) < 0) {
VIR_WARN("Clean rx qos for interface %s failed", ifname);
--
2.31.1