History | View | Annotate | Download (133.6 kB)
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.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
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.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
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: bdrv_create(): don't leak cco.filename on error
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: add bdrv_query_info
Extract it out of the implementation of "info block".
block: add bdrv_query_stats
qmp_query_blockstat cannot have errors, remove the Error argument andcreate a new public function bdrv_query_stats out of it.
block: add bdrv_open_backing_file
Mirroring runs without the backing file so that it can be copied outsideQEMU. However, we need to add it at the time the job is completed andQEMU switches to the target. Factor out the common bits of opening animage and completing a mirroring operation....
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
block: make bdrv_find_backing_image compare canonical filenames
Currently, bdrv_find_backing_image compares bs->backing_file withwhat is passed in as a backing_file name. Mismatches may occur,however, when bs->backing_file and backing_file are not both...
block: prepare code for adding block notifiers
There is no reason in principle to skip job cancellation and drainingof pending I/O when there is no medium in the disk. Do these unconditionally,which also prepares the code for the next patch.
block: add close notifiers
The first user of close notifiers will be the embedded NBD server.It would be possible to use them to do some of the ad hoc processing(e.g. for block jobs and I/O limits) that is currently done bybdrv_close.
Acked-by: Kevin Wolf <kwolf@redhat.com>...
block: avoid buffer overrun by using pstrcpy, not strncpy
Also, use PATH_MAX, rather than the arbitrary 1024.Using PATH_MAX is more consistent with other filename-relatedvariables in this file, like backing_filename and tmp_filename.
iostatus: change is_read to a bool
Do this while we are touching this part of the code, before introducingmore uses of "int is_read".
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
iostatus: reorganize io error code
Move the common part of IDE/SCSI/virtio error handling to the blocklayer. The new function bdrv_error_action subsumes all three ofbdrv_emit_qmp_error_event, vm_stop, bdrv_iostatus_set_err.
The same scheme will be used for errors in block jobs....
block: introduce block job error
The following behaviors are possible:
'report': The behavior is the same as in 1.1. An I/O error,respectively during a read or a write, will complete the job immediatelywith an error code.
'ignore': An I/O error, respectively during a read or a write, will be...
iostatus: move BlockdevOnError declaration to QAPI
This will let block-stream reuse the enum. Places that used the enumsare renamed accordingly.
iostatus: rename BlockErrorAction, BlockQMPEventAction
We want to remove knowledge of BLOCK_ERR_STOP_ENOSPC from drivers;drivers should only be told whether to stop/report/ignore the error.On the other hand, we want to keep using the nicer BlockErrorAction...
block: move job APIs to separate files
block: helper function, to find the base image of a chain
This is a simple helper function, that will return the base imageof a given image chain.
Signed-off-by: Jeff Cody <jcody@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: add support functions for live commit, to find and delete images.
Add bdrv_find_overlay(), and bdrv_drop_intermediate().
bdrv_find_overlay(): given 'bs' and the active (topmost) BDS of an image chain, find the image that is the immediate top of 'bs'...
block: remove keep_read_only flag from BlockDriverState struct
The keep_read_only flag is no longer used, in favor of the bdrvflag BDRV_O_ALLOW_RDWR.
Signed-off-by: Jeff Cody <jcody@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: convert bdrv_commit() to use bdrv_reopen()
Currently, bdrv_commit() reopens images r/w itself, via risky_delete() and _open() calls. Use the new safe method for drive reopen.
block: correctly set the keep_read_only flag
I believe the bs->keep_read_only flag is supposed to reflectthe initial open state of the device. If the device is initiallyopened R/O, then commit operations, or reopen operations changingto R/W, are prohibited....
block: make bdrv_set_enable_write_cache() modify open_flags
bdrv_set_enable_write_cache() sets the bs->enable_write_cache flag,but without the flag recorded in bs->open_flags, then next timea reopen() is performed the enable_write_cache setting may beinadvertently lost....
block: Framework for reopening files safely
This is based on Supriya Kannery's bdrv_reopen() patch series.
This provides a transactional method to reopen multipleimages files safely.
Image files are queue for reopen via bdrv_reopen_queue(), and thereopen occurs when bdrv_reopen_multiple() is called. Changes are...
block: fix block tray status
The tray status should change also if you eject empty block device.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: Don't forget to delete temporary file
The caller would not delete temporary file after failed get_tmp_filename().
Signed-off-by: Dunrong Huang <riegamaths@gmail.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: Flush parent to OS with cache=unsafe
Commit 29cdb251 already added a comment that no unnecessary flushes todisk will occur, this patch makes the code even get to the point of thecomment. This is mostly theoretical because in practice we only stack...
qmp: query-block: add 'encryption_key_missing' field
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Reviewed-by: Markus Armbruster <armbru@redhat.com>
block: Use bdrv_get_backing_file_depth()
Use the dedicated counting function in qmp_query_block in order topropagate the backing file depth to HMP and add backing_file_depthto qmp-commands.hx
Signed-off-by: Benoit Canet <benoit@irqsave.net>Reviewed-by: Eric Blake <eblake@redhat.com>...
block: create bdrv_get_backing_file_depth()
Create bdrv_get_backing_file_depth() in order to be able to showin QMP and HMP how many ancestors backing an image a block devicehave.
Avoid returning void
It's silly and non-conforming to standards to return void,don't do it.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
block: Geometry and translation hints are now useless, purge them
There are two producers of these hints: drive_init() on behalf of-drive, and hd_geometry_guess().
The only consumer of the hint is hd_geometry_guess().
The callers of hd_geometry_guess() call it only when drive_init()...
hd-geometry: Move disk geometry guessing back from block.c
Commit f3d54fc4 factored it out of hw/ide.c for reuse. Sensible,except it was put into block.c. Device-specific functionality shouldbe kept in device code, not the block layer. Move it tohw/hd-geometry.c, and make stylistic changes required to keep...
fdc: Move floppy geometry guessing back from block.c
Commit 5bbdbb46 moved it to block.c because "other geometry guessingfunctions already reside in block.c". Device-specific functionalityshould be kept in device code, not the block layer. Move it back....
Merge remote-tracking branch 'mjt/mjt-iov2' into staging
block: Factor bdrv_read_unthrottled() out of guess_disk_lchs()
To prepare move of guess_disk_lchs() into hw/, where it pokingBlockDriverState member io_limits_enabled directly would be unclean.
Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
fdc: Drop broken code for user-defined floppy geometry
bdrv_get_floppy_geometry_hint() fails to store through its parameterdrive when bs has a geometry hint. Makes fd_revalidate() assignrandom crap to drv->drive.
Has been broken that way for ages. Harmless, because:...
block: copy over job and dirty bitmap fields in bdrv_append
While these should not be in use at the time a transaction is started,a command in the prepare phase of a transaction might have added them,so they need to be brought over.
block: introduce bdrv_swap, implement bdrv_append on top of it
The new function can be made a bit nicer than bdrv_append. It swaps thewhole contents, and then swaps back (using the usual t=a;a=b;b=t idiom)the fields that need to stay on top. Thus, it does not need explicit...
block: New bdrv_get_flags()
Signed-off-by: Markus Armbruster <armbru@redhat.com>Acked-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: flush in writethrough mode after writes
We want to make the formats handle their own flushesautonomously, while keeping for guests the ability to use a writethroughcache. Since formats will write metadata via bs->file, bdrv_co_do_writevis the only place where we need to add a flush....
block: copy enable_write_cache in bdrv_append
Because the guest will be able to flip enable_write_cache, the actualstate may not match what is used to open the new snapshot.
block: add bdrv_set_enable_write_cache
block: always open drivers in writeback mode
Formats are entirely in charge of flushes for metadata writes. Forguest-initiated writes, a writethrough cache is faked in the block layer.So we can always open in writeback mode.
block: Replace bdrv_get_format() by bdrv_get_format_name()
So callers don't need to know anything about maximum name length.Returning a pointer is safe, because the name string lives as long asthe block driver it names, and block drivers don't die.
Requested by Peter Maydell....