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 <pmores@xxxxxxxxxx> --- 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_conf.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" int virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidth, unsigned int *class_id, @@ -57,3 +58,9 @@ static inline bool virNetDevSupportBandwidth(virDomainNetType type) } return false; } + + +static inline bool virNetDevBandwidthHasFloor(const virNetDevBandwidth *b) +{ + return b && b->in && b->in->floor != 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, virMacAddrFormat(ifaceMac, ifmac); - 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; -- 2.24.1