Sometimes the XenServer VDI delete command will fail with an error message "The attempt to mark the VDI as hidden failed". This is usually a result of corrupt metadata associated with the VDI. I first encountered this error when I mounted a VDI on the control domain to manually re-format it. Unfortunately this didn't work out as well as I expected and left me with a corrupted VDI.
When removing them, the /var/log/messages on the control domain will look similar to this
vhd-util: libvhd::vhd_validate_footer: invalid footer cookie: vhd-util: libvhd::vhd_read_footer_at: /dev/VG_XenStorage-9ee4c758-cda0-a6b5-a0b8-14ce6d200ff7/VHD-177fbd2b-a093-4c21-8785-46acddecf3e7: reading footer at 0x207ffe00 failed: -22 vhd-util: libvhd::vhd_read: /dev/VG_XenStorage-9ee4c758-cda0-a6b5-a0b8-14ce6d200ff7/VHD-177fbd2b-a093-4c21-8785-46acddecf3e7: read of 512 returned 0, errno: -22 vhd-util: libvhd::vhd_validate_footer: invalid footer cookie: vhd-util: libvhd::vhd_read_short_footer: /dev/VG_XenStorage-9ee4c758-cda0-a6b5-a0b8-14ce6d200ff7/VHD-177fbd2b-a093-4c21-8785-46acddecf3e7: failed reading short footer: -22 vhd-util: libvhd::vhd_validate_footer: invalid footer cookie: vhd-util: libvhd::vhd_read_footer_at: /dev/VG_XenStorage-9ee4c758-cda0-a6b5-a0b8-14ce6d200ff7/VHD-177fbd2b-a093-4c21-8785-46acddecf3e7: reading footer at 0x00000000 failed: -22
Invalid footer cookie?
Lucky for me I didn't need that VDI so I decided to force remove it. The easiest way I found was to just remove the logical volume of that VDI with the following command:
lvremove /dev/VG_XenStorage-9ee4c758-cda0-a6b5-a0b8-14ce6d200ff7/VHD-177fbd2b-a093-4c21-8785-46acddecf3e7
The logical volume name is the same one as in the log files. You can also find it with the lvdisplay name and grep for the VDIs uuid.