[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Convert VMDK to RAW
From: |
Max Reitz |
Subject: |
Re: Convert VMDK to RAW |
Date: |
Fri, 15 Nov 2019 09:07:45 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 |
On 14.11.19 18:39, address@hidden wrote:
> Hello,
>
> thank you for the quick feedback. I am sorry that I expressed myself so
> unclearly. I don't want to use qemu but want to know how qemu converts vmdk
> to raw. So how exactly is the conversion programmed? How are the sparse
> grains put together to get an uncompressed virtual disk? I am a programmer
> and would like to reimplement this function. I already looked at the qemu
> code, but couldn't figure out how the conversion works.
Oh, OK. Well, even (or maybe especially) programmers sometimes want to
reuse existing functionality, so I assumed it would be sufficient for
you to just use qemu tools. ;-) (For example, qemu-nbd allows
presenting a VMDK image as a local block device that you can randomly
access.)
The code to interpret the VMDK format is in block/vmdk.c. The function
to read an arbitrary guest offset of the disk image is vmdk_co_preadv().
The conversion just iterates over the whole image and copies everything
read with that function to the output image, so I don’t think you need
to look at anything but block/vmdk.c.
vmdk_open() opens the image and thus parses the description file. I
suppose (I’m no expert in the VMDK code) of particular interest are
vmdk_parse_extents() and anything that calls vmdk_add_extent(). These
code paths create a list of all extent files.
>From a quick look at vmdk_co_preadv(), find_extent() then looks up the
corresponding extent file based on the guest offset;
get_cluster_offset() looks up the file offset in that extent file for
the respective guest offset; and vmdk_read_extent() then reads from the
file at that offset, decompressing the data if necessary.
(Note that
https://www.vmware.com/support/developer/vddk/vmdk_50_technote.pdf
probably understands the concepts of VMDK much better than I do *cough*)
Max
signature.asc
Description: OpenPGP digital signature