411c548 network: set macvtap/hostdev networks active if their state file exists

Authored and Committed by Laine Stump 9 years ago
    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).
    
        
file modified
+1 -0
file modified
+50 -19