mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
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:
parent
e8a819e87f
commit
17f430eb5c
@ -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;
|
||||
}
|
||||
|
@ -57,3 +57,6 @@ static inline bool virNetDevSupportBandwidth(virDomainNetType type)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool virNetDevBandwidthHasFloor(const virNetDevBandwidth *b);
|
||||
|
@ -733,6 +733,7 @@ virInterfaceDefParseString;
|
||||
# conf/netdev_bandwidth_conf.h
|
||||
virDomainClearNetBandwidth;
|
||||
virNetDevBandwidthFormat;
|
||||
virNetDevBandwidthHasFloor;
|
||||
virNetDevBandwidthParse;
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user