Incremental commit

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Incremental commit (now it typechecks)

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Remove the 'handle' wrapper over file_descr-like things

The only function of this 'handle' was to prevent the accidental
double-closing of Unix file descriptors. Since this is really
a Unix-ism, remove from the generic code. A future version of the
Vhd_lwt module can do this instead.

Note this exposed a file descriptor handling buf: if one opens
a vhd and then creates a snapshot, one ends up with two references
to the original vhd and it's not clear when this should be closed.
The current code doesn't call close() recursively so it never
double-closes but will occasionally leak.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Handle closing files properly

When creating a differencing disk, we re-open the parent filehandle
so both sets of filehandles can be closed separately without having
to add reference-counting.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Move the Element module to the top level

This isn't vhd specific so it shouldn't be within the Vhd module.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
stream: define a stream as 'size metadata + elements'

The size metadata is useful for understanding progress as
we work through the stream elements.

Start making raw file support look like vhd support.
Possibly this could be further generalised in future (qcow2?)

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
stream: add raw -> raw streaming

The stream element Copy(_, _, len) has the type of len changed from
int to int64, since a lot of sectors could be copied in one go.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Add Footer.create and Header.create with sensible defaults

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
BAT: round up when computing the total number of blocks

We round up when calculating the BAT size, so we cover all
codepaths. Also add a sanity check in the tests that all
vhds have an apparent capacity (indicated by the BAT size)
sufficient to record the full vhd current_size.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
stream: add the ability to stream a raw disk as vhd

Signed-off-by: David Scott <dave.scott@eu.citrix.com>