]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: remove use hardcoded OVS_VSCTL path
authorDaniel P. Berrangé <berrange@redhat.com>
Mon, 28 Apr 2025 16:22:14 +0000 (17:22 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Fri, 2 May 2025 08:31:28 +0000 (09:31 +0100)
Allow virCommand to find 'ovs-vsctl' in $PATH. This command is only used
when running privileged in which case both 'bin' and 'sbin' dirs will
be in $PATH, so virFindFileInPath will do the right thing to find it.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
meson.build
src/util/virnetdevopenvswitch.c
tests/virnetdevbandwidthtest.c
tests/virnetdevopenvswitchtest.c

index e9d5f2bf0b64f6f48a340250ecbb2ce1efa39007..1c646aab621f73ad0a8494467b41eeae3218b262 100644 (file)
@@ -854,7 +854,6 @@ optional_test_programs = [
 ]
 
 optional_programs = [
-  'ovs-vsctl',
   'tc',
 ] + optional_test_programs
 
index 0f5d23b794a4eb569742c8fda30cf16a39737912..868d6d26bad7f2a9e3a4ff09daa42504b9706853 100644 (file)
@@ -56,7 +56,7 @@ virNetDevOpenvswitchSetTimeout(unsigned int timeout)
 static virCommand *
 virNetDevOpenvswitchCreateCmd(char **errbuf)
 {
-    virCommand *cmd = virCommandNew(OVS_VSCTL);
+    virCommand *cmd = virCommandNew("ovs-vsctl");
 
     virCommandAddArgFormat(cmd, "--timeout=%u", virNetDevOpenvswitchTimeout);
     if (errbuf)
@@ -552,7 +552,7 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *path,
     g_autofree char *absoluteOvsVsctlPath = NULL;
     int status;
 
-    if (!(absoluteOvsVsctlPath = virFindFileInPath(OVS_VSCTL))) {
+    if (!(absoluteOvsVsctlPath = virFindFileInPath("ovs-vsctl"))) {
         /* If there is no 'ovs-vsctl' then the interface is
          * probably not an OpenVSwitch interface and the @path to
          * socket was created by some DPDK testing script (e.g.
index 31aa7f469d871e75e02036d8daa064acfd878cff..b7cf546d9f8e765c13da8a462c3563df941804ff 100644 (file)
@@ -152,13 +152,13 @@ mymain(void)
                 TC " class add dev eth0 parent 1: classid 1:1 htb rate 1024kbps quantum 87\n"
                 TC " qdisc add dev eth0 parent 1:1 handle 2: sfq perturb 10\n"
                 TC " filter add dev eth0 parent 1:0 protocol all prio 1 handle 1 fw flowid 1\n",
-                OVS_VSCTL " --timeout=5 --no-heading --columns=_uuid find queue 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"'\n"
-                OVS_VSCTL " --timeout=5 --no-heading --columns=_uuid find qos 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"'\n"
-                OVS_VSCTL " --timeout=5 set port eth0 qos=@qos1 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"' --"
-                          " --id=@qos1 create qos type=linux-htb other_config:min-rate=8192000 queues:0=@queue0 'external-ids:vm-id=\"" VMUUID "\"'"
-                            " 'external-ids:ifname=\"eth0\"' --"
-                          " --id=@queue0 create queue other_config:min-rate=8192000 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"'\n"
-                OVS_VSCTL " --timeout=5 set Interface eth0 ingress_policing_rate=0 ingress_policing_burst=0\n");
+                "ovs-vsctl --timeout=5 --no-heading --columns=_uuid find queue 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"'\n"
+                "ovs-vsctl --timeout=5 --no-heading --columns=_uuid find qos 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"'\n"
+                "ovs-vsctl --timeout=5 set port eth0 qos=@qos1 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"' --"
+                         " --id=@qos1 create qos type=linux-htb other_config:min-rate=8192000 queues:0=@queue0 'external-ids:vm-id=\"" VMUUID "\"'"
+                           " 'external-ids:ifname=\"eth0\"' --"
+                         " --id=@queue0 create queue other_config:min-rate=8192000 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"'\n"
+                "ovs-vsctl --timeout=5 set Interface eth0 ingress_policing_rate=0 ingress_policing_burst=0\n");
 
     DO_TEST_SET("<bandwidth>"
                 "  <outbound average='1024'/>"
@@ -168,9 +168,9 @@ mymain(void)
                 TC " qdisc add dev eth0 ingress\n"
                 TC " filter add dev eth0 parent ffff: protocol all u32 match u32 0 0"
                    " police rate 1024kbps burst 1024kb mtu 64kb drop flowid :1\n",
-                OVS_VSCTL " --timeout=5 --no-heading --columns=_uuid find queue 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"'\n"
-                OVS_VSCTL " --timeout=5 --no-heading --columns=_uuid find qos 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"'\n"
-                OVS_VSCTL " --timeout=5 set Interface eth0 ingress_policing_rate=8192\n");
+                "ovs-vsctl --timeout=5 --no-heading --columns=_uuid find queue 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"'\n"
+                "ovs-vsctl --timeout=5 --no-heading --columns=_uuid find qos 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"'\n"
+                "ovs-vsctl --timeout=5 set Interface eth0 ingress_policing_rate=8192\n");
 
     DO_TEST_SET("<bandwidth>"
                 "  <inbound average='1' peak='2' floor='3' burst='4'/>"
@@ -186,14 +186,14 @@ mymain(void)
                 TC " qdisc add dev eth0 ingress\n"
                 TC " filter add dev eth0 parent ffff: protocol all u32 match u32 0 0"
                    " police rate 5kbps burst 7kb mtu 64kb drop flowid :1\n",
-                OVS_VSCTL " --timeout=5 --no-heading --columns=_uuid find queue 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"'\n"
-                OVS_VSCTL " --timeout=5 --no-heading --columns=_uuid find qos 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"'\n"
-                OVS_VSCTL " --timeout=5 set port eth0 qos=@qos1 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"' --"
-                          " --id=@qos1 create qos type=linux-htb other_config:min-rate=8000 other_config:burst=32768 other_config:max-rate=16000"
-                            " queues:0=@queue0 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"' --"
-                          " --id=@queue0 create queue other_config:min-rate=8000 other_config:burst=32768 other_config:max-rate=16000"
-                            " 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"'\n"
-                OVS_VSCTL " --timeout=5 set Interface eth0 ingress_policing_rate=40 ingress_policing_burst=56\n");
+                "ovs-vsctl --timeout=5 --no-heading --columns=_uuid find queue 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"'\n"
+                "ovs-vsctl --timeout=5 --no-heading --columns=_uuid find qos 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"'\n"
+                "ovs-vsctl --timeout=5 set port eth0 qos=@qos1 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"' --"
+                         " --id=@qos1 create qos type=linux-htb other_config:min-rate=8000 other_config:burst=32768 other_config:max-rate=16000"
+                           " queues:0=@queue0 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"' --"
+                         " --id=@queue0 create queue other_config:min-rate=8000 other_config:burst=32768 other_config:max-rate=16000"
+                           " 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"'\n"
+                "ovs-vsctl --timeout=5 set Interface eth0 ingress_policing_rate=40 ingress_policing_burst=56\n");
 
     DO_TEST_SET("<bandwidth>"
                 "  <inbound average='4294967295'/>"
@@ -210,14 +210,14 @@ mymain(void)
                 TC " filter add dev eth0 parent ffff: protocol all u32 match"
                    " u32 0 0 police rate 4294967295kbps burst 4194303kb mtu 64kb"
                    " drop flowid :1\n",
-                OVS_VSCTL " --timeout=5 --no-heading --columns=_uuid find queue 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"'\n"
-                OVS_VSCTL " --timeout=5 --no-heading --columns=_uuid find qos 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"'\n"
-                OVS_VSCTL " --timeout=5 set port eth0 qos=@qos1 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"' --"
-                          " --id=@qos1 create qos type=linux-htb other_config:min-rate=34359738360000"
-                            " queues:0=@queue0 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"' --"
-                          " --id=@queue0 create queue other_config:min-rate=34359738360000 'external-ids:vm-id=\"" VMUUID "\"'"
-                            " 'external-ids:ifname=\"eth0\"'\n"
-                OVS_VSCTL " --timeout=5 set Interface eth0 ingress_policing_rate=34359738360\n");
+                "ovs-vsctl --timeout=5 --no-heading --columns=_uuid find queue 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"'\n"
+                "ovs-vsctl --timeout=5 --no-heading --columns=_uuid find qos 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"'\n"
+                "ovs-vsctl --timeout=5 set port eth0 qos=@qos1 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"' --"
+                         " --id=@qos1 create qos type=linux-htb other_config:min-rate=34359738360000"
+                           " queues:0=@queue0 'external-ids:vm-id=\"" VMUUID "\"' 'external-ids:ifname=\"eth0\"' --"
+                         " --id=@queue0 create queue other_config:min-rate=34359738360000 'external-ids:vm-id=\"" VMUUID "\"'"
+                           " 'external-ids:ifname=\"eth0\"'\n"
+                "ovs-vsctl --timeout=5 set Interface eth0 ingress_policing_rate=34359738360\n");
 
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
index 6e93f5e65af94c528c1a2627795f09bcb85b3508..ffd75ad044a99af41ebcdb02d80d9e83587cd2ea 100644 (file)
@@ -259,22 +259,22 @@ mymain(void)
     DO_TEST_SET(("<bandwidth>"
                  "  <inbound average='20000'/>"
                  "</bandwidth>"),
-                (OVS_VSCTL " --timeout=5 --no-heading --columns=_uuid find queue"
-                           " 'external-ids:vm-id=\"66616b65-7575-6964-0000-000000000000\"'"
-                           " 'external-ids:ifname=\"tap-fake\"'\n"
-                 OVS_VSCTL " --timeout=5 --no-heading --columns=_uuid find qos"
-                           " 'external-ids:vm-id=\"66616b65-7575-6964-0000-000000000000\"'"
-                           " 'external-ids:ifname=\"tap-fake\"'\n"
-                 OVS_VSCTL " --timeout=5 set port tap-fake qos=@qos1"
-                           " 'external-ids:vm-id=\"66616b65-7575-6964-0000-000000000000\"'"
-                           " 'external-ids:ifname=\"tap-fake\"'"
-                           " -- --id=@qos1 create qos type=linux-htb other_config:min-rate=160000000"
-                           " queues:0=@queue0 'external-ids:vm-id=\"66616b65-7575-6964-0000-000000000000\"'"
-                           " 'external-ids:ifname=\"tap-fake\"'"
-                           " -- --id=@queue0 create queue other_config:min-rate=160000000 "
-                           "'external-ids:vm-id=\"66616b65-7575-6964-0000-000000000000\"'"
-                           " 'external-ids:ifname=\"tap-fake\"'\n"
-                 OVS_VSCTL " --timeout=5 set Interface tap-fake ingress_policing_rate=0 ingress_policing_burst=0\n"));
+                ("ovs-vsctl --timeout=5 --no-heading --columns=_uuid find queue"
+                          " 'external-ids:vm-id=\"66616b65-7575-6964-0000-000000000000\"'"
+                          " 'external-ids:ifname=\"tap-fake\"'\n"
+                 "ovs-vsctl --timeout=5 --no-heading --columns=_uuid find qos"
+                          " 'external-ids:vm-id=\"66616b65-7575-6964-0000-000000000000\"'"
+                          " 'external-ids:ifname=\"tap-fake\"'\n"
+                 "ovs-vsctl --timeout=5 set port tap-fake qos=@qos1"
+                          " 'external-ids:vm-id=\"66616b65-7575-6964-0000-000000000000\"'"
+                          " 'external-ids:ifname=\"tap-fake\"'"
+                          " -- --id=@qos1 create qos type=linux-htb other_config:min-rate=160000000"
+                          " queues:0=@queue0 'external-ids:vm-id=\"66616b65-7575-6964-0000-000000000000\"'"
+                          " 'external-ids:ifname=\"tap-fake\"'"
+                          " -- --id=@queue0 create queue other_config:min-rate=160000000 "
+                          "'external-ids:vm-id=\"66616b65-7575-6964-0000-000000000000\"'"
+                          " 'external-ids:ifname=\"tap-fake\"'\n"
+                 "ovs-vsctl --timeout=5 set Interface tap-fake ingress_policing_rate=0 ingress_policing_burst=0\n"));
 
     DO_TEST_SET(NULL, NULL);
 
@@ -283,25 +283,25 @@ mymain(void)
     DO_TEST_SET(("<bandwidth>"
                  "  <inbound average='0' />"
                  "</bandwidth>"),
-                (OVS_VSCTL " --timeout=5 --no-heading --columns=_uuid find queue"
-                           " 'external-ids:vm-id=\"66616b65-7575-6964-0000-000000000000\"'"
-                           " 'external-ids:ifname=\"tap-fake\"'\n"
-                 OVS_VSCTL " --timeout=5 --no-heading --columns=_uuid find qos"
-                           " 'external-ids:vm-id=\"66616b65-7575-6964-0000-000000000000\"'"
-                           " 'external-ids:ifname=\"tap-fake\"'\n"
-                 OVS_VSCTL " --timeout=5 set Interface tap-fake ingress_policing_rate=0 ingress_policing_burst=0\n"));
+                ("ovs-vsctl --timeout=5 --no-heading --columns=_uuid find queue"
+                          " 'external-ids:vm-id=\"66616b65-7575-6964-0000-000000000000\"'"
+                          " 'external-ids:ifname=\"tap-fake\"'\n"
+                 "ovs-vsctl --timeout=5 --no-heading --columns=_uuid find qos"
+                          " 'external-ids:vm-id=\"66616b65-7575-6964-0000-000000000000\"'"
+                          " 'external-ids:ifname=\"tap-fake\"'\n"
+                 "ovs-vsctl --timeout=5 set Interface tap-fake ingress_policing_rate=0 ingress_policing_burst=0\n"));
 
     DO_TEST_SET(("<bandwidth>"
                  "  <inbound average='0' />"
                  "  <outbound average='5000' />"
                  "</bandwidth>"),
-                (OVS_VSCTL " --timeout=5 --no-heading --columns=_uuid find queue"
-                           " 'external-ids:vm-id=\"66616b65-7575-6964-0000-000000000000\"'"
-                           " 'external-ids:ifname=\"tap-fake\"'\n"
-                 OVS_VSCTL " --timeout=5 --no-heading --columns=_uuid find qos"
-                           " 'external-ids:vm-id=\"66616b65-7575-6964-0000-000000000000\"'"
-                           " 'external-ids:ifname=\"tap-fake\"'\n"
-                 OVS_VSCTL " --timeout=5 set Interface tap-fake ingress_policing_rate=40000\n"));
+                ("ovs-vsctl --timeout=5 --no-heading --columns=_uuid find queue"
+                          " 'external-ids:vm-id=\"66616b65-7575-6964-0000-000000000000\"'"
+                          " 'external-ids:ifname=\"tap-fake\"'\n"
+                 "ovs-vsctl --timeout=5 --no-heading --columns=_uuid find qos"
+                          " 'external-ids:vm-id=\"66616b65-7575-6964-0000-000000000000\"'"
+                          " 'external-ids:ifname=\"tap-fake\"'\n"
+                 "ovs-vsctl --timeout=5 set Interface tap-fake ingress_policing_rate=40000\n"));
 
 #define DO_TEST_CLEAR_QOS(Iface, Vmid, Exp_cmd, ...) \
     do { \
@@ -316,13 +316,13 @@ mymain(void)
     } while (0)
 
     DO_TEST_CLEAR_QOS(("fake-iface"), vm_id,
-                      (OVS_VSCTL " --timeout=5 --no-heading --columns=_uuid find queue"
-                                 " 'external-ids:vm-id=\"66616b65-7575-6964-0000-000000000000\"'"
-                                 " 'external-ids:ifname=\"fake-iface\"'\n"
-                       OVS_VSCTL " --timeout=5 --no-heading --columns=_uuid find qos"
-                                 " 'external-ids:vm-id=\"66616b65-7575-6964-0000-000000000000\"'"
-                                 " 'external-ids:ifname=\"fake-iface\"'\n"
-                       OVS_VSCTL " --timeout=5 set Interface fake-iface ingress_policing_rate=0 ingress_policing_burst=0\n"));
+                      ("ovs-vsctl --timeout=5 --no-heading --columns=_uuid find queue"
+                                " 'external-ids:vm-id=\"66616b65-7575-6964-0000-000000000000\"'"
+                                " 'external-ids:ifname=\"fake-iface\"'\n"
+                       "ovs-vsctl --timeout=5 --no-heading --columns=_uuid find qos"
+                                " 'external-ids:vm-id=\"66616b65-7575-6964-0000-000000000000\"'"
+                                " 'external-ids:ifname=\"fake-iface\"'\n"
+                       "ovs-vsctl --timeout=5 set Interface fake-iface ingress_policing_rate=0 ingress_policing_burst=0\n"));
 
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }