Statistics
| Branch: | Revision:

root / block / vdi.c @ c4d9d196

History | View | Annotate | Download (24.7 kB)

# Date Author Comment
1a86938f 03/15/2013 05:07 pm Kevin Wolf

block: Add options QDict to .bdrv_open()

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

6528499f 01/30/2013 12:14 pm Markus Armbruster

g_malloc(0) and g_malloc0(0) return NULL; simplify

Once upon a time, it was decided that qemu_malloc(0) should abort.
Switching to glib retired that bright idea. Some code that was added
to cope with it (e.g. in commits 702ef63, b76b6e9) is still around....

9f0470bb 01/25/2013 07:18 pm Stefan Weil

block/vdi: Improve debug output for signature

The signature is a 32 bit value and needs up to 8 hex digits for printing.

Signed-off-by: Stefan Weil <>
Reviewed-by: Eric Blake <>
Signed-off-by: Kevin Wolf <>

8937f822 01/25/2013 07:18 pm Stefan Weil

block/vdi: Improved return values from vdi_open

vdi_open returned -1 in case of any error, but it should return an
error code (negative value of errno or -EMEDIUMTYPE).

Signed-off-by: Stefan Weil <>
Reviewed-by: Eric Blake <>...

0e87ba2c 01/25/2013 07:18 pm Stefan Weil

block/vdi: Check for bad signature

vdi_open did not check for a bad signature.
This check was only in vdi_probe.

Signed-off-by: Stefan Weil <>
Reviewed-by: Eric Blake <>
Signed-off-by: Kevin Wolf <>

9c17d615 12/19/2012 09:32 am Paolo Bonzini

softmmu: move include files to include/sysemu/

Signed-off-by: Paolo Bonzini <>

1de7afc9 12/19/2012 09:32 am Paolo Bonzini

misc: move include files to include/qemu/

Signed-off-by: Paolo Bonzini <>

caf71f86 12/19/2012 09:31 am Paolo Bonzini

migration: move include files to include/migration/

Signed-off-by: Paolo Bonzini <>

737e150e 12/19/2012 09:31 am Paolo Bonzini

block: move include files to include/block/

Signed-off-by: Paolo Bonzini <>

8ba2aae3 11/21/2012 10:40 am Stefan Hajnoczi

vdi: don't override libuuid symbols

It's poor symbol hygiene to provide a global symbols that collide with a
common library like libuuid. If QEMU links against a shared library
that depends on uuid_generate() it can end up calling our stub version
of the function....

ecfe2bba 09/24/2012 04:15 pm Jeff Cody

block: vdi image file reopen

There is currently nothing that needs to be done for VDI reopen.

Signed-off-by: Jeff Cody <>
Signed-off-by: Kevin Wolf <>

514f21a5 09/12/2012 04:50 pm Stefan Weil

vdi: Fix warning from clang

ccc-analyzer reports these warnings:

block/vdi.c:704:13: warning: Dereference of null pointer
bmap[i] = VDI_UNALLOCATED;
^
block/vdi.c:702:13: warning: Dereference of null pointer
bmap[i] = i;...

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 <>...

4534ff54 06/15/2012 03:03 pm Kevin Wolf

qemu-img check -r for repairing images

The QED block driver already provides the functionality to not only
detect inconsistencies in images, but also fix them. However, this
functionality cannot be manually invoked with qemu-img, but the
check happens only automatically during bdrv_open()....

3d46a75a 04/05/2012 03:54 pm Paolo Bonzini

vdi: basic conversion to coroutines

Even a basic conversion changing the bdrv_aio_readv/bdrv_aio_writev calls
to bdrv_co_readv/bdrv_co_writev, and callbacks to goto statements can
eliminate a lot of code. This is because error handling is simplified
and indirections through bottom halves can go away....

0c7bfc32 04/05/2012 03:54 pm Paolo Bonzini

vdi: move end-of-I/O handling at the end

The next step is to take code that only triggers after the first operation,
and move it at the end of vdi_aio_read_cb and vdi_aio_write_cb.

Acked-by: Stefan Weil <>
Signed-off-by: Paolo Bonzini <>...

