2008-07-11 10:48:34 +00:00
|
|
|
/*
|
|
|
|
* network_conf.h: network XML handling
|
|
|
|
*
|
2011-12-14 10:50:23 +00:00
|
|
|
* Copyright (C) 2006-2008, 2012 Red Hat, Inc.
|
2008-07-11 10:48:34 +00:00
|
|
|
* Copyright (C) 2006-2008 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-07-21 10:06:23 +00:00
|
|
|
* License along with this library; If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
2008-07-11 10:48:34 +00:00
|
|
|
*
|
|
|
|
* Author: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __NETWORK_CONF_H__
|
2010-03-09 18:22:22 +00:00
|
|
|
# define __NETWORK_CONF_H__
|
2008-07-11 10:48:34 +00:00
|
|
|
|
2012-01-02 16:58:26 +00:00
|
|
|
# define DNS_RECORD_LENGTH_SRV (512 - 30) /* Limit minus overhead as mentioned in RFC-2782 */
|
2012-01-02 14:23:54 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# include <libxml/parser.h>
|
|
|
|
# include <libxml/tree.h>
|
|
|
|
# include <libxml/xpath.h>
|
2008-11-04 23:22:06 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# include "internal.h"
|
|
|
|
# include "threads.h"
|
Split src/util/network.{c,h} into 5 pieces
The src/util/network.c file is a dumping ground for many different
APIs. Split it up into 5 pieces, along functional lines
- src/util/virnetdevbandwidth.c: virNetDevBandwidth type & helper APIs
- src/util/virnetdevvportprofile.c: virNetDevVPortProfile type & helper APIs
- src/util/virsocketaddr.c: virSocketAddr and APIs
- src/conf/netdev_bandwidth_conf.c: XML parsing / formatting
for virNetDevBandwidth
- src/conf/netdev_vport_profile_conf.c: XML parsing / formatting
for virNetDevVPortProfile
* src/util/network.c, src/util/network.h: Split into 5 pieces
* src/conf/netdev_bandwidth_conf.c, src/conf/netdev_bandwidth_conf.h,
src/conf/netdev_vport_profile_conf.c, src/conf/netdev_vport_profile_conf.h,
src/util/virnetdevbandwidth.c, src/util/virnetdevbandwidth.h,
src/util/virnetdevvportprofile.c, src/util/virnetdevvportprofile.h,
src/util/virsocketaddr.c, src/util/virsocketaddr.h: New pieces
* daemon/libvirtd.h, daemon/remote.c, src/conf/domain_conf.c,
src/conf/domain_conf.h, src/conf/network_conf.c,
src/conf/network_conf.h, src/conf/nwfilter_conf.h,
src/esx/esx_util.h, src/network/bridge_driver.c,
src/qemu/qemu_conf.c, src/rpc/virnetsocket.c,
src/rpc/virnetsocket.h, src/util/dnsmasq.h, src/util/interface.h,
src/util/iptables.h, src/util/macvtap.c, src/util/macvtap.h,
src/util/virnetdev.h, src/util/virnetdevtap.c,
tools/virsh.c: Update include files
2011-11-02 15:40:08 +00:00
|
|
|
# include "virsocketaddr.h"
|
|
|
|
# include "virnetdevbandwidth.h"
|
|
|
|
# include "virnetdevvportprofile.h"
|
2012-08-12 07:51:30 +00:00
|
|
|
# include "virnetdevvlan.h"
|
2012-01-27 17:23:05 +00:00
|
|
|
# include "virmacaddr.h"
|
2012-08-16 15:41:41 +00:00
|
|
|
# include "device_conf.h"
|
2008-07-11 10:48:34 +00:00
|
|
|
|
|
|
|
enum virNetworkForwardType {
|
|
|
|
VIR_NETWORK_FORWARD_NONE = 0,
|
|
|
|
VIR_NETWORK_FORWARD_NAT,
|
|
|
|
VIR_NETWORK_FORWARD_ROUTE,
|
conf: support abstracted interface info in network XML
The network XML is updated in the following ways:
1) The <forward> element can now contain a list of forward interfaces:
<forward .... >
<interface dev='eth10'/>
<interface dev='eth11'/>
<interface dev='eth12'/>
<interface dev='eth13'/>
</forward>
The first of these takes the place of the dev attribute that is
normally in <forward> - when defining a network you can specify
either one, and on output both will be present. If you specify
both on input, they must match.
2) In addition to forward modes of 'nat' and 'route', these new modes
are supported:
private, passthrough, vepa - when this network is referenced by a
domain's interface, it will have the same effect as if the
interface had been defined as type='direct', e.g.:
<interface type='direct'>
<source mode='${mode}' dev='${dev}>
...
</interface>
where ${mode} is one of the three new modes, and ${dev} is an interface
selected from the list given in <forward>.
bridge - if a <forward> dev (or multiple devs) is defined, and
forward mode is 'bridge' this is just like the modes 'private',
'passthrough', and 'vepa' above. If there is no forward dev
specified but a bridge name is given (e.g. "<bridge
name='br0'/>"), then guest interfaces using this network will use
libvirt's "host bridge" mode, equivalent to this:
<interface type='bridge'>
<source bridge='${bridge-name}'/>
...
</interface>
3) A network can have multiple <portgroup> elements, which may be
selected by the guest interface definition (by adding
"portgroup='${name}'" in the <source> element along with the
network name). Currently a portgroup can only contain a
virtportprofile, but the intent is that other configuration items
may be put there int the future (e.g. bandwidth config). When
building a guest's interface, if the <interface> XML itself has no
virtportprofile, and if the requested network has a portgroup with
a name matching the name given in the <interface> (or if one of the
network's portgroups is marked with the "default='yes'" attribute),
the virtportprofile from that portgroup will be used by the
interface.
4) A network can have a virtportprofile defined at the top level,
which will be used by a guest interface when connecting in one of
the 'direct' modes if the guest interface XML itself hasn't
specified any virtportprofile, and if there are also no matching
portgroups on the network.
2011-07-20 03:01:09 +00:00
|
|
|
VIR_NETWORK_FORWARD_BRIDGE,
|
|
|
|
VIR_NETWORK_FORWARD_PRIVATE,
|
|
|
|
VIR_NETWORK_FORWARD_VEPA,
|
|
|
|
VIR_NETWORK_FORWARD_PASSTHROUGH,
|
2012-08-16 15:41:41 +00:00
|
|
|
VIR_NETWORK_FORWARD_HOSTDEV,
|
2008-07-11 10:48:34 +00:00
|
|
|
|
|
|
|
VIR_NETWORK_FORWARD_LAST,
|
|
|
|
};
|
|
|
|
|
2012-08-16 15:41:41 +00:00
|
|
|
enum virNetworkForwardHostdevDeviceType {
|
|
|
|
VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NONE = 0,
|
|
|
|
VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI,
|
|
|
|
VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV,
|
|
|
|
/* USB Device to be added here when supported */
|
|
|
|
|
|
|
|
VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_LAST,
|
|
|
|
};
|
|
|
|
|
2008-07-11 10:48:34 +00:00
|
|
|
typedef struct _virNetworkDHCPRangeDef virNetworkDHCPRangeDef;
|
|
|
|
typedef virNetworkDHCPRangeDef *virNetworkDHCPRangeDefPtr;
|
|
|
|
struct _virNetworkDHCPRangeDef {
|
Convert virNetwork to use virSocketAddr everywhere
Instead of storing the IP address string in virNetwork related
structs, store the parsed virSocketAddr. This will make it
easier to add IPv6 support in the future, by letting driver
code directly check what address family is present
* src/conf/network_conf.c, src/conf/network_conf.h,
src/network/bridge_driver.c: Convert to use virSocketAddr
in virNetwork, instead of char *.
* src/util/bridge.c, src/util/bridge.h,
src/util/dnsmasq.c, src/util/dnsmasq.h,
src/util/iptables.c, src/util/iptables.h: Convert to
take a virSocketAddr instead of char * for any IP
address parameters
* src/util/network.h: Add macros to determine if an address
is set, and what address family is set.
2010-10-21 12:14:33 +00:00
|
|
|
virSocketAddr start;
|
|
|
|
virSocketAddr end;
|
2008-07-11 10:48:34 +00:00
|
|
|
};
|
|
|
|
|
2008-08-20 12:50:29 +00:00
|
|
|
typedef struct _virNetworkDHCPHostDef virNetworkDHCPHostDef;
|
|
|
|
typedef virNetworkDHCPHostDef *virNetworkDHCPHostDefPtr;
|
|
|
|
struct _virNetworkDHCPHostDef {
|
|
|
|
char *mac;
|
|
|
|
char *name;
|
Convert virNetwork to use virSocketAddr everywhere
Instead of storing the IP address string in virNetwork related
structs, store the parsed virSocketAddr. This will make it
easier to add IPv6 support in the future, by letting driver
code directly check what address family is present
* src/conf/network_conf.c, src/conf/network_conf.h,
src/network/bridge_driver.c: Convert to use virSocketAddr
in virNetwork, instead of char *.
* src/util/bridge.c, src/util/bridge.h,
src/util/dnsmasq.c, src/util/dnsmasq.h,
src/util/iptables.c, src/util/iptables.h: Convert to
take a virSocketAddr instead of char * for any IP
address parameters
* src/util/network.h: Add macros to determine if an address
is set, and what address family is set.
2010-10-21 12:14:33 +00:00
|
|
|
virSocketAddr ip;
|
2008-08-20 12:50:29 +00:00
|
|
|
};
|
|
|
|
|
2011-06-24 10:04:36 +00:00
|
|
|
typedef struct _virNetworkDNSTxtRecordsDef virNetworkDNSTxtRecordsDef;
|
|
|
|
typedef virNetworkDNSTxtRecordsDef *virNetworkDNSTxtRecordsDefPtr;
|
|
|
|
struct _virNetworkDNSTxtRecordsDef {
|
|
|
|
char *name;
|
|
|
|
char *value;
|
|
|
|
};
|
|
|
|
|
2012-01-02 14:23:54 +00:00
|
|
|
typedef struct _virNetworkDNSSrvRecordsDef virNetworkDNSSrvRecordsDef;
|
|
|
|
typedef virNetworkDNSSrvRecordsDef *virNetworkDNSSrvRecordsDefPtr;
|
|
|
|
struct _virNetworkDNSSrvRecordsDef {
|
|
|
|
char *domain;
|
|
|
|
char *service;
|
|
|
|
char *protocol;
|
|
|
|
char *target;
|
|
|
|
int port;
|
|
|
|
int priority;
|
|
|
|
int weight;
|
|
|
|
};
|
|
|
|
|
2011-07-04 15:20:02 +00:00
|
|
|
struct _virNetworkDNSHostsDef {
|
2011-06-24 10:04:40 +00:00
|
|
|
virSocketAddr ip;
|
|
|
|
int nnames;
|
|
|
|
char **names;
|
2011-07-04 15:20:02 +00:00
|
|
|
};
|
2011-06-24 10:04:40 +00:00
|
|
|
|
2011-07-04 15:20:02 +00:00
|
|
|
typedef struct _virNetworkDNSHostsDef *virNetworkDNSHostsDefPtr;
|
2011-06-24 10:04:40 +00:00
|
|
|
|
2011-07-04 15:20:02 +00:00
|
|
|
struct _virNetworkDNSDef {
|
2011-06-24 10:04:36 +00:00
|
|
|
unsigned int ntxtrecords;
|
|
|
|
virNetworkDNSTxtRecordsDefPtr txtrecords;
|
2011-06-24 10:04:40 +00:00
|
|
|
unsigned int nhosts;
|
|
|
|
virNetworkDNSHostsDefPtr hosts;
|
2012-01-02 14:23:54 +00:00
|
|
|
unsigned int nsrvrecords;
|
|
|
|
virNetworkDNSSrvRecordsDefPtr srvrecords;
|
2011-07-04 15:20:02 +00:00
|
|
|
};
|
2011-06-24 10:04:36 +00:00
|
|
|
|
2011-07-04 15:20:02 +00:00
|
|
|
typedef struct _virNetworkDNSDef *virNetworkDNSDefPtr;
|
2011-06-24 10:04:36 +00:00
|
|
|
|
2010-11-17 18:36:19 +00:00
|
|
|
typedef struct _virNetworkIpDef virNetworkIpDef;
|
|
|
|
typedef virNetworkIpDef *virNetworkIpDefPtr;
|
|
|
|
struct _virNetworkIpDef {
|
|
|
|
char *family; /* ipv4 or ipv6 - default is ipv4 */
|
|
|
|
virSocketAddr address; /* Bridge IP address */
|
|
|
|
|
|
|
|
/* One or the other of the following two will be used for a given
|
|
|
|
* IP address, but never both. The parser guarantees this.
|
|
|
|
* Use virNetworkIpDefPrefix/virNetworkIpDefNetmask rather
|
|
|
|
* than accessing the data directly - these utility functions
|
|
|
|
* will convert one into the other as necessary.
|
|
|
|
*/
|
|
|
|
unsigned int prefix; /* ipv6 - only prefix allowed */
|
|
|
|
virSocketAddr netmask; /* ipv4 - either netmask or prefix specified */
|
|
|
|
|
|
|
|
unsigned int nranges; /* Zero or more dhcp ranges */
|
|
|
|
virNetworkDHCPRangeDefPtr ranges;
|
|
|
|
|
|
|
|
unsigned int nhosts; /* Zero or more dhcp hosts */
|
|
|
|
virNetworkDHCPHostDefPtr hosts;
|
|
|
|
|
|
|
|
char *tftproot;
|
|
|
|
char *bootfile;
|
|
|
|
virSocketAddr bootserver;
|
|
|
|
};
|
|
|
|
|
conf: support abstracted interface info in network XML
The network XML is updated in the following ways:
1) The <forward> element can now contain a list of forward interfaces:
<forward .... >
<interface dev='eth10'/>
<interface dev='eth11'/>
<interface dev='eth12'/>
<interface dev='eth13'/>
</forward>
The first of these takes the place of the dev attribute that is
normally in <forward> - when defining a network you can specify
either one, and on output both will be present. If you specify
both on input, they must match.
2) In addition to forward modes of 'nat' and 'route', these new modes
are supported:
private, passthrough, vepa - when this network is referenced by a
domain's interface, it will have the same effect as if the
interface had been defined as type='direct', e.g.:
<interface type='direct'>
<source mode='${mode}' dev='${dev}>
...
</interface>
where ${mode} is one of the three new modes, and ${dev} is an interface
selected from the list given in <forward>.
bridge - if a <forward> dev (or multiple devs) is defined, and
forward mode is 'bridge' this is just like the modes 'private',
'passthrough', and 'vepa' above. If there is no forward dev
specified but a bridge name is given (e.g. "<bridge
name='br0'/>"), then guest interfaces using this network will use
libvirt's "host bridge" mode, equivalent to this:
<interface type='bridge'>
<source bridge='${bridge-name}'/>
...
</interface>
3) A network can have multiple <portgroup> elements, which may be
selected by the guest interface definition (by adding
"portgroup='${name}'" in the <source> element along with the
network name). Currently a portgroup can only contain a
virtportprofile, but the intent is that other configuration items
may be put there int the future (e.g. bandwidth config). When
building a guest's interface, if the <interface> XML itself has no
virtportprofile, and if the requested network has a portgroup with
a name matching the name given in the <interface> (or if one of the
network's portgroups is marked with the "default='yes'" attribute),
the virtportprofile from that portgroup will be used by the
interface.
4) A network can have a virtportprofile defined at the top level,
which will be used by a guest interface when connecting in one of
the 'direct' modes if the guest interface XML itself hasn't
specified any virtportprofile, and if there are also no matching
portgroups on the network.
2011-07-20 03:01:09 +00:00
|
|
|
typedef struct _virNetworkForwardIfDef virNetworkForwardIfDef;
|
|
|
|
typedef virNetworkForwardIfDef *virNetworkForwardIfDefPtr;
|
|
|
|
struct _virNetworkForwardIfDef {
|
2012-08-16 15:41:41 +00:00
|
|
|
int type;
|
|
|
|
union {
|
|
|
|
virDevicePCIAddress pci; /*PCI Address of device */
|
|
|
|
/* when USB devices are supported a new variable to be added here */
|
|
|
|
char *dev; /* name of device */
|
|
|
|
}device;
|
|
|
|
int connections; /* how many guest interfaces are connected to this device? */
|
conf: support abstracted interface info in network XML
The network XML is updated in the following ways:
1) The <forward> element can now contain a list of forward interfaces:
<forward .... >
<interface dev='eth10'/>
<interface dev='eth11'/>
<interface dev='eth12'/>
<interface dev='eth13'/>
</forward>
The first of these takes the place of the dev attribute that is
normally in <forward> - when defining a network you can specify
either one, and on output both will be present. If you specify
both on input, they must match.
2) In addition to forward modes of 'nat' and 'route', these new modes
are supported:
private, passthrough, vepa - when this network is referenced by a
domain's interface, it will have the same effect as if the
interface had been defined as type='direct', e.g.:
<interface type='direct'>
<source mode='${mode}' dev='${dev}>
...
</interface>
where ${mode} is one of the three new modes, and ${dev} is an interface
selected from the list given in <forward>.
bridge - if a <forward> dev (or multiple devs) is defined, and
forward mode is 'bridge' this is just like the modes 'private',
'passthrough', and 'vepa' above. If there is no forward dev
specified but a bridge name is given (e.g. "<bridge
name='br0'/>"), then guest interfaces using this network will use
libvirt's "host bridge" mode, equivalent to this:
<interface type='bridge'>
<source bridge='${bridge-name}'/>
...
</interface>
3) A network can have multiple <portgroup> elements, which may be
selected by the guest interface definition (by adding
"portgroup='${name}'" in the <source> element along with the
network name). Currently a portgroup can only contain a
virtportprofile, but the intent is that other configuration items
may be put there int the future (e.g. bandwidth config). When
building a guest's interface, if the <interface> XML itself has no
virtportprofile, and if the requested network has a portgroup with
a name matching the name given in the <interface> (or if one of the
network's portgroups is marked with the "default='yes'" attribute),
the virtportprofile from that portgroup will be used by the
interface.
4) A network can have a virtportprofile defined at the top level,
which will be used by a guest interface when connecting in one of
the 'direct' modes if the guest interface XML itself hasn't
specified any virtportprofile, and if there are also no matching
portgroups on the network.
2011-07-20 03:01:09 +00:00
|
|
|
};
|
|
|
|
|
2012-08-05 06:32:49 +00:00
|
|
|
typedef struct _virNetworkForwardPfDef virNetworkForwardPfDef;
|
|
|
|
typedef virNetworkForwardPfDef *virNetworkForwardPfDefPtr;
|
|
|
|
struct _virNetworkForwardPfDef {
|
|
|
|
char *dev; /* name of device */
|
2012-08-16 15:41:41 +00:00
|
|
|
int connections; /* how many guest interfaces are connected to this device? */
|
2012-08-05 06:32:49 +00:00
|
|
|
};
|
|
|
|
|
conf: support abstracted interface info in network XML
The network XML is updated in the following ways:
1) The <forward> element can now contain a list of forward interfaces:
<forward .... >
<interface dev='eth10'/>
<interface dev='eth11'/>
<interface dev='eth12'/>
<interface dev='eth13'/>
</forward>
The first of these takes the place of the dev attribute that is
normally in <forward> - when defining a network you can specify
either one, and on output both will be present. If you specify
both on input, they must match.
2) In addition to forward modes of 'nat' and 'route', these new modes
are supported:
private, passthrough, vepa - when this network is referenced by a
domain's interface, it will have the same effect as if the
interface had been defined as type='direct', e.g.:
<interface type='direct'>
<source mode='${mode}' dev='${dev}>
...
</interface>
where ${mode} is one of the three new modes, and ${dev} is an interface
selected from the list given in <forward>.
bridge - if a <forward> dev (or multiple devs) is defined, and
forward mode is 'bridge' this is just like the modes 'private',
'passthrough', and 'vepa' above. If there is no forward dev
specified but a bridge name is given (e.g. "<bridge
name='br0'/>"), then guest interfaces using this network will use
libvirt's "host bridge" mode, equivalent to this:
<interface type='bridge'>
<source bridge='${bridge-name}'/>
...
</interface>
3) A network can have multiple <portgroup> elements, which may be
selected by the guest interface definition (by adding
"portgroup='${name}'" in the <source> element along with the
network name). Currently a portgroup can only contain a
virtportprofile, but the intent is that other configuration items
may be put there int the future (e.g. bandwidth config). When
building a guest's interface, if the <interface> XML itself has no
virtportprofile, and if the requested network has a portgroup with
a name matching the name given in the <interface> (or if one of the
network's portgroups is marked with the "default='yes'" attribute),
the virtportprofile from that portgroup will be used by the
interface.
4) A network can have a virtportprofile defined at the top level,
which will be used by a guest interface when connecting in one of
the 'direct' modes if the guest interface XML itself hasn't
specified any virtportprofile, and if there are also no matching
portgroups on the network.
2011-07-20 03:01:09 +00:00
|
|
|
typedef struct _virPortGroupDef virPortGroupDef;
|
|
|
|
typedef virPortGroupDef *virPortGroupDefPtr;
|
|
|
|
struct _virPortGroupDef {
|
|
|
|
char *name;
|
|
|
|
bool isDefault;
|
2011-11-02 14:43:16 +00:00
|
|
|
virNetDevVPortProfilePtr virtPortProfile;
|
Adjust naming of network device bandwidth management APIs
Rename virBandwidth to virNetDevBandwidth, and virRate to
virNetDevBandwidthRate.
* src/util/network.c, src/util/network.h: Rename bandwidth
structs and APIs
* src/conf/domain_conf.c, src/conf/domain_conf.h,
src/conf/network_conf.c, src/conf/network_conf.h,
src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/qemu/qemu_command.c, src/util/macvtap.c,
src/util/macvtap.h, tools/virsh.c: Update for API changes.
2011-11-02 14:29:05 +00:00
|
|
|
virNetDevBandwidthPtr bandwidth;
|
2012-08-12 07:51:30 +00:00
|
|
|
virNetDevVlan vlan;
|
conf: support abstracted interface info in network XML
The network XML is updated in the following ways:
1) The <forward> element can now contain a list of forward interfaces:
<forward .... >
<interface dev='eth10'/>
<interface dev='eth11'/>
<interface dev='eth12'/>
<interface dev='eth13'/>
</forward>
The first of these takes the place of the dev attribute that is
normally in <forward> - when defining a network you can specify
either one, and on output both will be present. If you specify
both on input, they must match.
2) In addition to forward modes of 'nat' and 'route', these new modes
are supported:
private, passthrough, vepa - when this network is referenced by a
domain's interface, it will have the same effect as if the
interface had been defined as type='direct', e.g.:
<interface type='direct'>
<source mode='${mode}' dev='${dev}>
...
</interface>
where ${mode} is one of the three new modes, and ${dev} is an interface
selected from the list given in <forward>.
bridge - if a <forward> dev (or multiple devs) is defined, and
forward mode is 'bridge' this is just like the modes 'private',
'passthrough', and 'vepa' above. If there is no forward dev
specified but a bridge name is given (e.g. "<bridge
name='br0'/>"), then guest interfaces using this network will use
libvirt's "host bridge" mode, equivalent to this:
<interface type='bridge'>
<source bridge='${bridge-name}'/>
...
</interface>
3) A network can have multiple <portgroup> elements, which may be
selected by the guest interface definition (by adding
"portgroup='${name}'" in the <source> element along with the
network name). Currently a portgroup can only contain a
virtportprofile, but the intent is that other configuration items
may be put there int the future (e.g. bandwidth config). When
building a guest's interface, if the <interface> XML itself has no
virtportprofile, and if the requested network has a portgroup with
a name matching the name given in the <interface> (or if one of the
network's portgroups is marked with the "default='yes'" attribute),
the virtportprofile from that portgroup will be used by the
interface.
4) A network can have a virtportprofile defined at the top level,
which will be used by a guest interface when connecting in one of
the 'direct' modes if the guest interface XML itself hasn't
specified any virtportprofile, and if there are also no matching
portgroups on the network.
2011-07-20 03:01:09 +00:00
|
|
|
};
|
|
|
|
|
2008-07-11 10:48:34 +00:00
|
|
|
typedef struct _virNetworkDef virNetworkDef;
|
|
|
|
typedef virNetworkDef *virNetworkDefPtr;
|
|
|
|
struct _virNetworkDef {
|
|
|
|
unsigned char uuid[VIR_UUID_BUFLEN];
|
2012-08-05 20:11:50 +00:00
|
|
|
bool uuid_specified;
|
2008-07-11 10:48:34 +00:00
|
|
|
char *name;
|
2012-08-06 20:17:58 +00:00
|
|
|
int connections; /* # of guest interfaces connected to this network */
|
2008-07-11 10:48:34 +00:00
|
|
|
|
|
|
|
char *bridge; /* Name of bridge device */
|
2008-09-08 12:45:29 +00:00
|
|
|
char *domain;
|
2008-07-11 10:48:34 +00:00
|
|
|
unsigned long delay; /* Bridge forward delay (ms) */
|
2010-01-19 12:07:32 +00:00
|
|
|
unsigned int stp :1; /* Spanning tree protocol */
|
2012-07-17 12:07:59 +00:00
|
|
|
virMacAddr mac; /* mac address of bridge device */
|
Give each virtual network bridge its own fixed MAC address
This fixes https://bugzilla.redhat.com/show_bug.cgi?id=609463
The problem was that, since a bridge always acquires the MAC address
of the connected interface with the numerically lowest MAC, as guests
are started and stopped, it was possible for the MAC address to change
over time, and this change in the network was being detected by
Windows 7 (it sees the MAC of the default route change), so on each
reboot it would bring up a dialog box asking about this "new network".
The solution is to create a dummy tap interface with a MAC guaranteed
to be lower than any guest interface's MAC, and attach that tap to the
bridge as soon as it's created. Since all guest MAC addresses start
with 0xFE, we can just generate a MAC with the standard "0x52, 0x54,
0" prefix, and it's guaranteed to always win (physical interfaces are
never connected to these bridges, so we don't need to worry about
competing numerically with them).
Note that the dummy tap is never set to IFF_UP state - that's not
necessary in order for the bridge to take its MAC, and not setting it
to UP eliminates the clutter of having an (eg) "virbr0-nic" displayed
in the output of the ifconfig command.
I chose to not auto-generate the MAC address in the network XML
parser, as there are likely to be consumers of that API that don't
need or want to have a MAC address associated with the
bridge.
Instead, in bridge_driver.c when the network is being defined, if
there is no MAC, one is generated. To account for virtual network
configs that already exist when upgrading from an older version of
libvirt, I've added a %post script to the specfile that searches for
all network definitions in both the config directory
(/etc/libvirt/qemu/networks) and the state directory
(/var/lib/libvirt/network) that are missing a mac address, generates a
random address, and adds it to the config (and a matching address to
the state file, if there is one).
docs/formatnetwork.html.in: document <mac address.../>
docs/schemas/network.rng: add nac address to schema
libvirt.spec.in: %post script to update existing networks
src/conf/network_conf.[ch]: parse and format <mac address.../>
src/libvirt_private.syms: export a couple private symbols we need
src/network/bridge_driver.c:
auto-generate mac address when needed,
create dummy interface if mac address is present.
tests/networkxml2xmlin/isolated-network.xml
tests/networkxml2xmlin/routed-network.xml
tests/networkxml2xmlout/isolated-network.xml
tests/networkxml2xmlout/routed-network.xml: add mac address to some tests
2011-02-09 08:28:12 +00:00
|
|
|
bool mac_specified;
|
2008-07-11 10:48:34 +00:00
|
|
|
|
|
|
|
int forwardType; /* One of virNetworkForwardType constants */
|
2012-08-16 15:41:41 +00:00
|
|
|
int managed; /* managed attribute for hostdev mode */
|
conf: support abstracted interface info in network XML
The network XML is updated in the following ways:
1) The <forward> element can now contain a list of forward interfaces:
<forward .... >
<interface dev='eth10'/>
<interface dev='eth11'/>
<interface dev='eth12'/>
<interface dev='eth13'/>
</forward>
The first of these takes the place of the dev attribute that is
normally in <forward> - when defining a network you can specify
either one, and on output both will be present. If you specify
both on input, they must match.
2) In addition to forward modes of 'nat' and 'route', these new modes
are supported:
private, passthrough, vepa - when this network is referenced by a
domain's interface, it will have the same effect as if the
interface had been defined as type='direct', e.g.:
<interface type='direct'>
<source mode='${mode}' dev='${dev}>
...
</interface>
where ${mode} is one of the three new modes, and ${dev} is an interface
selected from the list given in <forward>.
bridge - if a <forward> dev (or multiple devs) is defined, and
forward mode is 'bridge' this is just like the modes 'private',
'passthrough', and 'vepa' above. If there is no forward dev
specified but a bridge name is given (e.g. "<bridge
name='br0'/>"), then guest interfaces using this network will use
libvirt's "host bridge" mode, equivalent to this:
<interface type='bridge'>
<source bridge='${bridge-name}'/>
...
</interface>
3) A network can have multiple <portgroup> elements, which may be
selected by the guest interface definition (by adding
"portgroup='${name}'" in the <source> element along with the
network name). Currently a portgroup can only contain a
virtportprofile, but the intent is that other configuration items
may be put there int the future (e.g. bandwidth config). When
building a guest's interface, if the <interface> XML itself has no
virtportprofile, and if the requested network has a portgroup with
a name matching the name given in the <interface> (or if one of the
network's portgroups is marked with the "default='yes'" attribute),
the virtportprofile from that portgroup will be used by the
interface.
4) A network can have a virtportprofile defined at the top level,
which will be used by a guest interface when connecting in one of
the 'direct' modes if the guest interface XML itself hasn't
specified any virtportprofile, and if there are also no matching
portgroups on the network.
2011-07-20 03:01:09 +00:00
|
|
|
|
|
|
|
/* If there are multiple forward devices (i.e. a pool of
|
|
|
|
* interfaces), they will be listed here.
|
|
|
|
*/
|
2011-12-14 10:50:23 +00:00
|
|
|
size_t nForwardPfs;
|
2012-08-05 06:32:49 +00:00
|
|
|
virNetworkForwardPfDefPtr forwardPfs;
|
2011-12-14 10:50:23 +00:00
|
|
|
|
conf: support abstracted interface info in network XML
The network XML is updated in the following ways:
1) The <forward> element can now contain a list of forward interfaces:
<forward .... >
<interface dev='eth10'/>
<interface dev='eth11'/>
<interface dev='eth12'/>
<interface dev='eth13'/>
</forward>
The first of these takes the place of the dev attribute that is
normally in <forward> - when defining a network you can specify
either one, and on output both will be present. If you specify
both on input, they must match.
2) In addition to forward modes of 'nat' and 'route', these new modes
are supported:
private, passthrough, vepa - when this network is referenced by a
domain's interface, it will have the same effect as if the
interface had been defined as type='direct', e.g.:
<interface type='direct'>
<source mode='${mode}' dev='${dev}>
...
</interface>
where ${mode} is one of the three new modes, and ${dev} is an interface
selected from the list given in <forward>.
bridge - if a <forward> dev (or multiple devs) is defined, and
forward mode is 'bridge' this is just like the modes 'private',
'passthrough', and 'vepa' above. If there is no forward dev
specified but a bridge name is given (e.g. "<bridge
name='br0'/>"), then guest interfaces using this network will use
libvirt's "host bridge" mode, equivalent to this:
<interface type='bridge'>
<source bridge='${bridge-name}'/>
...
</interface>
3) A network can have multiple <portgroup> elements, which may be
selected by the guest interface definition (by adding
"portgroup='${name}'" in the <source> element along with the
network name). Currently a portgroup can only contain a
virtportprofile, but the intent is that other configuration items
may be put there int the future (e.g. bandwidth config). When
building a guest's interface, if the <interface> XML itself has no
virtportprofile, and if the requested network has a portgroup with
a name matching the name given in the <interface> (or if one of the
network's portgroups is marked with the "default='yes'" attribute),
the virtportprofile from that portgroup will be used by the
interface.
4) A network can have a virtportprofile defined at the top level,
which will be used by a guest interface when connecting in one of
the 'direct' modes if the guest interface XML itself hasn't
specified any virtportprofile, and if there are also no matching
portgroups on the network.
2011-07-20 03:01:09 +00:00
|
|
|
size_t nForwardIfs;
|
|
|
|
virNetworkForwardIfDefPtr forwardIfs;
|
2008-07-11 10:48:34 +00:00
|
|
|
|
2010-11-17 18:36:19 +00:00
|
|
|
size_t nips;
|
|
|
|
virNetworkIpDefPtr ips; /* ptr to array of IP addresses on this network */
|
2011-06-24 10:04:36 +00:00
|
|
|
|
|
|
|
virNetworkDNSDefPtr dns; /* ptr to dns related configuration */
|
2011-11-02 14:43:16 +00:00
|
|
|
virNetDevVPortProfilePtr virtPortProfile;
|
conf: support abstracted interface info in network XML
The network XML is updated in the following ways:
1) The <forward> element can now contain a list of forward interfaces:
<forward .... >
<interface dev='eth10'/>
<interface dev='eth11'/>
<interface dev='eth12'/>
<interface dev='eth13'/>
</forward>
The first of these takes the place of the dev attribute that is
normally in <forward> - when defining a network you can specify
either one, and on output both will be present. If you specify
both on input, they must match.
2) In addition to forward modes of 'nat' and 'route', these new modes
are supported:
private, passthrough, vepa - when this network is referenced by a
domain's interface, it will have the same effect as if the
interface had been defined as type='direct', e.g.:
<interface type='direct'>
<source mode='${mode}' dev='${dev}>
...
</interface>
where ${mode} is one of the three new modes, and ${dev} is an interface
selected from the list given in <forward>.
bridge - if a <forward> dev (or multiple devs) is defined, and
forward mode is 'bridge' this is just like the modes 'private',
'passthrough', and 'vepa' above. If there is no forward dev
specified but a bridge name is given (e.g. "<bridge
name='br0'/>"), then guest interfaces using this network will use
libvirt's "host bridge" mode, equivalent to this:
<interface type='bridge'>
<source bridge='${bridge-name}'/>
...
</interface>
3) A network can have multiple <portgroup> elements, which may be
selected by the guest interface definition (by adding
"portgroup='${name}'" in the <source> element along with the
network name). Currently a portgroup can only contain a
virtportprofile, but the intent is that other configuration items
may be put there int the future (e.g. bandwidth config). When
building a guest's interface, if the <interface> XML itself has no
virtportprofile, and if the requested network has a portgroup with
a name matching the name given in the <interface> (or if one of the
network's portgroups is marked with the "default='yes'" attribute),
the virtportprofile from that portgroup will be used by the
interface.
4) A network can have a virtportprofile defined at the top level,
which will be used by a guest interface when connecting in one of
the 'direct' modes if the guest interface XML itself hasn't
specified any virtportprofile, and if there are also no matching
portgroups on the network.
2011-07-20 03:01:09 +00:00
|
|
|
|
|
|
|
size_t nPortGroups;
|
|
|
|
virPortGroupDefPtr portGroups;
|
Adjust naming of network device bandwidth management APIs
Rename virBandwidth to virNetDevBandwidth, and virRate to
virNetDevBandwidthRate.
* src/util/network.c, src/util/network.h: Rename bandwidth
structs and APIs
* src/conf/domain_conf.c, src/conf/domain_conf.h,
src/conf/network_conf.c, src/conf/network_conf.h,
src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/qemu/qemu_command.c, src/util/macvtap.c,
src/util/macvtap.h, tools/virsh.c: Update for API changes.
2011-11-02 14:29:05 +00:00
|
|
|
virNetDevBandwidthPtr bandwidth;
|
2012-08-12 07:51:30 +00:00
|
|
|
virNetDevVlan vlan;
|
2008-07-11 10:48:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _virNetworkObj virNetworkObj;
|
|
|
|
typedef virNetworkObj *virNetworkObjPtr;
|
|
|
|
struct _virNetworkObj {
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutex lock;
|
2008-12-04 22:00:14 +00:00
|
|
|
|
2008-07-11 10:48:34 +00:00
|
|
|
pid_t dnsmasqPid;
|
2010-12-20 06:14:11 +00:00
|
|
|
pid_t radvdPid;
|
2008-07-11 10:48:34 +00:00
|
|
|
unsigned int active : 1;
|
|
|
|
unsigned int autostart : 1;
|
|
|
|
unsigned int persistent : 1;
|
|
|
|
|
|
|
|
virNetworkDefPtr def; /* The current definition */
|
|
|
|
virNetworkDefPtr newDef; /* New definition to activate at shutdown */
|
2008-10-10 14:50:26 +00:00
|
|
|
};
|
2008-07-11 10:48:34 +00:00
|
|
|
|
2008-10-10 14:50:26 +00:00
|
|
|
typedef struct _virNetworkObjList virNetworkObjList;
|
|
|
|
typedef virNetworkObjList *virNetworkObjListPtr;
|
|
|
|
struct _virNetworkObjList {
|
|
|
|
unsigned int count;
|
|
|
|
virNetworkObjPtr *objs;
|
2008-07-11 10:48:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline int
|
Rename internal APis
Rename virDomainIsActive to virDomainObjIsActive, and
virInterfaceIsActive to virInterfaceObjIsActive and finally
virNetworkIsActive to virNetworkObjIsActive.
* src/conf/domain_conf.c, src/conf/domain_conf.h,
src/conf/interface_conf.h, src/conf/network_conf.c,
src/conf/network_conf.h, src/lxc/lxc_driver.c,
src/network/bridge_driver.c, src/opennebula/one_driver.c,
src/openvz/openvz_driver.c, src/qemu/qemu_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c: Update for
renamed APIs.
2009-10-20 14:51:03 +00:00
|
|
|
virNetworkObjIsActive(const virNetworkObjPtr net)
|
2008-07-11 10:48:34 +00:00
|
|
|
{
|
|
|
|
return net->active;
|
|
|
|
}
|
|
|
|
|
2008-10-10 14:50:26 +00:00
|
|
|
virNetworkObjPtr virNetworkFindByUUID(const virNetworkObjListPtr nets,
|
2008-07-11 10:48:34 +00:00
|
|
|
const unsigned char *uuid);
|
2008-10-10 14:50:26 +00:00
|
|
|
virNetworkObjPtr virNetworkFindByName(const virNetworkObjListPtr nets,
|
2008-07-11 10:48:34 +00:00
|
|
|
const char *name);
|
|
|
|
|
|
|
|
|
|
|
|
void virNetworkDefFree(virNetworkDefPtr def);
|
|
|
|
void virNetworkObjFree(virNetworkObjPtr net);
|
2008-10-10 14:50:26 +00:00
|
|
|
void virNetworkObjListFree(virNetworkObjListPtr vms);
|
2008-07-11 10:48:34 +00:00
|
|
|
|
2010-02-10 10:22:52 +00:00
|
|
|
virNetworkObjPtr virNetworkAssignDef(virNetworkObjListPtr nets,
|
2012-09-14 15:35:35 +00:00
|
|
|
const virNetworkDefPtr def,
|
|
|
|
bool live);
|
|
|
|
int virNetworkObjAssignDef(virNetworkObjPtr network,
|
|
|
|
const virNetworkDefPtr def,
|
|
|
|
bool live);
|
|
|
|
int virNetworkObjSetDefTransient(virNetworkObjPtr network, bool live);
|
|
|
|
virNetworkDefPtr virNetworkObjGetPersistentDef(virNetworkObjPtr network);
|
|
|
|
int virNetworkObjReplacePersistentDef(virNetworkObjPtr network,
|
|
|
|
virNetworkDefPtr def);
|
|
|
|
virNetworkDefPtr virNetworkDefCopy(virNetworkDefPtr def, unsigned int flags);
|
|
|
|
int virNetworkConfigChangeSetup(virNetworkObjPtr dom, unsigned int flags);
|
|
|
|
|
2008-10-10 14:50:26 +00:00
|
|
|
void virNetworkRemoveInactive(virNetworkObjListPtr nets,
|
2008-07-11 10:48:34 +00:00
|
|
|
const virNetworkObjPtr net);
|
|
|
|
|
2010-02-10 10:22:52 +00:00
|
|
|
virNetworkDefPtr virNetworkDefParseString(const char *xmlStr);
|
|
|
|
virNetworkDefPtr virNetworkDefParseFile(const char *filename);
|
|
|
|
virNetworkDefPtr virNetworkDefParseNode(xmlDocPtr xml,
|
2008-07-11 10:48:34 +00:00
|
|
|
xmlNodePtr root);
|
|
|
|
|
2011-12-14 10:50:40 +00:00
|
|
|
char *virNetworkDefFormat(const virNetworkDefPtr def, unsigned int flags);
|
2008-07-11 10:48:34 +00:00
|
|
|
|
conf: support abstracted interface info in network XML
The network XML is updated in the following ways:
1) The <forward> element can now contain a list of forward interfaces:
<forward .... >
<interface dev='eth10'/>
<interface dev='eth11'/>
<interface dev='eth12'/>
<interface dev='eth13'/>
</forward>
The first of these takes the place of the dev attribute that is
normally in <forward> - when defining a network you can specify
either one, and on output both will be present. If you specify
both on input, they must match.
2) In addition to forward modes of 'nat' and 'route', these new modes
are supported:
private, passthrough, vepa - when this network is referenced by a
domain's interface, it will have the same effect as if the
interface had been defined as type='direct', e.g.:
<interface type='direct'>
<source mode='${mode}' dev='${dev}>
...
</interface>
where ${mode} is one of the three new modes, and ${dev} is an interface
selected from the list given in <forward>.
bridge - if a <forward> dev (or multiple devs) is defined, and
forward mode is 'bridge' this is just like the modes 'private',
'passthrough', and 'vepa' above. If there is no forward dev
specified but a bridge name is given (e.g. "<bridge
name='br0'/>"), then guest interfaces using this network will use
libvirt's "host bridge" mode, equivalent to this:
<interface type='bridge'>
<source bridge='${bridge-name}'/>
...
</interface>
3) A network can have multiple <portgroup> elements, which may be
selected by the guest interface definition (by adding
"portgroup='${name}'" in the <source> element along with the
network name). Currently a portgroup can only contain a
virtportprofile, but the intent is that other configuration items
may be put there int the future (e.g. bandwidth config). When
building a guest's interface, if the <interface> XML itself has no
virtportprofile, and if the requested network has a portgroup with
a name matching the name given in the <interface> (or if one of the
network's portgroups is marked with the "default='yes'" attribute),
the virtportprofile from that portgroup will be used by the
interface.
4) A network can have a virtportprofile defined at the top level,
which will be used by a guest interface when connecting in one of
the 'direct' modes if the guest interface XML itself hasn't
specified any virtportprofile, and if there are also no matching
portgroups on the network.
2011-07-20 03:01:09 +00:00
|
|
|
static inline const char *
|
|
|
|
virNetworkDefForwardIf(const virNetworkDefPtr def, size_t n)
|
|
|
|
{
|
2012-08-16 15:41:41 +00:00
|
|
|
return ((def->forwardIfs && (def->nForwardIfs > n) &&
|
|
|
|
def->forwardIfs[n].type == VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV)
|
|
|
|
? def->forwardIfs[n].device.dev : NULL);
|
conf: support abstracted interface info in network XML
The network XML is updated in the following ways:
1) The <forward> element can now contain a list of forward interfaces:
<forward .... >
<interface dev='eth10'/>
<interface dev='eth11'/>
<interface dev='eth12'/>
<interface dev='eth13'/>
</forward>
The first of these takes the place of the dev attribute that is
normally in <forward> - when defining a network you can specify
either one, and on output both will be present. If you specify
both on input, they must match.
2) In addition to forward modes of 'nat' and 'route', these new modes
are supported:
private, passthrough, vepa - when this network is referenced by a
domain's interface, it will have the same effect as if the
interface had been defined as type='direct', e.g.:
<interface type='direct'>
<source mode='${mode}' dev='${dev}>
...
</interface>
where ${mode} is one of the three new modes, and ${dev} is an interface
selected from the list given in <forward>.
bridge - if a <forward> dev (or multiple devs) is defined, and
forward mode is 'bridge' this is just like the modes 'private',
'passthrough', and 'vepa' above. If there is no forward dev
specified but a bridge name is given (e.g. "<bridge
name='br0'/>"), then guest interfaces using this network will use
libvirt's "host bridge" mode, equivalent to this:
<interface type='bridge'>
<source bridge='${bridge-name}'/>
...
</interface>
3) A network can have multiple <portgroup> elements, which may be
selected by the guest interface definition (by adding
"portgroup='${name}'" in the <source> element along with the
network name). Currently a portgroup can only contain a
virtportprofile, but the intent is that other configuration items
may be put there int the future (e.g. bandwidth config). When
building a guest's interface, if the <interface> XML itself has no
virtportprofile, and if the requested network has a portgroup with
a name matching the name given in the <interface> (or if one of the
network's portgroups is marked with the "default='yes'" attribute),
the virtportprofile from that portgroup will be used by the
interface.
4) A network can have a virtportprofile defined at the top level,
which will be used by a guest interface when connecting in one of
the 'direct' modes if the guest interface XML itself hasn't
specified any virtportprofile, and if there are also no matching
portgroups on the network.
2011-07-20 03:01:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virPortGroupDefPtr virPortGroupFindByName(virNetworkDefPtr net,
|
|
|
|
const char *portgroup);
|
|
|
|
|
2010-11-17 18:36:19 +00:00
|
|
|
virNetworkIpDefPtr
|
|
|
|
virNetworkDefGetIpByIndex(const virNetworkDefPtr def,
|
|
|
|
int family, size_t n);
|
|
|
|
int virNetworkIpDefPrefix(const virNetworkIpDefPtr def);
|
|
|
|
int virNetworkIpDefNetmask(const virNetworkIpDefPtr def,
|
|
|
|
virSocketAddrPtr netmask);
|
2008-07-11 10:48:34 +00:00
|
|
|
|
2010-02-10 10:22:52 +00:00
|
|
|
int virNetworkSaveXML(const char *configDir,
|
2009-01-20 22:36:10 +00:00
|
|
|
virNetworkDefPtr def,
|
|
|
|
const char *xml);
|
|
|
|
|
2010-02-10 10:22:52 +00:00
|
|
|
int virNetworkSaveConfig(const char *configDir,
|
2009-01-20 22:36:10 +00:00
|
|
|
virNetworkDefPtr def);
|
2008-07-11 10:48:34 +00:00
|
|
|
|
2012-09-14 15:35:35 +00:00
|
|
|
int virNetworkSaveStatus(const char *statusDir,
|
|
|
|
virNetworkObjPtr net) ATTRIBUTE_RETURN_CHECK;
|
|
|
|
|
2010-02-10 10:22:52 +00:00
|
|
|
virNetworkObjPtr virNetworkLoadConfig(virNetworkObjListPtr nets,
|
2008-07-11 10:48:34 +00:00
|
|
|
const char *configDir,
|
|
|
|
const char *autostartDir,
|
|
|
|
const char *file);
|
|
|
|
|
2010-02-10 10:22:52 +00:00
|
|
|
int virNetworkLoadAllConfigs(virNetworkObjListPtr nets,
|
2008-07-11 10:48:34 +00:00
|
|
|
const char *configDir,
|
|
|
|
const char *autostartDir);
|
|
|
|
|
2010-02-10 10:22:52 +00:00
|
|
|
int virNetworkDeleteConfig(const char *configDir,
|
2009-01-20 22:36:10 +00:00
|
|
|
const char *autostartDir,
|
2008-07-11 10:48:34 +00:00
|
|
|
virNetworkObjPtr net);
|
|
|
|
|
2010-02-10 10:22:52 +00:00
|
|
|
char *virNetworkConfigFile(const char *dir,
|
2009-01-20 22:36:10 +00:00
|
|
|
const char *name);
|
|
|
|
|
2009-03-02 17:37:03 +00:00
|
|
|
int virNetworkBridgeInUse(const virNetworkObjListPtr nets,
|
|
|
|
const char *bridge,
|
|
|
|
const char *skipname);
|
|
|
|
|
2010-02-10 10:22:52 +00:00
|
|
|
char *virNetworkAllocateBridge(const virNetworkObjListPtr nets,
|
2009-04-21 19:00:06 +00:00
|
|
|
const char *template);
|
2009-03-02 17:37:03 +00:00
|
|
|
|
2010-02-10 10:22:52 +00:00
|
|
|
int virNetworkSetBridgeName(const virNetworkObjListPtr nets,
|
2009-05-29 14:18:57 +00:00
|
|
|
virNetworkDefPtr def,
|
|
|
|
int check_collision);
|
2009-01-20 22:36:10 +00:00
|
|
|
|
Give each virtual network bridge its own fixed MAC address
This fixes https://bugzilla.redhat.com/show_bug.cgi?id=609463
The problem was that, since a bridge always acquires the MAC address
of the connected interface with the numerically lowest MAC, as guests
are started and stopped, it was possible for the MAC address to change
over time, and this change in the network was being detected by
Windows 7 (it sees the MAC of the default route change), so on each
reboot it would bring up a dialog box asking about this "new network".
The solution is to create a dummy tap interface with a MAC guaranteed
to be lower than any guest interface's MAC, and attach that tap to the
bridge as soon as it's created. Since all guest MAC addresses start
with 0xFE, we can just generate a MAC with the standard "0x52, 0x54,
0" prefix, and it's guaranteed to always win (physical interfaces are
never connected to these bridges, so we don't need to worry about
competing numerically with them).
Note that the dummy tap is never set to IFF_UP state - that's not
necessary in order for the bridge to take its MAC, and not setting it
to UP eliminates the clutter of having an (eg) "virbr0-nic" displayed
in the output of the ifconfig command.
I chose to not auto-generate the MAC address in the network XML
parser, as there are likely to be consumers of that API that don't
need or want to have a MAC address associated with the
bridge.
Instead, in bridge_driver.c when the network is being defined, if
there is no MAC, one is generated. To account for virtual network
configs that already exist when upgrading from an older version of
libvirt, I've added a %post script to the specfile that searches for
all network definitions in both the config directory
(/etc/libvirt/qemu/networks) and the state directory
(/var/lib/libvirt/network) that are missing a mac address, generates a
random address, and adds it to the config (and a matching address to
the state file, if there is one).
docs/formatnetwork.html.in: document <mac address.../>
docs/schemas/network.rng: add nac address to schema
libvirt.spec.in: %post script to update existing networks
src/conf/network_conf.[ch]: parse and format <mac address.../>
src/libvirt_private.syms: export a couple private symbols we need
src/network/bridge_driver.c:
auto-generate mac address when needed,
create dummy interface if mac address is present.
tests/networkxml2xmlin/isolated-network.xml
tests/networkxml2xmlin/routed-network.xml
tests/networkxml2xmlout/isolated-network.xml
tests/networkxml2xmlout/routed-network.xml: add mac address to some tests
2011-02-09 08:28:12 +00:00
|
|
|
void virNetworkSetBridgeMacAddr(virNetworkDefPtr def);
|
|
|
|
|
2010-05-27 15:44:31 +00:00
|
|
|
int virNetworkObjIsDuplicate(virNetworkObjListPtr doms,
|
|
|
|
virNetworkDefPtr def,
|
|
|
|
unsigned int check_active);
|
|
|
|
|
2008-12-04 20:53:20 +00:00
|
|
|
void virNetworkObjLock(virNetworkObjPtr obj);
|
|
|
|
void virNetworkObjUnlock(virNetworkObjPtr obj);
|
|
|
|
|
2012-08-05 20:11:50 +00:00
|
|
|
VIR_ENUM_DECL(virNetworkForward)
|
|
|
|
|
2012-09-04 15:55:17 +00:00
|
|
|
# define VIR_CONNECT_LIST_NETWORKS_FILTERS_ACTIVE \
|
|
|
|
(VIR_CONNECT_LIST_NETWORKS_ACTIVE | \
|
|
|
|
VIR_CONNECT_LIST_NETWORKS_INACTIVE)
|
|
|
|
|
|
|
|
# define VIR_CONNECT_LIST_NETWORKS_FILTERS_PERSISTENT \
|
|
|
|
(VIR_CONNECT_LIST_NETWORKS_PERSISTENT | \
|
|
|
|
VIR_CONNECT_LIST_NETWORKS_TRANSIENT)
|
|
|
|
|
|
|
|
# define VIR_CONNECT_LIST_NETWORKS_FILTERS_AUTOSTART \
|
|
|
|
(VIR_CONNECT_LIST_NETWORKS_AUTOSTART | \
|
|
|
|
VIR_CONNECT_LIST_NETWORKS_NO_AUTOSTART)
|
|
|
|
|
|
|
|
# define VIR_CONNECT_LIST_NETWORKS_FILTERS_ALL \
|
|
|
|
(VIR_CONNECT_LIST_NETWORKS_FILTERS_ACTIVE | \
|
|
|
|
VIR_CONNECT_LIST_NETWORKS_FILTERS_PERSISTENT | \
|
|
|
|
VIR_CONNECT_LIST_NETWORKS_FILTERS_AUTOSTART)
|
|
|
|
|
|
|
|
int virNetworkList(virConnectPtr conn,
|
|
|
|
virNetworkObjList netobjs,
|
|
|
|
virNetworkPtr **nets,
|
|
|
|
unsigned int flags);
|
|
|
|
|
2008-07-11 10:48:34 +00:00
|
|
|
#endif /* __NETWORK_CONF_H__ */
|