| Branch: | Revision:

root / block @ 1e5b9d2f

# Date Author Comment
1e5b9d2f 10/30/2009 03:39 pm Kevin Wolf

Remove aio_ctx from paio_* interface

The context parameter in paio_submit isn't used anyway, so there is no reason
why block drivers should need to remember it. This also avoids passing a Linux
AIO context to paio_submit (which doesn't do any harm as long as the parameter...

8febfa26 10/27/2009 07:28 pm Kevin Wolf

Add qemu_aio_process_queue()

We'll leave some AIO completions unhandled when we can't call the callback.
qemu_aio_process_queue() is used later to run any callbacks that are left and
can be run then.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

72ecf02d 10/27/2009 07:28 pm Kevin Wolf

Revert "qcow2: Bring synchronous read/write back to life"

It was merely a workaround and the real fix is done now.
This reverts commit ef845c3bf421290153154635dc18eaa677cecb43.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

c5baaa48 10/27/2009 07:28 pm Kevin Wolf

qcow2: Fix grow_refcount_table error handling

In case of failure, we haven't increased the refcount for the newly allocated
cluster yet. Therefore we must not free the cluster or its refcount will become
negative (and endless recursion is possible).

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

d2e46345 10/27/2009 07:28 pm Kevin Wolf

raw/linux-aio: Also initialize POSIX AIO

When using Linux AIO raw still falls back to POSIX AIO sometimes, so we should
initialize it.

Not initializing it happens to work if POSIX AIO is used by another drive, or
if the format is not specified (probing the format uses POSIX AIO) or by pure...

ef845c3b 10/15/2009 05:32 pm Kevin Wolf

qcow2: Bring synchronous read/write back to life

When the synchronous read and write functions were dropped, they were replaced
by generic emulation functions. Unfortunately, these emulation functions don't
provide the same semantics as the original functions did....

0b4ce02e 10/05/2009 10:20 pm Kevin Wolf

block/raw: Add create_options for host_device

Today host_devices have a create function, so they also need a create_options
field to prevent qemu-img from complaining.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

80ee15a6 10/05/2009 05:32 pm Kevin Wolf

qcow2: Increase maximum cluster size to 2 MB

This patch increases the maximum qcow2 cluster size to 2 MB. Starting with 128k
clusters, L2 tables span 2 GB or more of virtual disk space, causing 32 bit
truncation and wraparound of signed integers. Therefore some variables need to...

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

c227f099 10/02/2009 12:12 am Anthony Liguori

Revert "Get rid of _t suffix"

In the very least, a change like this requires discussion on the list.

The naming convention is goofy and it causes a massive merge problem. Something
like this must be presented on the list first so people can provide input...

99a0949b 10/01/2009 09:45 pm malc

Get rid of _t suffix

Some not so obvious bits, slirp and Xen were left alone for the time

Signed-off-by: malc <>

6ab00cee 09/30/2009 09:45 pm Michael S. Tsirkin

vvfat: fix coding style nit

Put space between = and & when taking a pointer,
to avoid confusion with old-style "&=".

Signed-off-by: Michael S. Tsirkin <>
Signed-off-by: Blue Swirl <>

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

Fix signedness warnings on OpenSolaris

Signed-off-by: Blue Swirl <>

72cf2d4f 09/12/2009 10:36 am Blue Swirl

Fix sys-queue.h conflict for good

Problem: Our file sys-queue.h is a copy of the BSD file, but there are
some additions and it's not entirely compatible. Because of that, there have
been conflicts with system headers on BSD systems. Some hacks have been
introduced in the commits 15cc9235840a22c289edbe064a9b3c19c5f49896,...

6f1953c4 09/11/2009 06:19 pm Christoph Hellwig

block: use fdatasync instead of fsync if possible

If we are flushing the caches for our image files we only care about the
data (including the metadata required for accessing it) but not things
like timestamp updates. So try to use fdatasync instead of fsync to...

b2e12bc6 09/11/2009 06:19 pm Christoph Hellwig

block: add aio_flush operation

Instead stalling the VCPU while serving a cache flush try to do it
asynchronously. Use our good old helper thread pool to issue an
asynchronous fdatasync for raw-posix. Note that while Linux AIO
implements a fdatasync operation it is not useful for us because...

ea80b906 09/10/2009 01:31 am Kevin Wolf

qcow2: Fix metadata preallocation

The wrong version of the preallocation patch has been applied, so this is the
remaining diff.

We can't use truncate to grow the image file to the right size because we don't
know if metadata has been written after the last data cluster. In this case...

f214978a 09/10/2009 01:31 am Kevin Wolf

qcow2: Order concurrent AIO requests on the same unallocated cluster

When two AIO requests write to the same cluster, and this cluster is
unallocated, currently both requests allocate a new cluster and the second one
merges the first one when it is completed. This means an cluster allocation, a...

cc2040f8 09/09/2009 10:57 pm Stefan Weil

Fix spelling in comment.

The company which made Virtual PC was Connectix.
They use the magic string "conectix" in their disk images.

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

2000cbc5 08/29/2009 04:37 pm Blue Swirl

Fix gcc 3 warning about uninitialized variable

If nb_sectors is 0, cluster_offset will not be initialized.

Signed-off-by: Blue Swirl <>

e44bd6fc 08/28/2009 04:57 pm Stefan Weil

Don't compile aio code if CONFIG_LINUX_AIO is undefined

This patch fixes linker errors when building QEMU without Linux AIO support.

It is based on suggestions from malc and Kevin Wolf.

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

9ef91a67 08/28/2009 04:30 am Christoph Hellwig

raw-posix: refactor AIO support

Currently the raw-posix.c code contains a lot of knowledge about the
asynchronous I/O scheme that is mostly implemented in posix-aio-compat.c.
All this code does not really belong here and is getting a bit in the
way of implementing native AIO on Linux....

5c6c3a6c 08/28/2009 04:30 am Christoph Hellwig

raw-posix: add Linux native AIO support

Now that do have a nicer interface to work against we can add Linux native
AIO support. It's an extremly thing layer just setting up an iocb for
the io_submit system call in the submission path, and registering an...

a35e1c17 08/28/2009 04:30 am Kevin Wolf

qcow2: Metadata preallocation

This introduces a qemu-img create option for qcow2 which allows the metadata to
be preallocated, i.e. clusters are reserved in the refcount table and L1/L2
tables, but no data is written to them. Metadata is quite small, so this...

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
  • The size of the block map must be rounded to the next multiple...
5ec4d682 08/24/2009 04:46 pm Nathan Froyd

eliminate errors about unused results in block/vpc.c

These errors come up when compiling with gcc-4.3.3 and some older headers:

/scratch/froydnj/qemu.git/block/vpc.c: In function 'vpc_create':
/scratch/froydnj/qemu.git/block/vpc.c:514: error: value computed is not used...

4dd75c70 08/24/2009 04:46 pm Christoph Hellwig

make pthreads mandatory

As requested by Anthony make pthreads mandatory. This means we will always
have AIO available on posix hosts, and it will also allow enabling the I/O
thread unconditionally once it's ready.

Signed-off-by: Christoph Hellwig <>...

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)...
df3cee1a 08/01/2009 01:13 pm Blue Swirl

