[libvirt PATCH v2 2/6] qemu: add function to test if network supports setting 'floor'

Pavel Mores posted 6 patches 5 years, 12 months ago
[libvirt PATCH v2 2/6] qemu: add function to test if network supports setting 'floor'
Posted by Pavel Mores 5 years, 12 months ago
This function will be useful in upcoming commits when code to check whether
a network can support 'floor' in the first place is introduced.

Signed-off-by: Pavel Mores <pmores@redhat.com>
---
 src/conf/netdev_bandwidth_conf.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/conf/netdev_bandwidth_conf.h b/src/conf/netdev_bandwidth_conf.h
index 5b5ed52566..0596d555e5 100644
--- a/src/conf/netdev_bandwidth_conf.h
+++ b/src/conf/netdev_bandwidth_conf.h
@@ -60,6 +60,26 @@ static inline bool virNetDevSupportBandwidth(virDomainNetType type)
 }
 
 
+static inline bool 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;
+}
+
+
 static inline bool virNetDevBandwidthHasFloor(const virNetDevBandwidth *b)
 {
     return b && b->in && b->in->floor != 0;
-- 
2.24.1

Re: [libvirt PATCH v2 2/6] qemu: add function to test if network supports setting 'floor'
Posted by Michal Privoznik 5 years, 11 months ago
On 2/14/20 5:26 PM, Pavel Mores wrote:
> This function will be useful in upcoming commits when code to check whether
> a network can support 'floor' in the first place is introduced.
> 
> Signed-off-by: Pavel Mores <pmores@redhat.com>
> ---
>   src/conf/netdev_bandwidth_conf.h | 20 ++++++++++++++++++++
>   1 file changed, 20 insertions(+)
> 
> diff --git a/src/conf/netdev_bandwidth_conf.h b/src/conf/netdev_bandwidth_conf.h
> index 5b5ed52566..0596d555e5 100644
> --- a/src/conf/netdev_bandwidth_conf.h
> +++ b/src/conf/netdev_bandwidth_conf.h
> @@ -60,6 +60,26 @@ static inline bool virNetDevSupportBandwidth(virDomainNetType type)
>   }
>   
>   
> +static inline bool 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;
> +}
> +
> +
>   static inline bool virNetDevBandwidthHasFloor(const virNetDevBandwidth *b)
>   {
>       return b && b->in && b->in->floor != 0;
> 

This should be merged with 4/6 and per Jano's suggestion turned into 
regular function.

Michal