I’m using packer with qemu plugin, my builds where failing due to packer not provisioning onto a network that had the right access controls.
Looking at this I found that using the net_bridge option was probably the best way to solve this
on the packer build host I have 2 network interfaces set up, I’m unable to get either to work, so can only assume I’m using net_bridge wrongly’
Option 1: virbr1
This is a virtual interface setup by libvirt, it has a dhcp service running on it from libvirt and it has an IP address on it (that acts as the gateway out of the virtual network via a nat)
Virtual machines are using this network fine.
5: virbr1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc htb state DOWN group default qlen 1000
link/ether 52:54:00:af:2f:f6 brd ff:ff:ff:ff:ff:ff
inet 192.168.200.1/24 brd 192.168.200.255 scope global virbr1
if I set packer to use this device
"accelerator": "kvm",
"qemu_binary": "/usr/bin/qemu-kvm",
"net_device": "virtio-net",
"net_bridge": "virbr1",
"disk_interface": "virtio",
the packer build fails
==> qemu.rocky10: Overriding default Qemu arguments with qemuargs template option…
2025/07/01 09:35:14 packer-plugin-qemu_v1.1.3_x5.0_linux_amd64 plugin: 2025/07/01 09:35:14 Executing /usr/bin/qemu-kvm: string{“-smp”, “2”, “-display”, “gtk”, “-device”, “virtio-net,netdev=user.0”, “-boot”, “once=d”, “-m”, “4096M”, “-cpu”, “host,migratable=on”, “-name”, “packer-rocky10”, “-machine”, “type=pc,accel=kvm”, “-netdev”, “bridge,id=user.0,br=virbr1”, “-vnc”, “127.0.0.1:75”, “-qmp”, “unix:artifacts/qemu/rocky10/packer-rocky10.monitor,server,nowait”, “-drive”, “file=artifacts/qemu/rocky10/packer-rocky10,if=virtio,cache=none,discard=unmap,format=raw”, “-drive”, “file=/home/mattd/.cache/packer/1599a43de54dfe2cbe3fc7949b00365ace9accc2.iso,media=cdrom”}
2025/07/01 09:35:14 packer-plugin-qemu_v1.1.3_x5.0_linux_amd64 plugin: 2025/07/01 09:35:14 Started Qemu. Pid: 3976
2025/07/01 09:35:14 packer-plugin-qemu_v1.1.3_x5.0_linux_amd64 plugin: 2025/07/01 09:35:14 Qemu stderr: access denied by acl file
2025/07/01 09:35:14 packer-plugin-qemu_v1.1.3_x5.0_linux_amd64 plugin: 2025/07/01 09:35:14 Qemu stderr: qemu-kvm: -netdev bridge,id=user.0,br=virbr1: bridge helper failed
==> qemu.rocky10: Error launching VM: Qemu failed to start. Please run with PACKER_LOG=1 to get more info.
==> qemu.rocky10: Deleting output directory…
2025/07/01 09:35:14 packer-plugin-qemu_v1.1.3_x5.0_linux_amd64 plugin: 2025/07/01 09:35:14 failed to unlock port lockfile: close tcp 127.0.0.1:5975: use of closed network connection
The KVM guest doing the build doesn’t even actually start,
Options 2: link level bridge br0
on the host there is a bridge interface setup that has a physical interface slaved to it. This slave interface is a link level device to the actual LAN, and participates on the network as a virtual NIC for VM’s. VM’s using this interface participate on the network as nodes, get’s IP/DNS updates from the actual lan and is routeable, no natting etc.
4: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether c8:5b:76:41:0a:86 brd ff:ff:ff:ff:ff:ff
inet6 fdb7:e265:8872:bb1a:ca5b:76ff:fe41:a86/64 scope global dynamic mngtmpaddr proto kernel_ra
valid_lft 1788sec preferred_lft 1788sec
if I set packer to use this device
"accelerator": "kvm",
"qemu_binary": "/usr/bin/qemu-kvm",
"net_device": "virtio-net",
"net_bridge": "br0",
"disk_interface": "virtio",
"disk_cache": "none",
I expect the packer build to launch a VM that can participate on the network, get an IP from dhcp etc.
what I get is
2025/07/01 09:41:30 packer-plugin-qemu_v1.1.3_x5.0_linux_amd64 plugin: 2025/07/01 09:41:30 No floppy files specified. Floppy disk will not be made.
2025/07/01 09:41:30 packer-plugin-qemu_v1.1.3_x5.0_linux_amd64 plugin: 2025/07/01 09:41:30 No CD files specified. CD disk will not be made.
2025/07/01 09:41:30 packer-plugin-qemu_v1.1.3_x5.0_linux_amd64 plugin: 2025/07/01 09:41:30 [INFO] Creating disk with Path: artifacts/qemu/rocky10/packer-rocky10 and Size: 10G
2025/07/01 09:41:30 packer-plugin-qemu_v1.1.3_x5.0_linux_amd64 plugin: 2025/07/01 09:41:30 Executing qemu-img: []string{"create", "-f", "raw", "artifacts/qemu/rocky10/packer-rocky10", "10G"}
2025/07/01 09:41:30 packer-plugin-qemu_v1.1.3_x5.0_linux_amd64 plugin: 2025/07/01 09:41:30 stdout: Formatting 'artifacts/qemu/rocky10/packer-rocky10', fmt=raw size=10737418240
2025/07/01 09:41:30 packer-plugin-qemu_v1.1.3_x5.0_linux_amd64 plugin: 2025/07/01 09:41:30 stderr:
**==> qemu.rocky10: Error getting an IPv4 address from the bridge br0: cannot find any IPv4 address**
I’m unsure of the issue here.
1.) I put it on a virtual network, with a dhcp service and IP address on the interface, it fails
2.) I put it on a br0 interface which is a linked to a physical interface which can participate on the network, it can’t get an IP
Both of these networks work if I launch a VM using them, it’s only when packer launches a build VM using the net_bridge option
am I using net_bridge right ?