]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: openvswitch: split out virNetDevOpenvswitchInterfaceSetRxQos
authorJán Tomko <jtomko@redhat.com>
Mon, 17 Jan 2022 16:20:42 +0000 (17:20 +0100)
committerJán Tomko <jtomko@redhat.com>
Tue, 18 Jan 2022 16:48:32 +0000 (17:48 +0100)
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@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virnetdevopenvswitch.c

index 71bd961b5a033e19c02ea218510fc21661353f1d..32f423ef04f36b98fc16f45ce832c7397dc55fa5 100644 (file)
@@ -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);