Minimize race window between VDI.data_destroy and VBD.create
Minimize race window between VDI.data_destroy and VBD.create

by tentatively marking the VDI as cbt_metadata at the start of
data_destroy, and restoring the original VDI type in case something went
wrong.

Since VBD.create does not have a corresponding VBD operation enum, we do
not perform locking for it, and it is possible to create VBDs referring
to a VDI while it's being data_destroyed (or destroyed).

This change ensures that no VBDs will be left pointing to this VDI after
data_destroy finishes successfully, because during data_destroy, while
the type of the VDI is already cbt_metadata, we wait for all the VBDs of
the VDI to disappear, (and after that we also remove all such VBDs, as
for VDI.destroy, but in the case of data_destroy, there shouldn't be any
left), and VBD.create is not allowed for VDIs of type cbt_metadata.

Signed-off-by: Iglói Gábor <7535f5501fd71876c93d896691e178fd3a11cfbb@citrix.com>

srowe/xen-api,srowe/xen-api,srowe/xen-api,srowe/xen-api,srowe/xen-api