4de659e8 04/05/2012 03:54 pm Paolo Bonzini

vdi: merge aio_read_cb and aio_write_cb into callers

Now inline the former AIO callbacks into vdi_co_readv and vdi_co_writev.
While many cleanups are possible, the code now really looks synchronous.

Acked-by: Stefan Weil <>
Signed-off-by: Paolo Bonzini <>...

bfc45fc1 04/05/2012 03:54 pm Paolo Bonzini

vdi: move aiocb fields to locals

Most of the AIOCB really holds local variables that need to persist
across callback invocation. It can go away now.

Acked-by: Stefan Weil <>
Signed-off-by: Paolo Bonzini <>
Signed-off-by: Kevin Wolf <>

a7a43aa1 04/05/2012 03:54 pm Paolo Bonzini

vdi: leave bounce buffering to block layer

vdi.c really works as if it implemented bdrv_read and bdrv_write. However,
because only vector I/O is supported by the asynchronous callbacks, it
went through extra pain to bounce-buffer the I/O. This can be handled...

4eea78e6 04/05/2012 03:54 pm Paolo Bonzini

vdi: do not create useless iovecs

Reads and writes to the underlying file can also occur with the simple
non-vectored I/O interfaces.

Acked-by: Stefan Weil <>
Signed-off-by: Paolo Bonzini <>
Signed-off-by: Kevin Wolf <>

eb9566d1 04/05/2012 03:54 pm Paolo Bonzini

vdi: change goto to loop

Finally reindent all code and change goto statements to a loop.

Acked-by: Stefan Weil <>
Signed-off-by: Paolo Bonzini <>
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 <>

641543b7 01/26/2012 03:49 pm Stefan Weil

