libvirt/tests
Laine Stump 5754dbd56d 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-17 13:36:32 -05:00
..
capabilityschemadata
commanddata maint: improve tests distribution 2010-12-17 11:57:11 -07:00
confdata maint: improve tests distribution 2010-12-17 11:57:11 -07:00
cputestdata tests: Add unit tests for internal CPU APIs 2010-12-01 14:12:54 +01:00
domainschemadata schema: Move timer element inside clock 2010-11-09 15:35:43 +01:00
domainsnapshotxml2xmlin
domainsnapshotxml2xmlout
interfaceschemadata
networkxml2xmlin Give each virtual network bridge its own fixed MAC address 2011-02-17 13:36:32 -05:00
networkxml2xmlout Give each virtual network bridge its own fixed MAC address 2011-02-17 13:36:32 -05:00
nodedevschemadata
nodeinfodata
nwfilterxml2xmlin
nwfilterxml2xmlout
qemuhelpdata Add txmode attribute to interface XML for virtio backend 2011-02-17 11:07:58 -05:00
qemuxml2argvdata Add txmode attribute to interface XML for virtio backend 2011-02-17 11:07:58 -05:00
qemuxml2xmloutdata Add VIR_DIV_UP to divide memory or storage request sizes with round up 2011-01-29 00:42:10 +01:00
sexpr2xmldata maint: improve tests distribution 2010-12-17 11:57:11 -07:00
storagepoolxml2xmlin
storagepoolxml2xmlout
storagevolxml2xmlin
storagevolxml2xmlout
vmx2xmldata vmx: Add support for video device VRAM size 2011-01-06 18:18:35 +01:00
xencapsdata maint: improve tests distribution 2010-12-17 11:57:11 -07:00
xmconfigdata maint: improve tests distribution 2010-12-17 11:57:11 -07:00
xml2sexprdata maint: improve tests distribution 2010-12-17 11:57:11 -07:00
xml2vmxdata vmx: Add support for video device VRAM size 2011-01-06 18:18:35 +01:00
.gitignore Introduce new APIs for spawning processes 2010-12-02 16:00:44 -07:00
.valgrind.supp
capabilityschematest
commandhelper.c commandtest: avoid printing loader-control variables from commandhelper 2011-01-06 14:21:17 -07:00
commandtest.c build: avoid close, system 2011-01-29 10:36:45 -07:00
conftest.c
cpuset
cputest.c tests: Add unit tests for internal CPU APIs 2010-12-01 14:12:54 +01:00
daemon-conf tests: fix daemon-conf testing failure 2010-11-03 11:43:11 +01:00
define-dev-segfault
domainschematest
domainsnapshotschematest
esxutilstest.c esx: Move VMX handling code out of the driver directory 2010-12-21 22:40:17 +01:00
eventtest.c event: fix event-handling allocation crash 2011-01-27 09:12:36 -07:00
int-overflow
interfaceschematest
interfacexml2xmltest.c
libvirtd-fail
libvirtd-pool
Makefile.am tests: Remove obsolete secaatest 2011-01-15 23:36:31 +01:00
networkschematest
networkxml2xmltest.c
nodedevschematest
nodedevxml2xmltest.c
nodeinfotest.c tests: avoid spurious failure of nodeinfotest 2010-12-20 10:31:40 -07:00
nwfilterschematest
nwfilterxml2xmltest.c tests: Fix detection of expected errors 2010-11-29 16:35:20 +01:00
object-locking.ml
oomtrace.pl
qemuargv2xmltest.c qemu: Allow serving VNC over a unix domain socket 2011-01-21 16:03:04 -05:00
qemuhelptest.c Add txmode attribute to interface XML for virtio backend 2011-02-17 11:07:58 -05:00
qemuxml2argvtest.c Add txmode attribute to interface XML for virtio backend 2011-02-17 11:07:58 -05:00
qemuxml2xmltest.c Add txmode attribute to interface XML for virtio backend 2011-02-17 11:07:58 -05:00
qparamtest.c
read-bufsiz
read-non-seekable
reconnect.c
schematestutils.sh
seclabeltest.c Refactor the security drivers to simplify usage 2011-01-10 18:10:52 +00:00
sexpr2xmltest.c
sockettest.c
start
statstest.c
storagepoolschematest
storagepoolxml2xmltest.c
storagevolschematest
storagevolxml2xmltest.c
test_conf.sh
test-lib.sh
testutils.c tests: handle backspace-newline pairs in test input files 2011-01-31 11:25:34 -07:00
testutils.h
testutilsqemu.c tests: Fake host capabilities properly 2011-02-15 22:51:37 +01:00
testutilsqemu.h
testutilsxen.c
testutilsxen.h
undefine
vcpupin
virbuftest.c
virsh-all
virsh-schedinfo
virsh-synopsis
virshtest.c
virt-aa-helper-test
vmx2xmltest.c vmx: Add support for video device VRAM size 2011-01-06 18:18:35 +01:00
xencapstest.c deprecate fclose() and introduce VIR_{FORCE_}FCLOSE() 2010-11-16 21:13:29 -05:00
xmconfigtest.c
xml2sexprtest.c xend: Escape reserved sexpr characters 2010-11-22 16:43:29 -05:00
xml2vmxtest.c vmx: Add support for video device VRAM size 2011-01-06 18:18:35 +01:00