mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
qemu: check if 'floor' is supported for given interface and network
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>
This commit is contained in:
parent
92a71456ac
commit
aa985af212
@ -304,3 +304,23 @@ virNetDevBandwidthHasFloor(const virNetDevBandwidth *b)
|
|||||||
{
|
{
|
||||||
return b && b->in && b->in->floor != 0;
|
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;
|
||||||
|
}
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "virbuffer.h"
|
#include "virbuffer.h"
|
||||||
#include "virxml.h"
|
#include "virxml.h"
|
||||||
#include "domain_conf.h"
|
#include "domain_conf.h"
|
||||||
|
#include "network_conf.h"
|
||||||
|
|
||||||
int virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidth,
|
int virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidth,
|
||||||
unsigned int *class_id,
|
unsigned int *class_id,
|
||||||
@ -60,3 +61,4 @@ static inline bool virNetDevSupportBandwidth(virDomainNetType type)
|
|||||||
|
|
||||||
|
|
||||||
bool virNetDevBandwidthHasFloor(const virNetDevBandwidth *b);
|
bool virNetDevBandwidthHasFloor(const virNetDevBandwidth *b);
|
||||||
|
bool virNetDevBandwidthSupportsFloor(virNetworkForwardType type);
|
||||||
|
@ -735,6 +735,7 @@ virDomainClearNetBandwidth;
|
|||||||
virNetDevBandwidthFormat;
|
virNetDevBandwidthFormat;
|
||||||
virNetDevBandwidthHasFloor;
|
virNetDevBandwidthHasFloor;
|
||||||
virNetDevBandwidthParse;
|
virNetDevBandwidthParse;
|
||||||
|
virNetDevBandwidthSupportsFloor;
|
||||||
|
|
||||||
|
|
||||||
# conf/netdev_vlan_conf.h
|
# conf/netdev_vlan_conf.h
|
||||||
|
@ -5065,6 +5065,15 @@ networkCheckBandwidth(virNetworkObjPtr obj,
|
|||||||
|
|
||||||
virMacAddrFormat(ifaceMac, ifmac);
|
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) &&
|
if (virNetDevBandwidthHasFloor(ifaceBand) &&
|
||||||
!(netBand && netBand->in)) {
|
!(netBand && netBand->in)) {
|
||||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
|
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
|
||||||
|
Loading…
Reference in New Issue
Block a user