Incus VM with e1000e Network Driver

If you just want to alter the existing devices rather than define new ones from scratch, you can use the raw.qemu.scriptlet option to perform boot time re-configuration of those devices.

  raw.qemu.scriptlet: |
    def qemu_hook(instance, stage):
      if stage != "pre-start":
        return

      # Convert ethernet
      eth0_bus = run_qmp({"execute": "qom-get", "arguments": {"path": "/machine/peripheral/dev-incus_eth0", "property": "parent_bus"}})["return"].split("/")[-1]
      eth0_addr = run_qmp({"execute": "qom-get", "arguments": {"path": "/machine/peripheral/dev-incus_eth0", "property": "addr"}})["return"]
      eth0_mac = run_qmp({"execute": "qom-get", "arguments": {"path": "/machine/peripheral/dev-incus_eth0", "property": "mac"}})["return"]
      eth0_netdev = run_qmp({"execute": "qom-get", "arguments": {"path": "/machine/peripheral/dev-incus_eth0", "property": "netdev"}})["return"]
      run_qmp({"execute": "device_del", "arguments": {"id": "dev-incus_eth0"}})
      run_qmp({"execute": "system_reset"})
      run_qmp({"execute": "device_add", "arguments": {"id": "dev-incus_eth0", "driver": "e1000e", "bus": eth0_bus, "addr": eth0_addr, "netdev": eth0_netdev, "mac": eth0_mac}})

This effectively captures all the useful properties from the Incus-generated device, then removes it, restarts the emulator and adds the device back with the different driver.

1 Like