Opened 10 years ago
#14207 new defect
VBoxManage unregistervm --delete performs only a partial deletion if media file is locked by other process
Reported by: | sbarnden | Owned by: | |
---|---|---|---|
Component: | VM control | Version: | VirtualBox 4.3.28 |
Keywords: | vboxmanage unregister delete VBOX_E_INVALID_OBJECT_STATE VBOX_E_OBJECT_NOT_FOUND | Cc: | |
Guest type: | Linux | Host type: | Windows |
Description
Trying to produce an automatic provisioning script to build VM's on demand and encountering this issue when the machine get above a few GB in size.
Process calls the vboxmanage export command and then immediately calls the unregistervm --delete command to remove the VM leaving just the export file.
However if the VM is above a few GB in size the lock is not released on the media in time resulting in:
BoxManage.exe: error: Medium 'C:\Users\scobarn\VirtualBox VMs\My_VM\My_VM.vdi' is locked for reading by another task VBoxManage.exe: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component Medium, interface IMedium VBoxManage.exe: error: Context: "int __cdecl handleUnregisterVM(struct HandlerArg *)" at line 166 of file VBoxManageMisc.cpp
Subsequent delete commands fail due to the vboxmanage unregister command executing just the unregistration part but leaves all files and directories behind requiring manual cleanup.
VBoxManage.exe: error: Could not find a registered machine named 'My_VM' VBoxManage.exe: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component VirtualBox, interface IVirtualBox, callee IUnknown VBoxManage.exe: error: Context: "FindMachine(Bstr(VMName).raw(), machine.asOutParam())" at line 154 of file VBoxManageMisc.cpp
Shouldn't vboxmanage unregister --delete be an all or nothing command and if an error occurs perform none of the steps instead of just removing the registration and leaving all files behind to cause issues without manual cleanup?