xapi-project/xen-api — pull request #2063 by chengsun (2014-12-17 15:39:20+00:00)
Title: import_raw_vdi: Pass Content-Length to vhd-tool

This passes the `Content-Length` header to `vhd-tool serve` when using raw non-chunked imports. This way clients don't need to manually pad out the HTTP PUT with zeros, to fill it up to the next 2MB boundary.

Compiled and tested. No changes to `vhd-tool` required (so far -- see below).

Two issues/queries:
- I'm using the `--destination-size` parameter for `vhd-tool` to determine how much it should read from the source, which sounds counterintuitive. On the other hand, if it's intended behaviour that `vhd-tool` always expects to read as much as the size of the destination allows (which is how this 2MB rounding issue arose in the first place), then I can see how it could make some sense. Despite that, should we rename the argument?
- I haven't added explicit error handling for the case when `Content-Length` exceeds the allocated size of the VHD. In this case vhd-tool currently raises a VDI_IO_ERROR. Should we check for this up-front? If so, should the check go in xapi or vhd-tool?