]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: check if 'floor' is supported for given interface and network
authorPavel Mores <pmores@redhat.com>
Fri, 14 Feb 2020 16:26:20 +0000 (17:26 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 17 Feb 2020 16:26:31 +0000 (17:26 +0100)
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@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/netdev_bandwidth_conf.c
src/conf/netdev_bandwidth_conf.h
src/libvirt_private.syms
src/network/bridge_driver.c

index 6307ac4d56f5e2283559a59c3ba3d8c7a7c9d733..5cbb9f46e446c21a9015949f2dfd81e7ebed5ce6 100644 (file)
@@ -304,3 +304,23 @@ virNetDevBandwidthHasFloor(const virNetDevBandwidth *b)
 {
     return b && b->in && b->in->floor != 0;
 }
+
+
+bool virNetDevBandwidthSupportsFloor(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;
+}
index 0e10a4cb01f5c78a2a11a6340b6aa599b1aa91cd..b9e57168be8921f73976850940d8d470b0fe8a8f 100644 (file)
@@ -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,
@@ -60,3 +61,4 @@ static inline bool virNetDevSupportBandwidth(virDomainNetType type)
 
 
 bool virNetDevBandwidthHasFloor(const virNetDevBandwidth *b);
+bool virNetDevBandwidthSupportsFloor(virNetworkForwardType type);
index 73c94ed81a25600ed0465b49cee94a9c81f778a8..125d1836ddfff5448325d9756a6bde2caf589ae2 100644 (file)
@@ -735,6 +735,7 @@ virDomainClearNetBandwidth;
 virNetDevBandwidthFormat;
 virNetDevBandwidthHasFloor;
 virNetDevBandwidthParse;
+virNetDevBandwidthSupportsFloor;
 
 
 # conf/netdev_vlan_conf.h
index 6d7eadad437fb453b23f9cf115a8aa3fb2436091..8b1f722eb6cad86d0e11e42cc697173e619b4092 100644 (file)
@@ -5065,6 +5065,15 @@ networkCheckBandwidth(virNetworkObjPtr obj,
 
     virMacAddrFormat(ifaceMac, ifmac);
 
+    if (virNetDevBandwidthHasFloor(ifaceBand) &&
+        !virNetDevBandwidthSupportsFloor(def->forward.type)) {
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
+                       _("Invalid use of 'floor' on interface with MAC address %s "
+                         "- 'floor' is only supported for interface type 'network' with forward type 'nat', 'route', 'open' or none"),
+                       ifmac);
+        return -1;
+    }
+
     if (virNetDevBandwidthHasFloor(ifaceBand) &&
         !(netBand && netBand->in)) {
         virReportError(VIR_ERR_OPERATION_UNSUPPORTED,