conf: Move virDomainClearNetBandwidth() to src/hypervisor/

The reason virDomainClearNetBandwidth() exists in src/conf/ is
that at the time its introduction we did not have a better place.
But now we do. Firstly, virDomainClearNetBandwidth() is
hypervisor agnostic code, but really has nothing to do with
domain configuration (it doesn't parse/format XML). Secondly, in
near future it'll call another function from src/hypervisor/ and
that's not really allowed from src/conf/.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Michal Privoznik 2024-04-12 10:05:10 +02:00
parent 378dc6a32b
commit 93ff328ea0
5 changed files with 19 additions and 18 deletions

View File

@ -199,20 +199,6 @@ virNetDevBandwidthFormat(const virNetDevBandwidth *def,
return 0;
}
void
virDomainClearNetBandwidth(virDomainDef *def)
{
size_t i;
virDomainNetType type;
for (i = 0; i < def->nnets; i++) {
type = virDomainNetGetActualType(def->nets[i]);
if (virDomainNetGetActualBandwidth(def->nets[i]) &&
virNetDevSupportsBandwidth(type))
virNetDevBandwidthClear(def->nets[i]->ifname);
}
}
bool virNetDevSupportsBandwidth(virDomainNetType type)
{

View File

@ -34,9 +34,6 @@ int virNetDevBandwidthFormat(const virNetDevBandwidth *def,
unsigned int class_id,
virBuffer *buf);
void virDomainClearNetBandwidth(virDomainDef *def)
ATTRIBUTE_NONNULL(1);
bool virNetDevSupportsBandwidth(virDomainNetType type);
bool virNetDevBandwidthHasFloor(const virNetDevBandwidth *b);
bool virNetDevBandwidthSupportsFloor(virNetworkForwardType type);

View File

@ -27,6 +27,7 @@
#include "domain_driver.h"
#include "domain_interface.h"
#include "domain_nwfilter.h"
#include "netdev_bandwidth_conf.h"
#include "network_conf.h"
#include "viralloc.h"
#include "virconftypes.h"
@ -469,3 +470,18 @@ virDomainInterfaceDeleteDevice(virDomainDef *def,
}
}
void
virDomainClearNetBandwidth(virDomainDef *def)
{
size_t i;
virDomainNetType type;
for (i = 0; i < def->nnets; i++) {
type = virDomainNetGetActualType(def->nets[i]);
if (virDomainNetGetActualBandwidth(def->nets[i]) &&
virNetDevSupportsBandwidth(type))
virNetDevBandwidthClear(def->nets[i]->ifname);
}
}

View File

@ -44,3 +44,5 @@ void virDomainInterfaceDeleteDevice(virDomainDef *def,
virDomainNetDef *net,
bool priv_net_created,
char *stateDir);
void virDomainClearNetBandwidth(virDomainDef *def)
ATTRIBUTE_NONNULL(1);

View File

@ -813,7 +813,6 @@ virDomainMomentDefPostParse;
# conf/netdev_bandwidth_conf.h
virDomainClearNetBandwidth;
virNetDevBandwidthFormat;
virNetDevBandwidthHasFloor;
virNetDevBandwidthParse;
@ -1635,6 +1634,7 @@ virDomainDriverParseBlkioDeviceStr;
virDomainDriverSetupPersistentDefBlkioParams;
# hypervisor/domain_interface.h
virDomainClearNetBandwidth;
virDomainInterfaceDeleteDevice;
virDomainInterfaceEthernetConnect;
virDomainInterfaceIsVnetCompatModel;