History | View | Annotate | Download (150.9 kB)
block: use /var/tmp instead of /tmp for -snapshot
If TMPDIR is not specified, the default was to use /tmp for the workingcopy of the block devices. Update this to /var/tmp instead, so systemsusing tmp-on-tmpfs don't end up inadvertently using RAM for the block...
block: Add reference parameter to bdrv_open()
Allow bdrv_open() to handle references to existing block devices just asbdrv_file_open() is already capable of.
Signed-off-by: Max Reitz <mreitz@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: Make bdrv_file_open() static
Add the bdrv_open() option BDRV_O_PROTOCOL which results in passing thecall to bdrv_file_open(). Additionally, make bdrv_file_open() static andtherefore bdrv_open() the only way to call it.
Consequently, all existing calls to bdrv_file_open() have to be adjusted...
block: Reuse reference handling from bdrv_open()
Remove the reference parameter and the related handling code frombdrv_file_open(), since it exists in bdrv_open() now as well.
Signed-off-by: Max Reitz <mreitz@redhat.com>Reviewed-by: Benoit Canet <benoit@irqsave.net>...
block: Remove bdrv_new() from bdrv_file_open()
Change bdrv_file_open() to take a simple pointer to an already existingBDS instead of an indirect one. The BDS will be created in bdrv_open()if necessary.
block: Handle bs->options in bdrv_open() only
The fail paths of bdrv_file_open() and bdrv_open() naturally exhibitsimilarities, thus it is possible to reuse the one from bdrv_open() andshorten the one in bdrv_file_open() accordingly.
Also, setting bs->options in bdrv_file_open() is not necessary if it is...
block: Reuse success path from bdrv_open()
The fail and success paths of bdrv_file_open() may be further shortenedby reusing code already existent in bdrv_open(). This includesbdrv_file_open() not taking the reference to options which allows theremoval of QDECREF in that function....
block: Remove bdrv_open_image()'s force_raw option
This option is now unnecessary since specifying BDRV_O_PROTOCOL as flagwill do exactly the same.
Signed-off-by: Max Reitz <mreitz@redhat.com>Reviewed-by: Benoit Canet <benoit@irqsave.net>Reviewed-by: Kevin Wolf <kwolf@redhat.com>...
block: Fix bdrv_is_first_non_filter()
Consider top level BlockDriverStates as well.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Benoit Canet <benoit@irqsave.net>Tested-by: Benoit Canet <benoit@irqsave.net>
block: Change BDS parameter of bdrv_open() to **
Make bdrv_open() take a pointer to a BDS pointer, similarly tobdrv_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 notNULL, that existing BDS will be reused (in the same way as bdrv_open()...
Merge remote-tracking branch 'remotes/qmp-unstable/queue/qmp' into staging
Use error_is_set() only when necessary
error_is_set(&var) is the same as var != NULL, but it takeswhole-program analysis to figure that out. Unnecessarily hard foroptimizers, static checkers, and human readers. Dumb it down toobvious.
Gets rid of several dozen Coverity false positives....
block: Relax bdrv_lookup_bs constraints.
The following patch will reuse bdrv_lookup_bs in order to open images byreferences so the rules of usage of bdrv_lookup_bs must be relaxed a bit.
Signed-off-by: Benoit Canet <benoit@irqsave.net>Reviewed-by: Max Reitz <mreitz@redhat.com>...
block: Open by reference will try device then node_name.
Since we introduced node_name for named bs of the graph modify the opening byreference to use it as a fallback.
This patch also enforce the separation of the device id and graph nodenamespaces....
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 memoryleak.
Reported-by: Laszlo Ersek <lersek@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>...
block: bdrv_aligned_pwritev: Assert overlap range
This adds assertions that the request that we actually end up passing tothe block driver (which includes RMW data and has therefore potentiallybeen rounded to alignment boundaries) is fully covered by the...
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 <lersek@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>...
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 tomatch the field in BdrvTrackedRequest....
block: Fail gracefully with missing filename
This fixes a regression introduced in commit 2a05cbe42 ('block: Allowblock devices without files'):
$ qemu-system-x86_64 drive driver=fileqemu-system-x86_64: block.c:892: bdrv_open_common: Assertion`!drv>bdrv_needs_filename || filename != ((void *)0)' failed....
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 forwith their exact byte size.
Reported-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>...
qemu-iotests: Test pwritev RMW logic
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Max Reitz <mreitz@redhat.com>
block: Assert serialisation assumptions in pwritev
If a request calls wait_serialising_requests() and actually has to waitin this function (i.e. a coroutine yield), other requests can run andpreviously read data (like the head or tail buffer) could become...
block: Change coroutine wrapper to byte granularity
block: Make bdrv_pread() a bdrv_prwv_co() wrapper
Instead of implementing the alignment adjustment here, use the nowexisting functionality of bdrv_co_do_preadv().
block: Make bdrv_pwrite() a bdrv_prwv_co() wrapper
Instead of implementing the alignment adjustment here, use the nowexisting functionality of bdrv_co_do_pwritev().
raw: Probe required direct I/O alignment
Add a bs->request_alignment field that contains the requiredoffset/length alignment for I/O requests and fill it in the raw blockdrivers. Use ioctls if possible, else see what alignment it takes forO_DIRECT to succeed....
block: Introduce bdrv_aligned_preadv()
This separates the part of bdrv_co_do_readv() that needs to happenbefore the request is modified to match the backend alignment, and apart that needs to be executed afterwards and passes the request to theBlockDriver....
block: Introduce bdrv_co_do_preadv()
Similar to bdrv_pread(), which aligns byte-aligned request to 512 bytesectors, bdrv_co_do_preadv() takes a byte-aligned request and aligns itto the alignment specified in bs->request_alignment.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>...
block: Introduce bdrv_aligned_pwritev()
This separates the part of bdrv_co_do_writev() that needs to happenbefore the request is modified to match the backend alignment, and apart that needs to be executed afterwards and passes the request to theBlockDriver....
block: write: Handle COR dependency after I/O throttling
First waiting for all COR requests to complete and calling thethrottling function afterwards means that the request could be delayedand we still need to wait for the COR request even if it was issued only...
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.
block: Switch BdrvTrackedRequest to byte granularity
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Max Reitz <mreitz@redhat.com>Reviewed-by: Benoit Canet <benoit@irqsave.net>
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...
block: Make zero-after-EOF work with larger alignment
Odd file sizes could make bdrv_aligned_preadv() shorten the request innon-aligned ways. Fix it by rounding to the required alignment insteadof 512 bytes.
block: Generalise and optimise COR serialisation
Change the API so that specific requests can be marked serialising. Onlythese requests are checked for overlaps then.
This means that during a Copy on Read operation, not all requestsoverlapping other requests are serialised any more, but only those that...
block: Make overlap range for serialisation dynamic
Copy on Read wants to serialise with all requests touching the samecluster, so wait_serialising_requests() rounded to cluster boundaries.Other users like alignment RMW will have different requirements, though...
block: Allow wait_serialising_requests() at any point
We can only have a single wait_serialising_requests() call per requestbecause otherwise we can run into deadlocks where requests are waitingfor each other. The same is true when wait_serialising_requests() is not...
block: Align requests in bdrv_co_do_pwritev()
This patch changes bdrv_co_do_pwritev() to actually be what its namepromises. If requests aren't properly aligned, it performs a RMW.
Requests touching the same block are serialised against the RMW request....
block: Move initialisation of BlockLimits to bdrv_refresh_limits()
This function separates filling the BlockLimits from bdrv_open(), whichallows it to call it from other operations which may change the limits(e.g. modifications to the backing file chain or bdrv_reopen)...
block: Inherit opt_transfer_length
When there is a format driver between the backend, it's not guaranteedthat exposing the opt_transfer_length for the format driver results inthe optimal requests (because of fragmentation etc.), but it can't makethings worse, so let's just do it....
block: Update BlockLimits when they might have changed
When reopening with different flags, or when backing files disappearfrom the chain, the limits may change. Make sure they get updated inthese cases.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>...
block: Detect unaligned length in bdrv_qiov_is_aligned()
For an O_DIRECT request to succeed, it's not only necessary that allbase addresses in the qiov are aligned, but also that each length in itis aligned.
block: Don't use guest sector size for qemu_blockalign()
bs->buffer_alignment is set by the device emulation and contains thelogical block size of the guest device. This isn't something that theblock layer should know, and even less something to use for determining...
block: rename buffer_alignment to guest_block_size
The alignment field is now set to the value that is promised to theguest, rather than required by the host. The next patches will makeQEMU aware of the host-provided values, so make this clear.
The alignment is also not about memory buffers, but about the sectors on...
block: Fix bdrv_commit return value
bdrv_commit() could return 0 or 1 on success, depending on whether ornot the last sector was allocated in the overlay and whether the overlayformat had a .bdrv_make_empty callback.
Most callers ignored it, but qemu-img commit would print an error...
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...
qmp: Add QMP query-named-block-nodes to list the named BlockDriverState nodes.
Signed-off-by: Benoit Canet <benoit@irqsave.net>Reviewed-by: Fam Zheng <famz@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qmp: Allow to change password on named block driver states.
Signed-off-by: Benoit Canet <benoit@irqsave.net>Reviewed-by: Fam Zheng <famz@redhat.com>
There was two candidate ways to implement named node manipulation:
1) { 'command': 'block_passwd', 'data': {'*device': 'str',...
block: Create authorizations mechanism for external snapshot and resize.
Signed-off-by: Benoit Canet <benoit@irqsave.net>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: Allow the user to define "node-name" option both on command line and QMP.
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.
block: fix backing file segfault
When a backing file is opened such that (1) a protocol is directlyused as the block driver and (2) the block driver has bdrv_file_open,bdrv_open_backing_file segfaults. The problem arises becausebdrv_open_common returns without setting bd->backing_hd->file....
block: Add bdrv_open_image()
Add a common function for opening images to be used for block driversspecified through BlockdevRefs in an option QDict. The difference frombdrv_file_open() is that this function may invoke bdrv_open() instead,allowing auto-detection of the driver to be used; and second, it...
block: Use bdrv_open_image() in bdrv_open()
Using bdrv_open_image() instead of bdrv_file_open() directly inbdrv_open() is easier.
block: Allow recursive "file"s
It should be possible to use a format as a driver for a file which inturn requires another file, i.e., nesting file formats.
Allowing nested file formats results in e.g. qcow2 BlockDriverStatesnever being directly passed to bdrv_open_common() from bdrv_file_open(),...
block: Allow reference for bdrv_file_open()
Allow specifying a reference to an existing block device (by name) forbdrv_file_open() instead of a filename and/or options.
Signed-off-by: Max Reitz <mreitz@redhat.com>Reviewed-by: Kevin Wolf <kwolf@redhat.com>...
block: Pass reference to bdrv_file_open()
With that now being possible, bdrv_open() should try to extract a blockdevice reference from the options and pass it to bdrv_file_open().
block: Allow block devices without files
blkdebug and blkverify will, in order to retain compatibility, notsupport the field "file" implicitly through bdrv_open(). In order to beable to use those drivers without giving a filename anyway, it isnecessary to be able to have block devices without files implicitly...
block: expect get_block_status errors in bdrv_make_zero
during testing around with 4k LUNs a bad target implementationtriggert an -EIO in iscsi_get_block_status, but it got never caughtresulting in an infinite loop.
CC: qemu-stable@nongnu.orgSigned-off-by: Peter Lieven <pl@kamp.de>...
block: clean up bdrv_drain_all() throttling comments
Since cc0681c45430a1f1a4c2d06e9499b7775afc9a18 ("block: Enable the newthrottling code in the block layer.") bdrv_drain_all() no longer spins.The code used to look as follows:
do { busy = qemu_aio_wait();...
block: Close backing file early in bdrv_img_create
Leaving the backing file open although it is not needed anymore cancause problems if it is opened through a block driver which allowsexclusive access only and if the create function of the block driver...
block: add flags argument to bdrv_co_write_zeroes tracepoint
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Peter Lieven <pl@kamp.de>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block: add bdrv_aio_write_zeroes
This will be used by the SCSI layer.
block: handle ENOTSUP from discard in generic code
Similar to write_zeroes, let the generic code receive a ENOTSUP fordiscard operations. Since bdrv_discard has advisory semantics,we can just swallow the error.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
block: make bdrv_co_do_write_zeroes stricter in producing aligned requests
Right now, bdrv_co_do_write_zeroes will only try to align thebeginning of the request. However, it is simpler for manyformats to expect the block layer to separate both the head and...
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 <kwolf@redhat.com>...
block: add flags to BlockRequest
This lets bdrv_co_do_rw receive flags, so that it can be used forzero writes.
block: Use BDRV_O_NO_BACKING where appropriate
If you open an image temporarily just because you want to check its sizeor get it flushed, there's no real reason to open the whole backing filechain.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Fam Zheng <famz@redhat.com>...
blkdebug: add "remove_break" command
This adds "remove_break" command which is the reverse of blkdebugcommand "break": it removes all breakpoints with given tag and resumesall the requests.
Signed-off-by: Fam Zheng <famz@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block: Enable BDRV_O_SNAPSHOT with driver-specific options
In the case of snapshot=on, don't rely on the backing file path in thetemporary image any more, but override the backing file with the givenset of options. This way, block drivers that don't use a file name can...
qapi: Change BlockDirtyInfo to list
We have multiple dirty bitmaps in BDS now, switch QAPI to allow queryit (BlockInfo.dirty_bitmaps), and also drop old BlockInfo.dirty.
Signed-off-by: Fam Zheng <famz@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: per caller dirty bitmap
Previously a BlockDriverState has only one dirty bitmap, so only onecaller (e.g. a block job) can keep track of writing. This changes thedirty bitmap to a list and creates a BdrvDirtyBitmap for each caller, thelifecycle is managed with these new functions:...
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 andonly writing zeroes to the device if they currently do notreturn zeroes. optionally the zero writing can be sped up...
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...
block: make BdrvRequestFlags public
Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Peter Lieven <pl@kamp.de>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block: add flags to bdrv_*_write_zeroes
block: introduce BDRV_REQ_MAY_UNMAP request flag
block: add wrappers for logical block provisioning information
This adds 2 wrappers to read the unallocated_blocks_are_zero andcan_write_zeroes_with_unmap info from the BDI. The wrappers arerequired to check for the existence of a backing_hd andif the devices are opened with the correct flags....
block: honour BlockLimits in bdrv_co_do_write_zeroes
block: honour BlockLimits in bdrv_co_discard
block: Fail if requested driver is not available
If an explicit driver option is present, but doesn't specify a validdriver, then bdrv_open() should fail instead of probing the format.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Jeff Cody <jcody@redhat.com>...
block: Print its file name if backing file opening failed
If backing file doesn't exist, the error message is confusing andmisleading:
$ qemu /tmp/a.qcow2 qemu: could not open disk image /tmp/a.qcow2: Could not open file: No such file or directory...
block: Round up total_sectors
Since b94a2610, bdrv_getlength() is omitted when probing image. VMDKmonolithicFlat is broken by that because a file < 512 bytes can't beread with its total_sectors truncated to 0. This patch round up the sizeto BDRV_SECTOR_SIZE, when a image size is not sector aligned....
block: Save errno before error_setg_errno
error_setg_errno() may overwrite errno; therefore, its value should beread before calling that function and not afterwards.
Signed-off-by: Max Reitz <mreitz@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>...
block: Avoid unecessary drv->bdrv_getlength() calls
The block layer generally keeps the size of an image cached inbs->total_sectors so that it doesn't have to perform expensiveoperations to get the size whenever it needs it.
This doesn't work however when using a backend that can change its size...
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 fileread-only with the BDRV_O_COPY_ON_READ flag set.Although BDRV_O_RDWR is unset for the backing files,...
block: Don't copy backing file name on error
bdrv_open_backing_file() tries to copy the backing file name usingpstrcpy directly after calling bdrv_open() to open the backing filewithout checking whether that was actually successful. If it was not,ps->backing_hd->file will probably be NULL and qemu will crash....
blockdev: Don't disable COR automatically with blockdev-add
If a read-only device is configured with copy-on-read=on, the old codeonly prints a warning and automatically disables copy on read. Make ita real error for blockdev-add.
block: Improve driver whitelist checks
The main intent of this patch is to consolidate the whitelist checks toa single point in the code instead of spreading it everywhere. This addsa nicer error message for read-only whitelisting, too, in places where...
block/get_block_status: avoid redundant callouts on raw devices
if a raw device like an iscsi target or host device is usedthe current implementation makes a second call out to getthe block status of bs->file.
Signed-off-by: Peter Lieven <pl@kamp.de>Reviewed-by: Eric Blake <eblake@redhat.com>...
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 externalsnapshot creation.
Signed-off-by: Benoit Canet <benoit@irqsave.net>...
block: Add bdrv_get_specific_info
Add a function for retrieving an ImageInfoSpecific object from a blockdriver.
Signed-off-by: Max Reitz <mreitz@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
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 <riegamaths@gmail.com>Reviewed-by: Max Reitz <mreitz@redhat.com>...
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()
block: use DIV_ROUND_UP in bdrv_co_do_readv
Signed-off-by: Fam Zheng <famz@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
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...
qdict: Extract qdict_extract_subqdict
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 \...
block/get_block_status: set *pnum = 0 on error
if the call is invoked through bdrv_is_allocated the caller mightexpect *pnum = 0 on error. however, a new implementation ofbdrv_get_block_status might only return a negative exit value onerror while keeping *pnum untouched....
block/get_block_status: avoid segfault if there is no backing_hd
Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Peter Lieven <pl@kamp.de>Signed-off-by: Kevin Wolf <kwolf@redhat.com>