Commit 30be4927 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/virtualbox: use proper SATA port arg [GH-547]

parent 273e161b
...@@ -19,8 +19,10 @@ BUG FIXES: ...@@ -19,8 +19,10 @@ BUG FIXES:
* builder/virtualbox: detect if vboxdrv isn't properly setup. [GH-488] * builder/virtualbox: detect if vboxdrv isn't properly setup. [GH-488]
* builder/virtualbox: sleep a bit before export to ensure the sesssion * builder/virtualbox: sleep a bit before export to ensure the sesssion
is unlocked. [GH-512] is unlocked. [GH-512]
* builder/virtualbox: create SATA drives properly on VirtualBox 4.3 [GH-547]
* communicator/ssh: Fix issue where a panic could arise from a nil * communicator/ssh: Fix issue where a panic could arise from a nil
dereference. [GH-525] dereference. [GH-525]
* post-processor/vagrant: Fix issue with VirtualBox OVA. [GH-548]
* provisioner/shell: Won't block on certain scripts on Windows anymore. * provisioner/shell: Won't block on certain scripts on Windows anymore.
[GH-507] [GH-507]
......
...@@ -11,8 +11,15 @@ import ( ...@@ -11,8 +11,15 @@ import (
) )
// A driver is able to talk to VirtualBox and perform certain // A driver is able to talk to VirtualBox and perform certain
// operations with it. // operations with it. Some of the operations on here may seem overly
// specific, but they were built specifically in mind to handle features
// of the VirtualBox builder for Packer, and to abstract differences in
// versions out of the builder steps, so sometimes the methods are
// extremely specific.
type Driver interface { type Driver interface {
// Create a SATA controller.
CreateSATAController(vm string, controller string) error
// Checks if the VM with the given name is running. // Checks if the VM with the given name is running.
IsRunning(string) (bool, error) IsRunning(string) (bool, error)
...@@ -40,6 +47,27 @@ type VBox42Driver struct { ...@@ -40,6 +47,27 @@ type VBox42Driver struct {
VBoxManagePath string VBoxManagePath string
} }
func (d *VBox42Driver) CreateSATAController(vmName string, name string) error {
version, err := d.Version()
if err != nil {
return err
}
portCountArg := "sataportcount"
if strings.HasPrefix(version, "4.3") {
portCountArg = "portcount"
}
command := []string{
"storagectl", vmName,
"--name", name,
"--add", "sata",
portCountArg, "1",
}
return d.VBoxManage(command...)
}
func (d *VBox42Driver) IsRunning(name string) (bool, error) { func (d *VBox42Driver) IsRunning(name string) (bool, error) {
var stdout bytes.Buffer var stdout bytes.Buffer
......
...@@ -56,13 +56,7 @@ func (s *stepCreateDisk) Run(state multistep.StateBag) multistep.StepAction { ...@@ -56,13 +56,7 @@ func (s *stepCreateDisk) Run(state multistep.StateBag) multistep.StepAction {
// that. // that.
if config.HardDriveInterface == "sata" { if config.HardDriveInterface == "sata" {
controllerName = "SATA Controller" controllerName = "SATA Controller"
command = []string{ if err := driver.CreateSATAController(vmName, controllerName); err != nil {
"storagectl", vmName,
"--name", controllerName,
"--add", "sata",
"--sataportcount", "1",
}
if err := driver.VBoxManage(command...); err != nil {
err := fmt.Errorf("Error creating disk controller: %s", err) err := fmt.Errorf("Error creating disk controller: %s", err)
state.Put("error", err) state.Put("error", err)
ui.Error(err.Error()) ui.Error(err.Error())
......
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