]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commit
network: set macvtap/hostdev networks active if their state file exists
authorLaine Stump <laine@laine.org>
Wed, 9 Apr 2014 14:16:45 +0000 (17:16 +0300)
committerLaine Stump <laine@laine.org>
Sun, 27 Apr 2014 09:20:39 +0000 (12:20 +0300)
commit411c5486685b81d0c04ad7c83ac3552ec011968c
tree4481e14c6bfa71ff4d50d4b5d9076e26f18d78d4
parentb9e95491d120d05737b77e2c4dc14ba5dfac5fb0
network: set macvtap/hostdev networks active if their state file exists

libvirt attempts to determine at startup time which networks are
already active, and set their active flags. Previously it has done
this by assuming that all networks are inactive, then setting the
active flag if the network has a bridge device associated with it and
that bridge device exists. This is not useful for macvtap and hostdev
based networks, since they do not use a bridge device.

Of course the reason that such a check had to be done was that the
presence of a status file in the network "stateDir" couldn't be
trusted as an indicator of whether or not a network was active. This
was due to the network driver mistakenly using
/var/lib/libvirt/network to store the status files, rather than
/var/run/libvirt/network (similar to what is done by every other
libvirt driver that stores status xml for its objects). The difference
is that /var/run is cleared out when the host reboots, so you can be
assured that the state file you are seeing isn't just left over from a
previous boot of the host.

Now that the network driver has been switched to using
/var/run/libvirt/network for status, we can also modify it to assume
that any network with an existing status file is by definition active
- we do this when reading the status file. To fine tune the results,
networkFindActiveConfigs() is changed to networkUpdateAllState(),
and only sets active = 0 if the conditions for particular network
types are *not* met.

The result is that during the first run of libvirtd after the host
boots, there are no status files, so no networks are active. Any time
libvirtd is restarted, any network with a status file will be marked
as active (unless the network uses a bridge device and that device for
some reason doesn't exist).
src/conf/network_conf.c
src/network/bridge_driver.c