Add display template option for QEMU. Fixes #7675

This commit is contained in:
Lee Trager 2019-10-02 13:56:05 -07:00
parent c505f1c45e
commit c7f38b232f
2 changed files with 10 additions and 2 deletions

View File

@ -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.

View File

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