Commit f087489e authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

Merge pull request #391 from jbronn/hard_drive_interface

builder/virtualbox: Add `hard_drive_interface` option
parents 1df07357 96caaa06
...@@ -33,6 +33,7 @@ type config struct { ...@@ -33,6 +33,7 @@ type config struct {
GuestAdditionsSHA256 string `mapstructure:"guest_additions_sha256"` GuestAdditionsSHA256 string `mapstructure:"guest_additions_sha256"`
GuestOSType string `mapstructure:"guest_os_type"` GuestOSType string `mapstructure:"guest_os_type"`
Headless bool `mapstructure:"headless"` Headless bool `mapstructure:"headless"`
HardDriveInterface string `mapstructure:"hard_drive_interface"`
HTTPDir string `mapstructure:"http_directory"` HTTPDir string `mapstructure:"http_directory"`
HTTPPortMin uint `mapstructure:"http_port_min"` HTTPPortMin uint `mapstructure:"http_port_min"`
HTTPPortMax uint `mapstructure:"http_port_max"` HTTPPortMax uint `mapstructure:"http_port_max"`
...@@ -89,6 +90,10 @@ func (b *Builder) Prepare(raws ...interface{}) error { ...@@ -89,6 +90,10 @@ func (b *Builder) Prepare(raws ...interface{}) error {
b.config.GuestAdditionsPath = "VBoxGuestAdditions.iso" b.config.GuestAdditionsPath = "VBoxGuestAdditions.iso"
} }
if b.config.HardDriveInterface == "" {
b.config.HardDriveInterface = "ide"
}
if b.config.GuestOSType == "" { if b.config.GuestOSType == "" {
b.config.GuestOSType = "Other" b.config.GuestOSType = "Other"
} }
......
...@@ -39,7 +39,9 @@ func (s *stepCreateDisk) Run(state multistep.StateBag) multistep.StepAction { ...@@ -39,7 +39,9 @@ func (s *stepCreateDisk) Run(state multistep.StateBag) multistep.StepAction {
return multistep.ActionHalt return multistep.ActionHalt
} }
// Add the IDE controller so we can later attach the disk // Add the IDE controller so we can later attach the disk.
// When the hard disk controller is not IDE, this device is still used
// by VirtualBox to deliver the guest extensions.
controllerName := "IDE Controller" controllerName := "IDE Controller"
err = driver.VBoxManage("storagectl", vmName, "--name", controllerName, "--add", "ide") err = driver.VBoxManage("storagectl", vmName, "--name", controllerName, "--add", "ide")
if err != nil { if err != nil {
...@@ -49,6 +51,22 @@ func (s *stepCreateDisk) Run(state multistep.StateBag) multistep.StepAction { ...@@ -49,6 +51,22 @@ func (s *stepCreateDisk) Run(state multistep.StateBag) multistep.StepAction {
return multistep.ActionHalt return multistep.ActionHalt
} }
if config.HardDriveInterface == "sata" {
controllerName = "SATA Controller"
command = []string{
"storagectl", vmName,
"--name", controllerName,
"--add", "sata",
"--sataportcount", "1",
}
if err := driver.VBoxManage(command...); err != nil {
err := fmt.Errorf("Error creating disk controller: %s", err)
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt
}
}
// Attach the disk to the controller // Attach the disk to the controller
command = []string{ command = []string{
"storageattach", vmName, "storageattach", vmName,
......
...@@ -108,6 +108,10 @@ Optional: ...@@ -108,6 +108,10 @@ Optional:
how to optimize the virtual hardware to work best with that operating how to optimize the virtual hardware to work best with that operating
system. system.
* `hard_drive_interface` (string) - The type of controller that the primary
hard drive is attached to, defaults to "ide". When set to "sata", the
drive is attached to an AHCI SATA controller.
* `headless` (bool) - Packer defaults to building VirtualBox * `headless` (bool) - Packer defaults to building VirtualBox
virtual machines by launching a GUI that shows the console of the virtual machines by launching a GUI that shows the console of the
machine being built. When this value is set to true, the machine will machine being built. When this value is set to true, the machine will
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment