mitchellh/packer — pull request #1502 by JessThrysoee (2014-09-15 22:49:10+00:00)
Title: builder/parallels: Rely on Cleanup functions to detach devices

Remove the redundant StepRemoveDevices and rely on the cleanup to be handled by:
* StepAttachParallelsTools.Cleanup
* StepAttachFloppy.Cleanup
* stepAttachISO.Cleanup

---
This is mostly a speculative pull request, and I may be way off track with it :-)

I looked at this because `step_remove_devices` was trying to restore cdrom0 to a nonexisting real cdrom device and causing this error:
```
parallels-iso: The system is going down for power off NOW!
==> parallels-iso: Error detaching ISO: prlctl error: Unknown device: Default CD/DVD-ROM
==> parallels-iso: Failed to configure the virtual machine.
==> parallels-iso: Unregistering virtual machine...
==> parallels-iso: Deleting output directory...
Build 'parallels-iso' errored: Error detaching ISO: prlctl error: Unknown device: Default CD/DVD-ROM
Failed to configure the virtual machine.

==> Some builds didn't complete successfully and had errors:
--> parallels-iso: Error detaching ISO: prlctl error: Unknown device: Default CD/DVD-ROM
Failed to configure the virtual machine.
```

Don't know if this is a Parallels 10 bug, but I can't set the 'Default CD/DVD-ROM' device with prlctl (However I can set it successfully from the GUI?!?!):

```
$ prlctl list --info MY_VM | grep cdrom
Boot order: cdrom0 net0 net1 hdd0
cdrom0 (+) sata:1 real='Default CD/DVD-ROM'

$ prlctl set MY_VM --device-del cdrom0
Remove the cdrom0 device.

The VM has been successfully configured.

$ prlctl set MY_VM --device-add cdrom --device 'Default CD/DVD-ROM'
Unknown device: Default CD/DVD-ROM
Failed to configure the virtual machine.
```

I can set it if I use the explicit name of the device, but that isn't appropriate if I wish to share this box:
```
$ prlctl server info | grep cdrom
cdrom HL-DT-ST DVDRW GA32N 'IOService:/..'

$ prlctl set MY_VM --device-add cdrom --device 'HL-DT-ST DVDRW GA32N'
Creating cdrom1 (+) sata:2 real='HL-DT-ST DVDRW GA32N'

Created cdrom1 (+) sata:2 real='HL-DT-ST DVDRW GA32N'

The VM has been successfully configured.
```

Anyway, I discovered that `stepAttachISO.Cleanup` disconnects the device (maybe it should delete it?), which is probably the most reliable thing to do, because it becomes more and more likely that people are running on machines without any real optical devices.