Skip to content

fix: align controller names for VBoxManage#178

Open
taraxacum45e9a wants to merge 1 commit into
hashicorp:mainfrom
taraxacum45e9a:fix/storagectl
Open

fix: align controller names for VBoxManage#178
taraxacum45e9a wants to merge 1 commit into
hashicorp:mainfrom
taraxacum45e9a:fix/storagectl

Conversation

@taraxacum45e9a
Copy link
Copy Markdown
Contributor

Description

This pull request updates the storage controller naming conventions within the VirtualBox plugin to align with the specific strings expected by VBoxManage.

Specifically, this change:

  • Replace "IDE Controller" with "IDE"
  • Replace "SATA Controller" with "SATA"
  • Replace "SCSI Controller" with "SCSI"
  • Replace "Floppy Controller" with "Floppy"
  • Replace "NVMe Controller" with "NVMe"
  • Replace "VirtIO Controller" with "VirtioSCSI"

Resolved Issues

Closes #56
Closes #108

Changes to Security Controls

No changes to security controls are included in this PR.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request updates the VirtualBox builder’s hardcoded storage controller names to match the controller names commonly present in imported OVF/OVA images (e.g., Ubuntu cloud images), preventing VBoxManage storageattach from failing due to mismatched controller names.

Changes:

  • Renames storage controllers used by the ISO builder disk-creation step (IDE/SATA/SCSI/NVMe/VirtIO).
  • Updates ISO-attachment logic to use the new controller names.
  • Updates device-removal logic and tests to reflect the new floppy/ISO controller names.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
builder/virtualbox/iso/step_create_disk.go Renames created controller names (IDE/SATA/SCSI/NVMe/VirtIO) and adjusts disk attach to match.
builder/virtualbox/common/step_remove_devices.go Uses updated floppy controller name when detaching/removing.
builder/virtualbox/common/step_remove_devices_test.go Updates assertions/fixtures to expect the new controller names.
builder/virtualbox/common/step_attach_isos.go Updates controller names used for attaching boot/cd_files/guest additions ISOs.
builder/virtualbox/common/step_attach_floppy.go Uses updated floppy controller name when creating/attaching/cleaning up.
Comments suppressed due to low confidence (1)

builder/virtualbox/common/step_attach_isos.go:122

  • Hardcoding the controller name to "IDE"/"SATA"/"VirtioSCSI" can still fail for imported OVFs/VMs that use the previous/default VirtualBox controller names (e.g. "IDE Controller", "SATA Controller", or "VirtIO Controller"). Since this step is shared by the OVF builder, a regression here can reintroduce the same attach failure for other images. Consider retrying the storageattach with legacy controller names when the first attempt fails, and make sure the chosen controller name is also used for the corresponding unmount command.
				controllerName = "VirtioSCSI"
				port = 15
				device = 0
			}
			ui.Message("Mounting cd_files ISO...")

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@anurag5sh
Copy link
Copy Markdown
Collaborator

Hi @taraxacum45e9a , Thanks for looking into this!
It seems to me that this can introduce breaking changes to existing templates that use the current names. While I'm not entirely sure I understand the impact of these changes, would you like to pitch in to determine the impact for the users?

Update storage controller naming to match the strings used by VBoxManage. The previous names included a redundant "Controller" suffix, and "VirtIO Controller" has been corrected to "VirtioSCSI" to align with VirtualBox device identification.

* Replace "IDE Controller" with "IDE"
* Replace "SATA Controller" with "SATA"
* Replace "SCSI Controller" with "SCSI"
* Replace "Floppy Controller" with "Floppy"
* Replace "NVMe Controller" with "NVMe"
* Replace "VirtIO Controller" with "VirtioSCSI"

Fixes: hashicorp#56
Fixes: hashicorp#108

Signed-off-by: Shen Jiamin <shen_jiamin@comp.nus.edu.sg>
@taraxacum45e9a
Copy link
Copy Markdown
Contributor Author

Hi @anurag5sh

Thanks for looking into this

For virtualbox-ovf users: When VirtualBox imports an OVF, it automatically normalizes and renames the storage controllers to "IDE" (and similar short forms), regardless of whether it was "IDE Controller" defined in the OVF. Because Packer was looking for the longer name, the virtualbox-ovf builder is currently broken without this patch. This patch is a critical fix for them.

For virtualbox-iso users: This patch does not change any user-facing identifiers in the Packer templates. Setting hard_drive_interface = "ide" remains perfectly valid and unchanged. The only difference is that the internal controller created in the background will now be named "IDE" instead of "IDE Controller". Because this is an internal abstraction, it won't affect or break existing user templates. The only edge case where a user might notice this is if they have custom, raw vboxmanage post-processor scripts that explicitly hardcoded the old "Controller" string names.

I don't have any experience on virtualbox-vm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants