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" +