block/vdi: Zero unused parts when allocating a new block (fix #919242)

The new block was filled with zero when it was allocated by g_malloc0,
but when it was reused later and only partially used, data from the
previously allocated block were still present and written to the new...

91977c2e 12/15/2011 01:40 pm Paolo Bonzini

block: qemu_aio_get does not return NULL

Initially done with the following semantic patch:

rule1
expression E;
statement S;
@@
E = qemu_aio_get (...);
(
- if (E == NULL) { ... } |
- if (E) { <... S ...> }
)

which however missed occurrences in linux-aio.c and posix-aio-compat.c....

ad54ae80 12/15/2011 01:40 pm Paolo Bonzini

block: bdrv_aio_* do not return NULL

Initially done with the following semantic patch:

rule1
expression E;
statement S;
@@
E =
(
bdrv_aio_readv | bdrv_aio_writev | bdrv_aio_flush | bdrv_aio_discard | bdrv_aio_ioctl
)
(...);
(
- if (E == NULL) { ... }...

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

vdi: convert to .bdrv_co_is_allocated()

It is trivial to switch from the synchronous .bdrv_is_allocated()
interface to .bdrv_co_is_allocated() since vdi_is_allocated() does not
block.

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

6ac5f388 11/23/2011 06:04 pm Kevin Wolf

vdi: Fix memory leak

The block map is allocated in vdi_open, but was never freed.

Signed-off-by: Kevin Wolf <>

fc9d106c 11/23/2011 06:04 pm Kevin Wolf

vdi: Add migration blocker

vdi caches the block map. For migration to work, it would have to be
invalidated. Block migration for now.

Signed-off-by: Kevin Wolf <>

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...

c794b4e0 10/28/2011 08:25 pm Eric Sunshine

Teach block/vdi about "discarded" (no longer allocated) blocks

An entry in the VDI block map will hold an offset to the actual block if
the block is allocated, or one of two specially-interpreted values if
not allocated. Using VirtualBox terminology, value VDI_IMAGE_BLOCK_FREE...

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....

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 <>

e67a64a8 06/15/2011 03:35 pm Kevin Wolf

vdi: Avoid direct AIO callback

bdrv_aio_* must not call the callback before returning to its caller. In vdi,
this could happen in some error cases. This starts the real requests processing
in a BH to avoid this situation.

Signed-off-by: Kevin Wolf <>

99cce9fa 06/08/2011 12:56 pm Kevin Wolf

qemu-img create: Fix displayed default cluster size

When not specifying a cluster size on the command line, qemu-img printed
a cluster size of 0:

Formatting '/tmp/test.qcow2', fmt=qcow2 size=67108864
encryption=off cluster_size=0

This patch adds the default cluster size to the QEMUOptionParameter list, so...

4ff9786c 04/03/2011 10:42 pm Stefan Weil

Fix trivial "endianness bugs"

Replace endianess -> endianness.

Signed-off-by: Stefan Weil <>
Signed-off-by: Aurelien Jarno <>

40a892b7 03/15/2011 02:21 pm Stefan Weil

block/vdi: Don't ignore immediate read/write failures

This patch is similar to 171e3d6b9997c98a97d0c525867f7cd9b640cadd
which fixed qcow2:

Returning -EIO is far from optimal, but at least it's an error code.

Cc: Kevin Wolf <>
Signed-off-by: Stefan Weil <>...

4f3669ea 02/07/2011 11:07 am Stefan Weil

block/vdi: Fix wrong size in conditionally used memset, memcmp

Error report from cppcheck:
block/vdi.c:122: error: Using sizeof for array given as function argument returns the size of pointer.
block/vdi.c:128: error: Using sizeof for array given as function argument returns the size of pointer....

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 <>

9ac228e0 07/06/2010 06:05 pm Kevin Wolf

qcow2/vdi: Change check to distinguish error cases

This distinguishes between harmless leaks and real corruption. Hopefully users
better understand what qemu-img check wants to tell them.

Signed-off-by: Kevin Wolf <>

b666d239 05/17/2010 11:20 am Kevin Wolf

block: Avoid unchecked casts for AIOCBs

Use container_of for one direction and &acb->common for the other one.

Signed-off-by: Kevin Wolf <>

b76b6e95 05/17/2010 11:20 am Stefan Weil

block/vdi: Allow disk images of size 0

Even it is not very useful, users may create images of size 0.

Without the special option CONFIG_ZERO_MALLOC, qemu_mallocz
aborts execution when it is told to allocate 0 bytes,
so avoid this kind of call.

Cc: Kevin Wolf <>...

f21dc3a4 05/17/2010 11:20 am Stefan Weil

block/vdi: Fix image opening and creation for odd disk sizes

The fix is based on a patch from Kevin Wolf. Here his comment:

"The number of blocks needs to be rounded up to cover all of the virtual hard
disk. Without this fix, we can't even open our own images if their size is not...

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...

95a2f9bc 01/08/2010 05:58 pm François Revol

block/vdi: allow disk sizes not multiple of block size

The disk image I created from my old laptop disk with VBoxManage
internalcommand converthd obviously was not a multiple of 1MB as when
created from scratch. This fixes QEMU refusing it. We still require the...

ee682d27 10/04/2009 02:24 pm Stefan Weil

Check availability of uuid header / library

If available, the Universally Unique Identifier library
is used by the vdi block driver.

Other parts of QEMU (vl.c) could also use it.

Signed-off-by: Stefan Weil <>
Signed-off-by: Aurelien Jarno <>

a2a45a26 09/12/2009 03:36 pm Blue Swirl

Fix signedness warnings on OpenSolaris

Signed-off-by: Blue Swirl <>

6eea90eb 08/28/2009 03:33 am Stefan Weil

block/vdi.c: Fix several bugs

  • The code for option '-static' was wrong, so image creation
    always created static images.
  • Static images created with qemu-img did not set header entry
    blocks_allocated.
  • The size of the block map must be rounded to the next multiple...
1786dc15 08/15/2009 02:33 pm Blue Swirl

Use pstrcpy to avoid OpenBSD linker warnings

Signed-off-by: Blue Swirl <>

9aebd98a 08/10/2009 09:05 pm Stefan Weil

Add new block driver for the VDI format (only aio supported)

This is a new block driver written from scratch
to support the VDI format in QEMU.

VDI is the native format used by Innotek / SUN VirtualBox.

Latest changes:

  • stripped down version
    (code for synchronous operations and experimental code removed)...