2008-10-10 13:57:13 +00:00
|
|
|
/*
|
2014-03-07 14:38:51 +01:00
|
|
|
* bridge_driver.h: core driver methods for managing networks
|
2008-10-10 13:57:13 +00:00
|
|
|
*
|
2015-04-27 13:25:51 +02:00
|
|
|
* Copyright (C) 2006-2015 Red Hat, Inc.
|
2008-10-10 13:57:13 +00:00
|
|
|
* Copyright (C) 2006 Daniel P. Berrange
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-09-20 16:30:55 -06:00
|
|
|
* License along with this library. If not, see
|
2012-07-21 18:06:23 +08:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
2008-10-10 13:57:13 +00:00
|
|
|
*
|
|
|
|
* Author: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __VIR_NETWORK__DRIVER_H
|
2010-03-09 19:22:22 +01:00
|
|
|
# define __VIR_NETWORK__DRIVER_H
|
2008-10-10 13:57:13 +00:00
|
|
|
|
2010-03-09 19:22:22 +01:00
|
|
|
# include "internal.h"
|
2011-06-24 12:04:38 +02:00
|
|
|
# include "network_conf.h"
|
2011-07-04 02:27:12 -04:00
|
|
|
# include "domain_conf.h"
|
2012-12-12 16:27:01 +00:00
|
|
|
# include "vircommand.h"
|
2012-12-12 16:43:54 +00:00
|
|
|
# include "virdnsmasq.h"
|
2008-10-10 13:57:13 +00:00
|
|
|
|
|
|
|
int networkRegister(void);
|
2011-07-04 02:27:12 -04:00
|
|
|
|
|
|
|
# if WITH_NETWORK
|
2014-01-31 16:48:06 +01:00
|
|
|
int networkAllocateActualDevice(virDomainDefPtr dom,
|
|
|
|
virDomainNetDefPtr iface)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
|
|
|
int networkNotifyActualDevice(virDomainDefPtr dom,
|
|
|
|
virDomainNetDefPtr iface)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
|
|
|
int networkReleaseActualDevice(virDomainDefPtr dom,
|
|
|
|
virDomainNetDefPtr iface)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
2011-07-04 02:27:12 -04:00
|
|
|
|
2011-07-07 00:24:08 -04:00
|
|
|
int networkGetNetworkAddress(const char *netname, char **netaddr)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
|
|
|
|
2012-12-06 12:20:39 -05:00
|
|
|
int networkDnsmasqConfContents(virNetworkObjPtr network,
|
|
|
|
const char *pidfile,
|
|
|
|
char **configstr,
|
|
|
|
dnsmasqContext *dctx,
|
|
|
|
dnsmasqCapsPtr caps);
|
2015-07-31 17:02:10 +02:00
|
|
|
|
|
|
|
bool networkBandwidthChangeAllowed(virDomainNetDefPtr iface,
|
|
|
|
virNetDevBandwidthPtr newBandwidth)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
|
|
|
|
bridge_driver: Introduce networkBandwidthUpdate
So, if a domain vNIC's bandwidth has been successfully set, it's
possible that because @floor is set on network's bridge, this
part may need updating too. And that's exactly what this function
does. While the previous commit introduced a function to check if
@floor can be satisfied, this does all the hard work. In general,
there may be three, well four possibilities:
1) No change in @floor value (either it remain unset, or its
value hasn't changed)
2) The @floor value has changed from a non-zero to a non-zero
value
3) New @floor is to be set
4) Old @floor must be cleared out
The difference between 2), 3) and 4) is, that while in 2) the QoS
tree on the network's bridge already has a special class for the
vNIC, in 3) the class must be created from scratch. In 4) it must
be removed. Fortunately, we have helpers for all three
interesting cases.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-07-31 17:31:20 +02:00
|
|
|
int networkBandwidthUpdate(virDomainNetDefPtr iface,
|
|
|
|
virNetDevBandwidthPtr newBandwidth)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
|
|
|
|
2011-07-04 02:27:12 -04:00
|
|
|
# else
|
|
|
|
/* Define no-op replacements that don't drag in any link dependencies. */
|
2014-01-31 16:48:06 +01:00
|
|
|
# define networkAllocateActualDevice(dom, iface) 0
|
2011-07-26 19:57:34 +08:00
|
|
|
# define networkGetNetworkAddress(netname, netaddr) (-2)
|
2012-12-06 12:20:39 -05:00
|
|
|
# define networkDnsmasqConfContents(network, pidfile, configstr, \
|
|
|
|
dctx, caps) 0
|
2015-04-27 13:25:51 +02:00
|
|
|
|
|
|
|
static inline int
|
|
|
|
networkNotifyActualDevice(virDomainDefPtr dom ATTRIBUTE_UNUSED,
|
|
|
|
virDomainNetDefPtr iface ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
networkReleaseActualDevice(virDomainDefPtr dom ATTRIBUTE_UNUSED,
|
|
|
|
virDomainNetDefPtr iface ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-07-31 17:02:10 +02:00
|
|
|
static inline bool
|
|
|
|
networkBandwidthChangeAllowed(virDomainNetDefPtr iface ATTRIBUTE_UNUSED,
|
|
|
|
virNetDevBandwidthPtr newBandwidth ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
bridge_driver: Introduce networkBandwidthUpdate
So, if a domain vNIC's bandwidth has been successfully set, it's
possible that because @floor is set on network's bridge, this
part may need updating too. And that's exactly what this function
does. While the previous commit introduced a function to check if
@floor can be satisfied, this does all the hard work. In general,
there may be three, well four possibilities:
1) No change in @floor value (either it remain unset, or its
value hasn't changed)
2) The @floor value has changed from a non-zero to a non-zero
value
3) New @floor is to be set
4) Old @floor must be cleared out
The difference between 2), 3) and 4) is, that while in 2) the QoS
tree on the network's bridge already has a special class for the
vNIC, in 3) the class must be created from scratch. In 4) it must
be removed. Fortunately, we have helpers for all three
interesting cases.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-07-31 17:31:20 +02:00
|
|
|
static inline int
|
|
|
|
networkBandwidthUpdate(virDomainNetDefPtr iface ATTRIBUTE_UNUSED,
|
|
|
|
virNetDevBandwidthPtr newBandwidth ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-07-04 02:27:12 -04:00
|
|
|
# endif
|
2008-10-10 13:57:13 +00:00
|
|
|
|
2011-06-27 16:55:13 +02:00
|
|
|
typedef char *(*networkDnsmasqLeaseFileNameFunc)(const char *netname);
|
|
|
|
|
2008-10-10 13:57:13 +00:00
|
|
|
#endif /* __VIR_NETWORK__DRIVER_H */
|