hashicorp / packer-plugin-qemu

Packer plugin for QEMU Builder
https://www.packer.io/docs/builders/qemu
Mozilla Public License 2.0
65 stars 46 forks source link

Qemu stderr: gtk initialization failed #183

Open mikoday opened 1 month ago

mikoday commented 1 month ago

When filing a bug, please include the following headings if possible. Any example text in this template can be deleted.

Overview of the Issue

I'm trying to prepare a Windows image to use on maas, I also described my issue here: https://github.com/canonical/packer-maas/issues/272

Reproduction Steps

/home/maas/packer-maas/windows# make windows ISO=/home/maas/en-us_windows_11_business_editions_version_24h2_x64.iso VERSION=11 windows.json PACKER_LOG=1

Plugin and Packer version

v1.1.0

Simplified Packer Buildfile

If the file is longer than a few dozen lines, please include the URL to the gist of the log or use the Github detailed format instead of posting it directly in the issue.

Operating system and Environment details

OS, Architecture, and any other information you can provide about the environment.

Log Fragments and crash.log files

2024/10/28 15:49:37 packer-plugin-qemu_v1.1.0_x5.0_linux_amd64 plugin: 2024/10/28 15:49:37 Started Qemu. Pid: 2153
2024/10/28 15:49:37 packer-plugin-qemu_v1.1.0_x5.0_linux_amd64 plugin: 2024/10/28 15:49:37 Qemu stderr: WARNING: Image format was not specified for '/tmp/packer65686085' and probing guessed raw.
2024/10/28 15:49:37 packer-plugin-qemu_v1.1.0_x5.0_linux_amd64 plugin: 2024/10/28 15:49:37 Qemu stderr:          Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
2024/10/28 15:49:37 packer-plugin-qemu_v1.1.0_x5.0_linux_amd64 plugin: 2024/10/28 15:49:37 Qemu stderr:          Specify the 'raw' format explicitly to remove the restrictions.
2024/10/28 15:49:37 packer-plugin-qemu_v1.1.0_x5.0_linux_amd64 plugin: 2024/10/28 15:49:37 Qemu stderr: gtk initialization failed

Set the env var PACKER_LOG=1 for maximum log detail.

lbajolet-hashicorp commented 3 weeks ago

Hi @mikoday,

By default the display option is set to GTK for the plugin, so if you're trying to run a build on a Windows machine, chances are it'll fail.

You can change that by setting the display option to none, which will default to what the local binary supports.

We can probably change the default value to be none for future releases, but I'm concerned this is a potential breaking change for existing templates, so this will likely not happen soon. In the meantime I suggest changing this to none, or one of the other supported values, which you can get from the help for qemu: qemu --help | grep display should list the possibilities for your implementation.

Also if you don't need to run the build with a visual window for qemu, you can run headless (with headless = true in the configs) and use VNC to connect to the machine independently, the logs give you a URI/port for that purpose.