well known problem.
solution:
- shutdown vm (must be in halted state)
- find your VDI UUIDs
xe vm-disk-list vm=VMNAMEORUUID is-a-snapshot=false | grep -a1 'VDI\:' | grep 'uuid' | awk '{print $(NF)}'
- write down for all VDIs (in addition to you VMUUID):
VDIUUID
VDILABEL = xe vdi-param-get param-name=name-label uuid=VDIUUID
VDIDESCR = xe vdi-param-get param-name=name-description uuid=VDIUUID
SRUUID = xe vdi-param-get param-name=sr-uuid uuid=VDIUUID (if you have different SRs)
OLDVBDUUID = xe vdi-param-get uuid=VDIUUID param-name=vbd-uuids
VDIUSERDEVICE = xe vbd-param-get param-name=userdevice uuid=OLDVBDUUID
i have a script doing some checks at this point like getting current-operations etc. to prevent work on running/connected VMs/VDIs. If you are sure, the VM is offline, everything is ok. Sometimes thinks like a xe-toolstack-restart is needed, if the host is a long time runner
- now 'forget' all VDIs: (call for each VDI)
xe vdi-forget uuid=VDIUUID
- this could take some time AFTER the call above. Check that this responds with a 0, after you did the above call for all of your VM devices:
xe vbd-list vm-uuid=VMUUID | grep 'empty ( RO): false' | wc -l`
- now rescan all SRs where the VM had a VDI (maybe you have more than one SR):
xe sr-scan uuid=SRUUID
- now readd all devices again to the same position (VDIUSERDEVICE):
xe vbd-create vm-uuid=VMUUID device=VDIUSERDEVICE vdi-uuid=VDIUUID
xe vdi-param-set name-label='VDILABEL' name-description='VDIDESCR' uuid=VDIUUID
- If you got no errors (hopefully), start you VM:
xe vm-start uuid=VMUUID
This can easily scripted in shell or perl. We have 'The VDI is not available' errors and alike from time to time, so on all pool masters such a script exists to be run if needed. Especially if you have several drives and several VDI names/descriptions it's nice to not do it step by step