packer-plugin-virtualbox icon indicating copy to clipboard operation
packer-plugin-virtualbox copied to clipboard

Support .vhd file

Open remi-espie opened this issue 11 months ago • 2 comments

This PR adds support for .vhd files.

Before this PR, when using a .vhd as the iso_url (as stated possible in the documentation), VirtualBox returns the error Error attaching ISO: VBoxManage error: VBoxManage.exe: error: The medium '<path/to/vhd>' can't be used as the requested device type (DVD, detected HDD).

This solves the issue by checking the extension of the file and, if it is .vhd, by changing the disk type from dvddrive to hdd in the VirtualBox' VM creation command. If using a hdd type disk, it will not be unmounted before export. It also removes the creation of a .vdi disk if using a .vhd.

However, by using directly the .vhd file, it is modified and won't remain the same after running packer. An improvement would be to clone the .vhd file to the temp directory, as (for example) the Hyper-V plugin do.

This closes #123

remi-espie avatar Mar 06 '24 14:03 remi-espie

CLA assistant check
All committers have signed the CLA.

hashicorp-cla-app[bot] avatar Jun 24 '24 14:06 hashicorp-cla-app[bot]

With the latest commit, the source .vhd file is copied to a temporary directory randomly named with your tmp.Dir function, and the job is done on this copy.

The copy takes place during the attach_isos step of the common builder. I thought it made sense to put it here as it is where the file extension is also checked, and it made the modifications minimal.

As always, thanks for your review !

remi-espie avatar Jun 24 '24 14:06 remi-espie