libvirt/src/conf
Laine Stump a28d3e485f network: move auto-assign of bridge name from XML parser to net driver
We already check that any auto-assigned bridge device name for a
virtual network (e.g. "virbr1") doesn't conflict with the bridge name
for any existing libvirt network (via virNetworkSetBridgeName() in
conf/network_conf.c).

We also want to check that the name doesn't conflict with any bridge
device created on the host system outside the control of libvirt
(history: possibly due to the ploriferation of references to libvirt's
bridge devices in HOWTO documents all around the web, it is not
uncommon for an admin to manually create a bridge in their host's
system network config and name it "virbrX"). To add such a check to
virNetworkBridgeInUse() (which is called by virNetworkSetBridgeName())
we would have to call virNetDevExists() (from util/virnetdev.c); this
function calls ioctl(SIOCGIFFLAGS), which everyone on the mailing list
agreed should not be done from an XML parsing function in the conf
directory.

To remedy that problem, this patch removes virNetworkSetBridgeName()
from conf/network_conf.c and puts an identically functioning
networkBridgeNameValidate() in network/bridge_driver.c (because it's
reasonable for the bridge driver to call virNetDevExists(), although
we don't do that yet because I wanted this patch to have as close to 0
effect on function as possible).

There are a couple of inevitable changes though:

1) We no longer check the bridge name during
   virNetworkLoadConfig(). Close examination of the code shows that
   this wasn't necessary anyway - the only *correct* way to get XML
   into the config files is via networkDefine(), and networkDefine()
   will always call networkValidate(), which previously called
   virNetworkSetBridgeName() (and now calls
   networkBridgeNameValidate()). This means that the only way the
   bridge name can be unset during virNetworkLoadConfig() is if
   someone edited the config file on disk by hand (which we explicitly
   prohibit).

2) Just on the off chance that somebody *has* edited the file by hand,
   rather than crashing when they try to start their malformed
   network, a check for non-NULL bridge name has been added to
   networkStartNetworkVirtual().

   (For those wondering why I don't instead call
   networkValidateBridgeName() there to set a bridge name if one
   wasn't present - the problem is that during
   networkStartNetworkVirtual(), the lock for the network being
   started has already been acquired, but the lock for the network
   list itself *has not* (because we aren't adding/removing a
   network). But virNetworkBridgeInuse() iterates through *all*
   networks (including this one) and locks each network as it is
   checked for a duplicate entry; it is necessary to lock each network
   even before checking if it is the designated "skip" network because
   otherwise some other thread might acquire the list lock and delete
   the very entry we're examining. In the end, permitting a setting of
   the bridge name during network start would require that we lock the
   entire network list during any networkStartNetwork(), which
   eliminates a *lot* of parallelism that we've worked so hard to
   achieve (it can make a huge difference during libvirtd startup). So
   rather than try to adjust for someone playing against the rules, I
   choose to instead give them the error they deserve.)

3) virNetworkAllocateBridge() (now removed) would leak any "template"
   string set as the bridge name. Its replacement
   networkFindUnusedBridgeName() doesn't leak the template string - it
   is properly freed.
