From nobody Wed Dec 17 06:08:43 2025 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1517844531976194.78224144039962; Mon, 5 Feb 2018 07:28:51 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id C197980F95; Mon, 5 Feb 2018 15:28:50 +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 6AAFA5C25E; Mon, 5 Feb 2018 15:28:50 +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 2D61A18033DC; Mon, 5 Feb 2018 15:28:50 +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 w15FSjKO002859 for ; Mon, 5 Feb 2018 10:28:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3B1BA5D6B4; Mon, 5 Feb 2018 15:28:45 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id 887D35D6A8; Mon, 5 Feb 2018 15:28:44 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Mon, 5 Feb 2018 15:28:20 +0000 Message-Id: <20180205152829.12577-7-berrange@redhat.com> In-Reply-To: <20180205152829.12577-1-berrange@redhat.com> References: <20180205152829.12577-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: Peter Krempa Subject: [libvirt] [PATCH v3 06/15] conf: expand network device callbacks to cover bandwidth updates 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.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 05 Feb 2018 15:28:51 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Currently the QEMU driver will call directly into the network driver impl to modify network device bandwidth for interfaces with type=3Dnetwork. This introduces a callback system to allow us to decouple the QEMU driver from the network driver. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/conf/domain_conf.c | 35 ++++++++++++++++++++++++++++++++++- src/conf/domain_conf.h | 22 +++++++++++++++++++++- src/libvirt_private.syms | 2 ++ src/network/bridge_driver.c | 8 +++++--- src/network/bridge_driver.h | 24 ------------------------ src/qemu/qemu_driver.c | 5 ++--- 6 files changed, 64 insertions(+), 32 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1e3a83cf73..205f99618d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -28820,15 +28820,22 @@ virDomainNetTypeSharesHostView(const virDomainNet= Def *net) static virDomainNetAllocateActualDeviceImpl netAllocate; static virDomainNetNotifyActualDeviceImpl netNotify; static virDomainNetReleaseActualDeviceImpl netRelease; +static virDomainNetBandwidthChangeAllowedImpl netBandwidthChangeAllowed; +static virDomainNetBandwidthUpdateImpl netBandwidthUpdate; + =20 void virDomainNetSetDeviceImpl(virDomainNetAllocateActualDeviceImpl allocate, virDomainNetNotifyActualDeviceImpl notify, - virDomainNetReleaseActualDeviceImpl release) + virDomainNetReleaseActualDeviceImpl release, + virDomainNetBandwidthChangeAllowedImpl bandwidth= ChangeAllowed, + virDomainNetBandwidthUpdateImpl bandwidthUpdate) { netAllocate =3D allocate; netNotify =3D notify; netRelease =3D release; + netBandwidthChangeAllowed =3D bandwidthChangeAllowed; + netBandwidthUpdate =3D bandwidthUpdate; } =20 int @@ -28870,3 +28877,29 @@ virDomainNetReleaseActualDevice(virDomainDefPtr do= m, =20 return netRelease(dom, iface); } + +bool +virDomainNetBandwidthChangeAllowed(virDomainNetDefPtr iface, + virNetDevBandwidthPtr newBandwidth) +{ + if (!netBandwidthChangeAllowed) { + virReportError(VIR_ERR_NO_SUPPORT, "%s", + _("Network device release not available")); + return -1; + } + + return netBandwidthChangeAllowed(iface, newBandwidth); +} + +int +virDomainNetBandwidthUpdate(virDomainNetDefPtr iface, + virNetDevBandwidthPtr newBandwidth) +{ + if (!netBandwidthUpdate) { + virReportError(VIR_ERR_NO_SUPPORT, "%s", + _("Network device release not available")); + return -1; + } + + return netBandwidthUpdate(iface, newBandwidth); +} diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 45461f8ef2..32948e181c 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3466,10 +3466,21 @@ typedef int (*virDomainNetReleaseActualDeviceImpl)(virDomainDefPtr dom, virDomainNetDefPtr iface); =20 +typedef bool +(*virDomainNetBandwidthChangeAllowedImpl)(virDomainNetDefPtr iface, + virNetDevBandwidthPtr newBandwid= th); + +typedef int +(*virDomainNetBandwidthUpdateImpl)(virDomainNetDefPtr iface, + virNetDevBandwidthPtr newBandwidth); + + void virDomainNetSetDeviceImpl(virDomainNetAllocateActualDeviceImpl allocate, virDomainNetNotifyActualDeviceImpl notify, - virDomainNetReleaseActualDeviceImpl release); + virDomainNetReleaseActualDeviceImpl release, + virDomainNetBandwidthChangeAllowedImpl bandwidth= ChangeAllowed, + virDomainNetBandwidthUpdateImpl bandwidthUpdate); =20 int virDomainNetAllocateActualDevice(virDomainDefPtr dom, @@ -3486,6 +3497,15 @@ virDomainNetReleaseActualDevice(virDomainDefPtr dom, 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) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); =20 =20 #endif /* __DOMAIN_CONF_H */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index ecb90febc0..45ae25e57c 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -435,6 +435,8 @@ virDomainMemorySourceTypeFromString; virDomainMemorySourceTypeToString; virDomainNetAllocateActualDevice; virDomainNetAppendIPAddress; +virDomainNetBandwidthChangeAllowed; +virDomainNetBandwidthUpdate; virDomainNetDefClear; virDomainNetDefFormat; virDomainNetDefFree; diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 4113217882..ab1d82ed31 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -5631,7 +5631,7 @@ networkBandwidthGenericChecks(virDomainNetDefPtr ifac= e, } =20 =20 -bool +static bool networkBandwidthChangeAllowed(virDomainNetDefPtr iface, virNetDevBandwidthPtr newBandwidth) { @@ -5662,7 +5662,7 @@ networkBandwidthChangeAllowed(virDomainNetDefPtr ifac= e, } =20 =20 -int +static int networkBandwidthUpdate(virDomainNetDefPtr iface, virNetDevBandwidthPtr newBandwidth) { @@ -5814,7 +5814,9 @@ networkRegister(void) virDomainNetSetDeviceImpl( networkAllocateActualDevice, networkNotifyActualDevice, - networkReleaseActualDevice); + networkReleaseActualDevice, + networkBandwidthChangeAllowed, + networkBandwidthUpdate); =20 return 0; } diff --git a/src/network/bridge_driver.h b/src/network/bridge_driver.h index dbb4fa8086..098f9e5c5b 100644 --- a/src/network/bridge_driver.h +++ b/src/network/bridge_driver.h @@ -52,16 +52,6 @@ networkDnsmasqConfContents(virNetworkObjPtr obj, dnsmasqContext *dctx, dnsmasqCapsPtr caps); =20 -bool -networkBandwidthChangeAllowed(virDomainNetDefPtr iface, - virNetDevBandwidthPtr newBandwidth) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); - -int -networkBandwidthUpdate(virDomainNetDefPtr iface, - virNetDevBandwidthPtr newBandwidth) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); - # else /* Define no-op replacements that don't drag in any link dependencies. */ # define networkGetActualType(iface) (iface->type) @@ -69,20 +59,6 @@ networkBandwidthUpdate(virDomainNetDefPtr iface, # define networkDnsmasqConfContents(network, pidfile, configstr, \ dctx, caps) 0 =20 -static inline bool -networkBandwidthChangeAllowed(virDomainNetDefPtr iface ATTRIBUTE_UNUSED, - virNetDevBandwidthPtr newBandwidth ATTRIBUTE= _UNUSED) -{ - return true; -} - -static inline int -networkBandwidthUpdate(virDomainNetDefPtr iface ATTRIBUTE_UNUSED, - virNetDevBandwidthPtr newBandwidth ATTRIBUTE_UNUSED) -{ - return 0; -} - # endif =20 #endif /* __VIR_NETWORK__DRIVER_H */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 2b8b0682d5..c9bbe0ca37 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -106,7 +106,6 @@ #include "virperf.h" #include "virnuma.h" #include "dirname.h" -#include "network/bridge_driver.h" #include "netdev_bandwidth_conf.h" =20 #define VIR_FROM_THIS VIR_FROM_QEMU @@ -11265,12 +11264,12 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, sizeof(*newBandwidth->out)); } =20 - if (!networkBandwidthChangeAllowed(net, newBandwidth)) + if (!virDomainNetBandwidthChangeAllowed(net, newBandwidth)) goto endjob; =20 if (virNetDevBandwidthSet(net->ifname, newBandwidth, false, !virDomainNetTypeSharesHostView(net)) < = 0 || - networkBandwidthUpdate(net, newBandwidth) < 0) { + virDomainNetBandwidthUpdate(net, newBandwidth) < 0) { ignore_value(virNetDevBandwidthSet(net->ifname, net->bandwidth, false, --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list