From 0339fcc4426f7fe108a5de555472c7b2c2ef2a8c Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Fri, 16 Dec 2016 17:33:33 -0800 Subject: [PATCH] builder/qemu: add use_default_display option If set, won't set `-display dsl` as a default argument. Useful for osx compatibility. --- builder/qemu/builder.go | 49 ++++++++++++----------- builder/qemu/step_run.go | 4 +- website/source/docs/builders/qemu.html.md | 4 ++ 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/builder/qemu/builder.go b/builder/qemu/builder.go index 26cdd90eb..b1439fc46 100644 --- a/builder/qemu/builder.go +++ b/builder/qemu/builder.go @@ -84,30 +84,31 @@ type Config struct { Comm communicator.Config `mapstructure:",squash"` common.FloppyConfig `mapstructure:",squash"` - ISOSkipCache bool `mapstructure:"iso_skip_cache"` - Accelerator string `mapstructure:"accelerator"` - BootCommand []string `mapstructure:"boot_command"` - DiskInterface string `mapstructure:"disk_interface"` - DiskSize uint `mapstructure:"disk_size"` - DiskCache string `mapstructure:"disk_cache"` - DiskDiscard string `mapstructure:"disk_discard"` - SkipCompaction bool `mapstructure:"skip_compaction"` - DiskCompression bool `mapstructure:"disk_compression"` - Format string `mapstructure:"format"` - Headless bool `mapstructure:"headless"` - DiskImage bool `mapstructure:"disk_image"` - MachineType string `mapstructure:"machine_type"` - NetDevice string `mapstructure:"net_device"` - OutputDir string `mapstructure:"output_directory"` - QemuArgs [][]string `mapstructure:"qemuargs"` - QemuBinary string `mapstructure:"qemu_binary"` - ShutdownCommand string `mapstructure:"shutdown_command"` - SSHHostPortMin uint `mapstructure:"ssh_host_port_min"` - SSHHostPortMax uint `mapstructure:"ssh_host_port_max"` - VNCBindAddress string `mapstructure:"vnc_bind_address"` - VNCPortMin uint `mapstructure:"vnc_port_min"` - VNCPortMax uint `mapstructure:"vnc_port_max"` - VMName string `mapstructure:"vm_name"` + ISOSkipCache bool `mapstructure:"iso_skip_cache"` + Accelerator string `mapstructure:"accelerator"` + BootCommand []string `mapstructure:"boot_command"` + DiskInterface string `mapstructure:"disk_interface"` + DiskSize uint `mapstructure:"disk_size"` + DiskCache string `mapstructure:"disk_cache"` + DiskDiscard string `mapstructure:"disk_discard"` + SkipCompaction bool `mapstructure:"skip_compaction"` + DiskCompression bool `mapstructure:"disk_compression"` + Format string `mapstructure:"format"` + Headless bool `mapstructure:"headless"` + DiskImage bool `mapstructure:"disk_image"` + MachineType string `mapstructure:"machine_type"` + NetDevice string `mapstructure:"net_device"` + OutputDir string `mapstructure:"output_directory"` + QemuArgs [][]string `mapstructure:"qemuargs"` + QemuBinary string `mapstructure:"qemu_binary"` + ShutdownCommand string `mapstructure:"shutdown_command"` + SSHHostPortMin uint `mapstructure:"ssh_host_port_min"` + SSHHostPortMax uint `mapstructure:"ssh_host_port_max"` + UseDefaultDisplay bool `mapstructure:"use_default_display"` + VNCBindAddress string `mapstructure:"vnc_bind_address"` + VNCPortMin uint `mapstructure:"vnc_port_min"` + VNCPortMax uint `mapstructure:"vnc_port_max"` + VMName string `mapstructure:"vm_name"` // These are deprecated, but we keep them around for BC // TODO(@mitchellh): remove diff --git a/builder/qemu/step_run.go b/builder/qemu/step_run.go index 3d1c37c66..4c05e79b9 100644 --- a/builder/qemu/step_run.go +++ b/builder/qemu/step_run.go @@ -124,7 +124,9 @@ func getCommandArgs(bootDrive string, state multistep.StateBag) ([]string, error } } else { if qemuMajor >= 2 { - defaultArgs["-display"] = "sdl" + if !config.UseDefaultDisplay { + defaultArgs["-display"] = "sdl" + } } else { ui.Message("WARNING: The version of qemu on your host doesn't support display mode.\n" + "The display parameter will be ignored.") diff --git a/website/source/docs/builders/qemu.html.md b/website/source/docs/builders/qemu.html.md index d1118c928..3c25564f8 100644 --- a/website/source/docs/builders/qemu.html.md +++ b/website/source/docs/builders/qemu.html.md @@ -236,6 +236,10 @@ Linux server and have not enabled X11 forwarding (`ssh -X`). switch/value pairs. Any value specified as an empty string is ignored. All values after the switch are concatenated with no separator. +- `use_default_display` (boolean) - If true, do not pass a `-display` option + to qemu, allowing it to choose the default. This may be needed when running + under OS X. + \~> **Warning:** The qemu command line allows extreme flexibility, so beware of conflicting arguments causing failures of your run. For instance, using --no-acpi could break the ability to send power signal type commands (e.g.,