]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virnetdevbandwidth: Split virNetDevBandwidthClear into two helpers
authorWesley Hershberger via Devel <devel@lists.libvirt.org>
Thu, 7 May 2026 17:03:14 +0000 (12:03 -0500)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 19 May 2026 11:04:34 +0000 (13:04 +0200)
This allows virNetDevBandwidthSet to clear only the interface's qdisc
for directions where bandwidth is defined (see the next patch)

Signed-off-by: Wesley Hershberger <wesley.hershberger@canonical.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virnetdevbandwidth.c

index b141a38b1065ab77e18d8f72acffd1e9381fdf6e..dbceb6293446e2045e79c582a3406fbca8664e2b 100644 (file)
@@ -169,6 +169,40 @@ virNetDevBandwidthManipulateFilter(const char *ifname,
 }
 
 
+static int
+virNetDevBandwidthClearRoot(const char *ifname)
+{
+    int ret = 0;
+    int dummy; /* for ignoring the exit status */
+    g_autoptr(virCommand) cmd = NULL;
+
+    cmd = virCommandNew("tc");
+    virCommandAddArgList(cmd, "qdisc", "del", "dev", ifname, "root", NULL);
+
+    if (virCommandRun(cmd, &dummy) < 0)
+        ret = -1;
+
+    return ret;
+}
+
+
+static int
+virNetDevBandwidthClearIngress(const char *ifname)
+{
+    int ret = 0;
+    int dummy; /* for ignoring the exit status */
+    g_autoptr(virCommand) cmd = NULL;
+
+    cmd = virCommandNew("tc");
+    virCommandAddArgList(cmd, "qdisc",  "del", "dev", ifname, "ingress", NULL);
+
+    if (virCommandRun(cmd, &dummy) < 0)
+        ret = -1;
+
+    return ret;
+}
+
+
 /**
  * virNetDevBandwidthSet:
  * @ifname: on which interface
@@ -440,27 +474,13 @@ virNetDevBandwidthSet(const char *ifname,
 int
 virNetDevBandwidthClear(const char *ifname)
 {
-    int ret = 0;
-    int dummy; /* for ignoring the exit status */
-    g_autoptr(virCommand) rootcmd = NULL;
-    g_autoptr(virCommand) ingresscmd = NULL;
-
     if (!ifname)
        return 0;
 
-    rootcmd = virCommandNew("tc");
-    virCommandAddArgList(rootcmd, "qdisc", "del", "dev", ifname, "root", NULL);
-
-    if (virCommandRun(rootcmd, &dummy) < 0)
-        ret = -1;
-
-    ingresscmd = virCommandNew("tc");
-    virCommandAddArgList(ingresscmd, "qdisc",  "del", "dev", ifname, "ingress", NULL);
-
-    if (virCommandRun(ingresscmd, &dummy) < 0)
-        ret = -1;
+    if (virNetDevBandwidthClearRoot(ifname) < 0)
+        return -1;
 
-    return ret;
+    return virNetDevBandwidthClearIngress(ifname);
 }
 
 /*