From nobody Sun Feb 8 07:07:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1555521618; cv=none; d=zoho.com; s=zohoarc; b=GlY0W1B+UspSw9JIouGlLiDY7bD7MafTmL4HTLTvEQz3gGYWAmrdeCDybUa8hizQ++MFWQtHWgXJyOXvdhvsE6uZ54ylnTmWAzRPSHKfNZ0C3Dac9bdMkcA2zapXZ9y11KFoSdUxIB3qFtYGDambs0K2H/k4r/sOkQwztFDmKv4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555521618; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=ySo/UVC3gH5yQTjpEKuhml5WwfhdouV8nmFkQBusvpY=; b=mEOWHFEt25GwR3DWTArDXIQMQgF1dp87SOJwyFTd4z3kezJqwBQWDLoL8klKKdR4FBPHu6RKPZ/yusqyzbA8LNZbHLl7BPO5ZeqSW7l9dOAfBv8z3pnbNRh0dhbPEmXQ9Bls5aEpOrq4EDHPzbAv+qDtSW5cKZGjTEvHQuUGqxY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1555521618458328.80668887644515; Wed, 17 Apr 2019 10:20:18 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E370881DE3; Wed, 17 Apr 2019 17:20:16 +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 B73D61001DD5; Wed, 17 Apr 2019 17:20:16 +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 7EB503FA4A; Wed, 17 Apr 2019 17:20:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x3HHKFsp030672 for ; Wed, 17 Apr 2019 13:20:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id E11165D6A6; Wed, 17 Apr 2019 17:20:15 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-35.ams2.redhat.com [10.36.112.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 664095D71B; Wed, 17 Apr 2019 17:20:14 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 17 Apr 2019 18:19:15 +0100 Message-Id: <20190417171929.9399-16-berrange@redhat.com> In-Reply-To: <20190417171929.9399-1-berrange@redhat.com> References: <20190417171929.9399-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Laine Stump Subject: [libvirt] [PATCH v4 15/29] network: remove the virDomainNetBandwidthChangeAllowed callback 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 17 Apr 2019 17:20:17 +0000 (UTC) The current qemu driver code for changing bandwidth on a NIC first asks the network driver if the change is supported, then changes the bandwidth on the VIF, and then tells the network driver to update the bandwidth on the bridge. This is potentially racing if a parallel API call causes the network driver to allocate bandwidth on the bridge between the check and the update phases. Change the code to just try to apply the network bridge update immediately and rollback at the end if something failed. Reviewed-by: Laine Stump Signed-off-by: Daniel P. Berrang=C3=A9 --- src/conf/domain_conf.c | 15 -------- src/conf/domain_conf.h | 10 ----- src/libvirt_private.syms | 1 - src/network/bridge_driver.c | 75 ++++++++----------------------------- src/qemu/qemu_driver.c | 8 ++-- 5 files changed, 20 insertions(+), 89 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ad2b59abb4..1be78e1e26 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -30666,7 +30666,6 @@ virDomainNetDefActualToNetworkPort(virDomainDefPtr = dom, static virDomainNetAllocateActualDeviceImpl netAllocate; static virDomainNetNotifyActualDeviceImpl netNotify; static virDomainNetReleaseActualDeviceImpl netRelease; -static virDomainNetBandwidthChangeAllowedImpl netBandwidthChangeAllowed; static virDomainNetBandwidthUpdateImpl netBandwidthUpdate; =20 =20 @@ -30674,13 +30673,11 @@ void virDomainNetSetDeviceImpl(virDomainNetAllocateActualDeviceImpl allocate, virDomainNetNotifyActualDeviceImpl notify, virDomainNetReleaseActualDeviceImpl release, - virDomainNetBandwidthChangeAllowedImpl bandwidth= ChangeAllowed, virDomainNetBandwidthUpdateImpl bandwidthUpdate) { netAllocate =3D allocate; netNotify =3D notify; netRelease =3D release; - netBandwidthChangeAllowed =3D bandwidthChangeAllowed; netBandwidthUpdate =3D bandwidthUpdate; } =20 @@ -30774,18 +30771,6 @@ virDomainNetReleaseActualDevice(virConnectPtr conn, return ret; } =20 -bool -virDomainNetBandwidthChangeAllowed(virDomainNetDefPtr iface, - virNetDevBandwidthPtr newBandwidth) -{ - if (!netBandwidthChangeAllowed) { - virReportError(VIR_ERR_NO_SUPPORT, "%s", - _("Virtual networking driver is not available")); - return -1; - } - - return netBandwidthChangeAllowed(iface, newBandwidth); -} =20 int virDomainNetBandwidthUpdate(virDomainNetDefPtr iface, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 4f6229f289..be43b31123 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3579,10 +3579,6 @@ typedef int virDomainDefPtr dom, virDomainNetDefPtr iface); =20 -typedef bool -(*virDomainNetBandwidthChangeAllowedImpl)(virDomainNetDefPtr iface, - virNetDevBandwidthPtr newBandwid= th); - typedef int (*virDomainNetBandwidthUpdateImpl)(virDomainNetDefPtr iface, virNetDevBandwidthPtr newBandwidth); @@ -3592,7 +3588,6 @@ void virDomainNetSetDeviceImpl(virDomainNetAllocateActualDeviceImpl allocate, virDomainNetNotifyActualDeviceImpl notify, virDomainNetReleaseActualDeviceImpl release, - virDomainNetBandwidthChangeAllowedImpl bandwidth= ChangeAllowed, virDomainNetBandwidthUpdateImpl bandwidthUpdate); =20 int @@ -3613,11 +3608,6 @@ virDomainNetReleaseActualDevice(virConnectPtr conn, virDomainNetDefPtr iface) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); =20 -bool -virDomainNetBandwidthChangeAllowed(virDomainNetDefPtr iface, - virNetDevBandwidthPtr newBandwidth) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); - int virDomainNetBandwidthUpdate(virDomainNetDefPtr iface, virNetDevBandwidthPtr newBandwidth) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 4b1498d83c..29250cdb75 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -456,7 +456,6 @@ virDomainMemorySourceTypeFromString; virDomainMemorySourceTypeToString; virDomainNetAllocateActualDevice; virDomainNetAppendIPAddress; -virDomainNetBandwidthChangeAllowed; virDomainNetBandwidthUpdate; virDomainNetDefActualFromNetworkPort; virDomainNetDefActualToNetworkPort; diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index e212ba14e5..f8b58b3a25 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -5352,63 +5352,6 @@ networkNetworkObjTaint(virNetworkObjPtr obj, } =20 =20 -static bool -networkBandwidthGenericChecks(virDomainNetDefPtr iface, - virNetDevBandwidthPtr newBandwidth) -{ - virNetDevBandwidthPtr ifaceBand; - unsigned long long old_floor, new_floor; - - if (virDomainNetGetActualType(iface) !=3D VIR_DOMAIN_NET_TYPE_BRIDGE || - iface->data.network.actual->data.bridge.brname =3D=3D NULL) { - /* This is not an interface that's plugged into a network. - * We don't care. Thus from our POV bandwidth change is allowed. */ - return false; - } - - ifaceBand =3D virDomainNetGetActualBandwidth(iface); - old_floor =3D new_floor =3D 0; - - if (ifaceBand && ifaceBand->in) - old_floor =3D ifaceBand->in->floor; - if (newBandwidth && newBandwidth->in) - new_floor =3D newBandwidth->in->floor; - - return new_floor !=3D old_floor; -} - - -static bool -networkBandwidthChangeAllowed(virDomainNetDefPtr iface, - virNetDevBandwidthPtr newBandwidth) -{ - virNetworkDriverStatePtr driver =3D networkGetDriver(); - virNetworkObjPtr obj =3D NULL; - virNetDevBandwidthPtr ifaceBand =3D virDomainNetGetActualBandwidth(ifa= ce); - bool ret =3D false; - - if (!networkBandwidthGenericChecks(iface, newBandwidth)) - return true; - - obj =3D virNetworkObjFindByName(driver->networks, iface->data.network.= name); - if (!obj) { - virReportError(VIR_ERR_NO_NETWORK, - _("no network with matching name '%s'"), - iface->data.network.name); - return false; - } - - if (networkCheckBandwidth(obj, newBandwidth, ifaceBand, &iface->mac, N= ULL) < 0) - goto cleanup; - - ret =3D true; - - cleanup: - virNetworkObjEndAPI(&obj); - return ret; -} - - static int networkBandwidthUpdate(virDomainNetDefPtr iface, virNetDevBandwidthPtr newBandwidth) @@ -5419,6 +5362,7 @@ networkBandwidthUpdate(virDomainNetDefPtr iface, unsigned long long tmp_floor_sum; virNetDevBandwidthPtr ifaceBand =3D virDomainNetGetActualBandwidth(ifa= ce); unsigned long long new_rate =3D 0; + unsigned long long old_floor, new_floor; int plug_ret; int ret =3D -1; =20 @@ -5428,7 +5372,21 @@ networkBandwidthUpdate(virDomainNetDefPtr iface, return -1; } =20 - if (!networkBandwidthGenericChecks(iface, newBandwidth)) + if (virDomainNetGetActualType(iface) !=3D VIR_DOMAIN_NET_TYPE_BRIDGE || + iface->data.network.actual->data.bridge.brname =3D=3D NULL) { + /* This is not an interface that's plugged into a bridge. + * We don't care. Thus from our POV bandwidth change is allowed. */ + return 0; + } + + old_floor =3D new_floor =3D 0; + + if (ifaceBand && ifaceBand->in) + old_floor =3D ifaceBand->in->floor; + if (newBandwidth && newBandwidth->in) + new_floor =3D newBandwidth->in->floor; + + if (new_floor =3D=3D old_floor) return 0; =20 obj =3D virNetworkObjFindByName(driver->networks, iface->data.network.= name); @@ -5574,7 +5532,6 @@ networkRegister(void) networkAllocateActualDevice, networkNotifyActualDevice, networkReleaseActualDevice, - networkBandwidthChangeAllowed, networkBandwidthUpdate); =20 return 0; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 31d8647eee..6393a25b9a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -11628,17 +11628,17 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, } =20 if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK && - !virDomainNetBandwidthChangeAllowed(net, newBandwidth)) + virDomainNetBandwidthUpdate(net, newBandwidth) < 0) goto endjob; =20 if (virNetDevBandwidthSet(net->ifname, newBandwidth, false, - !virDomainNetTypeSharesHostView(net)) < = 0 || - (net->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK && - virDomainNetBandwidthUpdate(net, newBandwidth) < 0)) { + !virDomainNetTypeSharesHostView(net)) < = 0) { ignore_value(virNetDevBandwidthSet(net->ifname, net->bandwidth, false, !virDomainNetTypeSharesHost= View(net))); + ignore_value(virDomainNetBandwidthUpdate(net, + net->bandwidth)); goto endjob; } =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list