Skip to content

Commit eae4576

Browse files
authored
Merge pull request #178 from taraxacum45e9a/fix/storagectl
fix: align controller names for VBoxManage
2 parents 7eee773 + 04a615a commit eae4576

5 files changed

Lines changed: 30 additions & 30 deletions

File tree

builder/virtualbox/common/step_attach_floppy.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (s *StepAttachFloppy) Run(ctx context.Context, state multistep.StateBag) mu
6363
// Create the floppy disk controller
6464
command := []string{
6565
"storagectl", vmName,
66-
"--name", "Floppy Controller",
66+
"--name", "Floppy",
6767
"--add", "floppy",
6868
}
6969
if err := driver.VBoxManage(command...); err != nil {
@@ -74,7 +74,7 @@ func (s *StepAttachFloppy) Run(ctx context.Context, state multistep.StateBag) mu
7474
// Attach the floppy to the controller
7575
command = []string{
7676
"storageattach", vmName,
77-
"--storagectl", "Floppy Controller",
77+
"--storagectl", "Floppy",
7878
"--port", "0",
7979
"--device", "0",
8080
"--type", "fdd",
@@ -106,7 +106,7 @@ func (s *StepAttachFloppy) Cleanup(state multistep.StateBag) {
106106

107107
command := []string{
108108
"storageattach", vmName,
109-
"--storagectl", "Floppy Controller",
109+
"--storagectl", "Floppy",
110110
"--port", "0",
111111
"--device", "0",
112112
"--medium", "none",

builder/virtualbox/common/step_attach_isos.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,43 +79,43 @@ func (s *StepAttachISOs) Run(ctx context.Context, state multistep.StateBag) mult
7979
switch diskCategory {
8080
case "boot_iso":
8181
// figure out controller path
82-
controllerName = "IDE Controller"
82+
controllerName = "IDE"
8383
port = 0
8484
device = 1
8585
if s.ISOInterface == "sata" {
86-
controllerName = "SATA Controller"
86+
controllerName = "SATA"
8787
port = 13
8888
device = 0
8989
} else if s.ISOInterface == "virtio" {
90-
controllerName = "VirtIO Controller"
90+
controllerName = "VirtioSCSI"
9191
port = 13
9292
device = 0
9393
}
9494
ui.Message("Mounting boot ISO...")
9595
case "guest_additions":
96-
controllerName = "IDE Controller"
96+
controllerName = "IDE"
9797
port = 1
9898
device = 0
9999
if s.GuestAdditionsInterface == "sata" {
100-
controllerName = "SATA Controller"
100+
controllerName = "SATA"
101101
port = 14
102102
device = 0
103103
} else if s.GuestAdditionsInterface == "virtio" {
104-
controllerName = "VirtIO Controller"
104+
controllerName = "VirtioSCSI"
105105
port = 14
106106
device = 0
107107
}
108108
ui.Message("Mounting guest additions ISO...")
109109
case "cd_files":
110-
controllerName = "IDE Controller"
110+
controllerName = "IDE"
111111
port = 1
112112
device = 1
113113
if s.ISOInterface == "sata" {
114-
controllerName = "SATA Controller"
114+
controllerName = "SATA"
115115
port = 15
116116
device = 0
117117
} else if s.ISOInterface == "virtio" {
118-
controllerName = "VirtIO Controller"
118+
controllerName = "VirtioSCSI"
119119
port = 15
120120
device = 0
121121
}

builder/virtualbox/common/step_remove_devices.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (s *StepRemoveDevices) Run(ctx context.Context, state multistep.StateBag) m
3838
ui.Message("Removing floppy drive...")
3939
command := []string{
4040
"storageattach", vmName,
41-
"--storagectl", "Floppy Controller",
41+
"--storagectl", "Floppy",
4242
"--port", "0",
4343
"--device", "0",
4444
"--medium", "none",
@@ -59,7 +59,7 @@ func (s *StepRemoveDevices) Run(ctx context.Context, state multistep.StateBag) m
5959
// Don't forget to remove the floppy controller as well
6060
command = []string{
6161
"storagectl", vmName,
62-
"--name", "Floppy Controller",
62+
"--name", "Floppy",
6363
"--remove",
6464
}
6565
err := driver.VBoxManage(command...)

builder/virtualbox/common/step_remove_devices_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestStepRemoveDevices_attachedIso(t *testing.T) {
4343
diskUnmountCommands := map[string][]string{
4444
"boot_iso": []string{
4545
"storageattach", "myvm",
46-
"--storagectl", "IDE Controller",
46+
"--storagectl", "IDE",
4747
"--port", "0",
4848
"--device", "1",
4949
"--type", "dvddrive",
@@ -67,7 +67,7 @@ func TestStepRemoveDevices_attachedIso(t *testing.T) {
6767
if len(driver.VBoxManageCalls) != 1 {
6868
t.Fatalf("bad: %#v", driver.VBoxManageCalls)
6969
}
70-
if driver.VBoxManageCalls[0][3] != "IDE Controller" {
70+
if driver.VBoxManageCalls[0][3] != "IDE" {
7171
t.Fatalf("bad: %#v", driver.VBoxManageCalls)
7272
}
7373
}
@@ -79,7 +79,7 @@ func TestStepRemoveDevices_attachedIsoOnSata(t *testing.T) {
7979
diskUnmountCommands := map[string][]string{
8080
"boot_iso": []string{
8181
"storageattach", "myvm",
82-
"--storagectl", "SATA Controller",
82+
"--storagectl", "SATA",
8383
"--port", "0",
8484
"--device", "1",
8585
"--type", "dvddrive",
@@ -103,7 +103,7 @@ func TestStepRemoveDevices_attachedIsoOnSata(t *testing.T) {
103103
if len(driver.VBoxManageCalls) != 1 {
104104
t.Fatalf("bad: %#v", driver.VBoxManageCalls)
105105
}
106-
if driver.VBoxManageCalls[0][3] != "SATA Controller" {
106+
if driver.VBoxManageCalls[0][3] != "SATA" {
107107
t.Fatalf("bad: %#v", driver.VBoxManageCalls)
108108
}
109109
}
@@ -129,10 +129,10 @@ func TestStepRemoveDevices_floppyPath(t *testing.T) {
129129
if len(driver.VBoxManageCalls) != 2 {
130130
t.Fatalf("bad: %#v", driver.VBoxManageCalls)
131131
}
132-
if driver.VBoxManageCalls[0][3] != "Floppy Controller" {
132+
if driver.VBoxManageCalls[0][3] != "Floppy" {
133133
t.Fatalf("bad: %#v", driver.VBoxManageCalls)
134134
}
135-
if driver.VBoxManageCalls[1][3] != "Floppy Controller" {
135+
if driver.VBoxManageCalls[1][3] != "Floppy" {
136136
t.Fatalf("bad: %#v", driver.VBoxManageCalls)
137137
}
138138
}

builder/virtualbox/iso/step_create_disk.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (s *stepCreateDisk) Run(ctx context.Context, state multistep.StateBag) mult
6868
// Add the IDE controller so we can later attach the disk.
6969
// When the hard disk controller is not IDE, this device is still used
7070
// by VirtualBox to deliver the guest extensions.
71-
err := driver.VBoxManage("storagectl", vmName, "--name", "IDE Controller", "--add", "ide")
71+
err := driver.VBoxManage("storagectl", vmName, "--name", "IDE", "--add", "ide")
7272
if err != nil {
7373
err := fmt.Errorf("Error creating disk controller: %s", err)
7474
state.Put("error", err)
@@ -80,7 +80,7 @@ func (s *stepCreateDisk) Run(ctx context.Context, state multistep.StateBag) mult
8080
// the IDE controller above because some other things (disks) require
8181
// that.
8282
if config.HardDriveInterface == "sata" || config.ISOInterface == "sata" {
83-
if err := driver.CreateSATAController(vmName, "SATA Controller", config.SATAPortCount); err != nil {
83+
if err := driver.CreateSATAController(vmName, "SATA", config.SATAPortCount); err != nil {
8484
err := fmt.Errorf("Error creating disk controller: %s", err)
8585
state.Put("error", err)
8686
ui.Error(err.Error())
@@ -92,7 +92,7 @@ func (s *stepCreateDisk) Run(ctx context.Context, state multistep.StateBag) mult
9292
// the VirtIO controller above because some other things (disks) require
9393
// that.
9494
if config.HardDriveInterface == "virtio" || config.ISOInterface == "virtio" {
95-
if err := driver.CreateVirtIOController(vmName, "VirtIO Controller"); err != nil {
95+
if err := driver.CreateVirtIOController(vmName, "VirtioSCSI"); err != nil {
9696
err := fmt.Errorf("Error creating disk controller: %s", err)
9797
state.Put("error", err)
9898
ui.Error(err.Error())
@@ -101,14 +101,14 @@ func (s *stepCreateDisk) Run(ctx context.Context, state multistep.StateBag) mult
101101
}
102102

103103
if config.HardDriveInterface == "scsi" {
104-
if err := driver.CreateSCSIController(vmName, "SCSI Controller"); err != nil {
104+
if err := driver.CreateSCSIController(vmName, "SCSI"); err != nil {
105105
err := fmt.Errorf("Error creating disk controller: %s", err)
106106
state.Put("error", err)
107107
ui.Error(err.Error())
108108
return multistep.ActionHalt
109109
}
110110
} else if config.HardDriveInterface == "pcie" {
111-
if err := driver.CreateNVMeController(vmName, "NVMe Controller", config.NVMePortCount); err != nil {
111+
if err := driver.CreateNVMeController(vmName, "NVMe", config.NVMePortCount); err != nil {
112112
err := fmt.Errorf("Error creating NVMe controller: %s", err)
113113
state.Put("error", err)
114114
ui.Error(err.Error())
@@ -117,15 +117,15 @@ func (s *stepCreateDisk) Run(ctx context.Context, state multistep.StateBag) mult
117117
}
118118

119119
// Attach the disk to the controller
120-
controllerName := "IDE Controller"
120+
controllerName := "IDE"
121121
if config.HardDriveInterface == "sata" {
122-
controllerName = "SATA Controller"
122+
controllerName = "SATA"
123123
} else if config.HardDriveInterface == "scsi" {
124-
controllerName = "SCSI Controller"
124+
controllerName = "SCSI"
125125
} else if config.HardDriveInterface == "virtio" {
126-
controllerName = "VirtIO Controller"
126+
controllerName = "VirtioSCSI"
127127
} else if config.HardDriveInterface == "pcie" {
128-
controllerName = "NVMe Controller"
128+
controllerName = "NVMe"
129129
}
130130

131131
nonrotational := "off"

0 commit comments

Comments
 (0)