Vagrant資料一覧

vagrant destroyが「Cannot unregister the machine 'xxx' while it is locked」というメッセージを出して失敗する

2010/10/15更新

対応バージョン: 1.4.3

vagrant destroyコマンドにて仮想マシンを削除しようとすると以下のようなメッセージを出して失敗する。

% vagrant destroy s2
Are you sure you want to destroy the 's2' VM? [y/N] y
[s2] Destroying VM and associated drives...

There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["unregistervm", "6080f160-8732-4316-b18b-e2e2a96c9afc", "--delete"]

Stderr: VBoxManage: error: Cannot unregister the machine 'ha_s2_1413207998391_70783' 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

このような場合、ホストOS上でVBoxHeadlessをkillしてから改めてvagrant destroyを実行すればよい。

% VBoxManage list vms
:
"ha_s2_1413207998391_70783" {6080f160-8732-4316-b18b-e2e2a96c9afc}

% ps -ef | grep -i vboxheadless | grep ha_s2_1413207998391_70783
foo 16694 13380  4 22:46 ?        00:01:09 /usr/lib/virtualbox/VBoxHeadless --comment ha_s2_1413207998391_70783 --startvm 6080f160-8732-4316-b18b-e2e2a96c9afc --vrde config

% kill 16694

% vagrant destroy s2
Are you sure you want to destroy the 's2' VM? [y/N] y
[s2] Forcing shutdown of VM...
[s2] Destroying VM and associated drives...
[s2] Running cleanup tasks for 'shell' provisioner...