mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 09:17:52 +03:00
conf: expand network device callbacks to cover bandwidth updates
Currently the QEMU driver will call directly into the network driver impl to modify network device bandwidth for interfaces with type=network. This introduces a callback system to allow us to decouple the QEMU driver from the network driver. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
5b13570ab8
commit
1438aea4ee
@ -28821,15 +28821,22 @@ virDomainNetTypeSharesHostView(const virDomainNetDef *net)
|
|||||||
static virDomainNetAllocateActualDeviceImpl netAllocate;
|
static virDomainNetAllocateActualDeviceImpl netAllocate;
|
||||||
static virDomainNetNotifyActualDeviceImpl netNotify;
|
static virDomainNetNotifyActualDeviceImpl netNotify;
|
||||||
static virDomainNetReleaseActualDeviceImpl netRelease;
|
static virDomainNetReleaseActualDeviceImpl netRelease;
|
||||||
|
static virDomainNetBandwidthChangeAllowedImpl netBandwidthChangeAllowed;
|
||||||
|
static virDomainNetBandwidthUpdateImpl netBandwidthUpdate;
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
virDomainNetSetDeviceImpl(virDomainNetAllocateActualDeviceImpl allocate,
|
virDomainNetSetDeviceImpl(virDomainNetAllocateActualDeviceImpl allocate,
|
||||||
virDomainNetNotifyActualDeviceImpl notify,
|
virDomainNetNotifyActualDeviceImpl notify,
|
||||||
virDomainNetReleaseActualDeviceImpl release)
|
virDomainNetReleaseActualDeviceImpl release,
|
||||||
|
virDomainNetBandwidthChangeAllowedImpl bandwidthChangeAllowed,
|
||||||
|
virDomainNetBandwidthUpdateImpl bandwidthUpdate)
|
||||||
{
|
{
|
||||||
netAllocate = allocate;
|
netAllocate = allocate;
|
||||||
netNotify = notify;
|
netNotify = notify;
|
||||||
netRelease = release;
|
netRelease = release;
|
||||||
|
netBandwidthChangeAllowed = bandwidthChangeAllowed;
|
||||||
|
netBandwidthUpdate = bandwidthUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -28871,3 +28878,29 @@ virDomainNetReleaseActualDevice(virDomainDefPtr dom,
|
|||||||
|
|
||||||
return netRelease(dom, iface);
|
return netRelease(dom, iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
virDomainNetBandwidthChangeAllowed(virDomainNetDefPtr iface,
|
||||||
|
virNetDevBandwidthPtr newBandwidth)
|
||||||
|
{
|
||||||
|
if (!netBandwidthChangeAllowed) {
|
||||||
|
virReportError(VIR_ERR_NO_SUPPORT, "%s",
|
||||||
|
_("Network device bandwidth change query not available"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return netBandwidthChangeAllowed(iface, newBandwidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
virDomainNetBandwidthUpdate(virDomainNetDefPtr iface,
|
||||||
|
virNetDevBandwidthPtr newBandwidth)
|
||||||
|
{
|
||||||
|
if (!netBandwidthUpdate) {
|
||||||
|
virReportError(VIR_ERR_NO_SUPPORT, "%s",
|
||||||
|
_("Network device bandwidth update not available"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return netBandwidthUpdate(iface, newBandwidth);
|
||||||
|
}
|
||||||
|
@ -3468,10 +3468,21 @@ typedef int
|
|||||||
(*virDomainNetReleaseActualDeviceImpl)(virDomainDefPtr dom,
|
(*virDomainNetReleaseActualDeviceImpl)(virDomainDefPtr dom,
|
||||||
virDomainNetDefPtr iface);
|
virDomainNetDefPtr iface);
|
||||||
|
|
||||||
|
typedef bool
|
||||||
|
(*virDomainNetBandwidthChangeAllowedImpl)(virDomainNetDefPtr iface,
|
||||||
|
virNetDevBandwidthPtr newBandwidth);
|
||||||
|
|
||||||
|
typedef int
|
||||||
|
(*virDomainNetBandwidthUpdateImpl)(virDomainNetDefPtr iface,
|
||||||
|
virNetDevBandwidthPtr newBandwidth);
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
virDomainNetSetDeviceImpl(virDomainNetAllocateActualDeviceImpl allocate,
|
virDomainNetSetDeviceImpl(virDomainNetAllocateActualDeviceImpl allocate,
|
||||||
virDomainNetNotifyActualDeviceImpl notify,
|
virDomainNetNotifyActualDeviceImpl notify,
|
||||||
virDomainNetReleaseActualDeviceImpl release);
|
virDomainNetReleaseActualDeviceImpl release,
|
||||||
|
virDomainNetBandwidthChangeAllowedImpl bandwidthChangeAllowed,
|
||||||
|
virDomainNetBandwidthUpdateImpl bandwidthUpdate);
|
||||||
|
|
||||||
int
|
int
|
||||||
virDomainNetAllocateActualDevice(virDomainDefPtr dom,
|
virDomainNetAllocateActualDevice(virDomainDefPtr dom,
|
||||||
@ -3488,6 +3499,15 @@ virDomainNetReleaseActualDevice(virDomainDefPtr dom,
|
|||||||
virDomainNetDefPtr iface)
|
virDomainNetDefPtr iface)
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
||||||
|
|
||||||
|
bool
|
||||||
|
virDomainNetBandwidthChangeAllowed(virDomainNetDefPtr iface,
|
||||||
|
virNetDevBandwidthPtr newBandwidth)
|
||||||
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
||||||
|
|
||||||
|
int
|
||||||
|
virDomainNetBandwidthUpdate(virDomainNetDefPtr iface,
|
||||||
|
virNetDevBandwidthPtr newBandwidth)
|
||||||
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __DOMAIN_CONF_H */
|
#endif /* __DOMAIN_CONF_H */
|
||||||
|
@ -435,6 +435,8 @@ virDomainMemorySourceTypeFromString;
|
|||||||
virDomainMemorySourceTypeToString;
|
virDomainMemorySourceTypeToString;
|
||||||
virDomainNetAllocateActualDevice;
|
virDomainNetAllocateActualDevice;
|
||||||
virDomainNetAppendIPAddress;
|
virDomainNetAppendIPAddress;
|
||||||
|
virDomainNetBandwidthChangeAllowed;
|
||||||
|
virDomainNetBandwidthUpdate;
|
||||||
virDomainNetDefClear;
|
virDomainNetDefClear;
|
||||||
virDomainNetDefFormat;
|
virDomainNetDefFormat;
|
||||||
virDomainNetDefFree;
|
virDomainNetDefFree;
|
||||||
|
@ -5631,7 +5631,7 @@ networkBandwidthGenericChecks(virDomainNetDefPtr iface,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
static bool
|
||||||
networkBandwidthChangeAllowed(virDomainNetDefPtr iface,
|
networkBandwidthChangeAllowed(virDomainNetDefPtr iface,
|
||||||
virNetDevBandwidthPtr newBandwidth)
|
virNetDevBandwidthPtr newBandwidth)
|
||||||
{
|
{
|
||||||
@ -5662,7 +5662,7 @@ networkBandwidthChangeAllowed(virDomainNetDefPtr iface,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
static int
|
||||||
networkBandwidthUpdate(virDomainNetDefPtr iface,
|
networkBandwidthUpdate(virDomainNetDefPtr iface,
|
||||||
virNetDevBandwidthPtr newBandwidth)
|
virNetDevBandwidthPtr newBandwidth)
|
||||||
{
|
{
|
||||||
@ -5814,7 +5814,9 @@ networkRegister(void)
|
|||||||
virDomainNetSetDeviceImpl(
|
virDomainNetSetDeviceImpl(
|
||||||
networkAllocateActualDevice,
|
networkAllocateActualDevice,
|
||||||
networkNotifyActualDevice,
|
networkNotifyActualDevice,
|
||||||
networkReleaseActualDevice);
|
networkReleaseActualDevice,
|
||||||
|
networkBandwidthChangeAllowed,
|
||||||
|
networkBandwidthUpdate);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -52,16 +52,6 @@ networkDnsmasqConfContents(virNetworkObjPtr obj,
|
|||||||
dnsmasqContext *dctx,
|
dnsmasqContext *dctx,
|
||||||
dnsmasqCapsPtr caps);
|
dnsmasqCapsPtr caps);
|
||||||
|
|
||||||
bool
|
|
||||||
networkBandwidthChangeAllowed(virDomainNetDefPtr iface,
|
|
||||||
virNetDevBandwidthPtr newBandwidth)
|
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
|
||||||
|
|
||||||
int
|
|
||||||
networkBandwidthUpdate(virDomainNetDefPtr iface,
|
|
||||||
virNetDevBandwidthPtr newBandwidth)
|
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
|
||||||
|
|
||||||
# else
|
# else
|
||||||
/* Define no-op replacements that don't drag in any link dependencies. */
|
/* Define no-op replacements that don't drag in any link dependencies. */
|
||||||
# define networkGetActualType(iface) (iface->type)
|
# define networkGetActualType(iface) (iface->type)
|
||||||
@ -69,20 +59,6 @@ networkBandwidthUpdate(virDomainNetDefPtr iface,
|
|||||||
# define networkDnsmasqConfContents(network, pidfile, configstr, \
|
# define networkDnsmasqConfContents(network, pidfile, configstr, \
|
||||||
dctx, caps) 0
|
dctx, caps) 0
|
||||||
|
|
||||||
static inline bool
|
|
||||||
networkBandwidthChangeAllowed(virDomainNetDefPtr iface ATTRIBUTE_UNUSED,
|
|
||||||
virNetDevBandwidthPtr newBandwidth ATTRIBUTE_UNUSED)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int
|
|
||||||
networkBandwidthUpdate(virDomainNetDefPtr iface ATTRIBUTE_UNUSED,
|
|
||||||
virNetDevBandwidthPtr newBandwidth ATTRIBUTE_UNUSED)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#endif /* __VIR_NETWORK__DRIVER_H */
|
#endif /* __VIR_NETWORK__DRIVER_H */
|
||||||
|
@ -106,7 +106,6 @@
|
|||||||
#include "virperf.h"
|
#include "virperf.h"
|
||||||
#include "virnuma.h"
|
#include "virnuma.h"
|
||||||
#include "dirname.h"
|
#include "dirname.h"
|
||||||
#include "network/bridge_driver.h"
|
|
||||||
#include "netdev_bandwidth_conf.h"
|
#include "netdev_bandwidth_conf.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_QEMU
|
#define VIR_FROM_THIS VIR_FROM_QEMU
|
||||||
@ -11309,12 +11308,12 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
|
|||||||
sizeof(*newBandwidth->out));
|
sizeof(*newBandwidth->out));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!networkBandwidthChangeAllowed(net, newBandwidth))
|
if (!virDomainNetBandwidthChangeAllowed(net, newBandwidth))
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (virNetDevBandwidthSet(net->ifname, newBandwidth, false,
|
if (virNetDevBandwidthSet(net->ifname, newBandwidth, false,
|
||||||
!virDomainNetTypeSharesHostView(net)) < 0 ||
|
!virDomainNetTypeSharesHostView(net)) < 0 ||
|
||||||
networkBandwidthUpdate(net, newBandwidth) < 0) {
|
virDomainNetBandwidthUpdate(net, newBandwidth) < 0) {
|
||||||
ignore_value(virNetDevBandwidthSet(net->ifname,
|
ignore_value(virNetDevBandwidthSet(net->ifname,
|
||||||
net->bandwidth,
|
net->bandwidth,
|
||||||
false,
|
false,
|
||||||
|
Loading…
Reference in New Issue
Block a user