[libvirt PATCH 2/5] qemu: check if 'floor' is supported for given interface and network
Ján Tomko
jtomko at redhat.com
Wed Feb 12 11:13:13 UTC 2020
On Wed, Feb 12, 2020 at 09:20:55AM +0100, Michal Privoznik wrote:
>On 2/10/20 5:10 PM, Pavel Mores wrote:
>>Even if an interface of type 'network', setting 'floor' is only supported
>>if the network's forward type is nat, route, open or none.
>>
>>Signed-off-by: Pavel Mores <pmores at redhat.com>
>>---
>> src/network/bridge_driver.c | 17 +++++++++++++++++
>> 1 file changed, 17 insertions(+)
>>
>>diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
>>index 94212eec77..3b70e52afd 100644
>>--- a/src/network/bridge_driver.c
>>+++ b/src/network/bridge_driver.c
>>@@ -5062,9 +5062,26 @@ networkCheckBandwidth(virNetworkObjPtr obj,
>> unsigned long long tmp_floor_sum = virNetworkObjGetFloorSum(obj);
>> unsigned long long tmp_new_rate = 0;
>> char ifmac[VIR_MAC_STRING_BUFLEN];
>>+ virNetworkForwardType fwdType;
>>+ bool floorSupported;
>>+ bool floorRequested;
>> virMacAddrFormat(ifaceMac, ifmac);
>>+ fwdType = def->forward.type;
>>+ floorSupported = fwdType == VIR_NETWORK_FORWARD_NONE ||
>>+ fwdType == VIR_NETWORK_FORWARD_NAT ||
>>+ fwdType == VIR_NETWORK_FORWARD_ROUTE ||
>>+ fwdType == VIR_NETWORK_FORWARD_OPEN;
>
>What if this was turned into a function? For instance:
>
>static inline bool
In this day and age, there's no need to waste energy by writing the
inline keyword - the compiler will do as it pleases anyway
(which is why we need the G_GNUC_NO_INLINE marker in the first place).
Jano
>virNetDevSupportBandwidthFloor(virNetworkForwardType type)
>{
> switch (type) {
> case VIR_NETWORK_FORWARD_NONE:
> case VIR_NETWORK_FORWARD_NAT:
> case VIR_NETWORK_FORWARD_ROUTE:
> case VIR_NETWORK_FORWARD_OPEN:
> return true;
> case VIR_NETWORK_FORWARD_BRIDGE:
> case VIR_NETWORK_FORWARD_PRIVATE:
> case VIR_NETWORK_FORWARD_VEPA:
> case VIR_NETWORK_FORWARD_PASSTHROUGH:
> case VIR_NETWORK_FORWARD_HOSTDEV:
> case VIR_NETWORK_FORWARD_LAST:
> break;
> }
> return false;
>}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20200212/7d5ffeb4/attachment-0001.sig>
More information about the libvir-list
mailing list