I am using your suggested options, no dice.
Here is the JSON file I’m using to build the stage 2 image.
{
"builders": [
{
"accelerator": "kvm",
"boot_wait": "20s",
"disk_image": true,
"disk_interface": "virtio",
"disk_size": "16385",
"format": "qcow2",
"headless": true,
"iso_checksum": "sha256:db67609278f56933db76f26962ea0ecafdfd9268910f6833839a8fd3f100bde1",
"iso_url": "output-ubuntu1804/ubuntu1804",
"output_directory": "output-ubuntu-layer2",
"qemuargs": [
[ "-m", "512" ],
[ "-display", "none" ],
[ "-machine", "accel=kvm" ],
[ "-cpu", "host" ],
[ "-smp", "cpus=1" ],
[ "-netdev", "user,hostfwd=tcp::{{ .SSHHostPort }}-:22,id=forward"],
[ "-device", "virtio-net,netdev=forward,id=net0"]
],
"shutdown_command": "shutdown -P now",
"ssh_password": "vagrant",
"ssh_timeout": "1800s",
"ssh_username": "vagrant",
"type": "qemu",
"use_backing_file": true,
"vm_name": "ubuntu-layer2"
}
],
"provisioners": [
{
"inline": [ "sudo apt install -y nginx" ],
"pause_before": "5s",
"type": "shell"
}
]
}
Here is the output of “PACKER_LOG=1 packer build layer2.json”.
=> qemu: Overriding default Qemu arguments with qemuargs template option...
2021/03/19 03:28:27 packer-builder-qemu plugin: Executing /usr/bin/qemu-system-x86_64: []string{"-boot", "c", "-name", "ubuntu-layer2", "-m", "512", "-display", "none", "-machine", "accel=kvm", "-smp", "cpus=1", "-netdev", "user,hostfwd=tcp::3088-:22,id=forward", "-device", "virtio-net,netdev=forward,id=net0", "-cpu", "host", "-vnc", "127.0.0.1:13", "-drive", "file=output-ubuntu-layer2/ubuntu-layer2,if=virtio,cache=writeback,discard=ignore,format=qcow2", "-drive", "file=output-ubuntu-layer2/ubuntu-layer2,if=virtio,cache=writeback,discard=ignore,format=qcow2"}
2021/03/19 03:28:27 packer-builder-qemu plugin: Started Qemu. Pid: 35502
2021/03/19 03:28:27 packer-builder-qemu plugin: Qemu stderr: qemu-system-x86_64: -drive file=output-ubuntu-layer2/ubuntu-layer2,if=virtio,cache=writeback,discard=ignore,format=qcow2: Failed to get "write" lock
2021/03/19 03:28:27 packer-builder-qemu plugin: Qemu stderr: Is another process using the image [output-ubuntu-layer2/ubuntu-layer2]?
2021/03/19 03:28:27 packer-builder-qemu plugin: failed to unlock port lockfile: close tcp 127.0.0.1:5913: use of closed network connection
2021/03/19 03:28:27 packer-builder-qemu plugin: failed to unlock port lockfile: close tcp 127.0.0.1:3088: use of closed network connection
I don’t understand why this is happening, but I assume it has something to do with networking?
Thanks for a quick response. This has been a very stressful 2 days.