Statistics
| Branch: | Revision:

root / block / vmdk.c @ 737e150e

History | View | Annotate | Download (48.6 kB)

# Date Author Comment
737e150e 12/19/2012 09:31 am Paolo Bonzini

block: move include files to include/block/

Signed-off-by: Paolo Bonzini <>

b1649fae 11/14/2012 07:19 pm Gerhard Wiesinger

vmdk: Fix data corruption bug in WRITE and READ handling

Fixed a MAJOR BUG in VMDK files on file boundaries on reads
and ALSO ON WRITES WHICH MIGHT CORRUPT THE IMAGE AND DATA!!!!!!

Triggered for example with the following VMDK file (partly listed):
RW 4193792 FLAT "XP-W1-f001.vmdk" 0...

d66f8e7b 10/05/2012 03:58 pm Jim Meyering

vmdk: relative_path: use pstrcpy in place of strncpy

Avoid strncpy+manual-NUL-terminate. Use pstrcpy instead.

Acked-by: Kevin Wolf <>
Signed-off-by: Jim Meyering <>
Signed-off-by: Anthony Liguori <>

3897575f 09/24/2012 04:15 pm Jeff Cody

block: vmdk image file reopen

This patch supports reopen for VMDK image files. VMDK extents are added
to the existing reopen queue, so that the transactional model of reopen
is maintained with multiple image files.

Signed-off-by: Jeff Cody <>...

65bd155c 08/17/2012 02:27 pm Kevin Wolf

vmdk: Read footer for streamOptimized images

The footer takes precedence over the header when it exists. It contains
the real grain directory offset that is missing in the header. Without
this patch, streamOptimized images with a footer cannot be read.

Signed-off-by: Kevin Wolf <>...

7a736bfa 08/17/2012 12:14 pm Kevin Wolf

vmdk: Fix header structure

Commit bb45ded9 swapped gd_offset and rgd_offset. This is wrong.

Signed-off-by: Kevin Wolf <>

6165f4d8 08/15/2012 11:48 am Corey Bryant

block: Convert open calls to qemu_open

This patch converts all block layer open calls to qemu_open.

Note that this adds the O_CLOEXEC flag to the changed open paths
when the O_CLOEXEC macro is defined.

Signed-off-by: Corey Bryant <>...

2e1e79da 08/15/2012 11:48 am Corey Bryant

block: Convert close calls to qemu_close

This patch converts all block layer close calls, that correspond
to qemu_open calls, to qemu_close.

Signed-off-by: Corey Bryant <>
Signed-off-by: Kevin Wolf <>

29cdb251 04/05/2012 03:54 pm Paolo Bonzini

block: push recursive flushing up from drivers

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Kevin Wolf <>

75d12341 03/07/2012 03:03 pm Stefan Weil

block/vmdk: Fix warning from splint (comparision of unsigned value)

l1_entry_sectors will never be less than 0.

Signed-off-by: Stefan Weil <>
Signed-off-by: Stefan Hajnoczi <>

f8a2e5e3 12/05/2011 03:51 pm Stefan Hajnoczi

block: convert qcow2, qcow2, and vmdk to .bdrv_co_is_allocated()

The qcow2, qcow, and vmdk block drivers are based on coroutines. They have a
coroutine mutex which protects internal state. We can convert the
.bdrv_is_allocated() function to .bdrv_co_is_allocated() by holding the mutex...

2bc3166c 11/23/2011 06:04 pm Kevin Wolf

vmdk: Add migration blocker

VMDK caches L2 tables. For migration to work, they would have to be
invalidated. Block migration for now.

Signed-off-by: Kevin Wolf <>

2923d34f 11/21/2011 11:05 pm Stefan Weil

Include zlib.h using #include <>

zlib.h is not a local include file, therefore it should be included
using <> instead of "".

Signed-off-by: Stefan Weil <>
Signed-off-by: Anthony Liguori <>

c68b89ac 11/11/2011 03:02 pm Kevin Wolf

block: Rename bdrv_co_flush to bdrv_co_flush_to_disk

There are two different types of flush that you can do: Flushing one level up
to the OS (i.e. writing data to the host page cache) or flushing it all the way
down to the disk. The existing functions flush to the disk, reflect this in the...

