From f27ea933a45f815f3b1fbdc3e85887ef9b85e1fa Mon Sep 17 00:00:00 2001 From: Steven Merrill Date: Tue, 2 Jul 2013 00:13:24 -0400 Subject: [PATCH] Add VirtualBox headless mode. --- builder/virtualbox/builder.go | 1 + builder/virtualbox/step_run.go | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/builder/virtualbox/builder.go b/builder/virtualbox/builder.go index 5d1f9bcce..47df9e54b 100644 --- a/builder/virtualbox/builder.go +++ b/builder/virtualbox/builder.go @@ -30,6 +30,7 @@ type config struct { DiskSize uint `mapstructure:"disk_size"` GuestAdditionsPath string `mapstructure:"guest_additions_path"` GuestOSType string `mapstructure:"guest_os_type"` + Headless bool `mapstructure:"headless"` HTTPDir string `mapstructure:"http_directory"` HTTPPortMin uint `mapstructure:"http_port_min"` HTTPPortMax uint `mapstructure:"http_port_max"` diff --git a/builder/virtualbox/step_run.go b/builder/virtualbox/step_run.go index deb88863a..128be2fe1 100644 --- a/builder/virtualbox/step_run.go +++ b/builder/virtualbox/step_run.go @@ -23,7 +23,11 @@ func (s *stepRun) Run(state map[string]interface{}) multistep.StepAction { vmName := state["vmName"].(string) ui.Say("Starting the virtual machine...") - command := []string{"startvm", vmName, "--type", "gui"} + guiArgument := "gui" + if config.Headless == true { + guiArgument = "headless" + } + command := []string{"startvm", vmName, "--type", guiArgument} if err := driver.VBoxManage(command...); err != nil { err := fmt.Errorf("Error starting VM: %s", err) state["error"] = err