History | View | Annotate | Download (127.7 kB)
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.
Signed-off-by: Fam Zheng <famz@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
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.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>...
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....
block: Introduce bdrv_writev_vmstate
block: Introduce bdrv_pwritev() for qcow2_save_vmstate
Directly pass the QEMUIOVector on instead of linearising it.
block: fix I/O throttling accounting blind spot
I/O throttling relies on bdrv_acct_done() which is called when a requestcompletes. This leaves a blind spot since we only charge for completedrequests, not submitted requests.
For example, if there is 1 operation remaining in this time slice the...
block: keep I/O throttling slice time constant
It is not necessary to adjust the slice time at runtime. We alreadyextend the current slice in order to carry over accounting into the nextslice. Changing the actual slice time value introduces oscillations....
block: drop duplicated slice extension code
The current slice is extended when an I/O request exceeds the limit.There is no need to extend the slice every time we check a request.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>Tested-By: Benoit Canet <benoit@irqsave.net>...
block: clean up I/O throttling wait_time code
The wait_time variable is in seconds. Reflect this in a comment and useNANOSECONDS_PER_SECOND instead of BLOCK_IO_SLICE_TIME * 10 (whichhappens to have the right value).
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>...
block: Fix direct use of protocols as driver for bdrv_open()
bdrv_open_common() implements direct use of protocols by copying thepre-opened BlockDriverStates to bs using bdrv_swap(). It did howeverfirst set some fields in bs, which end up in file after the swap. When...
block: Introduce .bdrv_parse_filename callback
If a driver needs structured data and not just a string, it can providea .bdrv_parse_filename callback now that parses the command line stringinto separate options. Keeping this separate from .bdrv_open_filename...
block: Rename variable to avoid shadowing
bdrv_open() uses two different variables called options. Rename one ofthem to avoid confusion and to allow the outer one to be accessedeverywhere.
block: Allow omitting the file name when using driver-specific options
After this patch, using -drive with an empty file name continues to openthe file if driver-specific options are used. If no driver-specificoptions are specified, the semantics stay as it was: It defines a drive...
Revert "block: complete all IOs before .bdrv_truncate"
brdv_truncate() is also called from readv/writev commands on self-growing file based storage. this will result in requests waitingfor theirselves to complete.
This reverts commit 9a665b2b8640e464f0a778216fc2dca8d02acf33....
block: Add options QDict to bdrv_file_open() prototypes
The new parameter is unused yet.
block: Pass bdrv_file_open() options to block drivers
Specify -drive file.option=... on the command line to pass the option tothe protocol instead of the format driver.
block: fix BDRV_O_SNAPSHOT protocol detection
realpath(3) is used to get an absolute path to the image file whencreating a -drive snapshot=on temporary qcow2. This does not work forprotocols since their filenames ("proto:foo:...") do not correspond to...
block: add bdrv_get_aio_context()
For now bdrv_get_aio_context() is just a stub that callsqemu_aio_get_context() since the block layer is currently tied to themain loop AioContext.
Add the stub now so that the block layer can begin accessing itsAioContext....
block: Add options QDict to .bdrv_open()
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block: Add options QDict to bdrv_open() prototype
It doesn't do anything yet except storing the options QDict in theBlockDriverState.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>...
block: Add options QDict to bdrv_open_common()
The options are passed down to the block drivers, which are supposed toremove all options they have processed. Anything that is left over inthe end is an unknown option and results in an error.
block: for HMP commit() operations on 'all', skip non-COW drives
During a commit of 'all' using the HMP non-live commit, the operationis aborted and returns error on the first error enountered. Whennon-COW drives are in use (e.g. ejected floppy, cdrom, or drives without...
block: implement BDRV_O_UNMAP
It is better to present homogeneous hardware independent of the storagetechnology that is chosen on the host, hence we make discard a hostparameter; the user can choose whether to pass it down to the imageformat and protocol, or to ignore it....
block: complete all IOs before .bdrv_truncate
bdrv_truncate() invalidates the bdrv_check_request() result forin-flight requests, so there should better be none.
Cc: qemu-stable@nongnu.orgSigned-off-by: Peter Lieven <pl@kamp.de>Reported-by: Kevin Wolf <kwolf@redhat.com>...
block: Add synchronous wrapper for bdrv_co_is_allocated_above
There's no synchronous wrapper for bdrv_co_is_allocated_above functionso it's not possible to check for sector allocation in an image witha backing file.
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>...
qemu-img: Add "Quiet mode" option
There can be a need to turn output to stdout off. This patch adds a -q optionthat enable "Quiet mode". In Quiet mode, only errors are printed out.
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>Reviewed-by: Kevin Wolf <kwolf@redhat.com>...
block: Fix is_allocated_above with resized files
In an image chain, if the base image is smaller than the currentimage, we need to make sure to use the current images count ofunallocated blocks once we get to the end of the base image. Withoutthis change the code will return 0 blocks when it gets to the end...
block: allow customizing the granularity of the dirty bitmap
Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: implement dirty bitmap using HBitmap
This actually uses the dirty bitmap in the block layer, and convertsmirroring to use an HBitmapIter.
Reviewed-by: Laszlo Ersek <lersek@redhat.com> (except block/mirror.c parts)Reviewed-by: Eric Blake <eblake@redhat.com>...
block: make round_to_clusters public
This is needed in the following patch.
Reviewed-by: Laszlo Ersek <lersek@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: return count of dirty sectors, not chunks
block: clear dirty bitmap when discarding
Note that resetting bits in the dirty bitmap is done before actuallyprocessing the request. Writes, instead, set bits after the requestis completed.
This way, when there are concurrent write and discard requests, the...
block: fix initialization in bdrv_io_limits_enable()
bdrv_io_limits_enable() starts a new slice, but does not set io_basecorrectly 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;...
block: do not probe zero-sized disks
A blank CD or DVD is visible as a zero-sized disks. Probing suchdisks will lead to an EIO and a failure to start the VM. Treatingthem as raw is a better solution.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
block: make qiov_is_aligned() public
The qiov_is_aligned() function checks whether a QEMUIOVector meets aBlockDriverState's alignment requirements. This is needed byvirtio-blk-data-plane so:
1. Move the function from block/raw-posix.c to block/block.c....
Replace remaining gmtime, localtime by gmtime_r, localtime_r
This allows removing of MinGW specific code and improvesreentrancy 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]...
softmmu: move include files to include/sysemu/
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
misc: move include files to include/qemu/
monitor: move include files to include/monitor/
qapi: move include files to include/qobject/
block: move include files to include/block/
qemu-io: Add AIO debugging commands
This makes the blkdebug suspend/resume functionality available inqemu-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'...
block: bdrv_img_create(): add Error ** argument
This commit adds an Error ** argument to bdrv_img_create() and set itappropriately on error.
Callers of bdrv_img_create() pass NULL for the new argument and stillrely on bdrv_img_create()'s return value. Next commits will change...
block: bdrv_img_create(): drop unused error handling code
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: Improve bdrv_aio_co_cancel_em
Instead of waiting for all requests to complete, wait just for thespecific request that should be cancelled.
block: Factor out bdrv_open_flags
block: Avoid second open for format probing
This fixes problems that are caused by the additional open/close cycleof the existing format probing, for example related to qemu-nbd without-t option or file descriptor passing.
block: Fix regression for MinGW (assertion caused by short string)
The local string tmp_filename is passed to function get_tmp_filenamewhich 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....
aio: use g_slice_alloc() for AIOCB pooling
AIO control blocks are frequently acquired and released because each aiorequest involves at least one AIOCB. Therefore, we pool them to avoidheap allocation overhead.
The problem with the freelist approach in AIOPool is thread-safety. If...
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 longerneeds to be modified.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Merge remote-tracking branch 'kwolf/for-anthony' into staging
iostatus: forward block_job_iostatus_reset to block job
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
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 concurrentlyexamine them and copy incomplete data from the source.
block: export dirty bitmap information in query-block