Statistics
| Branch: | Revision:

root / block.c @ 2a2af967

History | View | Annotate | Download (108.7 kB)

# Date Author Comment
f08f2dda 02/09/2012 05:17 pm Stefan Hajnoczi

block: add .bdrv_co_write_zeroes() interface

The ability to zero regions of an image file is a useful primitive for
higher-level features such as image streaming or zero write detection.

Image formats may support an optimized metadata representation instead...

79c053bd 02/09/2012 05:17 pm Stefan Hajnoczi

block: perform zero-detection during copy-on-read

Copy-on-Read populates the image file with data read from a backing
image. In order to avoid bloating the image file when all zeroes are
read we should scan the buffer and perform an optimized zero write...

e8a6bb9c 01/26/2012 03:49 pm Marcelo Tosatti

block: add bdrv_find_backing_image

Add bdrv_find_backing_image: given a BlockDriverState pointer, and an id,
traverse the backing image chain to locate the id.

Signed-off-by: Marcelo Tosatti <>
Signed-off-by: Stefan Hajnoczi <>...

2d3735d3 01/26/2012 12:45 pm Stefan Hajnoczi

block: check bdrv_in_use() before blockdev operations

Long-running block operations like block migration and image streaming
must have continual access to their block device. It is not safe to
perform operations like hotplug, eject, change, resize, commit, or...

470c0504 01/26/2012 12:45 pm Stefan Hajnoczi

block: make copy-on-read a per-request flag

Previously copy-on-read could only be enabled for all requests to a
block device. This means requests coming from the guest as well as
QEMU's internal requests would perform copy-on-read when enabled.

For image streaming we want to support finer-grained behavior than just...

eeec61f2 01/26/2012 12:45 pm Stefan Hajnoczi

block: add BlockJob interface for long-running operations

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

3f3aace8 12/15/2011 01:40 pm Paolo Bonzini

block: avoid useless checks on acb->bh

Coverity is confused by this "if" and reports leaks on acb->bh.
The bottom half is always deleted before releasing the AIOCB,
in either bdrv_aio_cancel_em or bdrv_aio_bh_cb.

Signed-off-by: Paolo Bonzini <>...

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) { ... }...

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

block: simplify failure handling for bdrv_aio_multiwrite

Now that early failure of bdrv_aio_writev is not possible anymore,
mcb->num_requests can be set before the loop starts.

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

922453bc 12/05/2011 03:56 pm Stefan Hajnoczi

block: convert qemu_aio_flush() calls to bdrv_drain_all()

Many places in QEMU call qemu_aio_flush() to complete all pending
asynchronous I/O. Most of these places actually want to drain all block
requests but there is no block layer API to do so.

This patch introduces the bdrv_drain_all() API to wait for requests...

5f8b6491 12/05/2011 03:52 pm Stefan Hajnoczi

block: wait_for_overlapping_requests() deadlock detection

Debugging a reentrant request deadlock was fun but in the future we need
a quick and obvious way of detecting such bugs. Add an assert that
checks we are not about to deadlock when waiting for another request....

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

block: implement bdrv_co_is_allocated() boundary cases

Cases beyond the end of the disk image are only implemented for block
drivers that do not provide .bdrv_co_is_allocated(). It's worth making
these cases generic so that block drivers that do implement...

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

block: add request tracking

The block layer does not know about pending requests. This information
is necessary for copy-on-read since overlapping requests must be
serialized to prevent races that corrupt the image.

The BlockDriverState gets a new tracked_request list field which...

53fec9d3 12/05/2011 03:51 pm Stefan Hajnoczi

block: add interface to toggle copy-on-read

The bdrv_enable_copy_on_read()/bdrv_disable_copy_on_read() functions can
be used to programmatically enable or disable copy-on-read for a block
device. Later patches add the actual copy-on-read logic.

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

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

block: wait for overlapping requests

When copy-on-read is enabled it is necessary to wait for overlapping
requests before issuing new requests. This prevents races between the
copy-on-read and a write request.

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

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

block: request overlap detection

Detect overlapping requests and remember to align to cluster boundaries
if the image format uses them. This assumes that allocating I/O is
performed in cluster granularity - which is true for qcow2, qed, etc.

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

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

block: core copy-on-read logic

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

6aebab14 12/05/2011 03:51 pm Stefan Hajnoczi

