Statistics
| Branch: | Revision:

root / block.c @ feature-archipelago

History | View | Annotate | Download (150.9 kB)

# Date Author Comment
69bef793 02/28/2014 07:59 pm Amit Shah

block: use /var/tmp instead of /tmp for -snapshot

If TMPDIR is not specified, the default was to use /tmp for the working
copy of the block devices. Update this to /var/tmp instead, so systems
using tmp-on-tmpfs don't end up inadvertently using RAM for the block...

ddf5636d 02/21/2014 10:02 pm Max Reitz

block: Add reference parameter to bdrv_open()

Allow bdrv_open() to handle references to existing block devices just as
bdrv_file_open() is already capable of.

Signed-off-by: Max Reitz <>
Signed-off-by: Kevin Wolf <>

2e40134b 02/21/2014 10:02 pm Max Reitz

block: Make bdrv_file_open() static

Add the bdrv_open() option BDRV_O_PROTOCOL which results in passing the
call to bdrv_file_open(). Additionally, make bdrv_file_open() static and
therefore bdrv_open() the only way to call it.

Consequently, all existing calls to bdrv_file_open() have to be adjusted...

5d12aa63 02/21/2014 10:02 pm Max Reitz

block: Reuse reference handling from bdrv_open()

Remove the reference parameter and the related handling code from
bdrv_file_open(), since it exists in bdrv_open() now as well.

Signed-off-by: Max Reitz <>
Reviewed-by: Benoit Canet <>...

d4446eae 02/21/2014 10:02 pm Max Reitz

block: Remove bdrv_new() from bdrv_file_open()

Change bdrv_file_open() to take a simple pointer to an already existing
BDS instead of an indirect one. The BDS will be created in bdrv_open()
if necessary.

Signed-off-by: Max Reitz <>
Reviewed-by: Benoit Canet <>...

5469a2a6 02/21/2014 10:02 pm Max Reitz

block: Handle bs->options in bdrv_open() only

The fail paths of bdrv_file_open() and bdrv_open() naturally exhibit
similarities, thus it is possible to reuse the one from bdrv_open() and
shorten the one in bdrv_file_open() accordingly.

Also, setting bs->options in bdrv_file_open() is not necessary if it is...

5acd9d81 02/21/2014 10:02 pm Max Reitz

block: Reuse success path from bdrv_open()

The fail and success paths of bdrv_file_open() may be further shortened
by reusing code already existent in bdrv_open(). This includes
bdrv_file_open() not taking the reference to options which allows the
removal of QDECREF in that function....

f7d9fd8c 02/21/2014 10:02 pm Max Reitz

block: Remove bdrv_open_image()'s force_raw option

This option is now unnecessary since specifying BDRV_O_PROTOCOL as flag
will do exactly the same.

Signed-off-by: Max Reitz <>
Reviewed-by: Benoit Canet <>
Reviewed-by: Kevin Wolf <>...

e6dc8a1f 02/21/2014 10:02 pm Kevin Wolf

block: Fix bdrv_is_first_non_filter()

Consider top level BlockDriverStates as well.

Signed-off-by: Kevin Wolf <>
Reviewed-by: Benoit Canet <>
Tested-by: Benoit Canet <>

f67503e5 02/21/2014 10:02 pm Max Reitz

block: Change BDS parameter of bdrv_open() to **

