Virtualbox is locked when I try to destroy a kitchen instance
Asked Answered
V

2

8

I ran a test-kitchen instance and all was fine, but at the end when I did try to destroy it kitchen with:

roberto@pc:~$ kitchen destroy

Virtualbox gave me this error.

-----> Starting Kitchen (v1.1.1)
-----> Destroying <default-ubuntu-1204>...
       [default] Destroying VM and associated drives...
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: Failed to complete #destroy action: [Expected process to exit with [0], but received '1'
---- Begin output of vagrant destroy -f ----
STDOUT: [default] Destroying VM and associated drives...
STDERR: There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["unregistervm", "2507bc77-3734-429b-a573-d92fadb80e95", "--delete"]

Stderr: VBoxManage: error: Cannot unregister the machine 'default-ubuntu-1204_default_1391521776' while it is locked
VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component Machine, interface IMachine, callee nsISupports
VBoxManage: error: Context: "Unregister(CleanupMode_DetachAllReturnHardDisksOnly, ComSafeArrayAsOutParam(aMedia))" at line 158 of file VBoxManageMisc.cpp
---- End output of vagrant destroy -f ----
Ran vagrant destroy -f returned 1]
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details

I ran Virtualbox and I can not removed the instance because it also was locked and the close option was disable.

Anyone else with this problem?

Votyak answered 6/2, 2014 at 15:9 Comment(1)
Possible duplicate of A VirtualBox machine with the name 'homestead' already existsChoral
V
1

There are two things that can cause this issue. Please ensure:

  1. You restart your computer after installing/updating VirtualBox
  2. Please make sure you manually open VirtualBox at least once before using the driver

If the machine appears in the list of Virtual Machines in the VBox GUI, try the command again. If they are not listed in the VirtualBox GUI, remove the .kitchen directory and try again.

Virginiavirginie answered 8/2, 2014 at 19:15 Comment(1)
The following commands the trick for me : 1. VBoxManage startvm VMNAME/id --type emergencystop 2. VBoxManage unregistervm VMNAME --deleteProvidence
C
5

VBoxManage: error: Cannot unregister the machine 'X' while it is locked.

It's locked, because it's in use, so basically you need to shut it down, e.g.

VBoxManage controlvm VMNAME poweroff

Change VMNAME to your machine name, e.g. default-ubuntu-1204_default_1391521776.

Then you can unregister via:

VBoxManage unregistervm VMNAME --delete

Specifying --delete will delete your VM. If you don't want to delete it, you can make a backup from ~/"VirtualBox VMs/VMNAME.

Choral answered 17/3, 2016 at 15:19 Comment(1)
If you put this into a shell script, you need to add a slight delay between the 'poweroff' and the 'unregistervm' command....if you don't, the unregister will still fail with a 'locked' error. I add a sleep 2 between the two commands and it works fine.Margarine
V
1

There are two things that can cause this issue. Please ensure:

  1. You restart your computer after installing/updating VirtualBox
  2. Please make sure you manually open VirtualBox at least once before using the driver

If the machine appears in the list of Virtual Machines in the VBox GUI, try the command again. If they are not listed in the VirtualBox GUI, remove the .kitchen directory and try again.

Virginiavirginie answered 8/2, 2014 at 19:15 Comment(1)
The following commands the trick for me : 1. VBoxManage startvm VMNAME/id --type emergencystop 2. VBoxManage unregistervm VMNAME --deleteProvidence

© 2022 - 2024 — McMap. All rights reserved.