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

Re: [libvirt] virDomainNetGetActualBridgeName doesn't return the actual bridge



I'm working on a patch to change the network an interface is associated with while the guest is running. So one part of this is of course changing the bridge the interface is actually connected to. I already considered the way your described (from domain to net to bridge) but I'm wondering if that really the right way to do it. I'm not really familiar with the code but virDomainNetGetActualBridgeName seems to do exactly what I'm searching for:
const char *
virDomainNetGetActualBridgeName(virDomainNetDefPtr iface)
{
    if (iface->type == VIR_DOMAIN_NET_TYPE_BRIDGE)
        return iface->data.bridge.brname;
    if (iface->type != VIR_DOMAIN_NET_TYPE_NETWORK)
        return NULL;
    if (!iface->data.network.actual)
        return NULL;
    return iface->data.network.actual->data.bridge.brname;
}
It simply returns brname from data.network.actual if the struct exists. But it doesn't exist.
Is this indented or is the code to create this structure simply missing?



On 31.01.2012 17:00, Cole Robinson 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?

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

For the virtual network case, you could do it in a round about way by getting
the network name from the domain<interface>  block, then parsing the bridge
name from the equivalent of virsh net-dumpxml<netname>

But if we are providing an API like that it should probably work for virtual
networks (but then again I don't know the specific use case that API was meant
to address so it may be conceptually wrong).

- Cole



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