[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 07/42] vmdk: support vmfsSparse files
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 07/42] vmdk: support vmfsSparse files |
Date: |
Thu, 22 Aug 2013 22:11:03 +0200 |
From: Fam Zheng <address@hidden>
VMware ESX hosts use a variant of the VMDK3 format, identified by the
vmfsSparse create type ad the VMFSSPARSE extent type.
It has 16 KB grain tables (L2) and a variable-size grain directory (L1).
In addition, the grain size is always 512, but that is not a problem
because it is included in the header.
The format of the extents is documented in the VMDK spec. The format
of the descriptor file is not documented precisely, but it can be
found at http://kb.vmware.com/kb/10026353 (Recreating a missing virtual
machine disk (VMDK) descriptor file for delta disks).
With these patches, vmfsSparse files only work if opened through the
descriptor file. Data files without descriptor files, as far as I
could understand, are not supported by ESX.
Signed-off-by: Paolo Bonzini <address@hidden>
Signed-off-by: Fam Zheng <address@hidden>
--
v2: Rebase to patch 01.
Change le64_to_cpu to le32_to_cpu.
Rename vmdk_open_vmdk3 to vmdk_open_vmfs_sparse, which represents the
current usage of this format.
Signed-off-by: Fam Zheng <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
block/vmdk.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/block/vmdk.c b/block/vmdk.c
index 4d282a6..3986d1d 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -481,9 +481,9 @@ static int vmdk_init_tables(BlockDriverState *bs,
VmdkExtent *extent)
return ret;
}
-static int vmdk_open_vmdk3(BlockDriverState *bs,
- BlockDriverState *file,
- int flags)
+static int vmdk_open_vmfs_sparse(BlockDriverState *bs,
+ BlockDriverState *file,
+ int flags)
{
int ret;
uint32_t magic;
@@ -674,7 +674,7 @@ static int vmdk_open_sparse(BlockDriverState *bs,
magic = be32_to_cpu(magic);
switch (magic) {
case VMDK3_MAGIC:
- return vmdk_open_vmdk3(bs, file, flags);
+ return vmdk_open_vmfs_sparse(bs, file, flags);
break;
case VMDK4_MAGIC:
return vmdk_open_vmdk4(bs, file, flags);
@@ -718,7 +718,8 @@ static int vmdk_parse_extents(const char *desc,
BlockDriverState *bs,
}
if (sectors <= 0 ||
- (strcmp(type, "FLAT") && strcmp(type, "SPARSE")) ||
+ (strcmp(type, "FLAT") && strcmp(type, "SPARSE") &&
+ strcmp(type, "VMFSSPARSE")) ||
(strcmp(access, "RW"))) {
goto next_line;
}
@@ -741,8 +742,8 @@ static int vmdk_parse_extents(const char *desc,
BlockDriverState *bs,
return ret;
}
extent->flat_start_offset = flat_offset << 9;
- } else if (!strcmp(type, "SPARSE")) {
- /* SPARSE extent */
+ } else if (!strcmp(type, "SPARSE") || !strcmp(type, "VMFSSPARSE")) {
+ /* SPARSE extent and VMFSSPARSE extent are both "COWD" sparse
file*/
ret = vmdk_open_sparse(bs, extent_file, bs->open_flags);
if (ret) {
bdrv_delete(extent_file);
@@ -789,6 +790,7 @@ static int vmdk_open_desc_file(BlockDriverState *bs, int
flags,
goto exit;
}
if (strcmp(ct, "monolithicFlat") &&
+ strcmp(ct, "vmfsSparse") &&
strcmp(ct, "twoGbMaxExtentSparse") &&
strcmp(ct, "twoGbMaxExtentFlat")) {
fprintf(stderr,
@@ -1381,7 +1383,6 @@ static int coroutine_fn
vmdk_co_write_zeroes(BlockDriverState *bs,
return ret;
}
-
static int vmdk_create_extent(const char *filename, int64_t filesize,
bool flat, bool compress, bool zeroed_grain)
{
--
1.8.3.1
- [Qemu-devel] [PULL 00/42] Block patches, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 01/42] qcow2: Change default for new images to compat=1.1, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 02/42] block: Introduce bs->zero_beyond_eof, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 03/42] block: Produce zeros when protocols reading beyond end of file, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 04/42] block: better error message for read only format name, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 06/42] vmdk: fix L1 and L2 table size in vmdk3 open, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 05/42] vmdk: Move l1_size check into vmdk_add_extent(), Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 08/42] vmdk: support vmfs files, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 07/42] vmdk: support vmfsSparse files,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 10/42] aio / timers: Rename qemu_new_clock and expose clock types, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 09/42] aio / timers: Rename qemu_timer_* functions, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 11/42] aio / timers: add qemu-timer.c utility functions, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 13/42] aio / timers: add ppoll support with qemu_poll_ns, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 12/42] aio / timers: Consistent treatment of disabled clocks for deadlines, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 14/42] aio / timers: Add prctl(PR_SET_TIMERSLACK, 1, ...) to reduce timer slack, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 15/42] aio / timers: Make qemu_run_timers and qemu_run_all_timers return progress, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 16/42] aio / timers: Split QEMUClock into QEMUClock and QEMUTimerList, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 17/42] aio / timers: Untangle include files, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 18/42] aio / timers: Add QEMUTimerListGroup and helper functions, Stefan Hajnoczi, 2013/08/22