Perryg wrote:I'm not going to argue about this and it appears your mind is made up, but I can tell you VirtualBox does not go out of its way to prevent any 3rd party program from working and if packer wanted to improve they would contact the developers to see why they have an issue with the API. It is outlined in the SDK and does change from time to time. Good luck and I hope you find a resolve but at this point I have nothing further to contribute.
Hi
I went through Packer's code and saw that it was simply making calls to VBoxManage and so after some brief experimentation, I've reproduced the issue using solely VBoxManage commands and no third party products.
You can refer to Virtualbox
ticket 16063 (sorry I can't paste a U R L to the ticket directly since I need to be a member of this forum for >1 day and have at least 1 post before I can post U R Ls) to see issue reproduction steps and output.
As closely as possible, I followed the order of VBoxManage commands Packer was executing and I was wondering whether there was some other VBoxManage command it (packer) should have executed either after or before detaching the DVD drive and
before running the VBoxManage modifyvm commands? i.e. is there something wrong with the following flow?
Code: Select all
#!/usr/bin/env bash
echo "INFO: Creating VM: test1"
./VBoxManage.exe createvm --name "test1" --ostype "RedHat_64" --register
echo "INFO: Adding a SATA controller to VM: test1"
./VBoxManage.exe storagectl "test1" --name "SATA Controller" --add "sata" --portcount 1
# test.iso = CentOS-6.7-x86_64-minimal.iso
echo "INFO: Attaching a DVD drive with a CentOS 6.x ISO to VM: test1"
./VBoxManage.exe storageattach "test1" --storagectl "SATA Controller" --port 1 --device 0 --type "dvddrive" --medium "./test.iso"
echo "INFO: Starting VM: test1"
./VBoxManage.exe startvm "test1" --type "gui"
echo "INFO: Waiting 10 seconds"
sleep 10s
echo "INFO: Powering off VM: test1"
./VBoxManage.exe controlvm "test1" "poweroff"
echo "INFO: Detaching the DVD drive from VM: test1"
./VBoxManage.exe storageattach "test1" --storagectl "SATA Controller" --port 1 --device 0 --medium "none"
# The following command will fail with the following error:
# VBoxManage.exe: error: The machine 'test1' is already locked for a session (or being unlocked)
# VBoxManage.exe: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component MachineWrap, interface IMachine, callee IUnknown
# VBoxManage.exe: error: Context: "LockMachine(a->session, LockType_Write)" at line 507 of file VBoxManageModifyVM.cpp
echo "INFO: Adjusting memory size of VM: test1"
./VBoxManage.exe modifyvm "test1" --memory "2048"
Output for running the above script:
Code: Select all
$ ./test1.sh
INFO: Creating VM: test1
Virtual machine 'test1' is created and registered.
UUID: 6bf55cf5-a752-49ca-9730-67e791e2fa96
Settings file: 'C:\apps\VirtualBox\Machines\test1\test1.vbox'
INFO: Adding a SATA controller to VM: test1
INFO: Attaching a DVD drive with a CentOS 6.x ISO to VM: test1
INFO: Starting VM: test1
Waiting for VM "test1" to power on...
VM "test1" has been successfully started.
INFO: Waiting 10 seconds
INFO: Powering off VM: test1
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
INFO: Detaching the DVD drive from VM: test1
INFO: Adjusting memory size of VM: test1
VBoxManage.exe: error: The machine 'test1' is already locked for a session (or being unlocked)
VBoxManage.exe: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component MachineWrap, interface IMachine, callee IUnknown
VBoxManage.exe: error: Context: "LockMachine(a->session, LockType_Write)" at line 507 of file VBoxManageModifyVM.cpp
Is it important to note that if I add a "sleep 10s" command just before the "VBoxManage.exe modifyvm" command then no errors occur. Also, I don't think it matters what iso is used in case you were trying to reproduce this locally.
Regards,
Jinesh