CA-127975: Run sparse_dd with new subtask during cross-host VDI.copy
CA-127975: Run sparse_dd with new subtask during cross-host VDI.copy

Previously sparse_dd (and the receiving import_raw_vdi operation)
re-used the VDI.copy task, marking it complete once the import had
finished.

This caused problems with cross-host VM.copy, as the VM.copy operation
would also watch the VDI.copy task for completion. The VM.copy would
attempt to extract the new VDI reference from the task result straight
away, but import_raw_vdi did not add this to the task result on
completion, leading to the VM.copy failing with Xml.Error.

Adding the new VDI ref to the VDI.copy task result did not fix the
problem, as in this case the VM.copy operation would immediately destroy
the VDI.copy task as soon as it was marked completed. The VDI.copy
operation would then fail, as its task no longer existed, and it would
clean up by destroying the new VDI. Meanwhile the VM.copy operation would
complete without an exception being raised.

The approach taken here is to create a new task for the import_raw_vdi
operation. VDI.copy watches for this task to be completed, and VM.copy
in turn watches for the VDI.copy operation to be completed. This way
there is no race between VDI.copy and VM.copy, and the new VDI ref is
automatically added to the VDI.copy task's result on completion.

Signed-off-by: John Else <37b74501daa612e48fea94f9846ed4ddeb6a8f07@citrix.com>

cheng-z/xen-api,salvocambria/xen-api,euanh/xen-api,euanh/xen-api,srowe/xen-api,salvocambria/xen-api,euanh/xen-api,vasilenkomike/xen-api,simonjbeaumont/xen-api,agimofcarmen/xen-api,thomassa/xen-api,anoobs/xen-api,cheng--zhang/xen-api,robertbreker/xen-api,anoobs/xen-api,vasilenkomike/xen-api,cheng--zhang/xen-api,huizh/xen-api,cheng--zhang/xen-api,cheng--zhang/xen-api,cheng--zhang/xen-api,rafalmiel/xen-api,srowe/xen-api,srowe/xen-api,guard163/xen-api,simonjbeaumont/xen-api,koushikcgit/xen-api,agimofcarmen/xen-api,Frezzle/xen-api,thomassa/xen-api,simonjbeaumont/xen-api,rafalmiel/xen-api,anoobs/xen-api,koushikcgit/xen-api,salvocambria/xen-api,vasilenkomike/xen-api,Frezzle/xen-api,guard163/xen-api,vasilenkomike/xen-api,thomassa/xen-api,rafalmiel/xen-api,rafalmiel/xen-api,salvocambria/xen-api,robertbreker/xen-api,djs55/xen-api,guard163/xen-api,jjd27/xen-api,rafalmiel/xen-api,koushikcgit/xen-api,robertbreker/xen-api,cheng-z/xen-api,Frezzle/xen-api,euanh/xen-api,euanh/xen-api,huizh/xen-api,agimofcarmen/xen-api,simonjbeaumont/xen-api,simonjbeaumont/xen-api,cheng-z/xen-api,anoobs/xen-api,djs55/xen-api,euanh/xen-api,thomassa/xen-api,djs55/xen-api,huizh/xen-api,guard163/xen-api,guard163/xen-api,jjd27/xen-api,djs55/xen-api,huizh/xen-api,cheng-z/xen-api,Frezzle/xen-api,robertbreker/xen-api,anoobs/xen-api,cheng--zhang/xen-api,agimofcarmen/xen-api,srowe/xen-api,rafalmiel/xen-api,vasilenkomike/xen-api,anoobs/xen-api,robertbreker/xen-api,cheng-z/xen-api,koushikcgit/xen-api,huizh/xen-api,thomassa/xen-api,agimofcarmen/xen-api,guard163/xen-api,simonjbeaumont/xen-api,jjd27/xen-api,cheng--zhang/xen-api,Frezzle/xen-api,thomassa/xen-api,djs55/xen-api,djs55/xen-api,jjd27/xen-api,jjd27/xen-api,huizh/xen-api,salvocambria/xen-api,jjd27/xen-api,koushikcgit/xen-api,agimofcarmen/xen-api,koushikcgit/xen-api,srowe/xen-api,vasilenkomike/xen-api,cheng-z/xen-api,cheng-z/xen-api,robertbreker/xen-api,salvocambria/xen-api