From nobody Mon Feb 9 07:26:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1656425916136312.6668127478007; Tue, 28 Jun 2022 07:18:36 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-215-v3Jn2I21Oqe7XDCWcwDYUA-1; Tue, 28 Jun 2022 10:18:25 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 59F5C886D57; Tue, 28 Jun 2022 14:17:41 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3DBF82166B2A; Tue, 28 Jun 2022 14:17:41 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0D7F9194705F; Tue, 28 Jun 2022 14:17:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 40B42194705D for ; Tue, 28 Jun 2022 14:17:39 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 35E4B112131E; Tue, 28 Jun 2022 14:17:39 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5AC91121314 for ; Tue, 28 Jun 2022 14:17:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656425915; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=YwXK3sbdbF8Jwnbm1FWkxlclIZKj3Szkre1lFKzN0Pc=; b=b6ZKVMVhwLicMIRkHGcAekNLbQYv6cXVR12tBNXXfOw4fmg8mYY8vMdQFNEE+RuSGmbBol pGI8KBx3SfxIwMbdSRod5/PDOgV1lKdnAqYi/1dJzHagYt/JB5X0qIcWkgT26bS4GLYOXb BSqLfTN8T69JLPRUCN7/+vxv5nOHKSw= X-MC-Unique: v3Jn2I21Oqe7XDCWcwDYUA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/4] virnetdevbandwidthtest: Test QoS for OVS Date: Tue, 28 Jun 2022 16:17:35 +0200 Message-Id: <1500e9498ba2447e999b512eaa99115d21ed0e56.1656425669.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1656425916918100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Ever since v7.6.0-rc1~235 we can use ovs-vsctl to set QoS instead of tc. However, we don't have a test that's verifying generated cmd line for ovs-vsctl. Signed-off-by: Michal Privoznik --- tests/virnetdevbandwidthtest.c | 85 +++++++++++++++++++++++++++------- 1 file changed, 69 insertions(+), 16 deletions(-) diff --git a/tests/virnetdevbandwidthtest.c b/tests/virnetdevbandwidthtest.c index 51e5ec016b..d5e4092fc3 100644 --- a/tests/virnetdevbandwidthtest.c +++ b/tests/virnetdevbandwidthtest.c @@ -22,13 +22,17 @@ #define LIBVIRT_VIRCOMMANDPRIV_H_ALLOW #include "vircommandpriv.h" #include "virnetdevbandwidth.h" +#include "virnetdevopenvswitch.h" #include "netdev_bandwidth_conf.c" =20 #define VIR_FROM_THIS VIR_FROM_NONE =20 struct testSetStruct { const char *band; - const char *exp_cmd; + const char *exp_cmd_tc; + const char *exp_cmd_ovs; + bool ovs; + const unsigned char *uuid; const char *iface; const bool hierarchical_class; }; @@ -59,6 +63,7 @@ testVirNetDevBandwidthSet(const void *data) { const struct testSetStruct *info =3D data; const char *iface =3D info->iface; + const char *exp_cmd =3D NULL; g_autoptr(virNetDevBandwidth) band =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autofree char *actual_cmd =3D NULL; @@ -72,17 +77,24 @@ testVirNetDevBandwidthSet(const void *data) =20 virCommandSetDryRun(dryRunToken, &buf, false, false, NULL, NULL); =20 - if (virNetDevBandwidthSet(iface, band, info->hierarchical_class, true)= < 0) - return -1; + if (info->ovs) { + exp_cmd =3D info->exp_cmd_ovs; + if (virNetDevOpenvswitchInterfaceSetQos(iface, band, info->uuid, t= rue) < 0) + return -1; + } else { + exp_cmd =3D info->exp_cmd_tc; + if (virNetDevBandwidthSet(iface, band, info->hierarchical_class, t= rue) < 0) + return -1; + } =20 if (!(actual_cmd =3D virBufferContentAndReset(&buf))) { /* This is interesting, no command has been executed. * Maybe that's expected, actually. */ } =20 - if (STRNEQ_NULLABLE(info->exp_cmd, actual_cmd)) { + if (STRNEQ_NULLABLE(exp_cmd, actual_cmd)) { virTestDifference(stderr, - NULLSTR(info->exp_cmd), + NULLSTR(exp_cmd), NULLSTR(actual_cmd)); return -1; } @@ -94,22 +106,37 @@ static int mymain(void) { int ret =3D 0; + unsigned char uuid[VIR_UUID_BUFLEN] =3D { 0 }; =20 -#define DO_TEST_SET(Band, Exp_cmd, ...) \ +#define VMUUID "c1018351-a229-4209-9faf-42446e0b53e5" + + if (virUUIDParse(VMUUID, uuid) < 0) + return -1; + +#define DO_TEST_SET(Band, Exp_cmd_tc, Exp_cmd_ovs, ...) \ do { \ struct testSetStruct data =3D {.band =3D Band, \ - .exp_cmd =3D Exp_cmd, \ + .exp_cmd_tc =3D Exp_cmd_tc, \ + .exp_cmd_ovs =3D Exp_cmd_ovs, \ + .ovs =3D false, \ + .uuid =3D uuid, \ __VA_ARGS__}; \ - if (virTestRun("virNetDevBandwidthSet", \ + if (virTestRun("virNetDevBandwidthSet TC", \ testVirNetDevBandwidthSet, \ - &data) < 0) \ + &data) < 0) { \ ret =3D -1; \ + } \ + data.ovs =3D true; \ + if (virTestRun("virNetDevBandwidthSet OVS", \ + testVirNetDevBandwidthSet, \ + &data) < 0) { \ + ret =3D -1; \ + } \ } while (0) =20 + DO_TEST_SET(NULL, NULL, NULL); =20 - DO_TEST_SET(NULL, NULL); - - DO_TEST_SET("", NULL); + DO_TEST_SET("", NULL, NULL); =20 DO_TEST_SET("" " " @@ -119,7 +146,14 @@ mymain(void) TC " qdisc add dev eth0 root handle 1: htb default 1\n" TC " class add dev eth0 parent 1: classid 1:1 htb rate 102= 4kbps quantum 87\n" TC " qdisc add dev eth0 parent 1:1 handle 2: sfq perturb 1= 0\n" - TC " filter add dev eth0 parent 1:0 protocol all prio 1 ha= ndle 1 fw flowid 1\n"); + TC " filter add dev eth0 parent 1:0 protocol all prio 1 ha= ndle 1 fw flowid 1\n", + OVS_VSCTL " --timeout=3D5 --no-heading --columns=3D_uuid f= ind queue 'external-ids:vm-id=3D\"" VMUUID "\"' 'external-ids:ifname=3D\"et= h0\"'\n" + OVS_VSCTL " --timeout=3D5 --no-heading --columns=3D_uuid f= ind qos 'external-ids:vm-id=3D\"" VMUUID "\"' 'external-ids:ifname=3D\"eth0= \"'\n" + OVS_VSCTL " --timeout=3D5 set port eth0 qos=3D@qos1 'exter= nal-ids:vm-id=3D\"" VMUUID "\"' 'external-ids:ifname=3D\"eth0\"' --" + " --id=3D@qos1 create qos type=3Dlinux-htb other= _config:min-rate=3D8192000 queues:0=3D@queue0 'external-ids:vm-id=3D\"" VMU= UID "\"'" + " 'external-ids:ifname=3D\"eth0\"' --" + " --id=3D@queue0 create queue other_config:min-r= ate=3D8192000 'external-ids:vm-id=3D\"" VMUUID "\"' 'external-ids:ifname=3D= \"eth0\"'\n" + OVS_VSCTL " --timeout=3D5 set Interface eth0 ingress_polic= ing_rate=3D0 ingress_policing_burst=3D0\n"); =20 DO_TEST_SET("" " " @@ -128,7 +162,10 @@ mymain(void) TC " qdisc del dev eth0 ingress\n" TC " qdisc add dev eth0 ingress\n" TC " filter add dev eth0 parent ffff: protocol all u32 mat= ch u32 0 0" - " police rate 1024kbps burst 1024kb mtu 64kb drop flowi= d :1\n"); + " police rate 1024kbps burst 1024kb mtu 64kb drop flowi= d :1\n", + OVS_VSCTL " --timeout=3D5 --no-heading --columns=3D_uuid f= ind queue 'external-ids:vm-id=3D\"" VMUUID "\"' 'external-ids:ifname=3D\"et= h0\"'\n" + OVS_VSCTL " --timeout=3D5 --no-heading --columns=3D_uuid f= ind qos 'external-ids:vm-id=3D\"" VMUUID "\"' 'external-ids:ifname=3D\"eth0= \"'\n" + OVS_VSCTL " --timeout=3D5 set Interface eth0 ingress_polic= ing_rate=3D8192\n"); =20 DO_TEST_SET("" " " @@ -142,7 +179,15 @@ mymain(void) TC " filter add dev eth0 parent 1:0 protocol all prio 1 ha= ndle 1 fw flowid 1\n" TC " qdisc add dev eth0 ingress\n" TC " filter add dev eth0 parent ffff: protocol all u32 mat= ch u32 0 0" - " police rate 5kbps burst 7kb mtu 64kb drop flowid :1\n= "); + " police rate 5kbps burst 7kb mtu 64kb drop flowid :1\n= ", + OVS_VSCTL " --timeout=3D5 --no-heading --columns=3D_uuid f= ind queue 'external-ids:vm-id=3D\"" VMUUID "\"' 'external-ids:ifname=3D\"et= h0\"'\n" + OVS_VSCTL " --timeout=3D5 --no-heading --columns=3D_uuid f= ind qos 'external-ids:vm-id=3D\"" VMUUID "\"' 'external-ids:ifname=3D\"eth0= \"'\n" + OVS_VSCTL " --timeout=3D5 set port eth0 qos=3D@qos1 'exter= nal-ids:vm-id=3D\"" VMUUID "\"' 'external-ids:ifname=3D\"eth0\"' --" + " --id=3D@qos1 create qos type=3Dlinux-htb other= _config:min-rate=3D8000 other_config:burst=3D32768 other_config:max-rate=3D= 16000" + " queues:0=3D@queue0 'external-ids:vm-id=3D\""= VMUUID "\"' 'external-ids:ifname=3D\"eth0\"' --" + " --id=3D@queue0 create queue other_config:min-r= ate=3D8000 other_config:burst=3D32768 other_config:max-rate=3D16000" + " 'external-ids:vm-id=3D\"" VMUUID "\"' 'exter= nal-ids:ifname=3D\"eth0\"'\n" + OVS_VSCTL " --timeout=3D5 set Interface eth0 ingress_polic= ing_rate=3D40 ingress_policing_burst=3D56\n"); =20 DO_TEST_SET("" " " @@ -157,7 +202,15 @@ mymain(void) TC " qdisc add dev eth0 ingress\n" TC " filter add dev eth0 parent ffff: protocol all u32 mat= ch" " u32 0 0 police rate 4294967295kbps burst 4194303kb mt= u 64kb" - " drop flowid :1\n"); + " drop flowid :1\n", + OVS_VSCTL " --timeout=3D5 --no-heading --columns=3D_uuid f= ind queue 'external-ids:vm-id=3D\"" VMUUID "\"' 'external-ids:ifname=3D\"et= h0\"'\n" + OVS_VSCTL " --timeout=3D5 --no-heading --columns=3D_uuid f= ind qos 'external-ids:vm-id=3D\"" VMUUID "\"' 'external-ids:ifname=3D\"eth0= \"'\n" + OVS_VSCTL " --timeout=3D5 set port eth0 qos=3D@qos1 'exter= nal-ids:vm-id=3D\"" VMUUID "\"' 'external-ids:ifname=3D\"eth0\"' --" + " --id=3D@qos1 create qos type=3Dlinux-htb other= _config:min-rate=3D34359738360000" + " queues:0=3D@queue0 'external-ids:vm-id=3D\""= VMUUID "\"' 'external-ids:ifname=3D\"eth0\"' --" + " --id=3D@queue0 create queue other_config:min-r= ate=3D34359738360000 'external-ids:vm-id=3D\"" VMUUID "\"'" + " 'external-ids:ifname=3D\"eth0\"'\n" + OVS_VSCTL " --timeout=3D5 set Interface eth0 ingress_polic= ing_rate=3D34359738360\n"); =20 return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } --=20 2.35.1