Situation: A move of a VM failed and left me with the VDI (Virtual Disk) and the VM on the old “location” and a VDI on the designated new location (something like this). When you try to delete the new failed location the delete field is grayed out with a note “This Virtual Disk is active on VM Control Domain on VM. Deactivate the Virtual Disk before deleting.

Firstly try to identify the uuid of the VDI:
(I used the XenCenter and changed the description to “delete” to have an indicator that I picked the right VDI).

xe vdi-list

This will come back with all Vdisks and their uuids. Pick the one you have the issue with.

uuid ( RO) : bc67a8c9-5bf5-4eb0-b643-31d4f4f0de2f
name-label ( RW): XPVM-Spiceworks-Disk0
name-description ( RW): delete
sr-uuid ( RO): cf2b964c-baf4-5283-7a46-5b3f1170a321
virtual-size ( RO): 21460156416
sharable ( RO): false
read-only ( RO): false

That’s my disk and I want to remove it now.

xe vdi-destroy uuid=bc67a8c9-5bf5-4eb0-b643-31d4f4f0de2f
This operation cannot be performed because this VDI is in use by some other operation
vdi: bc67a8c9-5bf5-4eb0-b643-31d4f4f0de2f (XPVM-Spiceworks-Disk0)
operation: destroy

OK that didn’t go too well. It would have worked for any “normal unused” disk but this case is different since its locked by the control domain for the move.

Lets look into what the VDSI assignment says.

xe vbd-list vdi-uuid=bc67a8c9-5bf5-4eb0-b643-31d4f4f0de2f

uuid ( RO) : e632f58e-b607-6091-b845-6ffec1c255b9
vm-uuid ( RO): c8cf07ee-c37f-4374-8b9f-01c1b43d0d9b
vm-name-label ( RO): Control domain on host: xenserver01.local
vdi-uuid ( RO): bc67a8c9-5bf5-4eb0-b643-31d4f4f0de2f
empty ( RO): false
device ( RO): sm/backend/cf2b964c-baf4-5283-7a46-5b3f1170a321/bc67a8c9-5bf5-4eb0-b643-31d4f4f0de2f

In order to delete the virtual disk you have to unplug the virtual block device first to free up the virtual disk.

In my example below watch the color coding to see the pattern.

xe vbd-unplug uuid=e632f58e-b607-6091-b845-6ffec1c255b9

xe vbd-destroy uuid=e632f58e-b607-6091-b845-6ffec1c255b9

xe vdi-destroy uuid=bc67a8c9-5bf5-4eb0-b643-31d4f4f0de2f

That should have remove your device. You can now check again with xe vdi-list.

%d bloggers like this: