-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support .vhd file #124
base: main
Are you sure you want to change the base?
Support .vhd file #124
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @remi-espie,
Thanks for the contribution, and apologies for taking so long to review!
The idea makes sense, however before we can consider merging it I would suggest not making the changes in-place, and instead as you point out, clone the disk to another disk, and boot on it at that time. This becomes especially relevant as reusing input as the target makes options like output_directory
or output_filename
incompatible with that capability, so if we decide to NOT proceed with copying, we should add checks during the Prepare
step to make sure that no option gets ignored.
I believe this copy could be done even as a separate builder potentially? I feel like calling the builder ISO
and clone a disk may prove slightly confusing, but I can imagine that being a possibility though, especially considering the iso_url
docs do mention VHDs.
Thanks again, please let me know your thoughts and feel free to ping me when you're ready for another round of review, I'll take another look then!
"--medium", diskFullPaths[i], | ||
"--nonrotational", nonrotational, | ||
"--discard", discard, | ||
if path.Ext(state.Get("iso_path").(string)) != ".vhd" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like the condition could be reversed to limit the amount of changes here?
if path.Ext(state.Get("iso_path").(string)) != ".vhd" { | |
if path.Ext(state.Get("iso_path").(string)) == ".vhd" { | |
return multistep.ActionContinue | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, are we certain iso_path
is always set? I worry accessing this and casting it to a string
may crash the plugin if that's not the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @lbajolet-hashicorp ,
Per documentation and per code we are sure that the iso_url
is always set (in case of iso builder).
Btw, this is resolved in the following commits.
071c9d4
to
73d6cb8
Compare
With the latest commit, the source The copy takes place during the As always, thanks for your review ! |
500e71e
to
2c8ca45
Compare
This PR adds support for
.vhd
files.Before this PR, when using a
.vhd
as theiso_url
(as stated possible in the documentation), VirtualBox returns the errorError 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 fromdvddrive
tohdd
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