8494a397 10/31/2011 06:09 pm Anthony Liguori

Merge remote-tracking branch 'kwolf/for-anthony' into staging

Conflicts:
block/vmdk.c

3a069ff1 10/31/2011 05:23 pm Anthony Liguori

Merge remote-tracking branch 'stefanha/trivial-patches' into staging

bac8d7b4 10/28/2011 08:25 pm Kevin Wolf

vmdk: Fix use of uninitialised value

In error cases, cid is never set.

Signed-off-by: Kevin Wolf <>

99f1835d 10/28/2011 08:25 pm Kevin Wolf

vmdk: Improve error handling

Return the right error values in some more places.

Signed-off-by: Kevin Wolf <>

93897b9f 10/28/2011 08:25 pm Kevin Wolf

vmdk: Fix possible segfaults

Data we read from the disk isn't necessarily null terminated and may not
contain the string we're looking for. The code needs to be a bit more careful
here.

Signed-off-by: Kevin Wolf <>

c18a1c88 10/26/2011 03:36 pm Pavel Borzenkov

vmdk: remove unneeded variable assignment

Spotted by Clang Analyzer

Signed-off-by: Pavel Borzenkov <>
Signed-off-by: Stefan Hajnoczi <>

8379e46d 10/26/2011 03:36 pm Pavel Borzenkov

vmdk: vmdk_read_cid returns garbage if p_name is NULL

Spotted by Clang Analyzer

Signed-off-by: Pavel Borzenkov <>
Signed-off-by: Stefan Hajnoczi <>

2914caa0 10/21/2011 06:34 pm Paolo Bonzini

block: take lock around bdrv_read implementations

This does the first part of the conversion to coroutines, by
wrapping bdrv_read implementations to take the mutex.

