From c7f38b232f95aad107f8f36843f31cec5fd7f270 Mon Sep 17 00:00:00 2001 From: Lee Trager Date: Wed, 2 Oct 2019 13:56:05 -0700 Subject: [PATCH 1/2] Add display template option for QEMU. Fixes #7675 --- builder/qemu/builder.go | 4 ++++ builder/qemu/step_run.go | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/builder/qemu/builder.go b/builder/qemu/builder.go index 10c821b7e..8044d5c48 100644 --- a/builder/qemu/builder.go +++ b/builder/qemu/builder.go @@ -298,6 +298,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" + From 63bc9e8a9a13109c4e5b91c2d24177ff0edbf438 Mon Sep 17 00:00:00 2001 From: Lee Trager Date: Wed, 2 Oct 2019 14:06:46 -0700 Subject: [PATCH 2/2] Run make generate --- .../source/partials/builder/qemu/_Config-not-required.html.md | 4 ++++ 1 file changed, 4 insertions(+) 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.