On 07/08/2011 09:32 AM, Daniel P. Berrange wrote:
On Tue, Jul 05, 2011 at 03:45:56AM -0400, Laine Stump wrote:
> Previously all networks were composed of bridge devices created and
> managed by libvirt, and the same operations needed to be done for all
> of them when they were started and stopped (create and start the
> bridge device, configure its MAC address and IP address, add iptables
> rules). The new network types are (for now at least) managed outside
> of libvirt, and the network object is used only to contain information
> about the network, which is then used as each individual guest
> connects itself.
>
> This means that when starting/stopping one of these new networks, we
> really want to do nothing, aside from marking the network as
> active/inactive.
>
> This has been setup as toplevel Start/Shutdown functions that do the
> small bit of common stuff, then have a switch statement to execute
> network type-specific start/shutdown code, then do a bit more common
> code. The type-specific functions called for the new host bridge and
> macvtap based types are currently empty.
>
> In the future these functions may actually do something, and we will
> surely add more functions that are similarly patterned. Once
> everything has settled, we can make a table of "sub-driver" function
> pointers for each network type, and store a pointer to that table in
> the network object, then we can replace the switch statements with
> calls to functions in the table.
>
> The final step in this will be to add a new table (and corresponding
> new functions) for new network types as they are added.
> ---
> src/network/bridge_driver.c | 188 +++++++++++++++++++++++++++++++------------
> 1 files changed, 138 insertions(+), 50 deletions(-)
ACK, there is pretty much no functional change for existing
network types.
> +
> + VIR_INFO("Starting up network '%s'",
network->def->name);
> + network->active = 1;
...
> network->active = 0;
We could take this opportunity to change to using a bool and
true/false
I think I'd rather do that in a separate patch - there are several other
"ints used as booleans" in network_conf, domain_conf, and nwfilter_conf
(at least) and it would probably be good to make them all consistent.