2015-04-28 01:20:11 -04:00
..
capabilities.c qemu: fix memleak in virCapabilitiesDomainDataLookup 2015-04-27 10:04:38 +02:00
capabilities.h caps: Use DomainDataLookup to replace GuestDefault* 2015-04-20 16:43:13 -04:00
cpu_conf.c conf: Don't output <cpu> tag if it contains no information. 2015-04-13 09:27:26 +02:00
cpu_conf.h conf: Move all NUMA configuration to virDomainNuma 2015-02-20 17:50:08 +01:00
device_conf.c SRIOV NIC offload feature discovery 2015-03-05 11:31:05 +01:00
device_conf.h SRIOV NIC offload feature discovery 2015-03-05 11:31:05 +01:00
domain_addr.c virDomainVirtioSerialAddrSetFree: Fix memleak 2015-04-07 18:52:26 +02:00
domain_addr.h Auto add virtio-serial controllers 2015-04-02 15:00:13 +02:00
domain_audit.c qemu: Add support to Add/Delete IOThreads 2015-04-27 12:36:36 -04:00
domain_audit.h qemu: Add support to Add/Delete IOThreads 2015-04-27 12:36:36 -04:00
domain_capabilities.c domaincaps: Expose UEFI binary path, if it exists 2014-09-17 16:29:49 +02:00
domain_capabilities.h domaincaps: Expose UEFI binary path, if it exists 2014-09-17 16:29:49 +02:00
domain_conf.c domain: Introduce virDomainIOThreadSchedDelId 2015-04-27 12:36:36 -04:00
domain_conf.h domain: Introduce virDomainIOThreadSchedDelId 2015-04-27 12:36:36 -04:00
domain_event.c Add VIR_DOMAIN_EVENT_ID_DEVICE_ADDED event 2015-04-15 17:06:01 +02:00
domain_event.h Add VIR_DOMAIN_EVENT_ID_DEVICE_ADDED event 2015-04-15 17:06:01 +02:00
domain_nwfilter.c Remove use of nwfilterPrivateData from nwfilter driver 2015-01-27 12:02:03 +00:00
domain_nwfilter.h Remove use of nwfilterPrivateData from nwfilter driver 2015-01-27 12:02:03 +00:00
interface_conf.c Remove unnecessary curly brackets in src/conf/ 2014-11-14 17:13:01 +01:00
interface_conf.h maint: Prohibit "devname" by a syntax check rules 2014-10-01 16:39:01 +02:00
netdev_bandwidth_conf.c network: only clear bandwidth if it has been set 2015-02-25 13:09:34 -05:00
netdev_bandwidth_conf.h conf: Increase virNetDevBandwidthParse intelligence 2015-01-13 18:24:15 +01:00
netdev_vlan_conf.c Indent top-level labels by one space in src/conf/ 2014-03-25 14:58:38 +01:00
netdev_vlan_conf.h maint: avoid 'const fooPtr' in conf 2013-10-14 14:34:38 -06:00
netdev_vport_profile_conf.c docs: schema and docs for the midonet virtualport type 2015-03-17 13:09:05 -04:00
netdev_vport_profile_conf.h
network_conf.c network: move auto-assign of bridge name from XML parser to net driver 2015-04-28 01:20:11 -04:00
network_conf.h network: move auto-assign of bridge name from XML parser to net driver 2015-04-28 01:20:11 -04:00
network_event.c Replace virNetworkFree with virObjectUnref 2014-12-02 11:03:40 -05:00
network_event.h event: move event filtering to daemon (regression fix) 2014-02-05 08:03:31 -07:00
networkcommon_conf.c network: Resolve Coverity FORWARD_NULL 2015-01-16 06:40:15 -05:00
networkcommon_conf.h Use the network route definitions for domains 2015-01-16 10:14:03 +01:00
node_device_conf.c Introduce virBitmapIsBitSet 2015-03-13 15:31:33 +01:00
node_device_conf.h SRIOV NIC offload feature discovery 2015-03-05 11:31:05 +01:00
numa_conf.c virBitmap: Place virBitmapIsAllClear check after virBitmapParse calls 2015-04-13 14:21:02 +02:00
numa_conf.h conf: numa: Add helper to count total memory size configured in NUMA 2015-03-02 16:42:51 +01:00
nwfilter_conf.c nwfilter: Add support for icmpv6 filtering 2015-01-07 11:41:49 -05:00
nwfilter_conf.h nwfilter: Add support for icmpv6 filtering 2015-01-07 11:41:49 -05:00
nwfilter_ipaddrmap.c Remove pointless storage of var names in virNWFilterHashTable 2014-04-25 15:44:09 +01:00
nwfilter_ipaddrmap.h
nwfilter_params.c nwfilter: Change 'index' to 'idx' 2015-04-14 11:18:28 -04:00
nwfilter_params.h nwfilter: Change 'index' to 'idx' 2015-04-14 11:18:28 -04:00
object_event_private.h event: prepare client to track domain callbackID 2014-02-12 10:48:15 -07:00
object_event.c Remove unnecessary curly brackets in src/conf/ 2014-11-14 17:13:01 +01:00
object_event.h event: add notion of remoteID for filtering client network events 2014-01-15 13:55:21 -07:00
secret_conf.c maint: use consistent if-else braces in conf and friends 2014-09-04 08:53:21 -06:00
secret_conf.h maint: shorten 'TypeType' function names 2014-05-16 00:22:18 -06:00
snapshot_conf.c domain: conf: Drop expectedVirtTypes 2015-04-20 16:43:43 -04:00
snapshot_conf.h domain: conf: Drop expectedVirtTypes 2015-04-20 16:43:43 -04:00
storage_conf.c storage: Add duplicate devices check for zfs pool def 2015-04-15 06:51:20 -04:00
storage_conf.h conf: Introduce virStoragePoolLoadAllState && virStoragePoolLoadState 2015-04-07 16:22:40 +02:00
virchrdev.c Replace virStreamFree with virObjectUnref 2014-12-02 11:03:41 -05:00
virchrdev.h