History | View | Annotate | Download (14 kB)
Merge remote-tracking branch 'kwolf/for-anthony' into staging
mirror: add support for on-source-error/on-target-error
Error management is important for mirroring; otherwise, an error on thetarget (even something as "innocent" as ENOSPC) requires to start againwith a full copy. Similar to on_read_error/on_write_error, two separate...
mirror: introduce mirror job
This patch adds the implementation of a new job that mirrors a disk toa new image while letting the guest continue using the old image.The target is treated as a "black box" and data is copied from thesource to the target in the background. This can be used for several...
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: 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...
stream: add on-error argument
This patch adds support for error management to streaming.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
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: fix documentation of block_job_cancel_sync
Do this in a separate commit before we move the functions toblockjob.h.
block: add live block commit functionality
This adds the live commit coroutine. This iteration focuses on thecommit only below the active layer, and not the active layer itself.
The behaviour is similar to block streaming; the sectors are walkedthrough, and anything that exists above 'base' is committed back down...
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: 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: block_int: include qerror.h
Several block/ files are relying on qerror.h being provided byqapi-types.h. Fix this, as a future commit will change qapi-types.hnot to provide qerror.h.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Reviewed-by: Markus Armbruster <armbru@redhat.com>
qcow2: implement lazy refcounts
Lazy refcounts is a performance optimization for qcow2 that postponesrefcount metadata updates and instead marks the image dirty. In thecase of crash or power failure the image will be left in a dirty stateand repaired next time it is opened....
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()...
qemu-img check -r for repairing images
The QED block driver already provides the functionality to not onlydetect inconsistencies in images, but also fix them. However, thisfunctionality cannot be manually invoked with qemu-img, but thecheck happens only automatically during bdrv_open()....
block: prevent snapshot mode $TMPDIR symlink attack
In snapshot mode, bdrv_open creates an empty temporary file withoutchecking for mkstemp or close failure, and ignoring the possibilityof a buffer overrun given a surprisingly long $TMPDIR.Change the get_tmp_filename function to return int (not void),...
block: fix snapshot on QED
QED's opaque data includes a pointer back to the BlockDriverState.This breaks when bdrv_append shuffles data between bs_new and bs_top.To avoid this, add a "rebind" function that tells the driver aboutthe new relationship between the BlockDriverState and its opaque....
block: add block_job_sleep_ns
This function abstracts the pretty complex semantics of the "busy" member of BlockJob.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: wait for job callback in block_job_cancel_sync
The limitation on not having I/O after cancellation cannot really bekept. Even streaming has a very small race window where you couldcancel a job and have it report completion. If this window is hit,...
block: use Error mechanism instead of -errno for block_job_create()
The block job API uses -errno return values internally and we convertthese to Error in the QMP functions. This is ugly because the Errorshould be created at the point where we still have all the relevant...
block: use Error mechanism instead of -errno for block_job_set_speed()
There are at least two different errors that can occur inblock_job_set_speed(): the job might not support setting speeds or thevalue might be invalid.
Use the Error mechanism to report the error where it occurs....
block: change block-job-set-speed argument from 'value' to 'speed'
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Acked-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
block: add 'speed' optional parameter to block-stream
Allow streaming operations to be started with an initial speed limit.This eliminates the window of time between starting streaming andissuing block-job-set-speed. Users should use the new optional 'speed'...
qcow2: Version 3 images
This adds the basic infrastructure to qcow2 to handle version 3 images.It includes code to create v3 images, allow header updates for v3 imagesand checks feature bits.
It still misses support for zero clusters, so this is not a fully...
block: fix streaming/closing race
Streaming can issue I/O while qcow2_close is running. This causes theL2 caches to become very confused or, alternatively, could cause asegfault when the streaming coroutine is reentered after closing itsblock device. The fix is to cancel streaming jobs when closing their...
block: document job API
I am not sure that these are really proper GtkDoc, but they followthe existing documentation in block_int.h.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
aio: move BlockDriverAIOCB to qemu-aio.h
And remove several block_int.h inclusions that should not be there.
qapi: Introduce blockdev-group-snapshot-sync command
This is a QAPI/QMP only command to take a snapshot of a group ofdevices. This is similar to the blockdev-snapshot-sync command, exceptblockdev-group-snapshot-sync accepts a list devices, filenames, and...
block: remove unused fields in BlockDriverState
sync_aiocb is unused since commit ce1a14d (Dynamically allocate AIOCompletion Blocks., 2006-08-07).
private is unused since commit 56a1493 (drive cleanup fixes., 2009-09-25).
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
block: drop aio_multiwrite in BlockDriver
These were never used.
block: bdrv_eject(): Make eject_flag a real bool
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Reviewed-by: Markus Armbruster <armbru@redhat.com>Acked-by: Kevin Wolf <kwolf@redhat.com>
block: add .bdrv_co_write_zeroes() interface
The ability to zero regions of an image file is a useful primitive forhigher-level features such as image streaming or zero write detection.
Image formats may support an optimized metadata representation instead...
block: add support for partial streaming
Add support for streaming data from an intermediate section of theimage chain (see patch and documentation for details).
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>...
block: make copy-on-read a per-request flag
Previously copy-on-read could only be enabled for all requests to ablock device. This means requests coming from the guest as well asQEMU's internal requests would perform copy-on-read when enabled.
For image streaming we want to support finer-grained behavior than just...
block: add BlockJob interface for long-running operations
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: add image streaming block job
block: add request tracking
The block layer does not know about pending requests. This informationis necessary for copy-on-read since overlapping requests must beserialized to prevent races that corrupt the image.
The BlockDriverState gets a new tracked_request list field which...
block: add interface to toggle copy-on-read
The bdrv_enable_copy_on_read()/bdrv_disable_copy_on_read() functions canbe used to programmatically enable or disable copy-on-read for a blockdevice. Later patches add the actual copy-on-read logic.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>...
block: drop .bdrv_is_allocated() interface
Now that all block drivers have been converted to.bdrv_co_is_allocated() we can drop .bdrv_is_allocated().
Note that the public bdrv_is_allocated() interface is still availablebut is in fact a synchronous wrapper around .bdrv_co_is_allocated()....
block: add .bdrv_co_is_allocated()
This patch adds the .bdrv_co_is_allocated() interface which is identicalto .bdrv_is_allocated() but runs in coroutine context. Running incoroutine context implies that other coroutines might be performing I/Oat the same time. Therefore it must be safe to run while the following...
block: add the blockio limits command line support
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: add I/O throttling algorithm
block: allow migration to work with image files (v3)
Image files have two types of data: immutable data that describes things likeimage size, backing files, etc. and mutable data that includes offset andreference count tables.
Today, image formats aggressively cache mutable data to improve performance. In...
block: Rename bdrv_co_flush to bdrv_co_flush_to_disk
There are two different types of flush that you can do: Flushing one level upto the OS (i.e. writing data to the host page cache) or flushing it all the waydown to the disk. The existing functions flush to the disk, reflect this in the...
block: Introduce bdrv_co_flush_to_os
qcow2 has a writeback metadata cache, so flushing a qcow2 image actuallyconsists of writing back that cache to the protocol and only then flushes theprotocol in order to get everything stable on disk.
This introduces a separate bdrv_co_flush_to_os to reflect the split....
block: iostatus: Drop BDRV_IOS_INVAL
A future commit will convert bdrv_info() to the QAPI and it won'tprovide IOS_INVAL.
Luckily all we have to do is to add a new 'iostatus_enabled'member to BlockDriverState and use it instead.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
qapi: Convert query-block
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
block: change flush to co_flush
Since coroutine operation is now mandatory, convert all bdrv_flushimplementations to coroutines. For qcow2, this means taking the lock.Other implementations are simpler and just forward bdrv_flush to theunderlying protocol, so they can avoid the lock....
block: change discard to co_discard
Since coroutine operation is now mandatory, convert both bdrv_discardimplementations to coroutines. For qcow2, this means taking the lockaround the operation. raw-posix remains synchronous.
The bdrv_discard callback is then unused and can be eliminated....
block: unify flush implementations
Add coroutine support for flush and apply the same emulation thatwe already do for read/write. bdrv_aio_flush is simplified to alwaysgo through a coroutine.
block: add bdrv_co_discard and bdrv_aio_discard support
This similarly adds support for coroutine and asynchronous discard.
block: Keep track of devices' I/O status
This commit adds support to the BlockDriverState type to keep trackof devices' I/O status.
There are three possible status: BDRV_IOS_OK (no error), BDRV_IOS_ENOSPC(no space error) and BDRV_IOS_FAILED (any other error). The distinction...
block: Drop BlockDriverState member removable
It's a confused mess (see previous commit). No users remain.
Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: Move BlockConf & friends from block_int.h to block.h
It's convenience stuff for block device models, so block.h isn't theideal home either, but better than block_int.h.
Permits moving some #include "block_int.h" from device model .h into.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>...
block: Drop tray status tracking, no longer used
Commit 4be9762a is now completely redone.
block: Drop medium lock tracking, ask device models instead
Requires new BlockDevOps member is_medium_locked(). Implement for IDEand SCSI CD-ROMs.
block: Rename bdrv_set_locked() to bdrv_lock_medium()
While there, make the locked parameter bool.
block: Declare qemu_blockalign() in block.h, not block_int.h
Device models should be able to use it without an unclean include ofblock_int.h.
block: Leave tracking media change to device models
hw/fdc.c is the only one that cares.
block: Attach non-qdev devices as well
For now, this just protects against programming errors like having thesame drive back multiple non-qdev devices, or untimely bdrv_delete().Later commits will add other interesting uses.
While there, rename BlockDriverState member peer to dev, bdrv_attach()...
block: Generalize change_cb() to BlockDevOps
So we can more easily add device model callbacks.
block: Split change_cb() into change_media_cb(), resize_cb()
Multiplexing callbacks complicates matters needlessly.
block: latency accounting
Account the total latency for read/write/flush requests. This allowsmanagement tools to average it based on a snapshot of the nr opscounters and allow checking for SLAs or provide statistics.
Signed-off-by: Christoph Hellwig <hch@lst.de>...
block: explicit I/O accounting
Decouple the I/O accounting from bdrv_aio_readv/writev/flush andmake the hardware models call directly into the accounting helpers.
This means: - we do not count internal requests from image formats in addition to guest originating I/O...
block: include flush requests in info blockstats
Signed-off-by: Christoph Hellwig <hch@lst.de>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: Add bdrv_co_readv/writev
Add new block driver callbacks bdrv_co_readv/writev, which work on aQEMUIOVector like bdrv_aio_*, but don't need a callback. The function may onlybe called inside a coroutine, so a block driver implementing this interface can...
block: Make BlockDriver method bdrv_set_locked() return void
The only caller is bdrv_set_locked(), and it ignores the value.
Callees always return 0, except for FreeBSD's cdrom_set_locked(),which returns -ENOTSUP when the device is in a terminally wedged...
block: Make BlockDriver method bdrv_eject() return void
Callees always return 0, except for FreeBSD's cdrom_eject(), whichreturns -ENOTSUP when the device is in a terminally wedged state.
The only caller is bdrv_eject(), and it maps -ENOTSUP to 0 since...
block: add bdrv_get_allocated_file_size() operation
qemu-img.c wants to count allocated file size of image. Previously itcounts a single bs->file by 'stat' or Window API. As VMDK introducesmultiple file support, the operation becomes format specific with...
VMDK: create different subformats
Add create option 'format', with enums: monolithicSparse monolithicFlat twoGbMaxExtentSparse twoGbMaxExtentFlatEach creates a subformat image file. The default is monolithicSparse.
Signed-off-by: Fam Zheng <famcool@gmail.com>...
Replaced tabs with spaces in block.h and block_int.h
Signed-off-by: Devin Nakamura <devin122@gmail.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: Remove type hint, it's guest matter, doesn't belong here
No users of bdrv_get_type_hint() left. bdrv_set_type_hint() can makethe media removable by side effect. Make that explicit.
Add flag to indicate external users to block device
Certain operations such as drive_del or resize cannot be performedwhile external users (eg. block migration) reference the block device.
Add a flag to indicate that.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>...
block: tell drivers about an image resize
Extend the change_cb callback with a reason argument, and use itto tell drivers about size changes.
qed: Add QEMU Enhanced Disk image format
This patch introduces the qed on-disk layout and implements imagecreation. Later patches add read/write and other functionality.
block: add discard support
Add a new bdrv_discard method to free blocks in a mapping image, and a newdrive property to set the granularity for these discard. If no discardgranularity support is set discard support is disabled.
qemu-img: Deprecate obsolete -6 and -e options
If -6 or -e is specified, an error message is printed and we exit. Itdoes not print help() to avoid the error message getting lost in thenoise.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Add bootindex parameter to net/block/fd device
If bootindex is specified on command line a string that describes devicein firmware readable way is added into sorted list. Later this list willbe passed into firmware to control boot order.
Signed-off-by: Gleb Natapov <gleb@redhat.com>...
block: Allow bdrv_flush to return errors
This changes bdrv_flush to return 0 on success and -errno in case of failure.It's a requirement for implementing proper error handle in users of bdrv_flush.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Copy snapshots out of QCOW2 disk
In order to backup snapshots, created from QCOW2 iamge, we want to copy snapshots out of QCOW2 disk to a seperate storage.The following patch adds a new option in "qemu-img": qemu-img convert -f qcow2 -O qcow2 -s snapshot_name src_img bck_img....
Revert "Make default invocation of block drivers safer (v3)"
This reverts commit 79368c81bf8cf93864d7afc88b81b05d8f0a2c90.
Conflicts:
block.c
I haven't been able to come up with a solution yet for the corruption caused byunaligned requests from the IDE disk so revert until a solution can be written....
block: Fix bdrv_has_zero_init
Assuming that any image on a block device is not properly zero-initialized isactually wrong: Only raw images have this problem. Any other image formatshouldn't care about it, they initialize everything properly themselves....
block: Change bdrv_eject() not to drop the image
bdrv_eject() gets called when a device model opens or closes the tray.
If the block driver implements method bdrv_eject(), that method getscalled. Drivers host_cdrom implements it, and it opens and closes the...
block: default to 0 minimal / optiomal I/O size
Currently we set them to 512 bytes unless manually specified. Unforuntalysome brain-dead partitioning tools create unaligned partitions if theyget low enough optiomal I/O size values, so don't report any at all...
Make default invocation of block drivers safer (v3)
CVE-2008-2004 described a vulnerability in QEMU whereas a malicious user couldtrick the block probing code into accessing arbitrary files in a guest. Tomitigate this, we added an explicit format parameter to -drive which disabling...
qcow2/vdi: Change check to distinguish error cases
This distinguishes between harmless leaks and real corruption. Hopefully usersbetter understand what qemu-img check wants to tell them.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qdev: Decouple qdev_prop_drive from DriveInfo
Make the property point to BlockDriverState, cutting out the DriveInfomiddleman. This prepares the ground for block devices that don't havea DriveInfo.
Currently all user-defined ones have a DriveInfo, because the only way...
block: Catch attempt to attach multiple devices to a blockdev
For instance, -device scsi-disk,drive=foo -device scsi-disk,drive=foohappily creates two SCSI disks connected to the same block device.It's all downhill from there.
Device usb-storage deliberately attaches twice to the same blockdev,...
block: fix physical_block_size calculation
Both SCSI and virtio expect the physical block size relative to thelogical block size. So get the factor first before calculating thelog2.
Reported-by: Mike Cao <bcao@redhat.com>Signed-off-by: Christoph Hellwig <hch@lst.de>...
block: Move error actions from DriveInfo to BlockDriverState
That's where they belong semantically (block device host part), eventhough the actions are actually executed by guest device code.
block: Add wr_highest_sector blockstat
This adds the wr_highest_sector blockstat which implements what is generallyknown as the high watermark. It is the highest offset of a sector written tothe respective BlockDriverState since it has been opened.
The query-blockstat QMP command is extended to add this value to the result,...
block: Open the underlying image file in generic code
Format drivers shouldn't need to bother with things like file names, but ratherjust get an open BlockDriverState for the underlying protocol. This patchintroduces this behaviour for bdrv_open implementation. For protocols which...
block: Do not export bdrv_first
The bdrv_first linked list of BlockDriverStates is currently extern sothat block migration can iterate the list. However, since there isalready a bdrv_iterate() function there is no need to expose bdrv_first.
block: Convert bdrv_first to QTAILQ
block: Convert first_drv to QLIST
blkdebug: Add events and rules
Block drivers can trigger a blkdebug event whenever they reach a place where itcould be useful to inject an error for testing/debugging purposes.
Rules are read from a blkdebug config file and describe which action is taken...
block: add logical_block_size property
Add a logical block size attribute as various guest side tools onlyincrease the filesystem sector size based on it, not the advisoryphysical block size.
For scsi we already have support for a different logical block size...
block: more read-only changes, related to backing files
Open backing file read-only where possibleUpgrade backing file to read-write during commit, back to read-only after commit If upgrade fail, back to read-only. If also fail, "disconnect" the drive....