
Laine Stump wrote:
This is also needed if virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_NETWORK (since a libvirt virtual network is implemented using a bridge device connected to tap devices - see the corresponding "create a tap device" code for a network device at qemu_command.c:7562).
Since you would be calling the *Get function so many times, maybe it would be better to use a switch statement.
Of course, the bridge device used by a VIR_DOMAIN_NET_TYPE_NETWORK interface is *not* returned by virDomainNetGetActualBridgeName() (which is intended to only be a simple wrapper around the interface config), so you would need to use the code in the "actualType == VIR_DOMAIN_NET_TYPE_NETWORK" clause of qemuNetworkIfaceConnect() to retrieve the appropriate network object and get the name of the bridge it uses. (in other words - NETWORK and BRIDGE will need different cases in the switch :-( ) (this is now done in enough places that perhaps it is time for a helper function)
Also, notice that the code just below your addition is removing the tap device from an openvswitch bridge if necessary - your patch would end up calling the wrong function (virNetDevBridgeRemovePort) for interfaces attached to an openvswitch port. I think you need to first get the actualType and vport, then use the actualType to decide whether or not to retrieve brname, and then the vport setting to decide if you need to detach from an openvswitch port (always) or detach from a normal bridge (freebsd only).
Hi, Thanks for looking at this patch! Actually, it's not necessary to manually detach interfaces from bridge because they'll be detached automatically when destroyed. I added that code for explicitly and now I realise that it's probably a bad idea. I've uploaded v3 of that patch. Roman Bogorodskiy