QEMU/KVM Attaching a Virtual NIC Directly to a Physical Interface

Man, it took me a while to figure out how to do this! Over on Attaching a Virtual NIC Directly to a Physical Interface I figured out I could use this XML in Virtual Machine Manager (virt-manager) for my NIC device:

<interface type='direct'>
  <source dev='enp9s0' mode='bridge'/>
</interface>

That then gets expanded automatically to something like this:

<interface type="direct">
  <mac address="52:54:00:ce:5b:09"/>
  <source dev="enp9s0" mode="bridge"/>
  <target dev="macvtap4"/>
  <model type="rtl8139"/>
  <alias name="net0"/>
  <address type="pci" domain="0x0000" bus="0x10" slot="0x01" function="0x0"/>
</interface>

Update: ah, balls. This doesn’t completely work, because the guest can’t connect to the host, and vice versa, even though both the host and the guest can connect to the internet. This is a problem for another day. Maybe this or this will help?

Ethernet on ‘trick’

Note to self: I’ve disabled my second NIC enp7s0 for now, I can enable it when its cable arrives.

-------------------
Mon Mar 28 16:34:31 [bash:5.0.17 jobs:0 error:0 time:1505]
root@trick:/home/jj5
# cat /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
  ethernets:
    enp10s0:
      addresses:
      - 10.3.2.5/16
      gateway4: 10.3.1.1
      nameservers:
        addresses:
        - 10.1.1.113
        search: []
    #enp7s0:
    #  addresses:
    #  - 10.1.2.5/16
    #  nameservers:
    #    addresses: []
    #    search: []
  version: 2

-------------------