Confused with USB NIC emulation’s behavior? You’re not alone!

TL;DR: Update your host kernel!

Starting from Incus 6.11, we now have a new io.bus key for VM NICs. The general idea is to give support for network on more guests, as it’s a pretty critical component nowadays :slight_smile:.

You can skip this piece of background
More specifically, I’ve implemented it as a way to pursue my quest to macOS virtualization on Incus. I’ve discussed in a previous post about a problem that I had with some big packet loss. I thought it was due to the nasty bits of dark magic I was using, and, although it may have been the case, it turns out that I’m experiencing a similar behavior on the last stable Incus release, with close to no dark magic.

On to the fun bits. If you’re using USB NIC emulation, the following behaviors may be encountered:

  • Your NIC has the wrong MAC address
    • Your NIC name starts with enx40
      Almost everything is fine, but you’re running an unpatched version of QEMU. For reasons we are yet to understand, QEMU changes the first byte of the NIC MAC address to 0x40. If I were you, I’d either set manually the hwaddr to something starting with 40: or switch to the Zabbly repositories, that come with a QEMU patch.
    • Your NIC name starts with enp
      Well, tough luck. We think it’s a kernel bug leading to an improper USB enumeration. Just hot-unplug-replug your NIC or reboot your machine. Nothing else we can do here…
  • Your NIC has the correct MAC address
    • You are getting an IP but are unable to ping your gateway for a minute straight (and have triple-checked that your network is not messed up)
      Update your host kernel! I’ve found that it works on 6.12.20 and 6.12.21.
    • You are getting an IP and are able to ping your gateway for a minute straight
      You should be good to go.

I’ve tested on Arch and Debian Trixie Incus hosts and was quite surprised that it worked on the latter and not the former. Only to discover that we had pinned the kernel on the Arch machine. So I can tell with conviction that the USB emulation is broken on the 6.6.25 kernel, and I’ve tested it on 6.12.20 and 6.12.21 and it works. I insist that I’m talking about the host kernel, not the VM one.

Hope it saves you days of trouble. At least I’d have loved to read that a few months back :slight_smile:

1 Like