block: drop .bdrv_is_allocated() interface

Now that all block drivers have been converted to
.bdrv_co_is_allocated() we can drop .bdrv_is_allocated().

Note that the public bdrv_is_allocated() interface is still available
but is in fact a synchronous wrapper around .bdrv_co_is_allocated()....

060f51c9 12/05/2011 03:51 pm Stefan Hajnoczi

block: add bdrv_co_is_allocated() interface

This patch introduces the public bdrv_co_is_allocated() interface which
can be used to query image allocation status while the VM is running.

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

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

block: use public bdrv_is_allocated() interface

There is no need for bdrv_commit() to use the BlockDriver
.bdrv_is_allocated() interface directly. Converting to the public
interface gives us the freedom to drop .bdrv_is_allocated() entirely in
favor of a new .bdrv_co_is_allocated() in the future....

376ae3f1 12/05/2011 03:51 pm Stefan Hajnoczi

block: add .bdrv_co_is_allocated()

This patch adds the .bdrv_co_is_allocated() interface which is identical
to .bdrv_is_allocated() but runs in coroutine context. Running in
coroutine context implies that other coroutines might be performing I/O
at the same time. Therefore it must be safe to run while the following...

0563e191 12/05/2011 03:51 pm Zhi Yong Wu

block: add the blockio limits command line support

Signed-off-by: Zhi Yong Wu <>
Signed-off-by: Stefan Hajnoczi <>
Signed-off-by: Kevin Wolf <>

98f90dba 12/05/2011 03:51 pm Zhi Yong Wu

block: add I/O throttling algorithm

Signed-off-by: Zhi Yong Wu <>
Signed-off-by: Stefan Hajnoczi <>
Signed-off-by: Kevin Wolf <>

727f005e 12/05/2011 03:51 pm Zhi Yong Wu

hmp/qmp: add block_set_io_throttle

Signed-off-by: Zhi Yong Wu <>
Signed-off-by: Stefan Hajnoczi <>
Signed-off-by: Kevin Wolf <>

0f15423c 11/21/2011 10:58 pm Anthony Liguori

block: allow migration to work with image files (v3)

Image files have two types of data: immutable data that describes things like
image size, backing files, etc. and mutable data that includes offset and
reference count tables.

Today, image formats aggressively cache mutable data to improve performance. In...

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

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

block: Introduce bdrv_co_flush_to_os

qcow2 has a writeback metadata cache, so flushing a qcow2 image actually
consists of writing back that cache to the protocol and only then flushes the
protocol in order to get everything stable on disk.

This introduces a separate bdrv_co_flush_to_os to reflect the split....

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

block: Make cache=unsafe flush to the OS

cache=unsafe completely ignored bdrv_flush, because flushing the host disk
costs a lot of performance. However, this means that qcow2 images (and
potentially any other format) can lose data even after the guest has issued a...

025ccaa7 11/11/2011 03:02 pm Paolo Bonzini

block: add eject request callback

Recent versions of udev always keep the tray locked so that the kernel
can observe "eject request" events (aka tray button presses) even on
discs that aren't mounted. Add support for these events in the ATAPI
and SCSI cd drive device models....

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

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

Conflicts:
block/vmdk.c

03f541bd 10/28/2011 08:25 pm Stefan Hajnoczi

block: reinitialize across bdrv_close()/bdrv_open()

Several BlockDriverState fields are not being reinitialized across
bdrv_close()/bdrv_open(). Make sure they are reset to their default
values.

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

3574c608 10/28/2011 08:25 pm Kevin Wolf

block: Remove dead code

Signed-off-by: Kevin Wolf <>

2b572816 10/28/2011 08:25 pm Kevin Wolf

block: Fix bdrv_open use after free

tmp_filename was used outside the block it was defined in, i.e. after it went
out of scope. Move its declaration to the top level.

Signed-off-by: Kevin Wolf <>

e7c63796 10/28/2011 08:25 pm Stefan Hajnoczi

block: set bs->read_only before .bdrv_open()

Several block drivers set bs->read_only in .bdrv_open() but
block.c:bdrv_open_common() clobbers its value. Additionally, QED uses
bdrv_is_read_only() in .bdrv_open() to decide whether to perform
consistency checks....

d6bf279e 10/27/2011 04:48 pm Luiz Capitulino

block: iostatus: Drop BDRV_IOS_INVAL

