History | View | Annotate | Download (139.8 kB)
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 <benoit@irqsave.net>Reviewed-by: Fam Zheng <famz@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
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.
Signed-off-by: Max Reitz <mreitz@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
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.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>...
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
Signed-off-by: Benoit Canet <benoit@irqsave.net>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
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>
block: don't lose data from last incomplete sector
To read the last sector that is not aligned to sector boundary, currentcode for growable backends, since commit 893a8f6 "block: Produce zeroswhen protocols reading beyond end of file", drops the data and directly...
bdrv: Use "Error" for creating images
Add an Error ** parameter to BlockDriver.bdrv_create to allow morespecific error messages.
Signed-off-by: Max Reitz <mreitz@redhat.com>
block: Error parameter for open functions
Add an Error ** parameter to bdrv_open, bdrv_file_open and associatedfunctions to allow more specific error messages.
block: Error parameter for create functions
Add an Error ** parameter to bdrv_create and its associated functions toallow more specific error messages.
bdrv: Use "Error" for opening images
Add an Error ** parameter to BlockDriver.bdrv_open andBlockDriver.bdrv_file_open to allow more specific error messages.
block: Image file option amendment
This patch adds the "amend" option to qemu-img which allows changingimage options on existing image files. It also adds the generic bdrvimplementation which is basically just a wrapper for the image formatspecific function....
block: remove bdrv_is_allocated_above/bdrv_co_is_allocated_above distinction
Now that bdrv_is_allocated detects coroutine context, the two canuse the same code.
Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
block: expect errors from bdrv_co_is_allocated
Some bdrv_is_allocated callers do not expect errors, but the fallbackin qcow2.c might make other callers trip on assertion failures orinfinite loops.
Fix the callers to always look for errors.
Cc: qemu-stable@nongnu.org...
block: make bdrv_has_zero_init return false for copy-on-write-images
This helps implementing is_allocated on top of get_block_status.
Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block: introduce bdrv_get_block_status API
For now, bdrv_get_block_status is just another name for bdrv_is_allocated.The next patches will add more flags.
This also touches all block drivers with a mostly mechanical rename. Thesole exception is cow; because it calls cow_co_is_allocated from the read...
block: define get_block_status return value
Define the return value of get_block_status. Bits 0, 1, 2 and 9-62are valid; bit 63 (the sign bit) is reserved for errors. Bits 3-8are left for future extensions.
The return code is compatible with the old is_allocated API: if a driver...
block: use bdrv_has_zero_init to return BDRV_BLOCK_ZERO
Alternatively, this could use a "discard zeroes data" flag returnedby bdrv_get_info.
block: return BDRV_BLOCK_ZERO past end of backing file
If the sectors are unallocated and we are past the end of thebacking file, they will read as zero.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block: add default get_block_status implementation for protocols
Protocols return raw data, so you can assume the offsets to passthrough unchanged.
block: look for zero blocks in bs->file
block: implement reference count for BlockDriverState
Introduce bdrv_ref/bdrv_unref to manage the lifecycle ofBlockDriverState. They are unused for now but will used to replacebdrv_delete() later.
block: make bdrv_delete() static
Manage BlockDriverState lifecycle with refcnt, so bdrv_delete() is nolonger public and should be called by bdrv_unref() if refcnt isdecreased to 0.
This is an identical change because effectively, there's no multiplereference of BDS now: no caller of bdrv_ref() yet, only bdrv_new() sets...
block: keep bs->total_sectors up to date even for growable block devices
If a BlockDriverState is growable, after every write we need tocheck if bs->total_sectors might have changed. With this change,bdrv_getlength does not need anymore a system call....
block: make bdrv_co_is_allocated static
bdrv_is_allocated can detect coroutine context and go through a fastpath, similar to other block layer functions.
block: do not use ->total_sectors in bdrv_co_is_allocated
This is more robust when the device has removable media.
block: Enable the new throttling code in the block layer.
Signed-off-by: Benoit Canet <benoit@irqsave.net>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block: Remove redundant assertion
The failing condition is checked immediately before the assertion, sokeeping the assertion is kind of redundant.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
aio / timers: Switch entire codebase to the new timer API
This is an autogenerated patch using scripts/switch-timer-api.
Switch the entire code base to using the new timer API.
Note this patch may introduce some line length issues.
Signed-off-by: Alex Bligh <alex@alex.org.uk>...
block: Produce zeros when protocols reading beyond end of file
While Asias is debugging an issue creating qcow2 images on top ofnon-file protocols. It boils down to this example using NBD:
$ qemu-io -c 'open -g nbd+unix:///?socket=/tmp/nbd.sock' -c 'read -v 0 512'...
block: Introduce bs->zero_beyond_eof
In 4146b46c42e0989cb5842e04d88ab6ccb1713a48 (block: Produce zeros whenprotocols reading beyond end of file), we break qemu-iotests ./check-qcow2 022. This happens because qcow2 temporarily sets ->growable = 1for vmstate accesses (which are stored beyond the end of regular image...
block: ensure bdrv_drain_all() works during bdrv_delete()
In bdrv_delete() make sure to call bdrv_make_anon() after bdrv_close()so that the device is still seen by bdrv_drain_all() when iteratingbdrv_states.
Cc: qemu-stable@nongnu.orgSigned-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block: stop relying on io_flush() in bdrv_drain_all()
If a block driver has no file descriptors to monitor but there are stillactive requests, it can return 1 from .io_flush(). This is used to spinduring synchronous I/O.
Stop relying on .io_flush() and instead check...
block: Repair the throttling code.
The throttling code was segfaulting since commit02ffb504485f0920cfc75a0982a602f824a9a4f4 because some qemu_co_queue_next callerdoes not run in a coroutine.qemu_co_queue_do_restart assume that the caller is a coroutinne....
block: Allow "driver" option on the top level
This is traditionally -drive format=..., which is now translated intothe new driver option. This gives us a more consistent way to select thedriver of BlockDriverStates that can be used in QMP context, too....
block: fix bdrv_read_unthrottled()
Signed-off-by: Peter Lieven <pl@kamp.de>Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block: add bdrv_write_zeroes()
Signed-off-by: Peter Lieven <pl@kamp.de>Reviewed-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block: Add return value for bdrv_flush_all()
bdrv_flush() can fail, and bdrv_flush_all() should return an error aswell if this happens for a block device. It returns the first errorreturn now, but still at least tries to flush the remaining devices even...
block: Don't parse protocol from file.filename
One of the major reasons for doing something new for -blockdev andblockdev-add was that the old block layer code parses filenames insteadof just taking them literally. So we should really leave it untouched...
block: fix bdrv_flush() ordering in bdrv_close()
Since 80ccf93b we flush the block device during close. Thebdrv_drain_all() call should come before bdrv_flush() to ensure guestwrite requests have completed. Otherwise we may miss pending writeswhen flushing....
block: change default of .has_zero_init to 0
.has_zero_init defaults to 1 for all formats and protocols.
this is a dangerous default since this means that allnew added drivers need to manually overwrite it to 0 ifthey do not ensure that a device is zero initialized...
block: add bdrv_add_before_write_notifier()
The bdrv_add_before_write_notifier() function installs a callback thatis invoked before a write request is processed. This will be used toimplement copy-on-write point-in-time snapshots where we need to copy...
block: Always enable discard on the protocol level
Turning on discard options in qcow2 doesn't help a lot when the discardrequests that it issues are thrown away by the raw-posix layer. Thispatch always enables discard functionality on the protocol level so that...
block: bdrv_reopen_prepare(): don't use QERR_OPEN_FILE_FAILED
The call to drv->bdrv_reopen_prepare() can fail due to reasonsother than an open failure. Unfortunately, we can't use errnonor -ret, cause they are not always set.
Stick to a generic error message then....
blkdebug: Add BLKDBG_FLUSH_TO_OS/DISK events
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block: move snapshot code in block.c to block/snapshot.c
All snapshot related code, except bdrv_snapshot_dump() andbdrv_is_snapshot(), is moved to block/snapshot.c. bdrv_snapshot_dump()will be moved to another file later. bdrv_is_snapshot() is not related...
block: move qmp and info dump related code to block/qapi.c
This patch is a pure code move patch, except following modification:1 get_human_readable_size() is changed to static function.2 dump_human_image_info() is renamed to bdrv_image_info_dump().3 in qmp_query_block() and qmp_query_blockstats, use bdrv_next(bs)...
block: drop bs_snapshots global variable
The bs_snapshots global variable points to the BlockDriverState whichwill be used to save vmstate. This is really a savevm.c concept but wasmoved into block.c:bdrv_snapshots() when it became clear that hotplugcould result in a dangling pointer....
block: add block driver read only whitelist
We may want to include a driver in the whitelist for read only taskssuch as diagnosing or exporting guest data (with libguestfs as a goodexample). This patch introduces a readonly whitelist option, and forbackward compatibility, the old configure option --block-drv-whitelist...
block: Add hint to -EFBIG error message
The limit of qcow2 files at least depends on the cluster size. If theimage format has a cluster_size option, suggest to increase it.
block: Fix build with tracing enabled
filename was still uninitialised when it's used as a parameter to atracing function, so let's move the initialisation. Also, commit c2ad1b0cforgot to add a NULL check, which this patch adds while we're at it.
block: Allow overriding backing.file.filename
If a filename is passed in the driver-specific options from the commandline, the backing file path from the image is ignored now.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>
block: Remove filename parameter from .bdrv_file_open()
It is unused now in all block drivers.
block: Fail gracefully when using a format driver on protocol level
Specifying the wrong driver could fail an assertion:
$ qemu-system-x86_64 -drive file.driver=qcow2,file=xqemu-system-x86_64: block.c:721: bdrv_open_common: Assertion `file !=((void *)0)' failed....
block: Add driver-specific options for backing files
Options starting in "backing." are passed to the backing file now. Ifyou don't need to specify the filename for the backing file, you can addit on the command line instead of in the image file:
$ qemu-nbd -t /tmp/test.img...
block: Enable filename option
This allows using the file.filename option instead of the string thatcomes from -drive file=... and is passed around as a separate parameter.The goal is to get rid of this parameter and use the options QDict moreconsistently....