Re: virDomainNetGetActualBridgeName doesn't return the actual bridge

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 01/31/2012 11:55 AM, Laine Stump wrote:
On 01/30/2012 08:15 AM, Hendrik Schwartke wrote:
Hi,

calling virDomainNetGetActualBridgeName on a bridge with type VIR_DOMAIN_NET_TYPE_NETWORK seems to return NULL in any case, because iface->data.network.actual is NULL. Is that intented?

Yes, that's how it was intended to work. It has a very narrow purpose, only to be used for interfaces that end up being connected to host bridges not managed by libvirt (i.e., either the interface type is VIR_DOMAIN_NET_TYPE_BRIDGE, or the type is NETWORK, and the network has <forward mode='bridge'>). It's an internal API, so that purpose could change, but I would need to look and see if that would have any adverse side effect.


What is the best way to determine the bridge the interface is connected to?

I'm guessing you're writing the packet sniffing code you asked about the other day. Do you really want the bridge device that the guest is connecting to?

Heh. I just made the connection that you were also doing a patch to hot-switch the bridge that a guest is connected to, so you actually *do* want the bridge (as well as the tap device). In that case, the 2nd part of my earlier response applies.




I think the device you actually want to watch is the tap device that connects the guest to the bridge. That is in net->ifname ("net" being the virDomainNetDef containing the configuration for the interface); qemu uses that value directly when setting up the guests' interfaces.

If you really do need to get the device that the guest tap is connected to (which might be a bridge, or might be a physical ethernet, or might be ???), where that is depends on the type of interface:

1) for interface "actualType"=VIR_DOMAIN_NET_TYPE_NETWORK, currently you would need to call the public API virNetworkGetBridgeName (that requires you to first call virNetworkLookupByName).

2) for interface actualType=VIR_DOMAIN_NET_TYPE_DIRECT you would want to call virDomainNetGetActualDirectDev() - this gives you a physical interface which the guest connects to in one of the mavctap modes.

3) for interface actualType=VIR_DOMAIN_NET_TYPE_BRIDGE you would call virDomainNetGetActualBridgeName().

Note that in all cases, I'm talking about using the result of virDomainNetGetActualType(net), *not* just looking at net->type. (the latter is what's in the config, the former is what is figured out at runtime based on the config).

(Still, I'm guessing what you really want is just net->ifname).

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]