From: Daniel P. Berrangé <berrange(a)redhat.com>
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.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
meson.build | 1 -
src/util/virnetdevopenvswitch.c | 4 +-
tests/virnetdevbandwidthtest.c | 52 +++++++++++-----------
tests/virnetdevopenvswitchtest.c | 74 ++++++++++++++++----------------
4 files changed, 65 insertions(+), 66 deletions(-)
diff --git a/meson.build b/meson.build
index 3022f0b984..0515820cdd 100644
--- a/meson.build
+++ b/meson.build
@@ -854,7 +854,6 @@ optional_test_programs = [
]
optional_programs = [
- 'ovs-vsctl',
'tc',
] + optional_test_programs
diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
index 0f5d23b794..868d6d26ba 100644
--- a/src/util/virnetdevopenvswitch.c
+++ b/src/util/virnetdevopenvswitch.c
@@ -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.
diff --git a/tests/virnetdevbandwidthtest.c b/tests/virnetdevbandwidthtest.c
index 31aa7f469d..b7cf546d9f 100644
--- a/tests/virnetdevbandwidthtest.c
+++ b/tests/virnetdevbandwidthtest.c
@@ -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;
}
diff --git a/tests/virnetdevopenvswitchtest.c b/tests/virnetdevopenvswitchtest.c
index 6e93f5e65a..ffd75ad044 100644
--- a/tests/virnetdevopenvswitchtest.c
+++ b/tests/virnetdevopenvswitchtest.c
@@ -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;
}
--
2.49.0