Failing to raise 2ndary nic for an LXC container inside a KVM guest

I’m struggling to raise a secondary nic into an LXC container, that runs inside a VM (KVM guest).

The VM itself is a centos, and the LXC container that runs inside it is a debian, managed through LXD.

This container needs to be reachable from 2 vlans, and the 2 LXD bridges that sits on top of them have already been created and proven to work properly with both vlans. (other containers attached to them are reachable)

Centos VM :
virbr10 <-> LAN 10 : 192.168.10.0/24
virbr40 <-> LAN 40 : 192.168.40.0/24

LXC debian:
eth10 : parent = virbr10 WORKS
eth40 : parent = virbr40 FAILS TO RAISE

Now the problem is whenever i attach this secondary eth40 inside my LXC container using :

lxc config device add mydebian eth40 nic name=eth40 nictype=bridged parent=virbr40

i get a systematic ifup: failed to bring up eth40 when i go check the logs inside it, without any other meaningful information …

Is there any workaround this ?

I think the problem is that you’re trying to bring up the interface called eth40 inside your VM, however due to this being a VM, LXD is not able to actually specify the name of the interface inside the VM. It is named by the guest OS based on its position on the PCIe bus.

However LXD does take care to order the NIC devices consistently on the guest’s PCIe bus based on the NIC’s name so that they don’t fluctuate.

Take a look at ip l inside the VM guest and look out for an interface that isn’t configured, its likely to be the one you need.

@stgraber is this something we are planning to add to the lxd-agent or should we perhaps prevent the use of the name property for VM NICs?

We have an open issue to have the agent handle interface renaming, though that would likely be some kind of opt-in thing as it can be quite disruptive on some distros.