machyve / xhyve

xhyve, a lightweight OS X virtualization solution
Other
6.44k stars 353 forks source link

Implement split disk images and allow xhyve to create disk image files #82

Open dunkelstern opened 8 years ago

dunkelstern commented 8 years ago

This implements disk image files that are split into multiple files, this is stage one of allowing sparse disk images where empty sectors will not be written to the image file, but it is usable on it's own.

preadv/pwritev can not be used anymore if the read spans two disk image segments as we access two file descriptors here. But as a performance boost we could allow more than one thread reading/writing if they work on different image segments.

Additionally the disk image files will be created if they don't exist which means if you're using a split disk image the disk image is growable (just add more files to the set) and possibly shrinkable (just delete a part from the end of the set), if the target os supports it.

dunkelstern commented 8 years ago

I have implemented sparse disk images on a branch based on this patch, if this is merged i can send another pull request with that patch.

Sparse disk images will only write sectors that contain other things than zeroes actually to disk and skip over those zero blocks. This is implemented with a lookup table in a second file. If there's interest please tell me.

johanneswuerbach commented 8 years ago

In https://github.com/zchee/docker-machine-driver-xhyve I implemented sparse images (https://github.com/zchee/docker-machine-driver-xhyve/pull/44) using https://github.com/mist64/xhyve/pull/80 and OS X sparsebundle. Is there an advantage using your approach?

dunkelstern commented 8 years ago

See http://blog.dunkelstern.de/2016/01/16/xhyve-lightweight-vm-for-mac-os-x/

TL;DR: You can shrink the image after it has become bloated, by repeatedly writing and deleting data, with external tooling (which does not exist yet)

WANG-lp commented 8 years ago

vote for this feature 👍 😄