The VM metadata export handler (/export_metadata) will output the metadata of a VM, all its snapshots, and all their attached VDIs.  However, it doesn't walk the tree of VDIs defined by the VDI.sm_config["vhd_parent"] field.  For a full-fidelity representation, having the parent VDIs is very useful.
The VM metadata export handler (/export_metadata) will output the metadata
of a VM, all its snapshots, and all their attached VDIs.  However, it doesn't
walk the tree of VDIs defined by the VDI.sm_config["vhd_parent"] field.  For
a full-fidelity representation, having the parent VDIs is very useful.

This patch adds an "include_vhd_parents=(true|false)" option to the the
/export_metadata handler.  With this option on, the entire tree of VDIs is
exported.

This patch does not change the /export URL handler, does not change any
behaviour when include_vhd_parents is false or missing, and copes gracefully
with a missing or malformed vhd_parent entry.

Dave: modified to be robust to vhd parent cycles

Signed-off-by: Ewan Mellor <37d327f49c878137250e0b5d97408bd8b93d87e0@eu.citrix.com>
Signed-off-by: Dave Scott <63c9eb0ea83039690fefa11afe17873ba8278a56@eu.citrix.com>

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