diff --git a/builder/qemu/builder.go b/builder/qemu/builder.go index 461cea3a2..42d733792 100644 --- a/builder/qemu/builder.go +++ b/builder/qemu/builder.go @@ -299,6 +299,10 @@ type Config struct { // to qemu, allowing it to choose the default. This may be needed when running // under macOS, and getting errors about sdl not being available. UseDefaultDisplay bool `mapstructure:"use_default_display" required:"false"` + // What QEMU -display option to use. Defaults to gtk, use none to not pass the + // -display option allowing QEMU to choose the default. This may be needed when + // running under macOS, and getting errors about sdl not being available. + Display string `mapstructure:"display" required:"false"` // The IP address that should be // binded to for VNC. By default packer will use 127.0.0.1 for this. If you // wish to bind to all interfaces use 0.0.0.0. diff --git a/builder/qemu/step_run.go b/builder/qemu/step_run.go index 1a5001caf..e8c327f4a 100644 --- a/builder/qemu/step_run.go +++ b/builder/qemu/step_run.go @@ -170,8 +170,12 @@ func getCommandArgs(bootDrive string, state multistep.StateBag) ([]string, error } } else { if qemuVersion.GreaterThanOrEqual(v2) { - if !config.UseDefaultDisplay { - defaultArgs["-display"] = "sdl" + if len(config.Display) > 0 { + if config.Display != "none" { + defaultArgs["-display"] = config.Display + } + } else if !config.UseDefaultDisplay { + defaultArgs["-display"] = "gtk" } } else { ui.Message("WARNING: The version of qemu on your host doesn't support display mode.\n" + diff --git a/website/source/partials/builder/qemu/_Config-not-required.html.md b/website/source/partials/builder/qemu/_Config-not-required.html.md index 723c53276..b0b3922cc 100644 --- a/website/source/partials/builder/qemu/_Config-not-required.html.md +++ b/website/source/partials/builder/qemu/_Config-not-required.html.md @@ -199,6 +199,10 @@ to qemu, allowing it to choose the default. This may be needed when running under macOS, and getting errors about sdl not being available. +- `display` (string) - What QEMU -display option to use. Defaults to gtk, use none to not pass the + -display option allowing QEMU to choose the default. This may be needed when + running under macOS, and getting errors about sdl not being available. + - `vnc_bind_address` (string) - The IP address that should be binded to for VNC. By default packer will use 127.0.0.1 for this. If you wish to bind to all interfaces use 0.0.0.0.