From nobody Tue May 7 17:56:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642437658; cv=none; d=zohomail.com; s=zohoarc; b=aiKtpKY4pbMiwEDqiZBDJpIDjA8P67u1ZEyq7oSVRthb6tyRiM/OCqBQZaG0sK64D0DF4CRm03l+tvNhxe3KoxWWLHy7U2aFcHu5AvcAuc8aJbPMBzEvgiCjSsZBRgQOgXIjjP2+CNAAoyS30ayPJxXTkjrfI/QSb7mf8+0DHMw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642437658; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ydD/zEEvLlu4dPFpEBPkfEJkICf4NaWbkQC3jjq7Kpg=; b=GnFElmLUsN0Nr2MmA8Pw0C/l+PYKg6uakzNgHcaBy4tsvozCtMosoyl5DcjnKZUnZ7Vmk1NrnxoGYnQz1zU35KwFsHsEfLvhDUe2qZWkBqaSNX4D3OuNdIpXE9rzqHFci3lGNOqGcUumd5TDGg84Be/bcXKdJphuM/nddFrKSFI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1642437658273881.4728807655466; Mon, 17 Jan 2022 08:40:58 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-592-tjkC2f1kNyCBWQzx-QBMBA-1; Mon, 17 Jan 2022 11:40:53 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6D701874980; Mon, 17 Jan 2022 16:40:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 492207AB40; Mon, 17 Jan 2022 16:40:48 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 144AF1809CBA; Mon, 17 Jan 2022 16:40:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20HGejtR006681 for ; Mon, 17 Jan 2022 11:40:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id E149710A48CB; Mon, 17 Jan 2022 16:40:45 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A48010A48CA for ; Mon, 17 Jan 2022 16:40:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642437657; 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=ydD/zEEvLlu4dPFpEBPkfEJkICf4NaWbkQC3jjq7Kpg=; b=D6IujoHMoruUX7odkII1RwBadRRpCD+nUs+UKPSsGOcnvNcmy/MF5TUrO1HXiar3wCK4Sm tPRqT6HUjNBm3+eh+qQweW3chk7zaxNsKxKp276UIkn1PZLOVvxqeKf6NVDr9Kez5r7v0u knYebUaKWABidZG0N0pez9+FKIYc854= X-MC-Unique: tjkC2f1kNyCBWQzx-QBMBA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/6] util: openvswitch: move InterfaceClear{Rx,Tx}Qos Date: Mon, 17 Jan 2022 17:40:19 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642437658716100003 These functions are called by virNetDevOpenvswitchInterfaceSetQos as well as virNetDevOpenvswitchInterfaceClearQos. Move them above both fuctions. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/util/virnetdevopenvswitch.c | 196 ++++++++++++++++---------------- 1 file changed, 98 insertions(+), 98 deletions(-) diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitc= h.c index ba886dfb7d..5db4a397f4 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -637,6 +637,104 @@ virNetDevOpenvswitchFindUUID(const char *table, return uuid; } =20 +int +virNetDevOpenvswitchInterfaceClearTxQos(const char *ifname, + const unsigned char *vmuuid) +{ + int ret =3D 0; + char vmuuidstr[VIR_UUID_STRING_BUFLEN]; + g_autoptr(virCommand) cmd =3D NULL; + g_autofree char *ifname_ex_id =3D NULL; + g_autofree char *vmid_ex_id =3D NULL; + g_autofree char *qos_uuid =3D NULL; + g_autofree char *queue_uuid =3D NULL; + g_autofree char *port_qos =3D NULL; + size_t i; + + /* find qos */ + virUUIDFormat(vmuuid, vmuuidstr); + vmid_ex_id =3D g_strdup_printf("external-ids:vm-id=3D\"%s\"", vmuuidst= r); + ifname_ex_id =3D g_strdup_printf("external-ids:ifname=3D\"%s\"", ifnam= e); + /* find queue */ + queue_uuid =3D virNetDevOpenvswitchFindUUID("queue", vmid_ex_id, ifnam= e_ex_id); + /* find qos */ + qos_uuid =3D virNetDevOpenvswitchFindUUID("qos", vmid_ex_id, ifname_ex= _id); + + if (qos_uuid && *qos_uuid) { + g_auto(GStrv) lines =3D g_strsplit(qos_uuid, "\n", 0); + + /* destroy qos */ + for (i =3D 0; lines[i] !=3D NULL; i++) { + const char *line =3D lines[i]; + if (!*line) { + continue; + } + virCommandFree(cmd); + cmd =3D virNetDevOpenvswitchCreateCmd(); + virCommandAddArgList(cmd, "--no-heading", "--columns=3D_uuid",= "--if-exists", + "list", "port", ifname, "qos", NULL); + virCommandSetOutputBuffer(cmd, &port_qos); + if (virCommandRun(cmd, NULL) < 0) { + VIR_WARN("Unable to remove port qos on port %s", ifname); + } + if (port_qos && *port_qos) { + virCommandFree(cmd); + cmd =3D virNetDevOpenvswitchCreateCmd(); + virCommandAddArgList(cmd, "remove", "port", ifname, "qos",= line, NULL); + if (virCommandRun(cmd, NULL) < 0) { + VIR_WARN("Unable to remove port qos on port %s", ifnam= e); + } + } + virCommandFree(cmd); + cmd =3D virNetDevOpenvswitchCreateCmd(); + virCommandAddArgList(cmd, "destroy", "qos", line, NULL); + if (virCommandRun(cmd, NULL) < 0) { + VIR_WARN("Unable to destroy qos on port %s", ifname); + ret =3D -1; + } + } + } + /* destroy queue */ + if (queue_uuid && *queue_uuid) { + g_auto(GStrv) lines =3D g_strsplit(queue_uuid, "\n", 0); + + for (i =3D 0; lines[i] !=3D NULL; i++) { + const char *line =3D lines[i]; + if (!*line) { + continue; + } + virCommandFree(cmd); + cmd =3D virNetDevOpenvswitchCreateCmd(); + virCommandAddArgList(cmd, "destroy", "queue", line, NULL); + if (virCommandRun(cmd, NULL) < 0) { + VIR_WARN("Unable to destroy queue on port %s", ifname); + ret =3D -1; + } + } + } + + return ret; +} + +int +virNetDevOpenvswitchInterfaceClearRxQos(const char *ifname) +{ + g_autoptr(virCommand) cmd =3D NULL; + + cmd =3D virNetDevOpenvswitchCreateCmd(); + virCommandAddArgList(cmd, "set", "Interface", ifname, NULL); + virCommandAddArgFormat(cmd, "ingress_policing_rate=3D%llu", 0llu); + virCommandAddArgFormat(cmd, "ingress_policing_burst=3D%llu", 0llu); + + if (virCommandRun(cmd, NULL) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to reset ingress on port %s"), ifname); + return -1; + } + + return 0; +} + /* * In virNetDevBandwidthRate, average, peak, floor are in kilobyes and bur= st in * kibibytes. However other_config in ovs qos is in bits and @@ -822,104 +920,6 @@ virNetDevOpenvswitchInterfaceSetQos(const char *ifnam= e, return 0; } =20 -int -virNetDevOpenvswitchInterfaceClearTxQos(const char *ifname, - const unsigned char *vmuuid) -{ - int ret =3D 0; - char vmuuidstr[VIR_UUID_STRING_BUFLEN]; - g_autoptr(virCommand) cmd =3D NULL; - g_autofree char *ifname_ex_id =3D NULL; - g_autofree char *vmid_ex_id =3D NULL; - g_autofree char *qos_uuid =3D NULL; - g_autofree char *queue_uuid =3D NULL; - g_autofree char *port_qos =3D NULL; - size_t i; - - /* find qos */ - virUUIDFormat(vmuuid, vmuuidstr); - vmid_ex_id =3D g_strdup_printf("external-ids:vm-id=3D\"%s\"", vmuuidst= r); - ifname_ex_id =3D g_strdup_printf("external-ids:ifname=3D\"%s\"", ifnam= e); - /* find queue */ - queue_uuid =3D virNetDevOpenvswitchFindUUID("queue", vmid_ex_id, ifnam= e_ex_id); - /* find qos */ - qos_uuid =3D virNetDevOpenvswitchFindUUID("qos", vmid_ex_id, ifname_ex= _id); - - if (qos_uuid && *qos_uuid) { - g_auto(GStrv) lines =3D g_strsplit(qos_uuid, "\n", 0); - - /* destroy qos */ - for (i =3D 0; lines[i] !=3D NULL; i++) { - const char *line =3D lines[i]; - if (!*line) { - continue; - } - virCommandFree(cmd); - cmd =3D virNetDevOpenvswitchCreateCmd(); - virCommandAddArgList(cmd, "--no-heading", "--columns=3D_uuid",= "--if-exists", - "list", "port", ifname, "qos", NULL); - virCommandSetOutputBuffer(cmd, &port_qos); - if (virCommandRun(cmd, NULL) < 0) { - VIR_WARN("Unable to remove port qos on port %s", ifname); - } - if (port_qos && *port_qos) { - virCommandFree(cmd); - cmd =3D virNetDevOpenvswitchCreateCmd(); - virCommandAddArgList(cmd, "remove", "port", ifname, "qos",= line, NULL); - if (virCommandRun(cmd, NULL) < 0) { - VIR_WARN("Unable to remove port qos on port %s", ifnam= e); - } - } - virCommandFree(cmd); - cmd =3D virNetDevOpenvswitchCreateCmd(); - virCommandAddArgList(cmd, "destroy", "qos", line, NULL); - if (virCommandRun(cmd, NULL) < 0) { - VIR_WARN("Unable to destroy qos on port %s", ifname); - ret =3D -1; - } - } - } - /* destroy queue */ - if (queue_uuid && *queue_uuid) { - g_auto(GStrv) lines =3D g_strsplit(queue_uuid, "\n", 0); - - for (i =3D 0; lines[i] !=3D NULL; i++) { - const char *line =3D lines[i]; - if (!*line) { - continue; - } - virCommandFree(cmd); - cmd =3D virNetDevOpenvswitchCreateCmd(); - virCommandAddArgList(cmd, "destroy", "queue", line, NULL); - if (virCommandRun(cmd, NULL) < 0) { - VIR_WARN("Unable to destroy queue on port %s", ifname); - ret =3D -1; - } - } - } - - return ret; -} - -int -virNetDevOpenvswitchInterfaceClearRxQos(const char *ifname) -{ - g_autoptr(virCommand) cmd =3D NULL; - - cmd =3D virNetDevOpenvswitchCreateCmd(); - virCommandAddArgList(cmd, "set", "Interface", ifname, NULL); - virCommandAddArgFormat(cmd, "ingress_policing_rate=3D%llu", 0llu); - virCommandAddArgFormat(cmd, "ingress_policing_burst=3D%llu", 0llu); - - if (virCommandRun(cmd, NULL) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to reset ingress on port %s"), ifname); - return -1; - } - - return 0; -} - int virNetDevOpenvswitchInterfaceClearQos(const char *ifname, const unsigned char *vmuuid) --=20 2.31.1 From nobody Tue May 7 17:56:02 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1642437659; cv=none; d=zohomail.com; s=zohoarc; b=CCXKYEhQX3iCL7R0Afu1eXIp1vaplfZRGaFK7TsRNbOi+IyFL5fmqEvFHqXpKB4FsKbiHxYKDjQe0dBQlZWxkWjm/NqQjpRaBwhXxYnxUfDH3blaYKMTV1YqsQmL4RjZwvvJGrlNh/7LnZUOzgsPnKOF04S6AwgCQpWqx0iNKek= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642437659; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Y9kCBuSzmerNn/fVaSIK5HGXE4D2rwxkDsm+hb2cCOQ=; b=WDtg5fH9C/xxX2QREtbKFxCocw/fOttORwCnpxl44dRw0q9GB2MVEHjp9cFbgJ4kpoG4eqf8p57TiRufj4e9eaZaBqRgW4+RL0vDk39JglAz/RRM2G9vU/y9eW4OAwk+IQfPiT2LzHdt9QAT+tJPfyWfmQ4peo3PndPyuwouxuE= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) 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 1642437659725843.921276300554; Mon, 17 Jan 2022 08:40:59 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-107-CDuMXc-1O169WJit6YiEpA-1; Mon, 17 Jan 2022 11:40:55 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 266EE64171; Mon, 17 Jan 2022 16:40:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F3CBB2E020; Mon, 17 Jan 2022 16:40:49 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id BF6924A7CD; Mon, 17 Jan 2022 16:40:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20HGeklv006692 for ; Mon, 17 Jan 2022 11:40:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id B10E610A48CB; Mon, 17 Jan 2022 16:40:46 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A21410A48CA for ; Mon, 17 Jan 2022 16:40:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642437658; 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=Y9kCBuSzmerNn/fVaSIK5HGXE4D2rwxkDsm+hb2cCOQ=; b=iH4TL+pPm2RB5Vc2TKgrQCuZGos7AyfRGW3rfNJRbF2FADmF5gWxnzfYH/nORaQfrGyV4i ErQh/fwPk0RiZu8WcrHshTidi7RjBlBKdrB3LDMENeYTg/j7Tbx20WjbaH2+CAOydSwYLF +9T8usoWwhIJ2snjmQXMuR37023o4JE= X-MC-Unique: CDuMXc-1O169WJit6YiEpA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/6] util: openvswitch: unexport InterfaceClear{Rx, Tx}Qos Date: Mon, 17 Jan 2022 17:40:20 +0100 Message-Id: <477aeee6ed5832a1827f4164ebfeaa36588a0df0.1642437534.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642437661134100003 This also removes the indentation error. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/libvirt_private.syms | 2 -- src/util/virnetdevopenvswitch.c | 4 ++-- src/util/virnetdevopenvswitch.h | 7 ------- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index f75dea36c4..3f3357422e 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2825,8 +2825,6 @@ virNetDevOpenvswitchAddPort; virNetDevOpenvswitchGetMigrateData; virNetDevOpenvswitchGetVhostuserIfname; virNetDevOpenvswitchInterfaceClearQos; -virNetDevOpenvswitchInterfaceClearRxQos; -virNetDevOpenvswitchInterfaceClearTxQos; virNetDevOpenvswitchInterfaceGetMaster; virNetDevOpenvswitchInterfaceParseStats; virNetDevOpenvswitchInterfaceSetQos; diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitc= h.c index 5db4a397f4..b2cc2f36be 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -637,7 +637,7 @@ virNetDevOpenvswitchFindUUID(const char *table, return uuid; } =20 -int +static int virNetDevOpenvswitchInterfaceClearTxQos(const char *ifname, const unsigned char *vmuuid) { @@ -716,7 +716,7 @@ virNetDevOpenvswitchInterfaceClearTxQos(const char *ifn= ame, return ret; } =20 -int +static int virNetDevOpenvswitchInterfaceClearRxQos(const char *ifname) { g_autoptr(virCommand) cmd =3D NULL; diff --git a/src/util/virnetdevopenvswitch.h b/src/util/virnetdevopenvswitc= h.h index e275af59df..b16c8fe318 100644 --- a/src/util/virnetdevopenvswitch.h +++ b/src/util/virnetdevopenvswitch.h @@ -80,10 +80,3 @@ int virNetDevOpenvswitchInterfaceSetQos(const char *ifna= me, int virNetDevOpenvswitchInterfaceClearQos(const char *ifname, const unsigned char *vmuuid) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; - -int virNetDevOpenvswitchInterfaceClearRxQos(const char *ifname) -ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT; - -int virNetDevOpenvswitchInterfaceClearTxQos(const char *ifname, - const unsigned char *v= mid) -ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; --=20 2.31.1 From nobody Tue May 7 17:56:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642437659; cv=none; d=zohomail.com; s=zohoarc; b=PGTHcls9BVUGV6qnjxGr9dLy7njZse7oVM2DVnyjIdRa7pVkkzywOJVeb8ygxyXzlJjyE7E9kdc+3JmI0mEo+Czesz8krHXkrYhIUiGeyiFWNqOAWpRSLIiCIr4GxeCn6xCokqyzf4ONWf+M5HD7W6v2VCUhCtZtCAOnc4VSmgc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642437659; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TKUqUsaVkCqqK3yrIPc4/1UqPYZlqXLff03ndK1k4sQ=; b=ZmZDxjlW+jfCdsQvPSY7U+ta/4/aShtKvMGR8szr1O4ehjphP1PsQzmQ1yjmF+Oq+Ev0QJ25y5fGa6pHSD+HoB66lagoOvwmpxbwSCSWC4f9QWqNS0ljJyrpJmDosCaNV2NfwToMAA0OSMucekp4aedHLpvO2FarnUh1QhLLLPc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1642437659075190.36298831244756; Mon, 17 Jan 2022 08:40:59 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-344-ur3ueQhdMRyTgn9T623_Fw-1; Mon, 17 Jan 2022 11:40:54 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EB742100C619; Mon, 17 Jan 2022 16:40:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C85505B94A; Mon, 17 Jan 2022 16:40:48 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 949CD1809CB9; Mon, 17 Jan 2022 16:40:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20HGelOc006699 for ; Mon, 17 Jan 2022 11:40:47 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8150D10A48CB; Mon, 17 Jan 2022 16:40:47 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B10610A48CA for ; Mon, 17 Jan 2022 16:40:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642437658; 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=TKUqUsaVkCqqK3yrIPc4/1UqPYZlqXLff03ndK1k4sQ=; b=AHQD/F+1VHxaKuRYfnuf/3BVWuQsgpynIjpQGEr7yZAJvtc42dkVjU6IhWhBwo5P7Yb/yF X0ayg4rcD71RkaJ/vL7IfaoPyHpX2n8+QWri8dyK/zKF55AitThPF2E7TNjYEOnimT6L39 Fzu9tjvd70i/FCU3DV94b/gABNgq24Q= X-MC-Unique: ur3ueQhdMRyTgn9T623_Fw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 3/6] util: openvswitch: split out virNetDevOpenvswitchInterfaceSetTxQos Date: Mon, 17 Jan 2022 17:40:21 +0100 Message-Id: <8a64f249b86391f0778f9339a474af8ac1a1832c.1642437534.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642437660966100001 The virNetDevOpenvswitchInterfaceSetQos function is uneven because setting the Tx Qos is open-coded, while clearing it is sepearated in another function. Separate the setting too. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/util/virnetdevopenvswitch.c | 173 +++++++++++++++++--------------- 1 file changed, 92 insertions(+), 81 deletions(-) diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitc= h.c index b2cc2f36be..71bd961b5a 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -745,6 +745,97 @@ virNetDevOpenvswitchInterfaceClearRxQos(const char *if= name) #define KIBIBYTE_TO_BITS(x) (x * 8192ULL) #define VIR_NETDEV_RX_TO_OVS 8 =20 +static int +virNetDevOpenvswitchInterfaceSetTxQos(const char *ifname, + const virNetDevBandwidthRate *tx, + const unsigned char *vmuuid) +{ + char vmuuidstr[VIR_UUID_STRING_BUFLEN]; + g_autoptr(virCommand) cmd =3D NULL; + g_autofree char *vmid_ex_id =3D NULL; + g_autofree char *ifname_ex_id =3D NULL; + g_autofree char *average =3D NULL; + g_autofree char *peak =3D NULL; + g_autofree char *burst =3D NULL; + g_autofree char *qos_uuid =3D NULL; + g_autofree char *queue_uuid =3D NULL; + + average =3D g_strdup_printf("%llu", KBYTE_TO_BITS(tx->average)); + if (tx->burst) + burst =3D g_strdup_printf("%llu", KIBIBYTE_TO_BITS(tx->burst)); + if (tx->peak) + peak =3D g_strdup_printf("%llu", KBYTE_TO_BITS(tx->peak)); + + virUUIDFormat(vmuuid, vmuuidstr); + vmid_ex_id =3D g_strdup_printf("external-ids:vm-id=3D\"%s\"", vmuuidst= r); + ifname_ex_id =3D g_strdup_printf("external-ids:ifname=3D\"%s\"", ifnam= e); + /* find queue */ + queue_uuid =3D virNetDevOpenvswitchFindUUID("queue", vmid_ex_id, ifnam= e_ex_id); + /* find qos */ + qos_uuid =3D virNetDevOpenvswitchFindUUID("qos", vmid_ex_id, ifname_ex= _id); + + /* create qos and set */ + cmd =3D virNetDevOpenvswitchCreateCmd(); + if (queue_uuid && *queue_uuid) { + g_auto(GStrv) lines =3D g_strsplit(queue_uuid, "\n", 0); + virCommandAddArgList(cmd, "set", "queue", lines[0], NULL); + } else { + virCommandAddArgList(cmd, "set", "port", ifname, "qos=3D@qos1", + vmid_ex_id, ifname_ex_id, + "--", "--id=3D@qos1", "create", "qos", "type= =3Dlinux-htb", NULL); + virCommandAddArgFormat(cmd, "other_config:min-rate=3D%s", average); + if (burst) { + virCommandAddArgFormat(cmd, "other_config:burst=3D%s", burst); + } + if (peak) { + virCommandAddArgFormat(cmd, "other_config:max-rate=3D%s", peak= ); + } + virCommandAddArgList(cmd, "queues:0=3D@queue0", vmid_ex_id, ifname= _ex_id, + "--", "--id=3D@queue0", "create", "queue", NU= LL); + } + virCommandAddArgFormat(cmd, "other_config:min-rate=3D%s", average); + if (burst) { + virCommandAddArgFormat(cmd, "other_config:burst=3D%s", burst); + } + if (peak) { + virCommandAddArgFormat(cmd, "other_config:max-rate=3D%s", peak); + } + virCommandAddArgList(cmd, vmid_ex_id, ifname_ex_id, NULL); + if (virCommandRun(cmd, NULL) < 0) { + if (queue_uuid && *queue_uuid) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to set queue configuration on port %s= "), ifname); + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to create and set qos configuration o= n port %s"), ifname); + } + return -1; + } + + if (qos_uuid && *qos_uuid) { + g_auto(GStrv) lines =3D g_strsplit(qos_uuid, "\n", 0); + + virCommandFree(cmd); + cmd =3D virNetDevOpenvswitchCreateCmd(); + virCommandAddArgList(cmd, "set", "qos", lines[0], NULL); + virCommandAddArgFormat(cmd, "other_config:min-rate=3D%s", average); + if (burst) { + virCommandAddArgFormat(cmd, "other_config:burst=3D%s", burst); + } + if (peak) { + virCommandAddArgFormat(cmd, "other_config:max-rate=3D%s", peak= ); + } + virCommandAddArgList(cmd, vmid_ex_id, ifname_ex_id, NULL); + if (virCommandRun(cmd, NULL) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to set qos configuration on port %s")= , ifname); + return -1; + } + } + + return 0; +} + /** * virNetDevOpenvswitchInterfaceSetQos: * @ifname: on which interface @@ -807,88 +898,8 @@ virNetDevOpenvswitchInterfaceSetQos(const char *ifname, } =20 if (tx && tx->average) { - char vmuuidstr[VIR_UUID_STRING_BUFLEN]; - g_autoptr(virCommand) cmd =3D NULL; - g_autofree char *vmid_ex_id =3D NULL; - g_autofree char *ifname_ex_id =3D NULL; - g_autofree char *average =3D NULL; - g_autofree char *peak =3D NULL; - g_autofree char *burst =3D NULL; - g_autofree char *qos_uuid =3D NULL; - g_autofree char *queue_uuid =3D NULL; - - average =3D g_strdup_printf("%llu", KBYTE_TO_BITS(tx->average)); - if (tx->burst) - burst =3D g_strdup_printf("%llu", KIBIBYTE_TO_BITS(tx->burst)); - if (tx->peak) - peak =3D g_strdup_printf("%llu", KBYTE_TO_BITS(tx->peak)); - - virUUIDFormat(vmuuid, vmuuidstr); - vmid_ex_id =3D g_strdup_printf("external-ids:vm-id=3D\"%s\"", vmuu= idstr); - ifname_ex_id =3D g_strdup_printf("external-ids:ifname=3D\"%s\"", i= fname); - /* find queue */ - queue_uuid =3D virNetDevOpenvswitchFindUUID("queue", vmid_ex_id, i= fname_ex_id); - /* find qos */ - qos_uuid =3D virNetDevOpenvswitchFindUUID("qos", vmid_ex_id, ifnam= e_ex_id); - - /* create qos and set */ - cmd =3D virNetDevOpenvswitchCreateCmd(); - if (queue_uuid && *queue_uuid) { - g_auto(GStrv) lines =3D g_strsplit(queue_uuid, "\n", 0); - virCommandAddArgList(cmd, "set", "queue", lines[0], NULL); - } else { - virCommandAddArgList(cmd, "set", "port", ifname, "qos=3D@qos1", - vmid_ex_id, ifname_ex_id, - "--", "--id=3D@qos1", "create", "qos", "t= ype=3Dlinux-htb", NULL); - virCommandAddArgFormat(cmd, "other_config:min-rate=3D%s", aver= age); - if (burst) { - virCommandAddArgFormat(cmd, "other_config:burst=3D%s", bur= st); - } - if (peak) { - virCommandAddArgFormat(cmd, "other_config:max-rate=3D%s", = peak); - } - virCommandAddArgList(cmd, "queues:0=3D@queue0", vmid_ex_id, if= name_ex_id, - "--", "--id=3D@queue0", "create", "queue"= , NULL); - } - virCommandAddArgFormat(cmd, "other_config:min-rate=3D%s", average); - if (burst) { - virCommandAddArgFormat(cmd, "other_config:burst=3D%s", burst); - } - if (peak) { - virCommandAddArgFormat(cmd, "other_config:max-rate=3D%s", peak= ); - } - virCommandAddArgList(cmd, vmid_ex_id, ifname_ex_id, NULL); - if (virCommandRun(cmd, NULL) < 0) { - if (queue_uuid && *queue_uuid) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to set queue configuration on por= t %s"), ifname); - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to create and set qos configurati= on on port %s"), ifname); - } + if (virNetDevOpenvswitchInterfaceSetTxQos(ifname, tx, vmuuid) < 0) return -1; - } - - if (qos_uuid && *qos_uuid) { - g_auto(GStrv) lines =3D g_strsplit(qos_uuid, "\n", 0); - - virCommandFree(cmd); - cmd =3D virNetDevOpenvswitchCreateCmd(); - virCommandAddArgList(cmd, "set", "qos", lines[0], NULL); - virCommandAddArgFormat(cmd, "other_config:min-rate=3D%s", aver= age); - if (burst) { - virCommandAddArgFormat(cmd, "other_config:burst=3D%s", bur= st); - } - if (peak) { - virCommandAddArgFormat(cmd, "other_config:max-rate=3D%s", = peak); - } - virCommandAddArgList(cmd, vmid_ex_id, ifname_ex_id, NULL); - if (virCommandRun(cmd, NULL) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to set qos configuration on port = %s"), ifname); - return -1; - } - } } else { if (virNetDevOpenvswitchInterfaceClearTxQos(ifname, vmuuid) < 0) { VIR_WARN("Clean tx qos for interface %s failed", ifname); --=20 2.31.1 From nobody Tue May 7 17:56:02 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1642437668; cv=none; d=zohomail.com; s=zohoarc; b=LWmS52iHFTnQWPgw37xG3OpyGLeChRYVGIaKmqEqGODQy10BdJ3RZXgT2Zv8rN4fsmeUKegR4dNA5GwyPKePnjQ/IRerMIpTXrQsUnUa4UiXInr4baVXRGQwC8YVixCgl22MnG8nZFU1ffT59QOKCNY3xu0f8yyqvaxRvrPEsiY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642437668; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=q+bjGPFnOnFFel3B9fNqC6gUZw5RBK4QoacKfKD4NsY=; b=e1gg7x2znIB2aEBurbn52XvuLFstsLxha9Cg4XxtkU9NneXcGdI3l+YHOPK5s1srihaPtgYLMc0vA3Matm/8R6ibR07DktTOkXiu9ILp5QQ57nxtaBvdSWzKbo09/r06jZCwBooFJydKTLlICPI11eaFX5ovgTx2fO5q97z1c/w= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) 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 1642437668840423.02414404613864; Mon, 17 Jan 2022 08:41:08 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-627-JioDsaQvPlqFLG7NP1JsFw-1; Mon, 17 Jan 2022 11:40:58 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E76EB190A7C7; Mon, 17 Jan 2022 16:40:51 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C62484DC0B; Mon, 17 Jan 2022 16:40:51 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 91B8C180BAD1; Mon, 17 Jan 2022 16:40:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20HGemuj006704 for ; Mon, 17 Jan 2022 11:40:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 51ECD10A48CB; Mon, 17 Jan 2022 16:40:48 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF9EC10A48CA for ; Mon, 17 Jan 2022 16:40:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642437667; 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=q+bjGPFnOnFFel3B9fNqC6gUZw5RBK4QoacKfKD4NsY=; b=HLHLmATvwbZ3thTKb1I4EgXXgZChfTxW1R/as+Ppdxqf3v40/6uh8jokl8XIQbjSH694Fv a9LeUyIe/PcDksqVa9vIpcB0qrV3kHBdECA7QtrAc8vMEAtL9onzze2siihIAx2VolT3gb PBwM5NhI0BZiUSGcC+F1UjoCQ2yAyoQ= X-MC-Unique: JioDsaQvPlqFLG7NP1JsFw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 4/6] util: openvswitch: split out virNetDevOpenvswitchInterfaceSetRxQos Date: Mon, 17 Jan 2022 17:40:22 +0100 Message-Id: <1ad85dcd5a9841d55e0cd02fd1aa796353372533.1642437534.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642437669631100001 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=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/util/virnetdevopenvswitch.c | 38 +++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitc= h.c index 71bd961b5a..32f423ef04 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -836,6 +836,29 @@ virNetDevOpenvswitchInterfaceSetTxQos(const char *ifna= me, return 0; } =20 +static int +virNetDevOpenvswitchInterfaceSetRxQos(const char *ifname, + const virNetDevBandwidthRate *rx) +{ + g_autoptr(virCommand) cmd =3D NULL; + + cmd =3D virNetDevOpenvswitchCreateCmd(); + virCommandAddArgList(cmd, "set", "Interface", ifname, NULL); + virCommandAddArgFormat(cmd, "ingress_policing_rate=3D%llu", + rx->average * VIR_NETDEV_RX_TO_OVS); + if (rx->burst) + virCommandAddArgFormat(cmd, "ingress_policing_burst=3D%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"), i= fname); + return -1; + } + + return 0; +} + /** * virNetDevOpenvswitchInterfaceSetQos: * @ifname: on which interface @@ -907,21 +930,8 @@ virNetDevOpenvswitchInterfaceSetQos(const char *ifname, } =20 if (rx) { - g_autoptr(virCommand) cmd =3D NULL; - - cmd =3D virNetDevOpenvswitchCreateCmd(); - virCommandAddArgList(cmd, "set", "Interface", ifname, NULL); - virCommandAddArgFormat(cmd, "ingress_policing_rate=3D%llu", - rx->average * VIR_NETDEV_RX_TO_OVS); - if (rx->burst) - virCommandAddArgFormat(cmd, "ingress_policing_burst=3D%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); --=20 2.31.1 From nobody Tue May 7 17:56:02 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1642437664; cv=none; d=zohomail.com; s=zohoarc; b=CQCqOQkJuygoBjqj3dP7jmGqoC/BWjCXO2PJT5ui/XgHS/v7011WVC3Y73sVcLenQAwFlyTIVnU6M0tTEl0bfq7r7j6OjCc5c6LxOYg/22B2DqGPuABaHvlphchqdHHTeWpxg1bTTrTB0gFNVm0+tYEH3Bsqf03rHcvjqE6/SEg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642437664; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Yp4styILA/+5wgHDZZ5aPRR8NPIKvkZle5BYd/4UBFU=; b=mqpSFufb866LvnFs9g2rvUb831dDY4+/4GiUQCtojwe+4Vjlfn9xv4VnKZfCe+2NeyPJRdhaJaT8Sjv3MSFi7Zh6snZX1fp0IMGA3kjzAvJGSdoGyxowCi5ZO7dVfWOjTqZhDN0cykrFXFIwXbMp8V9Lt0uqU9TN1mtHqKSDeM4= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) 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 16424376642011020.1900741396076; Mon, 17 Jan 2022 08:41:04 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-111-suO_FBZ-M5S3tO7txrqxqQ-1; Mon, 17 Jan 2022 11:41:01 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A54FB876ED0; Mon, 17 Jan 2022 16:40:52 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 66AC74DC0C; Mon, 17 Jan 2022 16:40:52 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 015BE4A7CB; Mon, 17 Jan 2022 16:40:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20HGenqN006712 for ; Mon, 17 Jan 2022 11:40:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id 21ABF10A48CB; Mon, 17 Jan 2022 16:40:49 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id A09D610A48CA for ; Mon, 17 Jan 2022 16:40:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642437663; 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=Yp4styILA/+5wgHDZZ5aPRR8NPIKvkZle5BYd/4UBFU=; b=PK38/Qsiip39TIRmRjYV8xL8wWmIu3Dk18UuEV67KFgIqp8ivVtvR5tSUdQgcR3KQmQxy9 YMNR6ivShY1eH9LM1eN7FvU4gwu0czcQskfFdUH1wJbxy6CvEMiXyV4fWqW00aQ8zZcn7B xYwIDY4jVt3MZhb0MAoHtXGrpLGQgiU= X-MC-Unique: suO_FBZ-M5S3tO7txrqxqQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 5/6] util: openvswitch: do not reuse cmd in InterfaceSetTxQos Date: Mon, 17 Jan 2022 17:40:23 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642437666248100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/util/virnetdevopenvswitch.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitc= h.c index 32f423ef04..a5180e5843 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -814,19 +814,18 @@ virNetDevOpenvswitchInterfaceSetTxQos(const char *ifn= ame, =20 if (qos_uuid && *qos_uuid) { g_auto(GStrv) lines =3D g_strsplit(qos_uuid, "\n", 0); + g_autoptr(virCommand) qoscmd =3D virNetDevOpenvswitchCreateCmd(); =20 - virCommandFree(cmd); - cmd =3D virNetDevOpenvswitchCreateCmd(); - virCommandAddArgList(cmd, "set", "qos", lines[0], NULL); - virCommandAddArgFormat(cmd, "other_config:min-rate=3D%s", average); + virCommandAddArgList(qoscmd, "set", "qos", lines[0], NULL); + virCommandAddArgFormat(qoscmd, "other_config:min-rate=3D%s", avera= ge); if (burst) { - virCommandAddArgFormat(cmd, "other_config:burst=3D%s", burst); + virCommandAddArgFormat(qoscmd, "other_config:burst=3D%s", burs= t); } if (peak) { - virCommandAddArgFormat(cmd, "other_config:max-rate=3D%s", peak= ); + virCommandAddArgFormat(qoscmd, "other_config:max-rate=3D%s", p= eak); } - virCommandAddArgList(cmd, vmid_ex_id, ifname_ex_id, NULL); - if (virCommandRun(cmd, NULL) < 0) { + virCommandAddArgList(qoscmd, vmid_ex_id, ifname_ex_id, NULL); + if (virCommandRun(qoscmd, NULL) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to set qos configuration on port %s")= , ifname); return -1; --=20 2.31.1 From nobody Tue May 7 17:56:02 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1642437663; cv=none; d=zohomail.com; s=zohoarc; b=JpFiZwQ3W/Tc6hgsW5pm0zErjx/Kc0gRtVlN7Wb6bEEWQ/6TJHDFbJg2m5sCAwIO4tPvRo1SJRmR9ob6+D1ngxMeoqwtuW9AUCwmeeNfB5tN13Gpr2eNvQhv5tvnfuxhHlPb8+tJ9LuXC1UAuGTls5rrgk1rGmMv93beQQ2/w40= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642437663; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fF/XZacGkwPWX4BLk/NmxXebonvalxUq2HF20Ph9shE=; b=GT+KDlaPGesNp4N1pzhmabNhAMeYCPgRzaruLmEMDfDwtn6NTTHppJk48TlQBwA8MnFixDfJmrUnIEgB9C6QTN42EQhMoapQT8zLcy2p1bJGlixGLBH06Z2TuHAm/7V+cs8Qfomet63tQFTfVvpcqq9S9Xf1ojAOrarSBf6vikQ= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) 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 1642437663578458.17870013591426; Mon, 17 Jan 2022 08:41:03 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-173-ZgrA5POeNjOSWJ1dlouU7Q-1; Mon, 17 Jan 2022 11:41:00 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 72A82190A7D1; Mon, 17 Jan 2022 16:40:55 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 076934DC02; Mon, 17 Jan 2022 16:40:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C7CD44A706; Mon, 17 Jan 2022 16:40:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20HGentV006725 for ; Mon, 17 Jan 2022 11:40:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id E5F0F10A48CB; Mon, 17 Jan 2022 16:40:49 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 708B710A48CA for ; Mon, 17 Jan 2022 16:40:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642437662; 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=fF/XZacGkwPWX4BLk/NmxXebonvalxUq2HF20Ph9shE=; b=SxBph9T9PhFdIwmNA76J/0u4zpF5O/ngMnqkY2lNaCRm25ou0rSgUaiJf6GIQisdYnToqr XYLunjzp8E9DdxO6U9yRV7wC43unVSOwrwcHwgThI8XvAStwnfjxKgN8OIJvD5XoqusqcG SPd2ff1no4+IoYaIk1vWWPkm06KCgeA= X-MC-Unique: ZgrA5POeNjOSWJ1dlouU7Q-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 6/6] util: openvswitch: do not reuse cmd in InterfaceClearTxQos Date: Mon, 17 Jan 2022 17:40:24 +0100 Message-Id: <7e6f5feef8e43ee2faceda2c0ea707e228f7eb7e.1642437534.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642437664082100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/util/virnetdevopenvswitch.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitc= h.c index a5180e5843..bcdb7c4180 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -643,7 +643,6 @@ virNetDevOpenvswitchInterfaceClearTxQos(const char *ifn= ame, { int ret =3D 0; char vmuuidstr[VIR_UUID_STRING_BUFLEN]; - g_autoptr(virCommand) cmd =3D NULL; g_autofree char *ifname_ex_id =3D NULL; g_autofree char *vmid_ex_id =3D NULL; g_autofree char *qos_uuid =3D NULL; @@ -666,29 +665,29 @@ virNetDevOpenvswitchInterfaceClearTxQos(const char *i= fname, /* destroy qos */ for (i =3D 0; lines[i] !=3D NULL; i++) { const char *line =3D lines[i]; + g_autoptr(virCommand) listcmd =3D NULL; + g_autoptr(virCommand) destroycmd =3D NULL; + if (!*line) { continue; } - virCommandFree(cmd); - cmd =3D virNetDevOpenvswitchCreateCmd(); - virCommandAddArgList(cmd, "--no-heading", "--columns=3D_uuid",= "--if-exists", + listcmd =3D virNetDevOpenvswitchCreateCmd(); + virCommandAddArgList(listcmd, "--no-heading", "--columns=3D_uu= id", "--if-exists", "list", "port", ifname, "qos", NULL); - virCommandSetOutputBuffer(cmd, &port_qos); - if (virCommandRun(cmd, NULL) < 0) { + virCommandSetOutputBuffer(listcmd, &port_qos); + if (virCommandRun(listcmd, NULL) < 0) { VIR_WARN("Unable to remove port qos on port %s", ifname); } if (port_qos && *port_qos) { - virCommandFree(cmd); - cmd =3D virNetDevOpenvswitchCreateCmd(); + g_autoptr(virCommand) cmd =3D virNetDevOpenvswitchCreateCm= d(); virCommandAddArgList(cmd, "remove", "port", ifname, "qos",= line, NULL); if (virCommandRun(cmd, NULL) < 0) { VIR_WARN("Unable to remove port qos on port %s", ifnam= e); } } - virCommandFree(cmd); - cmd =3D virNetDevOpenvswitchCreateCmd(); - virCommandAddArgList(cmd, "destroy", "qos", line, NULL); - if (virCommandRun(cmd, NULL) < 0) { + destroycmd =3D virNetDevOpenvswitchCreateCmd(); + virCommandAddArgList(destroycmd, "destroy", "qos", line, NULL); + if (virCommandRun(destroycmd, NULL) < 0) { VIR_WARN("Unable to destroy qos on port %s", ifname); ret =3D -1; } @@ -699,11 +698,12 @@ virNetDevOpenvswitchInterfaceClearTxQos(const char *i= fname, g_auto(GStrv) lines =3D g_strsplit(queue_uuid, "\n", 0); =20 for (i =3D 0; lines[i] !=3D NULL; i++) { + g_autoptr(virCommand) cmd =3D NULL; const char *line =3D lines[i]; if (!*line) { continue; } - virCommandFree(cmd); + cmd =3D virNetDevOpenvswitchCreateCmd(); virCommandAddArgList(cmd, "destroy", "queue", line, NULL); if (virCommandRun(cmd, NULL) < 0) { --=20 2.31.1