From: Ján Tomko Date: Mon, 17 Jan 2022 16:20:42 +0000 (+0100) Subject: util: openvswitch: split out virNetDevOpenvswitchInterfaceSetRxQos X-Git-Tag: v8.1.0-rc1~391 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5d55546e0f60936878227220a2bcf61c5a92a811;p=thirdparty%2Flibvirt.git util: openvswitch: split out virNetDevOpenvswitchInterfaceSetRxQos 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 Reviewed-by: Michal Privoznik --- 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);