Libvirt provides a portable, long term stable C API for managing the virtualization technologies provided by many operating systems. It includes support for QEMU, KVM, Xen, LXC, bhyve, Virtuozzo, VMware vCenter and ESX, VMware Desktop, Hyper-V, VirtualBox and the POWER Hypervisor.
Go to file
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
.gnulib@ecb020f2b0 virsh: avoid mingw compiler warnings 2011-02-12 06:39:27 -07:00
daemon Add a little more debugging for async events 2011-02-09 16:45:05 +00:00
docs Give each virtual network bridge its own fixed MAC address 2011-02-17 13:36:32 -05:00
examples Prevent overfilling of self-pipe in python event loop 2011-01-28 11:48:27 +00:00
include libvirt-qemu: Fix enum type declaration 2011-02-14 12:35:39 +01:00
m4 maint: update to latest gnulib 2010-11-17 10:13:12 -07:00
po Move all the QEMU migration code to a new file 2011-02-17 12:56:10 +00:00
python python: Use PyCapsule API if available 2011-01-10 15:18:05 -05:00
src Give each virtual network bridge its own fixed MAC address 2011-02-17 13:36:32 -05:00
tests Give each virtual network bridge its own fixed MAC address 2011-02-17 13:36:32 -05:00
tools build: silence some clang warnings 2011-02-15 10:43:40 -07:00
.dir-locals.el maint: whitespace cleanup 2011-02-09 11:18:06 -07:00
.gitignore Release of libvirt-0.8.7 2011-01-04 03:37:17 +01:00
.gitmodules make .gnulib a submodule 2009-07-08 16:17:51 +02:00
.mailmap maint: update an email address preference 2010-08-10 08:13:22 -06:00
.x-sc_avoid_ctype_macros exempt gnulib from ctype-macros prohibition 2008-10-28 17:36:31 +00:00
.x-sc_avoid_if_before_free avoid a "make syntax-check" failure 2009-07-09 20:00:37 +02:00
.x-sc_avoid_write Introduce new APIs for spawning processes 2010-12-02 16:00:44 -07:00
.x-sc_bindtextdomain maint: update to latest gnulib 2010-11-17 10:13:12 -07:00
.x-sc_m4_quote_check syntax-check: enable more checks 2009-02-03 13:08:36 +00:00
.x-sc_po_check build: avoid false positive syntax-check failure 2010-10-19 09:28:35 -06:00
.x-sc_prohibit_always_true_header_tests build: update gnulib 2010-05-06 14:35:38 -06:00
.x-sc_prohibit_asprintf util: add virVasprintf 2010-12-02 11:23:15 -07:00
.x-sc_prohibit_close maint: reject raw close, popen in 'make syntax-check' 2011-01-29 10:36:47 -07:00
.x-sc_prohibit_empty_lines_at_EOF tests: test RHEL 6.0 qemu-kvm -help parsing 2010-12-13 16:30:02 -07:00
.x-sc_prohibit_fork_wrappers maint: reject raw close, popen in 'make syntax-check' 2011-01-29 10:36:47 -07:00
.x-sc_prohibit_gethostby Various syntax-check fixes. 2009-10-26 10:34:05 +01:00
.x-sc_prohibit_gethostname Add a new syntax-check rule for gethostname. 2009-10-26 10:34:27 +01:00
.x-sc_prohibit_gettext_noop build: fix syntax-check problems 2010-04-12 16:43:05 -06:00
.x-sc_prohibit_have_config_h maint: sync from coreutils 2009-01-29 18:06:19 +00:00
.x-sc_prohibit_HAVE_MBRTOWC maint: sync from coreutils 2009-01-29 18:06:19 +00:00
.x-sc_prohibit_nonreentrant Tighten up nonreentrant syntax-check. 2009-10-26 10:33:42 +01:00
.x-sc_prohibit_readlink Add a rule to check for uses of readlink. 2010-01-22 09:42:35 -05:00
.x-sc_prohibit_sprintf maint: avoid remaining sprintf uses 2010-11-17 10:13:12 -07:00
.x-sc_prohibit_strncpy Avoid checking against strncpy in virsh.c 2010-10-12 19:26:10 +02:00
.x-sc_prohibit_test_minus_ao build: fix syntax-check problems 2010-04-12 16:43:05 -06:00
.x-sc_prohibit_VIR_ERR_NO_MEMORY Various syntax-check fixes. 2009-10-26 10:34:05 +01:00
.x-sc_prohibit_xmlGetProp maint: prohibit most uses of xmlGetProp 2010-11-24 15:23:43 -07:00
.x-sc_require_config_h Various syntax-check fixes. 2009-10-26 10:34:05 +01:00
.x-sc_require_config_h_first Misc syntax-check fixes 2009-09-21 14:41:47 +01:00
.x-sc_trailing_blank build: exempt *.ico files from the trailing blank check 2008-10-16 13:28:07 +00:00
.x-sc_unmarked_diagnostics build: import latest gnulib 2010-04-02 10:18:55 -06:00
acinclude.m4 maint: turn on gcc logical-op checking 2010-07-28 15:25:36 +02:00
AUTHORS fix OOM handling in hash routines 2011-02-14 13:36:06 +08:00
autobuild.sh test: fix commandtest under autobuild.sh 2010-12-13 16:04:56 -07:00
autogen.sh build: avoid problems with autogen.sh runs from tarball 2011-02-12 06:28:28 -07:00
bootstrap maint: support --no-git option during autogen.sh 2011-01-21 09:45:37 -07:00
bootstrap.conf build: avoid corrupted gnulib/tests/Makefile 2011-01-24 17:19:25 -07:00
cfg.mk build: avoid problems with autogen.sh runs from tarball 2011-02-12 06:28:28 -07:00
ChangeLog-old generate ChangeLog from git logs into distribution tarball 2009-07-08 16:17:51 +02:00
configure.ac storage: Allow to delete device mapper disk partition 2011-02-17 15:29:07 +08:00
COPYING.LIB remove all trailing blank lines 2009-07-16 15:06:42 +02:00
HACKING maint: document dislike of mismatched if/else bracing 2011-01-05 11:05:28 -07:00
libvirt.pc.in * libvirt.pc.in: applied patch from Daniel Berrange to fix --cflags 2006-03-24 13:18:12 +00:00
libvirt.spec.in Give each virtual network bridge its own fixed MAC address 2011-02-17 13:36:32 -05:00
Makefile.am build: distribute 'make syntax-check' tweaks 2011-02-09 12:34:32 -07:00
Makefile.nonreentrant Ban use of all inet_* functions 2010-10-22 11:59:23 +01:00
mingw32-libvirt.spec.in Add dtrace static probes in libvirtd 2010-10-22 12:00:39 +01:00
README Correct typos in the documentation (Atsushi SAKAI) 2008-01-24 10:15:13 +00:00
README-hacking maint: relax git minimum version 2010-02-24 14:29:27 -05:00
TODO Update todo list file to point at bugzilla/website 2010-10-13 16:45:26 +01:00

         LibVirt : simple API for virtualization

  Libvirt is a C toolkit to interact with the virtualization capabilities
of recent versions of Linux (and other OSes). It is free software
available under the GNU Lesser General Public License. Virtualization of
the Linux Operating System means the ability to run multiple instances of
Operating Systems concurrently on a single hardware system where the basic
resources are driven by a Linux instance. The library aim at providing
long term stable C API initially for the Xen paravirtualization but
should be able to integrate other virtualization mechanisms if needed.

Daniel Veillard <veillard@redhat.com>