Sunday, September 1, 2013

Xenserver: Deleting VDIs locked by the control domain



You can run into a situation where during a canceled move, a VDI is created on a SR that is locked by the control domain, even after a reboot.

Here is the method I used to solve this situation: 
  1. Find the UUID of the VDI: xe vdi-list name-label = <Name of the VDI>
  2. Find the UUID of the block device that the VDI is mounted with: xe vbd-list vdi-uuid=<UUID of the VDI>
  3. Unplug the block device, this will corrupt the VDI: xe vbd-unplug uuid=<UUID of the block device>
  4. Make the control domain forget the vdi: xe vdi-forget uuid=<UUID of the VDI>
  5. Rescan the SR: xe vdi-scan sr-uuid=<UUID of the SR>
  6. Destroy the VDI file: xe vdi-destroy uuid=<UUID of the VDI>