From nobody Mon Feb 9 15:08:17 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1581697614337293.6562540071196; Fri, 14 Feb 2020 08:26:54 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-215-Vnx6EM9DMmeHXNBDImPBhA-1; Fri, 14 Feb 2020 11:26:50 -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 B673B13E6; Fri, 14 Feb 2020 16:26:43 +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 886625C13E; Fri, 14 Feb 2020 16:26:43 +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 2DA0F8B2C8; Fri, 14 Feb 2020 16:26:43 +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 01EGQU8d028503 for ; Fri, 14 Feb 2020 11:26:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id B78241001B3F; Fri, 14 Feb 2020 16:26:30 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 048951001B28; Fri, 14 Feb 2020 16:26:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581697612; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=0ecCAvAs8RN9b72q+4/aIgDwmaxt5re9ICZls2cJpoM=; b=Og3mJgGMCzxZ+1bL80eOcbbfC8iaendmE7B7wVq9M/YMRo5t70W0GgnL6LPPU/qniW6lVU LnA7mvhUmR2e5sF4fpdNSAtaZOV0mPaAgVunqttI9tDn0FArfK6hzgzdLE/+NCeYY5m5yN gm4qhV8+juD2YnyoULWXyJNAyXgje38= From: Pavel Mores To: libvir-list@redhat.com Subject: [libvirt PATCH v2 1/6] qemu: test if bandwidth has 'floor' factored out to separate function Date: Fri, 14 Feb 2020 17:26:19 +0100 Message-Id: <20200214162624.147825-2-pmores@redhat.com> In-Reply-To: <20200214162624.147825-1-pmores@redhat.com> References: <20200214162624.147825-1-pmores@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Pavel Mores 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 X-MC-Unique: Vnx6EM9DMmeHXNBDImPBhA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This compound condition will be useful in several places so it makes sense to give it a name for better readability. Signed-off-by: Pavel Mores --- src/conf/netdev_bandwidth_conf.h | 7 +++++++ src/network/bridge_driver.c | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/conf/netdev_bandwidth_conf.h b/src/conf/netdev_bandwidth_c= onf.h index 0004e48a4a..5b5ed52566 100644 --- a/src/conf/netdev_bandwidth_conf.h +++ b/src/conf/netdev_bandwidth_conf.h @@ -23,6 +23,7 @@ #include "virbuffer.h" #include "virxml.h" #include "domain_conf.h" +#include "network_conf.h" =20 int virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidth, unsigned int *class_id, @@ -57,3 +58,9 @@ static inline bool virNetDevSupportBandwidth(virDomainNet= Type type) } return false; } + + +static inline bool virNetDevBandwidthHasFloor(const virNetDevBandwidth *b) +{ + return b && b->in && b->in->floor !=3D 0; +} diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 94212eec77..14976c9821 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -5065,8 +5065,7 @@ networkCheckBandwidth(virNetworkObjPtr obj, =20 virMacAddrFormat(ifaceMac, ifmac); =20 - if (ifaceBand && ifaceBand->in && ifaceBand->in->floor && - !(netBand && netBand->in)) { + if (virNetDevBandwidthHasFloor(ifaceBand) && !(netBand && netBand->in)= ) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("Invalid use of 'floor' on interface with MAC " "address %s - network '%s' has no inbound QoS set= "), @@ -5079,8 +5078,9 @@ networkCheckBandwidth(virNetworkObjPtr obj, /* no QoS required, claim success */ return 1; } - if (((!ifaceBand || !ifaceBand->in || !ifaceBand->in->floor) && - (!oldBandwidth || !oldBandwidth->in || !oldBandwidth->in->floor))= ) { + if (!virNetDevBandwidthHasFloor(ifaceBand) && + !virNetDevBandwidthHasFloor(oldBandwidth)) { + VIR_DEBUG("No old/new interface bandwidth floor"); /* no QoS required, claim success */ return 1; --=20 2.24.1