A future commit will convert bdrv_info() to the QAPI and it won't
provide IOS_INVAL.

Luckily all we have to do is to add a new 'iostatus_enabled'
member to BlockDriverState and use it instead.

Signed-off-by: Luiz Capitulino <>

58e21ef5 10/27/2011 04:48 pm Luiz Capitulino

block: Rename the BlockIOStatus enum values

The biggest change is to rename its prefix from BDRV_IOS to
BLOCK_DEVICE_IO_STATUS.

Next commit will convert the query-block command to the QAPI
and that's how the enumeration is going to be generated.

Signed-off-by: Luiz Capitulino <>

b2023818 10/27/2011 04:48 pm Luiz Capitulino

qapi: Convert query-block

Signed-off-by: Anthony Liguori <>
Signed-off-by: Luiz Capitulino <>

f11f57e4 10/27/2011 04:48 pm Luiz Capitulino

qapi: Convert query-blockstats

Signed-off-by: Anthony Liguori <>
Signed-off-by: Luiz Capitulino <>

f795e743 10/27/2011 04:48 pm Luiz Capitulino

Drop qemu-objects.h from modules that don't require it

Previous commits dropped most qobjects usage from qemu modules
(now they are a low level interface used by the QAPI). However,
some modules still include the qemu-objects.h header file.

This commit drops qemu-objects.h from some of those modules...

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

6db39ae2 10/21/2011 06:34 pm Paolo Bonzini

block: change discard to co_discard

Since coroutine operation is now mandatory, convert both bdrv_discard
implementations to coroutines. For qcow2, this means taking the lock
around the operation. raw-posix remains synchronous.

The bdrv_discard callback is then unused and can be eliminated....

07f07615 10/21/2011 06:34 pm Paolo Bonzini

block: unify flush implementations

Add coroutine support for flush and apply the same emulation that
we already do for read/write. bdrv_aio_flush is simplified to always
go through a coroutine.

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

4265d620 10/21/2011 06:34 pm Paolo Bonzini

block: add bdrv_co_discard and bdrv_aio_discard support

This similarly adds support for coroutine and asynchronous discard.

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

35246a68 10/21/2011 06:34 pm Paolo Bonzini

block: rename bdrv_co_rw_bh

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

8c5873d6 10/14/2011 06:31 pm Stefan Hajnoczi

block: drop emulation functions that use coroutines

Block drivers that implement coroutine functions used to get sync and
aio wrappers. This is no longer necessary since all request processing
now happens in a coroutine. If a block driver implements the coroutine...

f8c35c1d 10/14/2011 06:31 pm Stefan Hajnoczi

block: drop .bdrv_read()/.bdrv_write() emulation

There is no need to emulate .bdrv_read()/.bdrv_write() since these
interfaces are only called if aio and coroutine interfaces are not
present. All valid BlockDrivers must implement either sync, aio, or
coroutine interfaces....

09f085d5 10/14/2011 06:31 pm Stefan Hajnoczi

block: drop bdrv_has_async_rw()