Make bdrv_open() take a pointer to a BDS pointer, similarly to
bdrv_file_open(). If a pointer to a NULL pointer is given, bdrv_open()
will create a new BDS with an empty name; if the BDS pointer is not
NULL, that existing BDS will be reused (in the same way as bdrv_open()...

4c0c9bbe 02/20/2014 02:10 pm Peter Maydell

Merge remote-tracking branch 'remotes/qmp-unstable/queue/qmp' into staging

  • remotes/qmp-unstable/queue/qmp:
    monitor: Add object_add class argument completion.
    monitor: Add object_del id argument completion.
    monitor: Add device_add device argument completion....
84d18f06 02/17/2014 06:57 pm Markus Armbruster

Use error_is_set() only when necessary

error_is_set(&var) is the same as var != NULL, but it takes
whole-program analysis to figure that out. Unnecessarily hard for
optimizers, static checkers, and human readers. Dumb it down to
obvious.

Gets rid of several dozen Coverity false positives....

dd67fa50 02/14/2014 07:05 pm Benoît Canet

block: Relax bdrv_lookup_bs constraints.

The following patch will reuse bdrv_lookup_bs in order to open images by
references so the rules of usage of bdrv_lookup_bs must be relaxed a bit.

Signed-off-by: Benoit Canet <>
Reviewed-by: Max Reitz <>...

0c5e94ee 02/14/2014 07:05 pm Benoît Canet

block: Open by reference will try device then node_name.

Since we introduced node_name for named bs of the graph modify the opening by
reference to use it as a fallback.

This patch also enforce the separation of the device id and graph node
namespaces.
...

99c4a85c 02/09/2014 10:12 am Kevin Wolf

block: Fix memory leaks in bdrv_co_do_pwritev()

The error path for a failure in one of the two bdrv_aligned_preadv()
calls leaked head_buf or tail_buf, respectively. This fixes the memory
leak.

Reported-by: Laszlo Ersek <>
Signed-off-by: Kevin Wolf <>...

af91f9a7 02/09/2014 10:12 am Kevin Wolf

block: bdrv_aligned_pwritev: Assert overlap range

This adds assertions that the request that we actually end up passing to
the block driver (which includes RMW data and has therefore potentially
been rounded to alignment boundaries) is fully covered by the...

5f5bcd80 02/09/2014 10:12 am Kevin Wolf

block: Don't call ROUND_UP with negative values

The behaviour of the ROUND_UP macro with negative numbers isn't obvious.
It happens to do the right thing in this please, but better avoid it.

Suggested-by: Laszlo Ersek <>
Signed-off-by: Kevin Wolf <>...

e96126ff 02/09/2014 10:12 am Kevin Wolf

block: Fix 32 bit truncation in mark_request_serialising()

On 32 bit hosts, size_t is too small for align as the bitmask
~(align - 1) will zero out the higher 32 bits of the offset.

While at it, change the local overlap_bytes variable to unsigned to
match the field in BdrvTrackedRequest....

765003db 02/09/2014 10:12 am Kevin Wolf

block: Fail gracefully with missing filename

This fixes a regression introduced in commit 2a05cbe42 ('block: Allow
block devices without files'):

$ qemu-system-x86_64 drive driver=file
qemu-system-x86_64: block.c:892: bdrv_open_common: Assertion
`!drv
>bdrv_needs_filename || filename != ((void *)0)' failed....

d5103588 01/24/2014 06:40 pm Kevin Wolf

block: Switch bdrv_io_limits_intercept() to byte granularity

Request sizes used to be rounded down to the next sector boundary,
allowing to bypass the I/O limit. Now all requests are accounted for
with their exact byte size.

Reported-by: Wenchao Xia <>...

9e1cb96d 01/24/2014 06:40 pm Kevin Wolf

qemu-iotests: Test pwritev RMW logic

Signed-off-by: Kevin Wolf <>
Reviewed-by: Max Reitz <>

28de2dcd 01/24/2014 06:40 pm Kevin Wolf

block: Assert serialisation assumptions in pwritev

If a request calls wait_serialising_requests() and actually has to wait
in this function (i.e. a coroutine yield), other requests can run and
previously read data (like the head or tail buffer) could become...

775aa8b6 01/24/2014 06:40 pm Kevin Wolf

block: Change coroutine wrapper to byte granularity

Signed-off-by: Kevin Wolf <>
Reviewed-by: Max Reitz <>

a3ef6571 01/24/2014 06:40 pm Kevin Wolf

block: Make bdrv_pread() a bdrv_prwv_co() wrapper

Instead of implementing the alignment adjustment here, use the now
existing functionality of bdrv_co_do_preadv().

Signed-off-by: Kevin Wolf <>
Reviewed-by: Max Reitz <>

8407d5d7 01/24/2014 06:40 pm Kevin Wolf

block: Make bdrv_pwrite() a bdrv_prwv_co() wrapper

Instead of implementing the alignment adjustment here, use the now
existing functionality of bdrv_co_do_pwritev().

Signed-off-by: Kevin Wolf <>
Reviewed-by: Max Reitz <>

c25f53b0 01/24/2014 06:40 pm Paolo Bonzini

raw: Probe required direct I/O alignment

Add a bs->request_alignment field that contains the required
offset/length alignment for I/O requests and fill it in the raw block
drivers. Use ioctls if possible, else see what alignment it takes for
O_DIRECT to succeed....

d0c7f642 01/24/2014 06:40 pm Kevin Wolf

block: Introduce bdrv_aligned_preadv()

This separates the part of bdrv_co_do_readv() that needs to happen
before the request is modified to match the backend alignment, and a
part that needs to be executed afterwards and passes the request to the
BlockDriver....

1b0288ae 01/24/2014 06:40 pm Kevin Wolf

block: Introduce bdrv_co_do_preadv()

Similar to bdrv_pread(), which aligns byte-aligned request to 512 byte
sectors, bdrv_co_do_preadv() takes a byte-aligned request and aligns it
to the alignment specified in bs->request_alignment.

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

b404f720 01/24/2014 06:40 pm Kevin Wolf

block: Introduce bdrv_aligned_pwritev()

This separates the part of bdrv_co_do_writev() that needs to happen
before the request is modified to match the backend alignment, and a
part that needs to be executed afterwards and passes the request to the
BlockDriver....

244eadef 01/24/2014 06:40 pm Kevin Wolf

block: write: Handle COR dependency after I/O throttling

First waiting for all COR requests to complete and calling the
throttling function afterwards means that the request could be delayed
and we still need to wait for the COR request even if it was issued only...

6601553e 01/24/2014 06:40 pm Kevin Wolf

block: Introduce bdrv_co_do_pwritev()

This is going to become the bdrv_co_do_preadv() equivalent for writes.
In this patch, however, just a function taking byte offsets is created,
it doesn't align anything yet.

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

793ed47a 01/24/2014 06:40 pm Kevin Wolf

block: Switch BdrvTrackedRequest to byte granularity

Signed-off-by: Kevin Wolf <>
Reviewed-by: Max Reitz <>
Reviewed-by: Benoit Canet <>

65afd211 01/24/2014 06:40 pm Kevin Wolf

block: Allow waiting for overlapping requests between begin/end

Previously, it was not possible to use wait_for_overlapping_requests()
between tracked_request_begin()/end() because it would wait for itself.

Ignore the current request in the overlap check and run more of the...

ec746e10 01/24/2014 06:40 pm Kevin Wolf

block: Make zero-after-EOF work with larger alignment

Odd file sizes could make bdrv_aligned_preadv() shorten the request in
non-aligned ways. Fix it by rounding to the required alignment instead
of 512 bytes.

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

2dbafdc0 01/24/2014 06:40 pm Kevin Wolf

block: Generalise and optimise COR serialisation

Change the API so that specific requests can be marked serialising. Only
these requests are checked for overlaps then.

This means that during a Copy on Read operation, not all requests
overlapping other requests are serialised any more, but only those that...

7327145f 01/24/2014 06:40 pm Kevin Wolf

block: Make overlap range for serialisation dynamic

Copy on Read wants to serialise with all requests touching the same
cluster, so wait_serialising_requests() rounded to cluster boundaries.
Other users like alignment RMW will have different requirements, though...

6460440f 01/24/2014 06:40 pm Kevin Wolf

block: Allow wait_serialising_requests() at any point

We can only have a single wait_serialising_requests() call per request
because otherwise we can run into deadlocks where requests are waiting
for each other. The same is true when wait_serialising_requests() is not...

3b8242e0 01/24/2014 06:40 pm Kevin Wolf

block: Align requests in bdrv_co_do_pwritev()

This patch changes bdrv_co_do_pwritev() to actually be what its name
promises. If requests aren't properly aligned, it performs a RMW.

Requests touching the same block are serialised against the RMW request....

d34682cd 01/24/2014 06:40 pm Kevin Wolf

block: Move initialisation of BlockLimits to bdrv_refresh_limits()

This function separates filling the BlockLimits from bdrv_open(), which
allows it to call it from other operations which may change the limits
(e.g. modifications to the backing file chain or bdrv_reopen)...

466ad822 01/24/2014 06:40 pm Kevin Wolf

block: Inherit opt_transfer_length

When there is a format driver between the backend, it's not guaranteed
that exposing the opt_transfer_length for the format driver results in
the optimal requests (because of fragmentation etc.), but it can't make
things worse, so let's just do it....

355ef4ac 01/24/2014 06:40 pm Kevin Wolf

block: Update BlockLimits when they might have changed

When reopening with different flags, or when backing files disappear
from the chain, the limits may change. Make sure they get updated in
these cases.

Signed-off-by: Kevin Wolf <>
Reviewed-by: Wenchao Xia <>...

1ff735bd 01/24/2014 06:40 pm Kevin Wolf

block: Detect unaligned length in bdrv_qiov_is_aligned()

For an O_DIRECT request to succeed, it's not only necessary that all
base addresses in the qiov are aligned, but also that each length in it
is aligned.

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

339064d5 01/24/2014 06:40 pm Kevin Wolf

block: Don't use guest sector size for qemu_blockalign()

bs->buffer_alignment is set by the device emulation and contains the
logical block size of the guest device. This isn't something that the
block layer should know, and even less something to use for determining...

1b7fd729 01/24/2014 06:40 pm Paolo Bonzini

block: rename buffer_alignment to guest_block_size

The alignment field is now set to the value that is promised to the
guest, rather than required by the host. The next patches will make
QEMU aware of the host-provided values, so make this clear.

The alignment is also not about memory buffers, but about the sectors on...

dabfa6cc 01/24/2014 05:53 pm Kevin Wolf

block: Fix bdrv_commit return value

bdrv_commit() could return 0 or 1 on success, depending on whether or
not the last sector was allocated in the overlay and whether the overlay
format had a .bdrv_make_empty callback.

Most callers ignored it, but qemu-img commit would print an error...

72706ea4 01/24/2014 05:12 pm Jeff Cody

block: resize backing file image during offline commit, if necessary

Currently, if an image file is logically larger than its backing file,
committing it via 'qemu-img commit' will fail.

For instance, if we have a base image with a virtual size 10G, and a...

c13163fb 01/24/2014 05:07 pm Benoît Canet

qmp: Add QMP query-named-block-nodes to list the named BlockDriverState nodes.

Signed-off-by: Benoit Canet <>
Reviewed-by: Fam Zheng <>
Signed-off-by: Kevin Wolf <>

12d3ba82 01/24/2014 05:07 pm Benoît Canet

qmp: Allow to change password on named block driver states.

Signed-off-by: Benoit Canet <>
Reviewed-by: Fam Zheng <>

There was two candidate ways to implement named node manipulation:

1) { 'command': 'block_passwd', 'data': {'*device': 'str',...

212a5a8f 01/24/2014 05:07 pm Benoît Canet

block: Create authorizations mechanism for external snapshot and resize.

Signed-off-by: Benoit Canet <>
Signed-off-by: Kevin Wolf <>

6913c0c2 01/24/2014 05:06 pm Benoît Canet

block: Allow the user to define "node-name" option both on command line and QMP.

Signed-off-by: Benoit Canet <>
Signed-off-by: Kevin Wolf <>

dc364f4c 01/24/2014 03:33 pm Benoît Canet

block: Add bs->node_name to hold the name of a bs node of the bs graph.

Add the minimum of code to prepare for the following patches.

Signed-off-by: Benoit Canet <>
Reviewed-by: Fam Zheng <>
Signed-off-by: Kevin Wolf <>

d80ac658 01/22/2014 02:47 pm Peter Feiner

block: fix backing file segfault

When a backing file is opened such that (1) a protocol is directly
used as the block driver and (2) the block driver has bdrv_file_open,
bdrv_open_backing_file segfaults. The problem arises because
bdrv_open_common returns without setting bd->backing_hd->file....

da557aac 01/22/2014 01:07 pm Max Reitz

block: Add bdrv_open_image()

Add a common function for opening images to be used for block drivers
specified through BlockdevRefs in an option QDict. The difference from
bdrv_file_open() is that this function may invoke bdrv_open() instead,
allowing auto-detection of the driver to be used; and second, it...

054963f8 01/22/2014 01:07 pm Max Reitz

block: Use bdrv_open_image() in bdrv_open()

Using bdrv_open_image() instead of bdrv_file_open() directly in
bdrv_open() is easier.

Signed-off-by: Max Reitz <>
Signed-off-by: Kevin Wolf <>

505d7583 01/22/2014 01:07 pm Max Reitz

block: Allow recursive "file"s

It should be possible to use a format as a driver for a file which in
turn requires another file, i.e., nesting file formats.

Allowing nested file formats results in e.g. qcow2 BlockDriverStates
never being directly passed to bdrv_open_common() from bdrv_file_open(),...

72daa72e 01/22/2014 01:07 pm Max Reitz

block: Allow reference for bdrv_file_open()

Allow specifying a reference to an existing block device (by name) for
bdrv_file_open() instead of a filename and/or options.

Signed-off-by: Max Reitz <>
Reviewed-by: Kevin Wolf <>...

2258e3fe 01/22/2014 01:07 pm Max Reitz

block: Pass reference to bdrv_file_open()

With that now being possible, bdrv_open() should try to extract a block
device reference from the options and pass it to bdrv_file_open().

Signed-off-by: Max Reitz <>
Reviewed-by: Kevin Wolf <>...

2a05cbe4 01/22/2014 01:07 pm Max Reitz

block: Allow block devices without files

blkdebug and blkverify will, in order to retain compatibility, not
support the field "file" implicitly through bdrv_open(). In order to be
able to use those drivers without giving a filename anyway, it is
necessary to be able to have block devices without files implicitly...

3d94ce60 12/13/2013 03:49 pm Peter Lieven

block: expect get_block_status errors in bdrv_make_zero

during testing around with 4k LUNs a bad target implementation
triggert an -EIO in iscsi_get_block_status, but it got never caught
resulting in an infinite loop.

CC:
Signed-off-by: Peter Lieven <>...

0b06ef3b 12/06/2013 05:53 pm Stefan Hajnoczi

block: clean up bdrv_drain_all() throttling comments

Since cc0681c45430a1f1a4c2d06e9499b7775afc9a18 ("block: Enable the new
throttling code in the block layer.") bdrv_drain_all() no longer spins.
The code used to look as follows:

do {
busy = qemu_aio_wait();...
66f6b814 12/04/2013 12:29 pm Max Reitz

block: Close backing file early in bdrv_img_create

Leaving the backing file open although it is not needed anymore can
cause problems if it is opened through a block driver which allows
exclusive access only and if the create function of the block driver...

94d6ff21 12/03/2013 04:26 pm Paolo Bonzini

block: add flags argument to bdrv_co_write_zeroes tracepoint

Signed-off-by: Paolo Bonzini <>
Reviewed-by: Peter Lieven <>
Signed-off-by: Stefan Hajnoczi <>

d5ef94d4 12/03/2013 04:26 pm Paolo Bonzini

block: add bdrv_aio_write_zeroes

This will be used by the SCSI layer.

Signed-off-by: Paolo Bonzini <>
Reviewed-by: Peter Lieven <>
Signed-off-by: Stefan Hajnoczi <>

7ce21016 12/03/2013 04:26 pm Paolo Bonzini

block: handle ENOTSUP from discard in generic code

Similar to write_zeroes, let the generic code receive a ENOTSUP for
discard operations. Since bdrv_discard has advisory semantics,
we can just swallow the error.

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

b8d71c09 12/03/2013 04:26 pm Paolo Bonzini

block: make bdrv_co_do_write_zeroes stricter in producing aligned requests

Right now, bdrv_co_do_write_zeroes will only try to align the
beginning of the request. However, it is simpler for many
formats to expect the block layer to separate both the head and...

d51e9fe5 12/03/2013 04:26 pm Paolo Bonzini

block: generalize BlockLimits handling to cover bdrv_aio_discard too

bdrv_co_discard is only covering drivers which have a .bdrv_co_discard()
implementation, but not those with .bdrv_aio_discard(). Not very nice,
and easy to avoid.

Suggested-by: Kevin Wolf <>...

d20d9b7c 12/03/2013 04:26 pm Paolo Bonzini

block: add flags to BlockRequest

This lets bdrv_co_do_rw receive flags, so that it can be used for
zero writes.

Signed-off-by: Paolo Bonzini <>
Reviewed-by: Peter Lieven <>
Signed-off-by: Stefan Hajnoczi <>

c9fbb99d 11/29/2013 06:41 pm Kevin Wolf

block: Use BDRV_O_NO_BACKING where appropriate

If you open an image temporarily just because you want to check its size
or get it flushed, there's no real reason to open the whole backing file
chain.

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

4cc70e93 11/29/2013 02:40 pm Fam Zheng

blkdebug: add "remove_break" command

This adds "remove_break" command which is the reverse of blkdebug
command "break": it removes all breakpoints with given tag and resumes
all the requests.

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

9fd3171a 11/29/2013 02:40 pm Kevin Wolf

block: Enable BDRV_O_SNAPSHOT with driver-specific options

In the case of snapshot=on, don't rely on the backing file path in the
temporary image any more, but override the backing file with the given
set of options. This way, block drivers that don't use a file name can...

21b56835 11/29/2013 02:40 pm Fam Zheng

qapi: Change BlockDirtyInfo to list

We have multiple dirty bitmaps in BDS now, switch QAPI to allow query
it (BlockInfo.dirty_bitmaps), and also drop old BlockInfo.dirty.

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

e4654d2d 11/29/2013 02:40 pm Fam Zheng

block: per caller dirty bitmap

Previously a BlockDriverState has only one dirty bitmap, so only one
caller (e.g. a block job) can keep track of writing. This changes the
dirty bitmap to a list and creates a BdrvDirtyBitmap for each caller, the
lifecycle is managed with these new functions:...

d75cbb5e 11/28/2013 11:30 am Peter Lieven

block: introduce bdrv_make_zero

this patch adds a call to completely zero out a block device.
the operation is sped up by checking the block status and
only writing zeroes to the device if they currently do not
return zeroes. optionally the zero writing can be sped up...

c3d86884 11/28/2013 11:30 am Peter Lieven

block/get_block_status: fix BDRV_BLOCK_ZERO for unallocated blocks

this patch does 2 things:
a) only do additional call outs if BDRV_BLOCK_ZERO is not already set.
b) use the newly introduced bdrv_unallocated_blocks_are_zero()
to return the zero state of an unallocated block. the used callout...

6faac15f 11/28/2013 11:30 am Peter Lieven

block: make BdrvRequestFlags public

Reviewed-by: Eric Blake <>
Signed-off-by: Peter Lieven <>
Signed-off-by: Stefan Hajnoczi <>

aa7bfbff 11/28/2013 11:30 am Peter Lieven

block: add flags to bdrv_*_write_zeroes

Reviewed-by: Eric Blake <>
Signed-off-by: Peter Lieven <>
Signed-off-by: Stefan Hajnoczi <>

d32f35cb 11/28/2013 11:30 am Peter Lieven

block: introduce BDRV_REQ_MAY_UNMAP request flag

Reviewed-by: Eric Blake <>
Signed-off-by: Peter Lieven <>
Signed-off-by: Stefan Hajnoczi <>

4ce78691 11/28/2013 11:30 am Peter Lieven

block: add wrappers for logical block provisioning information

This adds 2 wrappers to read the unallocated_blocks_are_zero and
can_write_zeroes_with_unmap info from the BDI. The wrappers are
required to check for the existence of a backing_hd and
if the devices are opened with the correct flags....

c31cb707 11/28/2013 11:30 am Peter Lieven

block: honour BlockLimits in bdrv_co_do_write_zeroes

Reviewed-by: Eric Blake <>
Signed-off-by: Peter Lieven <>
Signed-off-by: Stefan Hajnoczi <>

6f14da52 11/28/2013 11:30 am Peter Lieven

block: honour BlockLimits in bdrv_co_discard

Reviewed-by: Eric Blake <>
Signed-off-by: Peter Lieven <>
Signed-off-by: Stefan Hajnoczi <>

06d22aa3 11/15/2013 02:37 pm Kevin Wolf

block: Fail if requested driver is not available

If an explicit driver option is present, but doesn't specify a valid
driver, then bdrv_open() should fail instead of probing the format.

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

b04b6b6e 11/14/2013 02:09 pm Fam Zheng

block: Print its file name if backing file opening failed

If backing file doesn't exist, the error message is confusing and
misleading:

$ qemu /tmp/a.qcow2
qemu: could not open disk image /tmp/a.qcow2: Could not open file: No
such file or directory...
7e382003 11/08/2013 11:44 am Fam Zheng

block: Round up total_sectors

Since b94a2610, bdrv_getlength() is omitted when probing image. VMDK
monolithicFlat is broken by that because a file < 512 bytes can't be
read with its total_sectors truncated to 0. This patch round up the size
to BDRV_SECTOR_SIZE, when a image size is not sector aligned....

17826bc1 11/07/2013 02:58 pm Max Reitz

block: Save errno before error_setg_errno

error_setg_errno() may overwrite errno; therefore, its value should be
read before calling that function and not afterwards.

Signed-off-by: Max Reitz <>
Reviewed-by: Eric Blake <>...

b94a2610 10/29/2013 02:10 pm Kevin Wolf

block: Avoid unecessary drv->bdrv_getlength() calls

The block layer generally keeps the size of an image cached in
bs->total_sectors so that it doesn't have to perform expensive
operations to get the size whenever it needs it.

This doesn't work however when using a backend that can change its size...

87a5debd 10/29/2013 02:06 pm Thibaut LAURENT

block: Disable BDRV_O_COPY_ON_READ for the backing file

Since commit 0ebd24e0a203cf2852c310b59fbe050190dc6c8c,
bdrv_open_common will throw an error when trying to open a file
read-only with the BDRV_O_COPY_ON_READ flag set.
Although BDRV_O_RDWR is unset for the backing files,...

61ed2684 10/28/2013 06:35 pm Max Reitz

block: Don't copy backing file name on error

bdrv_open_backing_file() tries to copy the backing file name using
pstrcpy directly after calling bdrv_open() to open the backing file
without checking whether that was actually successful. If it was not,
ps->backing_hd->file will probably be NULL and qemu will crash....

0ebd24e0 10/11/2013 05:50 pm Kevin Wolf

blockdev: Don't disable COR automatically with blockdev-add

If a read-only device is configured with copy-on-read=on, the old code
only prints a warning and automatically disables copy on read. Make it
a real error for blockdev-add.

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

8f94a6e4 10/11/2013 05:50 pm Kevin Wolf

block: Improve driver whitelist checks

The main intent of this patch is to consolidate the whitelist checks to
a single point in the code instead of spreading it everywhere. This adds
a nicer error message for read-only whitelisting, too, in places where...

92bc50a5 10/11/2013 05:49 pm Peter Lieven

block/get_block_status: avoid redundant callouts on raw devices

if a raw device like an iscsi target or host device is used
the current implementation makes a second call out to get
the block status of bs->file.

Signed-off-by: Peter Lieven <>
Reviewed-by: Eric Blake <>...

f6186f49 10/11/2013 05:49 pm Benoît Canet

block: Add BlockDriver.bdrv_check_ext_snapshot.

This field is used by blkverify to disable external snapshots creation.
It will also be used by block filters like quorum to disable external
snapshot creation.

Signed-off-by: Benoit Canet <>...

eae041fe 10/11/2013 11:52 am Max Reitz

block: Add bdrv_get_specific_info

Add a function for retrieving an ImageInfoSpecific object from a block
driver.

Signed-off-by: Max Reitz <>
Reviewed-by: Eric Blake <>
Signed-off-by: Kevin Wolf <>

d4cea8df 10/07/2013 02:23 pm Dunrong Huang

block: use correct filename

The content filename point to may be erased by qemu_opts_absorb_qdict()
in raw_open_common() in drv->bdrv_file_open()

So it's better to use bs->filename.

Signed-off-by: Dunrong Huang <>
Reviewed-by: Max Reitz <>...

2fa9aa59 10/02/2013 12:41 pm Dunrong Huang

block: use correct filename for error report

The content filename point to will be erased by qemu_opts_absorb_qdict()
in raw_open_common() in drv->bdrv_file_open()

So it's better to use bs->filename.

Signed-off-by: Dunrong Huang <>
Reviewed-by: Max Reitz <>...

d055a1fe 09/26/2013 03:11 pm Fam Zheng

block: use DIV_ROUND_UP in bdrv_co_do_readv

Signed-off-by: Fam Zheng <>
Reviewed-by: Eric Blake <>
Signed-off-by: Kevin Wolf <>

030be321 09/25/2013 05:21 pm Benoît Canet

block: introduce BlockDriver.bdrv_needs_filename to enable some drivers.

Some drivers will have driver specifics options but no filename.
This new bool allow the block layer to treat them correctly.

The .bdrv_needs_filename is set in drivers not having .bdrv_parse_filename and...

5726d872 09/25/2013 05:21 pm Benoît Canet

qdict: Extract qdict_extract_subqdict

Signed-off-by: Benoit Canet <>
Signed-off-by: Kevin Wolf <>

dbecebdd 09/25/2013 11:08 am Fam Zheng

block: fix backing file overriding

Providing backing.file.filename doesn't override backing file as expected:

$ x86_64-softmmu/qemu-system-x86_64 -drive \
file=/tmp/child.qcow2,backing.file.filename=/tmp/fake.qcow2
qemu-system-x86_64: -drive \...
3e0a233d 09/25/2013 11:08 am Peter Lieven

block/get_block_status: set *pnum = 0 on error

if the call is invoked through bdrv_is_allocated the caller might
expect *pnum = 0 on error. however, a new implementation of
bdrv_get_block_status might only return a negative exit value on
error while keeping *pnum untouched....

1f9db224 09/25/2013 11:08 am Peter Lieven

block/get_block_status: avoid segfault if there is no backing_hd

Reviewed-by: Eric Blake <>
Signed-off-by: Peter Lieven <>
Signed-off-by: Kevin Wolf <>