qemu: test if bandwidth has 'floor' factored out to separate function

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@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Pavel Mores 2020-02-14 17:26:19 +01:00 committed by Michal Privoznik
parent e8a819e87f
commit 17f430eb5c
4 changed files with 15 additions and 3 deletions

View File

@ -297,3 +297,10 @@ virDomainClearNetBandwidth(virDomainObjPtr vm)
virNetDevBandwidthClear(vm->def->nets[i]->ifname);
}
}
bool
virNetDevBandwidthHasFloor(const virNetDevBandwidth *b)
{
return b && b->in && b->in->floor != 0;
}

View File

@ -57,3 +57,6 @@ static inline bool virNetDevSupportBandwidth(virDomainNetType type)
}
return false;
}
bool virNetDevBandwidthHasFloor(const virNetDevBandwidth *b);

View File

@ -733,6 +733,7 @@ virInterfaceDefParseString;
# conf/netdev_bandwidth_conf.h
virDomainClearNetBandwidth;
virNetDevBandwidthFormat;
virNetDevBandwidthHasFloor;
virNetDevBandwidthParse;

View File

@ -5065,7 +5065,7 @@ networkCheckBandwidth(virNetworkObjPtr obj,
virMacAddrFormat(ifaceMac, ifmac);
if (ifaceBand && ifaceBand->in && ifaceBand->in->floor &&
if (virNetDevBandwidthHasFloor(ifaceBand) &&
!(netBand && netBand->in)) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("Invalid use of 'floor' on interface with MAC "
@ -5079,8 +5079,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;