Commit cd74d83345e0e3b708330ab8c4cd9111bb82cda6 ("block: switch
bdrv_read()/bdrv_write() to coroutines") removed the bdrv_has_async_rw()
callers. This patch removes bdrv_has_async_rw() since it is no longer
used.

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

b2a61371 10/13/2011 04:02 pm Stefan Hajnoczi

block: switch bdrv_aio_readv() to coroutines

More sync, aio, and coroutine unification. Make bdrv_aio_readv() go
through coroutine request processing.

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

6b7cb247 10/13/2011 04:02 pm Stefan Hajnoczi

block: mark blocks dirty on coroutine write completion

The aio write operation marks blocks dirty when the write operation
completes. The coroutine write operation marks blocks dirty before
issuing the write operation.

It seems safest to mark the block dirty when the operation completes so...

1a6e115b 10/13/2011 04:02 pm Stefan Hajnoczi

block: switch bdrv_aio_writev() to coroutines

More sync, aio, and coroutine unification. Make bdrv_aio_writev() go
through coroutine request processing.

Remove the dirty block callback mechanism which was needed only for aio
processing and can be done more naturally in coroutine context....

1ed20acf 10/13/2011 04:02 pm Stefan Hajnoczi

block: directly invoke .bdrv_* from emulation functions

The emulation functions which supply default BlockDriver .bdrv_*()
functions given another implemented .bdrv_*() function should not use
public bdrv_*() interfaces. This patch ensures they invoke .bdrv_*()...

c5fbe571 10/13/2011 04:02 pm Stefan Hajnoczi

block: split out bdrv_co_do_readv() and bdrv_co_do_writev()

The public interface for I/O in coroutine context is bdrv_co_readv() and
bdrv_co_writev(). Split out the request processing code into
bdrv_co_do_readv() and bdrv_co_writev() so that it can be called...

1c9805a3 10/13/2011 04:02 pm Stefan Hajnoczi

block: switch bdrv_read()/bdrv_write() to coroutines

The bdrv_read()/bdrv_write() functions call .bdrv_read()/.bdrv_write().
They should go through bdrv_co_do_readv() and bdrv_co_do_writev()
instead in order to unify request processing code across sync, aio, and...

a652d160 10/13/2011 04:02 pm Stefan Hajnoczi

block: directly invoke .bdrv_aio_*() in bdrv_co_io_em()

We will unify block layer request processing across sync, aio, and
coroutines and this means a .bdrv_co_*() emulation function should not
call back into the public interface. There's no need here, just call...

f04ef601 10/11/2011 10:42 am Luiz Capitulino

QMP: query-status: Add 'io-status' key

Contains the I/O status for the given device. The key is only present
if the device supports it and the VM is configured to stop on errors.

Please, check the documentation being added in this commit for more
information....

d2078cc2 10/11/2011 10:42 am Luiz Capitulino

HMP: Print 'io-status' information

Signed-off-by: Luiz Capitulino <>
Reviewed-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

28a7282a 10/11/2011 10:41 am Luiz Capitulino

block: Keep track of devices' I/O status

This commit adds support to the BlockDriverState type to keep track
of devices' I/O status.

There are three possible status: BDRV_IOS_OK (no error), BDRV_IOS_ENOSPC
(no space error) and BDRV_IOS_FAILED (any other error). The distinction...

59370aaa 10/03/2011 12:56 pm Stefan Hajnoczi

trace: add arguments to bdrv_co_io_em() trace event

It is useful to know the BlockDriverState as well as the
sector_num/nb_sectors of an emulated .bdrv_co_*() request.

Signed-off-by: Stefan Hajnoczi <>

28dcee10 10/03/2011 12:55 pm Stefan Hajnoczi

trace: trace bdrv_open_common()

bdrv_open_common() is a useful point to trace since it reveals the
filename and block driver for a given BlockDriverState.

Signed-off-by: Stefan Hajnoczi <>

7b6f9300 09/12/2011 04:17 pm Markus Armbruster

block: New bdrv_set_buffer_alignment()

Device models should be able to set it without an unclean include of
block_int.h.

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

29e05f20 09/12/2011 04:17 pm Markus Armbruster

block: Reset buffer alignment on detach

BlockDriverState member buffer_alignment is initially 512. The device
model may set them, with bdrv_set_buffer_alignment(). If the device
model gets detached (hot unplug), the device's alignment is left
behind. Only okay because device hot unplug automatically destroys...

7d4b4ba5 09/12/2011 04:17 pm Markus Armbruster

block: New change_media_cb() parameter load

To let device models distinguish between eject and load.

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

2c6942fa 09/12/2011 04:17 pm Markus Armbruster

block: Clean up remaining users of "removable"

BlockDriverState member removable is a confused mess. It is true when
an ide-cd, scsi-cd or floppy qdev is attached, or when the
BlockDriverState was created with -drive if={floppy,sd} or -drive
if={ide,scsi,xen,none},media=cdrom ("created removable"), except when...

9e6a4c91 09/12/2011 04:17 pm Markus Armbruster

block: Drop BlockDriverState member removable

It's a confused mess (see previous commit). No users remain.

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

e4def80b 09/12/2011 04:17 pm Markus Armbruster

block: Show whether the virtual tray is open in info block

Need to ask the device, so this requires new BlockDevOps member
is_tray_open().

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

a1aff5bf 09/12/2011 04:17 pm Markus Armbruster

block: Revert entanglement of bdrv_is_inserted() with tray status

Commit 4be9762a changed bdrv_is_inserted() to fail when the tray is
open. Unfortunately, there are two different kinds of users, with
conflicting needs.

1. Device models using bdrv_eject(), currently ide-cd and scsi-cd....

22cf56c4 09/12/2011 04:17 pm Markus Armbruster

block: Drop tray status tracking, no longer used

Commit 4be9762a is now completely redone.

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

fdec4404 09/12/2011 04:17 pm Markus Armbruster

block: Leave enforcing tray lock to device models

The device model knows best when to accept the guest's eject command.
No need to detour through the block layer.

bdrv_eject() can't fail anymore. Make it void.

Signed-off-by: Markus Armbruster <>...

f107639a 09/12/2011 04:17 pm Markus Armbruster

block: Drop medium lock tracking, ask device models instead

Requires new BlockDevOps member is_medium_locked(). Implement for IDE
and SCSI CD-ROMs.

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

025e849a 09/12/2011 04:17 pm Markus Armbruster

block: Rename bdrv_set_locked() to bdrv_lock_medium()

While there, make the locked parameter bool.

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

c602a489 09/06/2011 12:24 pm Markus Armbruster

block: Clean up bdrv_flush_all()

Change (!bdrv_is_removable(bs) || bdrv_is_inserted(bs)) to just
bdrv_is_inserted(). Rationale:

The value of bdrv_is_removable(bs) matters only when
bdrv_is_inserted(bs) is false.
bdrv_is_inserted(bs) is true when bs is open (bs->drv != NULL) and...
07b70bfb 09/06/2011 12:24 pm Markus Armbruster

savevm: Include writable devices with removable media

savevm and loadvm silently ignore block devices with removable media,
such as floppies and SD cards. Rolling back a VM to a previous
checkpoint will not roll back writes to block devices with removable...

8e49ca46 09/06/2011 12:24 pm Markus Armbruster

block: Leave tracking media change to device models

hw/fdc.c is the only one that cares.

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

fa879d62 09/06/2011 12:23 pm Markus Armbruster

block: Attach non-qdev devices as well

For now, this just protects against programming errors like having the
same drive back multiple non-qdev devices, or untimely bdrv_delete().
Later commits will add other interesting uses.

While there, rename BlockDriverState member peer to dev, bdrv_attach()...

0e49de52 09/06/2011 12:23 pm Markus Armbruster

block: Generalize change_cb() to BlockDevOps

So we can more easily add device model callbacks.

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

145feb17 09/06/2011 12:23 pm Markus Armbruster

block: Split change_cb() into change_media_cb(), resize_cb()

Multiplexing callbacks complicates matters needlessly.

Signed-off-by: Markus Armbruster <>
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/'...

c488c7f6 08/26/2011 07:18 pm Christoph Hellwig

block: latency accounting

Account the total latency for read/write/flush requests. This allows
management tools to average it based on a snapshot of the nr ops
counters and allow checking for SLAs or provide statistics.

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

a597e79c 08/25/2011 07:18 pm Christoph Hellwig

block: explicit I/O accounting

Decouple the I/O accounting from bdrv_aio_readv/writev/flush and
make the hardware models call directly into the accounting helpers.

This means:
- we do not count internal requests from image formats in addition
to guest originating I/O...

e8045d67 08/23/2011 06:41 pm Christoph Hellwig

block: include flush requests in info blockstats

Signed-off-by: Christoph Hellwig <>
Signed-off-by: Kevin Wolf <>

c3993cdc 08/23/2011 03:15 pm Stefan Hajnoczi

block: parse cache mode flags in a single place

This patch introduces bdrv_parse_cache_flags() which sets open flags
given a cache mode. Previously this was duplicated in blockdev.c and
qemu-img.c.

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

92196b2f 08/23/2011 03:15 pm Stefan Hajnoczi

block: add cache=directsync parameter to -drive

This patch adds -drive cache=directsync for O_DIRECT | O_SYNC host file
I/O with no disk write cache presented to the guest.

This mode is useful when guests may not be sending flushes when
appropriate and therefore leave data at risk in case of power failure....

d62b5dea 08/22/2011 06:17 pm Robert Wang

fix code format

Fix code format to make checkpatch.pl happy.

Signed-off-by: Robert Wang <>
Signed-off-by: Anthony Liguori <>

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

e7a8a783 08/04/2011 12:27 pm Kevin Wolf

block: Use bdrv_co_* instead of synchronous versions in coroutines

If we're already in a coroutine, there is no reason to use the synchronous
version of block layer functions when a coroutine one exists. This makes
bdrv_read/write/flush use bdrv_co_* when used inside a coroutine....

384acbf4 08/02/2011 04:53 pm Kevin Wolf

async: Remove AsyncContext

The purpose of AsyncContexts was to protect qcow and qcow2 against reentrancy
during an emulated bdrv_read/write (which includes a qemu_aio_wait() call and
can run AIO callbacks of different requests if it weren't for AsyncContexts)....

da1fa91d 08/02/2011 04:53 pm Kevin Wolf

block: Add bdrv_co_readv/writev

Add new block driver callbacks bdrv_co_readv/writev, which work on a
QEMUIOVector like bdrv_aio_*, but don't need a callback. The function may only
be called inside a coroutine, so a block driver implementing this interface can...

68485420 08/02/2011 04:53 pm Kevin Wolf

block: Emulate AIO functions with bdrv_co_readv/writev

Use the bdrv_co_readv/writev callbacks to implement bdrv_aio_readv/writev and
bdrv_read/write if a driver provides the coroutine version instead of the
synchronous or AIO version.

Signed-off-by: Kevin Wolf <>

f9f05dc5 08/02/2011 04:53 pm Kevin Wolf

block: Add bdrv_co_readv/writev emulation

In order to be able to call bdrv_co_readv/writev for drivers that don't
implement the functions natively, add an emulation that uses the AIO functions
to implement them.

Signed-off-by: Kevin Wolf <>

5bf3f8e4 08/01/2011 01:10 pm Frediano Ziglio

block: Removed unused function bdrv_write_sync

Signed-off-by: Frediano Ziglio <>
Signed-off-by: Kevin Wolf <>

822e1cd1 08/01/2011 01:10 pm Markus Armbruster

block: Make BlockDriver method bdrv_eject() return void

Callees always return 0, except for FreeBSD's cdrom_eject(), which
returns -ENOTSUP when the device is in a terminally wedged state.

The only caller is bdrv_eject(), and it maps -ENOTSUP to 0 since...

49aa46bb 08/01/2011 01:10 pm Markus Armbruster

block: Don't let locked flag prevent medium load

Commit aea2a33c made bdrv_eject() obey the locked flag. Correct for
medium eject (eject_flag set), incorrect for medium load (eject_flag
clear). See MMC-5 Table 341 "Actions for Lock/Unlock/Eject".

Signed-off-by: Markus Armbruster <>...

a19712b0 08/01/2011 01:09 pm Markus Armbruster

block: Reset device model callbacks on detach

BlockDriverState members change_cb and change_opaque are initially
null. The device model may set them, with bdrv_set_change_cb(). If
the device model gets detached (hot unplug), they're left dangling.
Only safe because device hot unplug automatically destroys the...

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

d220894e 06/08/2011 12:56 pm Kevin Wolf

bdrv_img_create: Fix segfault

Block drivers that don't support creating images don't have a size option. Fail
gracefully instead of segfaulting when trying to access the option's value.

Signed-off-by: Kevin Wolf <>

a6599793 06/08/2011 11:39 am Christoph Hellwig

block: clarify the meaning of BDRV_O_NOCACHE

Change BDRV_O_NOCACHE to only imply bypassing the host OS file cache,
but no writeback semantics. All existing callers are changed to also
specify BDRV_O_CACHE_WB to give them writeback semantics.

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

8d278467 05/19/2011 11:26 am Markus Armbruster

block: Remove type hint, it's guest matter, doesn't belong here

No users of bdrv_get_type_hint() left. bdrv_set_type_hint() can make
the media removable by side effect. Make that explicit.

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

d8aeeb31 05/19/2011 11:26 am Markus Armbruster

block QMP: Deprecate query-block's "type", drop info block's "type="

query-block's specification documents response member "type" with
values "hd", "cdrom", "floppy", "unknown".

Its value is unreliable: a block device used as floppy has type
"floppy" if created with if=floppy, but type "hd" if created with...

a1c7273b 05/08/2011 12:02 pm Stefan Weil

Fix typos in comments and code (occured -> occurred and related)

The code changed here is an unused data type name (evt_flush_occurred).

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

ebabb67a 05/06/2011 10:19 am Stefan Weil

Fix typo in code and comments

Replace writeable -> writable

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