Statistics
| Branch: | Revision:

root / block.c @ de9c0cec

History | View | Annotate | Download (126.6 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 <>

de9c0cec 03/15/2013 05:07 pm Kevin Wolf

block: Add options QDict to bdrv_open() prototype

It doesn't do anything yet except storing the options QDict in the
BlockDriverState.

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

272d2d8e 03/04/2013 10:54 am Jeff Cody

block: for HMP commit() operations on 'all', skip non-COW drives

During a commit of 'all' using the HMP non-live commit, the operation
is aborted and returns error on the first error enountered. When
non-COW drives are in use (e.g. ejected floppy, cdrom, or drives without...

9e8f1835 02/22/2013 10:29 pm Paolo Bonzini

block: implement BDRV_O_UNMAP

It is better to present homogeneous hardware independent of the storage
technology that is chosen on the host, hence we make discard a host
parameter; the user can choose whether to pass it down to the image
format and protocol, or to ignore it....

9a665b2b 02/22/2013 10:21 pm Peter Lieven

block: complete all IOs before .bdrv_truncate

bdrv_truncate() invalidates the bdrv_check_request() result for
in-flight requests, so there should better be none.

Cc:
Signed-off-by: Peter Lieven <>
Reported-by: Kevin Wolf <>...

b35b2bba 02/22/2013 10:21 pm Miroslav Rezanina

block: Add synchronous wrapper for bdrv_co_is_allocated_above

There's no synchronous wrapper for bdrv_co_is_allocated_above function
so it's not possible to check for sector allocation in an image with
a backing file.

Signed-off-by: Miroslav Rezanina <>...

f382d43a 02/22/2013 10:21 pm Miroslav Rezanina

qemu-img: Add "Quiet mode" option

There can be a need to turn output to stdout off. This patch adds a -q option
that enable "Quiet mode". In Quiet mode, only errors are printed out.

Signed-off-by: Miroslav Rezanina <>
Reviewed-by: Kevin Wolf <>...

63ba17d3 02/01/2013 03:58 pm Vishvananda Ishaya

block: Fix is_allocated_above with resized files

In an image chain, if the base image is smaller than the current
image, we need to make sure to use the current images count of
unallocated blocks once we get to the end of the base image. Without
this change the code will return 0 blocks when it gets to the end...

50717e94 01/25/2013 07:18 pm Paolo Bonzini

block: allow customizing the granularity of the dirty bitmap

Reviewed-by: Eric Blake <>
Signed-off-by: Paolo Bonzini <>
Signed-off-by: Kevin Wolf <>

8f0720ec 01/25/2013 07:18 pm Paolo Bonzini

block: implement dirty bitmap using HBitmap

This actually uses the dirty bitmap in the block layer, and converts
mirroring to use an HBitmapIter.

Reviewed-by: Laszlo Ersek <> (except block/mirror.c parts)
Reviewed-by: Eric Blake <>...

343bded4 01/25/2013 07:18 pm Paolo Bonzini

block: make round_to_clusters public

This is needed in the following patch.

Reviewed-by: Laszlo Ersek <>
Reviewed-by: Eric Blake <>
Signed-off-by: Paolo Bonzini <>
Signed-off-by: Kevin Wolf <>

acc906c6 01/25/2013 07:18 pm Paolo Bonzini

block: return count of dirty sectors, not chunks

Reviewed-by: Laszlo Ersek <>
Reviewed-by: Eric Blake <>
Signed-off-by: Paolo Bonzini <>
Signed-off-by: Kevin Wolf <>

df702c9b 01/15/2013 11:03 am Paolo Bonzini

block: clear dirty bitmap when discarding

Note that resetting bits in the dirty bitmap is done before actually
processing the request. Writes, instead, set bits after the request
is completed.

This way, when there are concurrent write and discard requests, the...

029d091e 01/15/2013 10:24 am Peter Lieven

block: fix initialization in bdrv_io_limits_enable()

bdrv_io_limits_enable() starts a new slice, but does not set io_base
correctly for that slice.

Here is how io_base is used:

bytes_base  = bs->nr_bytes[is_write] - bs->io_base.bytes[is_write];
bytes_res = (unsigned) nb_sectors * BDRV_SECTOR_SIZE;...
8e895599 01/14/2013 11:06 am Paolo Bonzini

block: do not probe zero-sized disks

A blank CD or DVD is visible as a zero-sized disks. Probing such
disks will lead to an EIO and a failure to start the VM. Treating
them as raw is a better solution.

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

c53b1c51 01/14/2013 11:06 am Stefan Hajnoczi

block: make qiov_is_aligned() public

The qiov_is_aligned() function checks whether a QEMUIOVector meets a
BlockDriverState's alignment requirements. This is needed by
virtio-blk-data-plane so:

1. Move the function from block/raw-posix.c to block/block.c....

eb7ff6fb 01/11/2013 10:44 am Stefan Weil

Replace remaining gmtime, localtime by gmtime_r, localtime_r

This allows removing of MinGW specific code and improves
reentrancy for POSIX hosts.

[Removed unused ret variable in qemu_get_timedate() to fix warning:
vl.c: In function ‘qemu_get_timedate’:
vl.c:451:16: error: variable ‘ret’ set but not used [-Werror=unused-but-set-variable]...

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

83c9089e 12/19/2012 09:31 am Paolo Bonzini

monitor: move include files to include/monitor/

Signed-off-by: Paolo Bonzini <>

7b1b5d19 12/19/2012 09:31 am Paolo Bonzini

qapi: move include files to include/qobject/

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

41c695c7 12/12/2012 01:33 pm Kevin Wolf

qemu-io: Add AIO debugging commands

This makes the blkdebug suspend/resume functionality available in
qemu-io. Use it like this:

$ ./qemu-io blkdebug::/tmp/test.qcow2
qemu-io> break write_aio req_a
qemu-io> aio_write 0 4k
qemu-io> blkdebug: Suspended request 'req_a'...
71c79813 12/11/2012 12:05 pm Luiz Capitulino

block: bdrv_img_create(): add Error ** argument

This commit adds an Error ** argument to bdrv_img_create() and set it
appropriately on error.

Callers of bdrv_img_create() pass NULL for the new argument and still
rely on bdrv_img_create()'s return value. Next commits will change...

d92ada22 12/11/2012 12:05 pm Luiz Capitulino

block: bdrv_img_create(): drop unused error handling code

Signed-off-by: Luiz Capitulino <>
Signed-off-by: Kevin Wolf <>

d318aea9 12/11/2012 12:04 pm Kevin Wolf

block: Improve bdrv_aio_co_cancel_em

Instead of waiting for all requests to complete, wait just for the
specific request that should be cancelled.

Signed-off-by: Kevin Wolf <>

7b272452 12/11/2012 12:04 pm Kevin Wolf

block: Factor out bdrv_open_flags

Signed-off-by: Kevin Wolf <>

f500a6d3 12/11/2012 12:04 pm Kevin Wolf

block: Avoid second open for format probing

This fixes problems that are caused by the additional open/close cycle
of the existing format probing, for example related to qemu-nbd without
-t option or file descriptor passing.

Signed-off-by: Kevin Wolf <>

89c9bc3d 11/24/2012 09:54 pm Stefan Weil

block: Fix regression for MinGW (assertion caused by short string)

The local string tmp_filename is passed to function get_tmp_filename
which expects a string with minimum size MAX_PATH for w32 hosts.

MAX_PATH is 260 and PATH_MAX is 259, so tmp_filename was too short....

d37c975f 11/14/2012 07:19 pm Stefan Hajnoczi

aio: use g_slice_alloc() for AIOCB pooling

AIO control blocks are frequently acquired and released because each aio
request involves at least one AIOCB. Therefore, we pool them to avoid
heap allocation overhead.

The problem with the freelist approach in AIOPool is thread-safety. If...

d7331bed 11/14/2012 07:19 pm Stefan Hajnoczi

aio: rename AIOPool to AIOCBInfo

Now that AIOPool no longer keeps a freelist, it isn't really a "pool"
anymore. Rename it to AIOCBInfo and make it const since it no longer
needs to be modified.

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

90c45b30 10/29/2012 05:34 pm Anthony Liguori

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

  • kwolf/for-anthony: (32 commits)
    osdep: Less restrictive F_SEFL in qemu_dup_flags()
    qemu-iotests: add testcases for mirroring on-source-error/on-target-error
    qmp: add pull_event function...
3bd293c3 10/24/2012 11:26 am Paolo Bonzini

iostatus: forward block_job_iostatus_reset to block job

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

80168bff 10/24/2012 11:26 am Luiz Capitulino

block: bdrv_create(): don't leak cco.filename on error

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

ac84adac 10/24/2012 11:26 am Paolo Bonzini

block: add bdrv_query_info

Extract it out of the implementation of "info block".

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

9887b616 10/24/2012 11:26 am Paolo Bonzini

block: add bdrv_query_stats

qmp_query_blockstat cannot have errors, remove the Error argument and
create a new public function bdrv_query_stats out of it.

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

9156df12 10/24/2012 11:26 am Paolo Bonzini

block: add bdrv_open_backing_file

Mirroring runs without the backing file so that it can be copied outside
QEMU. However, we need to add it at the time the job is completed and
QEMU switches to the target. Factor out the common bits of opening an
image and completing a mirroring operation....

1755da16 10/24/2012 11:26 am Paolo Bonzini

block: introduce new dirty bitmap functionality

Assert that write_compressed is never used with the dirty bitmap.
Setting the bits early is wrong, because a coroutine might concurrently
examine them and copy incomplete data from the source.

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

b9a9b3a4 10/24/2012 11:26 am Paolo Bonzini

block: export dirty bitmap information in query-block

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

b1b1d783 10/24/2012 11:26 am Jeff Cody

block: make bdrv_find_backing_image compare canonical filenames

Currently, bdrv_find_backing_image compares bs->backing_file with
what is passed in as a backing_file name. Mismatches may occur,
however, when bs->backing_file and backing_file are not both...

3cbc002c 10/23/2012 11:39 pm Paolo Bonzini

block: prepare code for adding block notifiers

There is no reason in principle to skip job cancellation and draining
of pending I/O when there is no medium in the disk. Do these unconditionally,
which also prepares the code for the next patch.

Signed-off-by: Paolo Bonzini <>

d7d512f6 10/23/2012 11:39 pm Paolo Bonzini

block: add close notifiers

The first user of close notifiers will be the embedded NBD server.
It would be possible to use them to do some of the ad hoc processing
(e.g. for block jobs and I/O limits) that is currently done by
bdrv_close.

Acked-by: Kevin Wolf <>...

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

block: avoid buffer overrun by using pstrcpy, not strncpy

Also, use PATH_MAX, rather than the arbitrary 1024.
Using PATH_MAX is more consistent with other filename-related
variables in this file, like backing_filename and tmp_filename.

Acked-by: Kevin Wolf <>...

1ceee0d5 09/28/2012 08:40 pm Paolo Bonzini

iostatus: change is_read to a bool

Do this while we are touching this part of the code, before introducing
more uses of "int is_read".

Signed-off-by: Paolo Bonzini <>
Reviewed-by: Eric Blake <>
Signed-off-by: Kevin Wolf <>

3e1caa5f 09/28/2012 08:40 pm Paolo Bonzini

iostatus: reorganize io error code

Move the common part of IDE/SCSI/virtio error handling to the block
layer. The new function bdrv_error_action subsumes all three of
bdrv_emit_qmp_error_event, vm_stop, bdrv_iostatus_set_err.

The same scheme will be used for errors in block jobs....

32c81a4a 09/28/2012 08:40 pm Paolo Bonzini

block: introduce block job error

The following behaviors are possible:

'report': The behavior is the same as in 1.1. An I/O error,
respectively during a read or a write, will complete the job immediately
with an error code.

'ignore': An I/O error, respectively during a read or a write, will be...

92aa5c6d 09/28/2012 08:40 pm Paolo Bonzini

iostatus: move BlockdevOnError declaration to QAPI

This will let block-stream reuse the enum. Places that used the enums
are renamed accordingly.

Signed-off-by: Paolo Bonzini <>
Reviewed-by: Eric Blake <>
Signed-off-by: Kevin Wolf <>

ff06f5f3 09/28/2012 08:14 pm Paolo Bonzini

iostatus: rename BlockErrorAction, BlockQMPEventAction

We want to remove knowledge of BLOCK_ERR_STOP_ENOSPC from drivers;
drivers should only be told whether to stop/report/ignore the error.
On the other hand, we want to keep using the nicer BlockErrorAction...

2f0c9fe6 09/28/2012 08:14 pm Paolo Bonzini

block: move job APIs to separate files

Signed-off-by: Paolo Bonzini <>
Reviewed-by: Eric Blake <>
Signed-off-by: Kevin Wolf <>

79fac568 09/28/2012 07:23 pm Jeff Cody

block: helper function, to find the base image of a chain

This is a simple helper function, that will return the base image
of a given image chain.

Signed-off-by: Jeff Cody <>
Reviewed-by: Eric Blake <>
Signed-off-by: Kevin Wolf <>

6ebdcee2 09/28/2012 07:22 pm Jeff Cody

block: add support functions for live commit, to find and delete images.

Add bdrv_find_overlay(), and bdrv_drop_intermediate().

bdrv_find_overlay(): given 'bs' and the active (topmost) BDS of an image chain,
find the image that is the immediate top of 'bs'...

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

block: remove keep_read_only flag from BlockDriverState struct

The keep_read_only flag is no longer used, in favor of the bdrv
flag BDRV_O_ALLOW_RDWR.

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

0bce597d 09/24/2012 04:15 pm Jeff Cody

block: convert bdrv_commit() to use bdrv_reopen()

Currently, bdrv_commit() reopens images r/w itself, via risky
_delete() and _open() calls. Use the new safe method for drive reopen.

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

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

block: correctly set the keep_read_only flag

I believe the bs->keep_read_only flag is supposed to reflect
the initial open state of the device. If the device is initially
opened R/O, then commit operations, or reopen operations changing
to R/W, are prohibited....

55b110f2 09/24/2012 04:15 pm Jeff Cody

block: make bdrv_set_enable_write_cache() modify open_flags

bdrv_set_enable_write_cache() sets the bs->enable_write_cache flag,
but without the flag recorded in bs->open_flags, then next time
a reopen() is performed the enable_write_cache setting may be
inadvertently lost....

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

block: Framework for reopening files safely

This is based on Supriya Kannery's bdrv_reopen() patch series.

This provides a transactional method to reopen multiple
images files safely.

Image files are queue for reopen via bdrv_reopen_queue(), and the
reopen occurs when bdrv_reopen_multiple() is called. Changes are...

9ca11154 09/12/2012 04:50 pm Pavel Hrdina

block: fix block tray status

The tray status should change also if you eject empty block device.

Signed-off-by: Pavel Hrdina <>
Signed-off-by: Kevin Wolf <>

fe235a06 09/12/2012 04:50 pm Dunrong Huang

block: Don't forget to delete temporary file

The caller would not delete temporary file after failed get_tmp_filename().

Signed-off-by: Dunrong Huang <>
Signed-off-by: Kevin Wolf <>

d4c82329 08/15/2012 04:14 pm Kevin Wolf

block: Flush parent to OS with cache=unsafe

Commit 29cdb251 already added a comment that no unnecessary flushes to
disk will occur, this patch makes the code even get to the point of the
comment. This is mostly theoretical because in practice we only stack...

c75a1a8a 08/13/2012 07:20 pm Luiz Capitulino

qmp: query-block: add 'encryption_key_missing' field

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

2e3e3317 08/03/2012 04:10 pm Benoît Canet

block: Use bdrv_get_backing_file_depth()

Use the dedicated counting function in qmp_query_block in order to
propagate the backing file depth to HMP and add backing_file_depth
to qmp-commands.hx

Signed-off-by: Benoit Canet <>
Reviewed-by: Eric Blake <>...

f198fd1c 08/03/2012 04:10 pm Benoît Canet

block: create bdrv_get_backing_file_depth()

Create bdrv_get_backing_file_depth() in order to be able to show
in QMP and HMP how many ancestors backing an image a block device
have.

Signed-off-by: Benoit Canet <>
Reviewed-by: Eric Blake <>...

0ed8b6f6 07/28/2012 12:23 pm Blue Swirl

Avoid returning void

It's silly and non-conforming to standards to return void,
don't do it.

Signed-off-by: Blue Swirl <>

2b584959 07/17/2012 05:48 pm Markus Armbruster

block: Geometry and translation hints are now useless, purge them

There are two producers of these hints: drive_init() on behalf of
-drive, and hd_geometry_guess().

The only consumer of the hint is hd_geometry_guess().

The callers of hd_geometry_guess() call it only when drive_init()...

9db1c0f7 07/17/2012 05:48 pm Markus Armbruster

hd-geometry: Move disk geometry guessing back from block.c

Commit f3d54fc4 factored it out of hw/ide.c for reuse. Sensible,
except it was put into block.c. Device-specific functionality should
be kept in device code, not the block layer. Move it to
hw/hd-geometry.c, and make stylistic changes required to keep...

61a8d649 07/17/2012 05:48 pm Markus Armbruster

fdc: Move floppy geometry guessing back from block.c

Commit 5bbdbb46 moved it to block.c because "other geometry guessing
functions already reside in block.c". Device-specific functionality
should be kept in device code, not the block layer. Move it back....

23797df3 07/09/2012 08:35 pm Anthony Liguori

Merge remote-tracking branch 'mjt/mjt-iov2' into staging

  • mjt/mjt-iov2:
    rewrite iov_send_recv() and move it to iov.c
    cleanup qemu_co_sendv(), qemu_co_recvv() and friends
    export iov_send_recv() and use it in iov_send() and iov_recv()
    rename qemu_sendv to iov_send, change proto and move declarations to iov.h...
07d27a44 07/09/2012 06:21 pm Markus Armbruster

block: Factor bdrv_read_unthrottled() out of guess_disk_lchs()

To prepare move of guess_disk_lchs() into hw/, where it poking
BlockDriverState member io_limits_enabled directly would be unclean.

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

1f69c2b0 07/09/2012 04:53 pm Markus Armbruster

fdc: Drop broken code for user-defined floppy geometry

bdrv_get_floppy_geometry_hint() fails to store through its parameter
drive when bs has a geometry hint. Makes fd_revalidate() assign
random crap to drv->drive.

Has been broken that way for ages. Harmless, because:...

a9fc4408 07/09/2012 04:53 pm Paolo Bonzini

block: copy over job and dirty bitmap fields in bdrv_append

While these should not be in use at the time a transaction is started,
a command in the prepare phase of a transaction might have added them,
so they need to be brought over.

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

4ddc07ca 07/09/2012 04:53 pm Paolo Bonzini

block: introduce bdrv_swap, implement bdrv_append on top of it

The new function can be made a bit nicer than bdrv_append. It swaps the
whole contents, and then swaps back (using the usual t=a;a=b;b=t idiom)
the fields that need to stay on top. Thus, it does not need explicit...

c8433287 06/15/2012 03:03 pm Markus Armbruster

block: New bdrv_get_flags()

Signed-off-by: Markus Armbruster <>
Acked-by: Paolo Bonzini <>
Signed-off-by: Kevin Wolf <>

f05fa4ad 06/15/2012 03:03 pm Paolo Bonzini

block: flush in writethrough mode after writes

We want to make the formats handle their own flushes
autonomously, while keeping for guests the ability to use a writethrough
cache. Since formats will write metadata via bs->file, bdrv_co_do_writev
is the only place where we need to add a flush....

c4a248a1 06/15/2012 03:03 pm Paolo Bonzini

block: copy enable_write_cache in bdrv_append

Because the guest will be able to flip enable_write_cache, the actual
state may not match what is used to open the new snapshot.

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

425b0148 06/15/2012 03:03 pm Paolo Bonzini

block: add bdrv_set_enable_write_cache

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

e1e9b0ac 06/15/2012 03:03 pm Paolo Bonzini

block: always open drivers in writeback mode

Formats are entirely in charge of flushes for metadata writes. For
guest-initiated writes, a writethrough cache is faked in the block layer.
So we can always open in writeback mode.

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

f8d6bba1 06/15/2012 03:03 pm Markus Armbruster

block: Replace bdrv_get_format() by bdrv_get_format_name()

So callers don't need to know anything about maximum name length.
Returning a pointer is safe, because the name string lives as long as
the block driver it names, and block drivers don't die.

Requested by Peter Maydell....

188a7bbf 06/15/2012 03:03 pm Paolo Bonzini

stream: move is_allocated_above to block.c

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

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

03396148 06/11/2012 10:12 pm Michael Tokarev

allow qemu_iovec_from_buffer() to specify offset from which to start copying

Similar to
qemu_iovec_memset(QEMUIOVector *qiov, size_t offset,
int c, size_t bytes);
the new prototype is:
qemu_iovec_from_buf(QEMUIOVector *qiov, size_t offset,...

1b093c48 06/11/2012 10:12 pm Michael Tokarev

consolidate qemu_iovec_copy() and qemu_iovec_concat() and make them consistent

qemu_iovec_concat() is currently a wrapper for
qemu_iovec_copy(), use the former (with extra
"0" arg) in a few places where it is used.

Change skip argument of qemu_iovec_copy() from...

d5e6b161 06/11/2012 10:12 pm Michael Tokarev

change qemu_iovec_to_buf() to match other to,from_buf functions

It now allows specifying offset within qiov to start from and
amount of bytes to copy. Actual implementation is just a call
to iov_to_buf().

Signed-off-by: Michael Tokarev <>

eba25057 05/30/2012 09:48 am Jim Meyering

block: prevent snapshot mode $TMPDIR symlink attack

In snapshot mode, bdrv_open creates an empty temporary file without
checking for mkstemp or close failure, and ignoring the possibility
of a buffer overrun given a surprisingly long $TMPDIR.
Change the get_tmp_filename function to return int (not void),...

e023b2e2 05/10/2012 11:32 am Paolo Bonzini

block: fix snapshot on QED

QED's opaque data includes a pointer back to the BlockDriverState.
This breaks when bdrv_append shuffles data between bs_new and bs_top.
To avoid this, add a "rebind" function that tells the driver about
the new relationship between the BlockDriverState and its opaque....

3a389e79 05/10/2012 11:32 am Paolo Bonzini

block: another bdrv_append fix

bdrv_append must also copy open_flags to the top, because the snapshot
has BDRV_O_NO_BACKING set. This causes interesting results if you
later use drive-reopen (not upstream) to reopen the image, and lose
the backing file in the process....

a275fa42 05/10/2012 11:32 am Paolo Bonzini

block: do not reuse the backing file across bdrv_close/bdrv_open

This is another bug caused by not doing a full cleanup of the BDS
across close/open. This was found with mirroring by Shaolong Hu,
but it can probably be reproduced also with eject or change....

0ac9377d 05/10/2012 11:32 am Paolo Bonzini

block: fully delete bs->file when closing

We are reusing bs->file across close/open, which may not cause any
known bugs but is a recipe for trouble. Prefer bdrv_delete, and
enjoy the new invariant in the implementation of bdrv_delete.

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

4513eafe 05/10/2012 11:32 am Paolo Bonzini

block: add block_job_sleep_ns

This function abstracts the pretty complex semantics of the "busy"
member of BlockJob.

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

fa4478d5 05/10/2012 11:32 am Paolo Bonzini

block: wait for job callback in block_job_cancel_sync

The limitation on not having I/O after cancellation cannot really be
kept. Even streaming has a very small race window where you could
cancel a job and have it report completion. If this window is hit,...

f53f4da9 05/10/2012 11:32 am Paolo Bonzini

block: simplify path_is_absolute

On Windows, all the logic is already in is_windows_drive and
is_windows_drive_prefix. On POSIX, there is no need to look
out for colons.

The win32 code changes the behaviour in some cases, we could have
something like "d:foo.img". The old code would treat it as relative...

947995c0 05/10/2012 11:32 am Paolo Bonzini

block: protect path_has_protocol from filenames with colons

path_has_protocol will erroneously return "true" if the colon is part
of a filename. These names are common with stable device names produced
by udev. We cannot fully protect against this in case the filename...

6405875c 05/10/2012 11:32 am Paolo Bonzini

block: move field reset from bdrv_open_common to bdrv_close

bdrv_close should leave fields in the same state as bdrv_new. It is
not up to bdrv_open_common to fix the mess.

Also, backing_format was not being re-initialized.

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

dc5a1371 05/10/2012 11:32 am Paolo Bonzini

qemu-img: make "info" backing file output correct and easier to use

qemu-img info should use the same logic as qemu when printing the
backing file path, or debugging becomes quite tricky. We can also
simplify the output in case the backing file has an absolute path...

4c355d53 05/10/2012 11:32 am Zhi Yong Wu

block: add the support to drain throttled requests

Signed-off-by: Zhi Yong Wu <>
[ Iterate until all block devices have processed all requests,
add comments. - Paolo ]
Signed-off-by: Paolo Bonzini <>
Signed-off-by: Kevin Wolf <>

5f377794 05/10/2012 11:32 am Paolo Bonzini

block: push bdrv_change_backing_file error checking up from drivers

This check applies to all drivers, but QED lacks it.

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

469ef350 05/10/2012 11:32 am Paolo Bonzini

block: update in-memory backing file and format

These are needed to print "info block" output correctly. QCOW2 does this
because it needs it to write the header, but QED does not, and common code
is the right place to do it.

Reviewed-by: Kevin Wolf <>...

63090dac 05/10/2012 11:32 am Paolo Bonzini

block: open backing file as read-only when probing for size

bdrv_img_create will temporarily open the backing file to probe its size.
However, this could be done with a read-write open if the wrong flags are
passed to bdrv_img_create. Since there is really no documentation on...

71df14fc 05/10/2012 11:32 am Paolo Bonzini

block: fix allocation size for dirty bitmap

Also reuse elsewhere the new constant for sizeof(unsigned long) * 8.

The dirty bitmap is allocated in bits but declared as unsigned long.
Thus, its memory block is accessed beyond its end unless the image
is a multiple of 64 chunks (i.e. a multiple of 64 MB)....

5b7e1542 05/07/2012 08:33 pm Zhi Yong Wu

block: make bdrv_create adopt coroutine

The current qemu.git introduces failure with preallocation and some
sizes:

qemu-img create f qcow2 new.img 976563K -o preallocation=metadata
qemu-img: qemu-coroutine-lock.c:111: qemu_co_mutex_unlock: Assertion
`mutex
>locked == 1' failed....

c83c66c3 04/27/2012 05:44 pm Stefan Hajnoczi

block: add 'speed' optional parameter to block-stream

Allow streaming operations to be started with an initial speed limit.
This eliminates the window of time between starting streaming and
issuing block-job-set-speed. Users should use the new optional 'speed'...