Drivers that implement bdrv_read rather than bdrv_co_readv can
then benefit from asynchronous operation (at least if the underlying...

e183ef75 10/21/2011 06:34 pm Paolo Bonzini

block: take lock around bdrv_write implementations

This does the first part of the conversion to coroutines, by
wrapping bdrv_write implementations to take the mutex.

Drivers that implement bdrv_write rather than bdrv_co_writev can
then benefit from asynchronous operation (at least if the underlying...

8b94ff85 10/21/2011 06:34 pm Paolo Bonzini

block: change flush to co_flush

Since coroutine operation is now mandatory, convert all bdrv_flush
implementations to coroutines. For qcow2, this means taking the lock.
Other implementations are simpler and just forward bdrv_flush to the
underlying protocol, so they can avoid the lock....

588b65a3 10/21/2011 06:34 pm Paolo Bonzini

vmdk: fix return values of vmdk_parent_open

While vmdk_open_desc_file (touched by the patch) correctly changed -1
to -EINVAL, vmdk_open did not. Fix it directly in vmdk_parent_open.

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Kevin Wolf <>

bae0a0cc 10/21/2011 06:34 pm Paolo Bonzini

vmdk: clean up open

Move vmdk_parent_open to vmdk_open. There's another path how
vmdk_parent_open can be reached:

vmdk_parse_extents() ->  vmdk_open_sparse() ->  vmdk_open_vmdk4() ->
vmdk_open_desc_file().

If that can happen, however, the code is bogus. vmdk_parent_open...

848c66e8 10/21/2011 06:34 pm Paolo Bonzini

block: add a CoMutex to synchronous read drivers

The big conversion of bdrv_read/write to coroutines caused the two
homonymous callbacks in BlockDriver to become reentrant. It goes
like this:

1) bdrv_read is now called in a coroutine, and calls bdrv_read or...

b3c0bfb6 09/20/2011 01:27 pm Fam Zheng

VMDK: fix leak of extent_file

Release extent_file on error in vmdk_parse_extents. Added closing files
in freeing extents.

Signed-off-by: Fam Zheng <>
Signed-off-by: Kevin Wolf <>

bb45ded9 09/06/2011 01:33 pm Fam Zheng

VMDK: bugfix, opening vSphere 4 exported image

The vSphere 4 exported image is streamOptimized extent, which is not
quite correctly handled. Ignore rdgOffset when RGD flag bit not set.

Signed-off-by: Fam Zheng <>
Reviewed-by: Stefan Hajnoczi <>...

f16f509d 09/06/2011 01:33 pm Fam Zheng

VMDK: bugfix, open Haiku vmdk image

Haiku provides a specially formed vmdk image, which let qemu abort. It a
combination of sparse header and flat data (i.e. with not l1/l2 table at
all). The fix is turn to descriptor when sparse header is zero in field
'capacity'....

6c031aac 09/06/2011 01:31 pm Fam Zheng

VMDK: creating streamOptimized subformat

Creating streamOptimized subformat. Added subformat option
'streamOptimized', to create a image with compression enabled and each
cluster with a GrainMarker.

Signed-off-by: Fam Zheng <>
Reviewed-by: Stefan Hajnoczi <>...

2b2c8c5d 09/06/2011 01:30 pm Fam Zheng

VMDK: read/write compressed extent

Add support for reading/writing compressed extent.

Signed-off-by: Fam Zheng <>
Reviewed-by: Stefan Hajnoczi <>
Signed-off-by: Kevin Wolf <>

432bb170 09/06/2011 01:27 pm Fam Zheng

VMDK: Opening compressed extent.

Added flags field for compressed/streamOptimized extents, open and save
image configuration.

Signed-off-by: Fam Zheng <>
Reviewed-by: Stefan Hajnoczi <>
Signed-off-by: Kevin Wolf <>

dd3f6ee2 09/06/2011 01:25 pm Fam Zheng

VMDK: separate vmdk_read_extent/vmdk_write_extent

Factor out read/write extent code, since there will be more things to
take care of once reading/writing compressed clusters is introduced.

Signed-off-by: Fam Zheng <>
Reviewed-by: Stefan Hajnoczi <>...

86c6b429 09/06/2011 01:22 pm Fam Zheng

VMDK: add twoGbMaxExtentSparse support

Add twoGbMaxExtentSparse support. Introduce vmdk_free_last_extent.

Signed-off-by: Fam Zheng <>
Reviewed-by: Stefan Hajnoczi <>
Signed-off-by: Kevin Wolf <>

6398de51 09/06/2011 01:20 pm Fam Zheng

VMDK: enable twoGbMaxExtentFlat

Enable the createType 'twoGbMaxExtentFlat'. The supporting code is
already in.

Signed-off-by: Fam Zheng <>
Reviewed-by: Stefan Hajnoczi <>
Signed-off-by: Kevin Wolf <>

541dc0d4 09/03/2011 01:45 pm Stefan Weil

Use new macro QEMU_PACKED for packed structures

Most changes were made using these commands:

git grep -la '__attribute__((packed))'|xargs perl -pi -e 's/__attribute__\(\(packed\)\)/QEMU_PACKED/'
git grep -la '__attribute__ ((packed))'|xargs perl -pi -e 's/__attribute__ \(\(packed\)\)/QEMU_PACKED/'...

7267c094 08/21/2011 07:01 am Anthony Liguori

Use glib memory allocation and free functions

qemu_malloc/qemu_free no longer exist after this commit.

Signed-off-by: Anthony Liguori <>

4a1d5e1f 07/19/2011 04:39 pm Fam Zheng

block: add bdrv_get_allocated_file_size() operation

qemu-img.c wants to count allocated file size of image. Previously it
counts a single bs->file by 'stat' or Window API. As VMDK introduces
multiple file support, the operation becomes format specific with...

69b4d86d 07/19/2011 04:39 pm Fam Zheng

VMDK: move 'static' cid_update flag to bs field

Cid_update is the flag for updating CID on first write after opening the
image. This should be per image open rather than per program life cycle,
so change it from static var of vmdk_write to a field in BDRVVmdkState....

91b85bd3 07/19/2011 04:39 pm Fam Zheng

VMDK: change get_cluster_offset return type

The return type of get_cluster_offset was an offset that use 0 to denote
'not allocated', this will be no longer true for flat extents, as we see
flat extent file as a single huge cluster whose offset is 0 and length...

7fa60fa3 07/19/2011 04:39 pm Fam Zheng

VMDK: open/read/write for monolithicFlat image

Parse vmdk decriptor file and open mono flat image.
Read/write the flat extent.

Signed-off-by: Fam Zheng <>
Reviewed-by: Stefan Hajnoczi <>
Signed-off-by: Kevin Wolf <>

f66fd6c3 07/19/2011 04:39 pm Fam Zheng

VMDK: create different subformats

Add create option 'format', with enums:
monolithicSparse
monolithicFlat
twoGbMaxExtentSparse
twoGbMaxExtentFlat
Each creates a subformat image file. The default is monolithicSparse.

Signed-off-by: Fam Zheng <>...

ae261c86 07/19/2011 04:39 pm Fam Zheng

VMDK: fix coding style

Conform coding style in vmdk.c to pass scripts/checkpatch.pl checks.

Signed-off-by: Fam Zheng <>
Reviewed-by: Stefan Hajnoczi <>
Signed-off-by: Kevin Wolf <>

0e69c543 07/19/2011 04:39 pm Fam Zheng

VMDK: bugfix, align offset to cluster in get_whole_cluster

In get_whole_cluster, the offset is not aligned to cluster when reading
from backing_hd. When the first write to child is not at the cluster
boundary, wrong address data from parent is copied to child....

01fc99d6 07/19/2011 04:39 pm Fam Zheng

VMDK: probe for monolithicFlat images

Probe as the same behavior as VMware does.
Recognize image as monolithicFlat descriptor file when the file is text
and the first effective line (not '#' leaded comment or space line) is
either 'version=1' or 'version=2'. No space or upper case charactors...

b4b3ab14 07/19/2011 04:39 pm Fam Zheng

VMDK: separate vmdk_open by format version

Separate vmdk_open by subformats to:
  • vmdk_open_vmdk3
  • vmdk_open_vmdk4

Signed-off-by: Fam Zheng <>
Reviewed-by: Stefan Hajnoczi <>
Signed-off-by: Kevin Wolf <>

e1da9b24 07/19/2011 04:39 pm Fam Zheng

VMDK: add field BDRVVmdkState.desc_offset

There are several occurrence of magic number 0x200 as the descriptor
offset within mono sparse image file. This is not the case for images
with separate descriptor file. So a field is added to BDRVVmdkState to
hold the correct value....

333c574d 07/19/2011 04:39 pm Fam Zheng

VMDK: flush multiple extents

Flush all the file that referenced by the image.

Signed-off-by: Fam Zheng <>
Reviewed-by: Stefan Hajnoczi <>
Signed-off-by: Kevin Wolf <>

b3976d3c 07/19/2011 04:39 pm Fam Zheng

VMDK: introduce VmdkExtent

Introduced VmdkExtent array into BDRVVmdkState, enable holding multiple
image extents for multiple file image support.

Signed-off-by: Fam Zheng <>
Reviewed-by: Stefan Hajnoczi <>
Signed-off-by: Kevin Wolf <>

16372ff0 06/08/2011 11:39 am Alexander Graf

vmdk: fix endianness bugs

The vmdk code is sloppy when handling the header descriptor during
creation of an image. Fix all header accesses in the create path to
either store native endianness or convert it when appropriate.

Reported-by: Yury Tsarev <>...

80465c50 11/24/2010 06:31 pm Kevin Wolf

block: Remove unused s->hd in various drivers

All drivers use bs->file instead of s->hd for quite a while now, so it's time
to remove s->hd.

Signed-off-by: Kevin Wolf <>
Reviewed-by: Stefan Hajnoczi <>

205ef796 11/04/2010 01:52 pm Kevin Wolf

block: Allow bdrv_flush to return errors

This changes bdrv_flush to return 0 on success and -errno in case of failure.
It's a requirement for implementing proper error handle in users of bdrv_flush.

Signed-off-by: Kevin Wolf <>
Reviewed-by: Stefan Hajnoczi <>

b8852e87 06/22/2010 03:38 pm Kevin Wolf

vmdk: Use bdrv_(p)write_sync for metadata writes

Use bdrv_(p)write_sync to ensure metadata integrity in case of a crash.

Signed-off-by: Kevin Wolf <>

c336500d 05/03/2010 11:07 am Kevin Wolf

vmdk: Fix COW

When trying to do COW, VMDK wrote the data back to the backing file. This
problem was revealed by the patch that made backing files read-only. This patch
does not only fix the problem, but also simplifies the VMDK code a bit.

This fixes the backing file qemu-iotests cases for VMDK....

9949f97e 05/03/2010 11:07 am Kevin Wolf

vmdk: Clean up backing file handling

VMDK is doing interesting things when it needs to open a backing file. This
patch changes that part to look more like in other drivers. The nice side
effect is that the file name isn't needed any more in the open function....

6511ef77 05/03/2010 11:07 am Kevin Wolf

vmdk: Convert to bdrv_open

It's a format driver, so implement bdrv_open instead of bdrv_file_open.

Signed-off-by: Kevin Wolf <>

66f82cee 05/03/2010 11:07 am Kevin Wolf

block: Open the underlying image file in generic code

Format drivers shouldn't need to bother with things like file names, but rather
just get an open BlockDriverState for the underlying protocol. This patch
introduces this behaviour for bdrv_open implementation. For protocols which...

d6e9098e 04/23/2010 05:08 pm Kevin Wolf

Replace calls of old bdrv_open

What is known today as bdrv_open2 becomes the new bdrv_open. All remaining
callers of the old function are converted to the new one. In some places they
even know the right format, so they should have used bdrv_open2 from the...

b781cce5 03/09/2010 07:23 pm Juan Quintela

vmdk: return errno instead of -1

Signed-off-by: Juan Quintela <>
Signed-off-by: Anthony Liguori <>

53c2e716 03/09/2010 07:23 pm Juan Quintela

vmdk: make vmdk_snapshot_create return -errno

Signed-off-by: Juan Quintela <>
Signed-off-by: Anthony Liguori <>

a161329b 03/09/2010 07:23 pm Juan Quintela

vmdk: fix double free

fail_gd error case would also free rgd_buf that was already freed

Signed-off-by: Juan Quintela <>
Signed-off-by: Anthony Liguori <>

3829cb46 03/09/2010 07:23 pm Juan Quintela

vmdk: share cleanup code

cleanup code is identical for error/success cases. Only difference
are goto labels.

Signed-off-by: Juan Quintela <>
Signed-off-by: Anthony Liguori <>

1640366c 01/26/2010 10:59 pm Kirill A. Shutemov

block/vmdk.o: fix warnings with _FORTIFY_SOURCE

CC block/vmdk.o
cc1: warnings being treated as errors
block/vmdk.c: In function 'vmdk_snapshot_create':
block/vmdk.c:236: error: ignoring return value of 'ftruncate', declared with attribute warn_unused_result...

f5edb014 01/20/2010 04:25 pm Naphtali Sprei

Clean-up a little bit the RW related bits of BDRV_O_FLAGS. BDRV_O_RDONLY gone (and so is BDRV_O_ACCESS). Default value for bdrv_flags (0/zero) is READ-ONLY. Need to explicitly request READ-WRITE.

Instead of using the field 'readonly' of the BlockDriverState struct for passing the request,...

b171271a 07/22/2009 06:58 pm Kevin Wolf

vmdk: Fix backing file handling

Instead of storing the backing file in its own BlockDriverState, VMDK uses the
BlockDriverState of the raw image file it opened. This is wrong and breaks
functions that access the backing file or protocols. This fix replaces all...

db08adf5 06/06/2009 06:38 pm Kevin Wolf

qemu-img: Print available options with -o ?

This patch adds a small help text to each of the options in the block drivers
which can be displayed by using qemu-img create -f fmt -o ?

Signed-off-by: Kevin Wolf <>

0e7e1989 05/22/2009 06:50 pm Kevin Wolf

Convert all block drivers to new bdrv_create

Now we can make use of the newly introduced option structures. Instead of
having bdrv_create carry more and more parameters (which are format specific in
most cases), just pass a option structure as defined by the driver itself....

019d6b8f 05/15/2009 12:13 am Anthony Liguori

Move block drivers into their own directory

Signed-off-by: Anthony Liguori <>