Fix Sparse warning about "expression using sizeof on a function"

Signed-off-by: Blue Swirl <>

71e72a19 07/27/2009 10:09 pm Juan Quintela


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

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

0bf9e31a 07/20/2009 08:19 pm Blue Swirl

Fix most warnings (errors with -Werror) when debugging is enabled

I used the following command to enable debugging:
perl -p -i -e 's/^\/\/#define DEBUG/#define DEBUG/g' * /* *//*

Signed-off-by: Blue Swirl <>

1e37d059 07/17/2009 01:28 am Stefan Weil

raw-posix: Handle errors in raw_create

In qemu-iotests, some large images are created using qemu-img.

Without checks for errors, qemu-img will just create an
empty image, and later read / write tests will fail.

With the patch, failures during image creation are detected...

45566e9c 07/16/2009 04:28 pm Christoph Hellwig

replace bdrv_{get, put}_buffer with bdrv_{load, save}_vmstate

The VM state offset is a concept internal to the image format. Replace
the old bdrv_{get,put}_buffer method that require an index into the
image file that is constructed from the VM state offset and an offset...

c53ffce9 07/10/2009 09:44 pm Kevin Wolf

qcow1: Fix qcow_aio_writev

Pass is_write = 1 to qcow_aio_setup when writing.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

3f6a3ee5 07/10/2009 09:44 pm Kevin Wolf

qcow2: Fix L1 table memory allocation

Contrary to what one could expect, the size of L1 tables is not cluster
aligned. So as we're writing whole sectors now instead of single entries,
we need to ensure that the L1 table in memory is large enough; otherwise...

1c27a8b3 07/10/2009 12:58 am G 3

Substitute O_DSYNC with O_SYNC or O_FSYNC when needed.

Signed-off-by: John Arbuckle <>
Signed-off-by: Anthony Liguori <>

c76f4952 07/10/2009 12:06 am Nolan

Allow adjustment of http block device's readahead size, via a new
":readahead=###:" suffix.

Signed-off-by: Nolan Leake <nolan <at>>
Signed-off-by: Anthony Liguori <>

1cec71e3 07/10/2009 12:06 am Anthony Liguori

Revert "support colon in filenames"

This reverts commit 707c0dbc97cddfe8d2441b8259c6c526d99f2dd8.

Signed-off-by: Anthony Liguori <>

0aa217e4 07/10/2009 12:06 am Kevin Wolf

qcow2: Make cache=writethrough default

The performance of qcow2 has improved meanwhile, so we don't need to
special-case it any more. Switch the default to write-through caching
like all other block drivers.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

22afa7b5 06/29/2009 10:18 pm Kevin Wolf

block-raw: Allow pread beyond the end of growable images

When using O_DIRECT, qcow2 snapshots didn't work any more for me. In the
process of creating the snapshot, qcow2 tries to pwrite some new information
(e.g. new L1 table) which will often end up being after the old end of the...

3b88e52b 06/29/2009 10:18 pm Kevin Wolf

qcow2: Cache refcount blocks during snapshot creation

The really time consuming part of snapshotting is to adjust the reference count
of all clusters. Currently after each adjusted cluster the refcount block is
written to disk.

Don't write each single byte immediately to disk but cache all writes to the...

707c0dbc 06/29/2009 09:50 pm Ram Pai

support colon in filenames

Problem: It is impossible to feed filenames with the character colon because
qemu interprets such names as a protocol. For example filename scsi:0, is
interpreted as a protocol by name "scsi".

This patch allows user to espace colon characters. For example the above...

14899cdf 06/29/2009 04:52 pm Filip Navara

Fix QCOW2 debugging code to compile again

Updated to use C99 comments.

Signed-off-by: Filip Navara <>
Signed-off-by: Anthony Liguori <>

19a3da7f 06/17/2009 06:27 pm Blue Swirl

Fix opening of read only raw images

Signed-off-by: Blue Swirl <>

9923e05e 06/16/2009 11:18 pm Kevin Wolf

update_refcount: Write complete sectors

When updating the refcount blocks in update_refcount(), write complete sectors
instead of updating single entries.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

9ccb258e 06/16/2009 11:18 pm Kevin Wolf

qcow2: Change default cluster size to 64k

Larger cluster sizes mean less metadata. This has been discussion a few times,
let's do it now. This turns 64k clusters on by default for new images.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

f7d0fe02 06/16/2009 11:18 pm Kevin Wolf

qcow2: Split out refcount handling

qcow2-refcount.c contains all functions which are related to cluster
allocation and management in the image file. A large part of this is the
reference counting of these clusters.

Also a header file qcow2.h is introduced which will contain the interface of...

45aba42f 06/16/2009 11:18 pm Kevin Wolf

qcow2: Split out guest cluster functions

qcow2-cluster.c contains all functions related to the management of guest
clusters, i.e. what the guest sees on its virtual disk. This code is about
mapping these guest clusters to host clusters in the image file using the...

c142442b 06/16/2009 11:18 pm Kevin Wolf

qcow2: Split out snapshot functions

qcow2-snapshot.c contains the code related to snapshotting.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

ed6ccf0f 06/16/2009 11:18 pm Kevin Wolf

qcow2: Rename global functions

The qcow2 source is now split into several more manageable files. During the
conversion quite some functions that were static before needed to be changed to
be global to make the source compile again.

We were lucky enough not to get name conflicts with these additional global...

6583e3c7 06/16/2009 11:18 pm Kevin Wolf

l2_allocate: Write complete sectors

When modifying the L1 table, l2_allocate() needs to write complete sectors
instead of single entries. The L1 table is already in memory, reading it from
disk in the block layer to align the request is wasted performance....

4c1612d9 06/16/2009 11:18 pm Kevin Wolf

alloc_cluster_link_l2: Write complete sectors

When updating the L2 tables in alloc_cluster_link_l2(), write complete
sectors instead of updating single entries.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

736d0c25 06/16/2009 11:18 pm Avi Kivity

raw-posix: open flags use BDRV_ namespace, not posix namespace

The flags argument to raw_common_open() contain bits defined by the BDRV_O_*
namespace, not the posix O_* namespace.

Adjust to use the correct constants.

Signed-off-by: Avi Kivity <>...

11a1feb6 06/16/2009 11:18 pm Avi Kivity

raw-posix: Remove O_RDWR when attempting to open a file read-only

When we open a file, we first attempt to open it read-write, then fall back
to read-only. Unfortunately we reuse the flags from the previous attempt,
so both attempts try to open the file with write permissions, and fail....

63ec93db 06/15/2009 03:04 pm Christoph Hellwig

raw-posix: cleanup ioctl methods

Rename raw_ioctl and raw_aio_ioctl to hdev_ioctl and hdev_aio_ioctl as they
are only used for the host device. Also only add them to the method table
for the cases where we need them (generic hdev if linux and linux CDROM)...

508c7cb3 06/15/2009 03:04 pm Christoph Hellwig

block: add bdrv_probe_device method

Add a bdrv_probe_device method to all BlockDriver instances implementing
host devices to move matching of host device types into the actual drivers.
For now we keep exacly the old matching behaviour based on the devices names,...

f3a5d3f8 06/15/2009 02:55 pm Christoph Hellwig

raw-posix: split hdev drivers

Instead of declaring one BlockDriver for all host devices declared one
for each type: a generic one for normal disk devices, a Linux floppy
driver and a CDROM driver for Linux and FreeBSD. This gets rid of a lot
of messy ifdefs and switching based on the type in the various removal...

90babde0 06/15/2009 02:53 pm Christoph Hellwig

raw-posix: add a raw_open_common helper

raw_open and hdev_open contain the same basic logic. Add a new
raw_open_common helper containing the guts of the open routine
and call it from raw_open and hdev_open.

We use the new open_flags field in BDRVRawState to allow passing...

0e1d8f4c 06/15/2009 02:53 pm Christoph Hellwig

raw-posix: always store open flags

Both the Linux floppy and the FreeBSD CDROM host device need to store
the open flags so that they can re-open the device later. Store the
open flags unconditionally to remove the ifdef mess and simply the
calling conventions for the later patches in the series....

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

f9e96436 05/28/2009 10:14 am Christoph Hellwig

vvfat: one more missing BlockDriver C99 initializer conversion

Signed-off-by: Christoph Hellwig <>
Signed-off-by: Anthony Liguori <>

c16b5a2c 05/27/2009 05:46 pm Christoph Hellwig

fully split aio_pool from BlockDriver

Now that we have a separate aio pool structure we can remove those
aio pool details from BlockDriver.

Every driver supporting AIO now needs to declare a static AIOPool
with the aiocb size and the cancellation method. This cleans up the...

ad53089b 05/27/2009 05:45 pm Christoph Hellwig

qcow: add qcow_aio_setup helper

[this one is required for [PATCH] fully split aio_pool from BlockDriver,
sorry for not sending it out earlier]

Add a qcow_aio_setup helper to qcow to shared common code between
the aio_readv and aio_writev methods. Based on the function with...

4099df58 05/27/2009 05:45 pm Christoph Hellwig

raw-posix: fix hdev_create

We do need hdev_create unconditionally on all platforms so that qemu-img
create support for host device works on all platforms.

Also relax the check to allow character devices in addition to block
devices. On many Unix platforms block devices have buffered block...

94c6d6d8 05/27/2009 05:45 pm Christoph Hellwig

fix raw_pread_aligned return value

raw_pread_aligned currently returns the raw return value from
lseek/read, which is always -1 in case of an error. But the
callers higher up the stack expect it to return the negated
errno just like raw_pwrite_aligned.

91a073a9 05/27/2009 05:45 pm Kevin Wolf

Drop bdrv_create2

This patch converts the remaining users of bdrv_create2 to bdrv_create and
removes the now unused function.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

a980c98c 05/27/2009 05:45 pm Kevin Wolf

qcow2: Update multiple refcounts at once

Don't write each single changed refcount block entry to the disk after it is
written, but update all entries of the block and write all of them at once.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

44ff42de 05/27/2009 05:45 pm Kevin Wolf

qcow2: Refactor update_refcount

This is a preparation patch with no functional changes. It moves the allocation
of new refcounts block to a new function and makes update_cluster_refcount (for
one cluster) call update_refcount (for multiple clusters) instead the other way...

ade40677 05/27/2009 05:45 pm Kevin Wolf

qcow/qcow2: Drop synchronous qcow_write()

There is only one (internal) user left and it can be switched to the normal
emulation provided in block.c

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

769ce76d 05/22/2009 06:50 pm Alexander Graf

Add HTTP protocol using curl v6

Currently Qemu can read from posix I/O and NBD. This patch adds a
third protocol to the game: HTTP.

In certain situations it can be useful to access HTTP data directly,
for example if you want to try out an http provided OS image, but...

73c632ed 05/22/2009 06:50 pm Kevin Wolf

qcow2: Allow different cluster sizes

Add an option to specify the cluster size of a newly created qcow2 image.
Default is 4k which is the same value that was hard-coded before.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

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

eb0b64f7 05/21/2009 04:40 am malc

Do not attempt to allocate sn_tab when there are no snapshots

This was caught by a7d27b536ffc0773028a90f14580552c0c3ddb2a which
aborted on this attempt, thanks to Alex Ivanov for report.

Signed-off-by: malc <>

dcc5e4a0 05/15/2009 01:03 am Anthony Liguori

Fix warning on WIN32

Signed-off-by: Anthony Liguori <>

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

Move block drivers into their own directory

Signed-off-by: Anthony Liguori <>