History | View | Annotate | Download (88.3 kB)
Merge remote-tracking branch 'kwolf/for-anthony' into staging
Conflicts: block/vmdk.c
block: reinitialize across bdrv_close()/bdrv_open()
Several BlockDriverState fields are not being reinitialized acrossbdrv_close()/bdrv_open(). Make sure they are reset to their defaultvalues.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>...
block: Remove dead code
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: Fix bdrv_open use after free
tmp_filename was used outside the block it was defined in, i.e. after it wentout of scope. Move its declaration to the top level.
block: set bs->read_only before .bdrv_open()
Several block drivers set bs->read_only in .bdrv_open() butblock.c:bdrv_open_common() clobbers its value. Additionally, QED usesbdrv_is_read_only() in .bdrv_open() to decide whether to performconsistency checks....
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>
block: Rename the BlockIOStatus enum values
The biggest change is to rename its prefix from BDRV_IOS toBLOCK_DEVICE_IO_STATUS.
Next commit will convert the query-block command to the QAPIand that's how the enumeration is going to be generated.
qapi: Convert query-block
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
qapi: Convert query-blockstats
Drop qemu-objects.h from modules that don't require it
Previous commits dropped most qobjects usage from qemu modules(now they are a low level interface used by the QAPI). However,some modules still include the qemu-objects.h header file.
This commit drops qemu-objects.h from some of those modules...
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.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: add bdrv_co_discard and bdrv_aio_discard support
This similarly adds support for coroutine and asynchronous discard.
block: rename bdrv_co_rw_bh
block: drop emulation functions that use coroutines
Block drivers that implement coroutine functions used to get sync andaio wrappers. This is no longer necessary since all request processingnow happens in a coroutine. If a block driver implements the coroutine...
block: drop .bdrv_read()/.bdrv_write() emulation
There is no need to emulate .bdrv_read()/.bdrv_write() since theseinterfaces are only called if aio and coroutine interfaces are notpresent. All valid BlockDrivers must implement either sync, aio, orcoroutine interfaces....
block: drop bdrv_has_async_rw()
Commit cd74d83345e0e3b708330ab8c4cd9111bb82cda6 ("block: switchbdrv_read()/bdrv_write() to coroutines") removed the bdrv_has_async_rw()callers. This patch removes bdrv_has_async_rw() since it is no longerused.
block: switch bdrv_aio_readv() to coroutines
More sync, aio, and coroutine unification. Make bdrv_aio_readv() gothrough coroutine request processing.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: mark blocks dirty on coroutine write completion
The aio write operation marks blocks dirty when the write operationcompletes. The coroutine write operation marks blocks dirty beforeissuing the write operation.
It seems safest to mark the block dirty when the operation completes so...
block: switch bdrv_aio_writev() to coroutines
More sync, aio, and coroutine unification. Make bdrv_aio_writev() gothrough coroutine request processing.
Remove the dirty block callback mechanism which was needed only for aioprocessing and can be done more naturally in coroutine context....
block: directly invoke .bdrv_* from emulation functions
The emulation functions which supply default BlockDriver .bdrv_*()functions given another implemented .bdrv_*() function should not usepublic bdrv_*() interfaces. This patch ensures they invoke .bdrv_*()...
block: split out bdrv_co_do_readv() and bdrv_co_do_writev()
The public interface for I/O in coroutine context is bdrv_co_readv() andbdrv_co_writev(). Split out the request processing code intobdrv_co_do_readv() and bdrv_co_writev() so that it can be called...
block: switch bdrv_read()/bdrv_write() to coroutines
The bdrv_read()/bdrv_write() functions call .bdrv_read()/.bdrv_write().They should go through bdrv_co_do_readv() and bdrv_co_do_writev()instead in order to unify request processing code across sync, aio, and...
block: directly invoke .bdrv_aio_*() in bdrv_co_io_em()
We will unify block layer request processing across sync, aio, andcoroutines and this means a .bdrv_co_*() emulation function should notcall back into the public interface. There's no need here, just call...
QMP: query-status: Add 'io-status' key
Contains the I/O status for the given device. The key is only presentif the device supports it and the VM is configured to stop on errors.
Please, check the documentation being added in this commit for moreinformation....
HMP: Print 'io-status' information
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Reviewed-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
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...
trace: add arguments to bdrv_co_io_em() trace event
It is useful to know the BlockDriverState as well as thesector_num/nb_sectors of an emulated .bdrv_co_*() request.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
trace: trace bdrv_open_common()
bdrv_open_common() is a useful point to trace since it reveals thefilename and block driver for a given BlockDriverState.
block: New bdrv_set_buffer_alignment()
Device models should be able to set it without an unclean include ofblock_int.h.
Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: Reset buffer alignment on detach
BlockDriverState member buffer_alignment is initially 512. The devicemodel may set them, with bdrv_set_buffer_alignment(). If the devicemodel gets detached (hot unplug), the device's alignment is leftbehind. Only okay because device hot unplug automatically destroys...
block: New change_media_cb() parameter load
To let device models distinguish between eject and load.
block: Clean up remaining users of "removable"
BlockDriverState member removable is a confused mess. It is true whenan ide-cd, scsi-cd or floppy qdev is attached, or when theBlockDriverState was created with -drive if={floppy,sd} or -driveif={ide,scsi,xen,none},media=cdrom ("created removable"), except when...
block: Drop BlockDriverState member removable
It's a confused mess (see previous commit). No users remain.
block: Show whether the virtual tray is open in info block
Need to ask the device, so this requires new BlockDevOps memberis_tray_open().
block: Revert entanglement of bdrv_is_inserted() with tray status
Commit 4be9762a changed bdrv_is_inserted() to fail when the tray isopen. Unfortunately, there are two different kinds of users, withconflicting needs.
1. Device models using bdrv_eject(), currently ide-cd and scsi-cd....
block: Drop tray status tracking, no longer used
Commit 4be9762a is now completely redone.
block: Leave enforcing tray lock to device models
The device model knows best when to accept the guest's eject command.No need to detour through the block layer.
bdrv_eject() can't fail anymore. Make it void.
Signed-off-by: Markus Armbruster <armbru@redhat.com>...
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: Clean up bdrv_flush_all()
Change (!bdrv_is_removable(bs) || bdrv_is_inserted(bs)) to justbdrv_is_inserted(). Rationale:
The value of bdrv_is_removable(bs) matters only when bdrv_is_inserted(bs) is false.
bdrv_is_inserted(bs) is true when bs is open (bs->drv != NULL) and...
savevm: Include writable devices with removable media
savevm and loadvm silently ignore block devices with removable media,such as floppies and SD cards. Rolling back a VM to a previouscheckpoint will not roll back writes to block devices with removable...
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.
Use new macro QEMU_PACKED for packed structures
Most changes were made using these commands:
git grep -la '__attribute__((packed))'|xargs perl -pi -e 's/__attribute__\(\(packed\)\)/QEMU_PACKED/'git grep -la '__attribute__ ((packed))'|xargs perl -pi -e 's/__attribute__ \(\(packed\)\)/QEMU_PACKED/'...
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: parse cache mode flags in a single place
This patch introduces bdrv_parse_cache_flags() which sets open flagsgiven a cache mode. Previously this was duplicated in blockdev.c andqemu-img.c.
block: add cache=directsync parameter to -drive
This patch adds -drive cache=directsync for O_DIRECT | O_SYNC host fileI/O with no disk write cache presented to the guest.
This mode is useful when guests may not be sending flushes whenappropriate and therefore leave data at risk in case of power failure....
fix code format
Fix code format to make checkpatch.pl happy.
Signed-off-by: Robert Wang <wdongxu@linux.vnet.ibm.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
block: Use bdrv_co_* instead of synchronous versions in coroutines
If we're already in a coroutine, there is no reason to use the synchronousversion of block layer functions when a coroutine one exists. This makesbdrv_read/write/flush use bdrv_co_* when used inside a coroutine....
async: Remove AsyncContext
The purpose of AsyncContexts was to protect qcow and qcow2 against reentrancyduring an emulated bdrv_read/write (which includes a qemu_aio_wait() call andcan run AIO callbacks of different requests if it weren't for AsyncContexts)....
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: Emulate AIO functions with bdrv_co_readv/writev
Use the bdrv_co_readv/writev callbacks to implement bdrv_aio_readv/writev andbdrv_read/write if a driver provides the coroutine version instead of thesynchronous or AIO version.
block: Add bdrv_co_readv/writev emulation
In order to be able to call bdrv_co_readv/writev for drivers that don'timplement the functions natively, add an emulation that uses the AIO functionsto implement them.
block: Removed unused function bdrv_write_sync
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
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: Don't let locked flag prevent medium load
Commit aea2a33c made bdrv_eject() obey the locked flag. Correct formedium eject (eject_flag set), incorrect for medium load (eject_flagclear). See MMC-5 Table 341 "Actions for Lock/Unlock/Eject".
block: Reset device model callbacks on detach
BlockDriverState members change_cb and change_opaque are initiallynull. The device model may set them, with bdrv_set_change_cb(). Ifthe device model gets detached (hot unplug), they're left dangling.Only safe because device hot unplug automatically destroys the...
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...
bdrv_img_create: Fix segfault
Block drivers that don't support creating images don't have a size option. Failgracefully instead of segfaulting when trying to access the option's value.
block: clarify the meaning of BDRV_O_NOCACHE
Change BDRV_O_NOCACHE to only imply bypassing the host OS file cache,but no writeback semantics. All existing callers are changed to alsospecify BDRV_O_CACHE_WB to give them writeback semantics.
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.
block QMP: Deprecate query-block's "type", drop info block's "type="
query-block's specification documents response member "type" withvalues "hd", "cdrom", "floppy", "unknown".
Its value is unreliable: a block device used as floppy has type"floppy" if created with if=floppy, but type "hd" if created with...
Fix typos in comments and code (occured -> occurred and related)
The code changed here is an unused data type name (evt_flush_occurred).
Signed-off-by: Stefan Weil <weil@mail.berlios.de>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Fix typo in code and comments
Replace writeable -> writable
Do not delete BlockDriverState when deleting the drive
When removing a drive from the host-side via drive_del we currently havethe following path:
drive_delqemu_aio_flush()bdrv_close() // zaps bs->drv, which makes any subsequent I/O get // dropped. Works as designed...
trace: Trace bdrv_set_locked()
It can be handy to know when the guest locks/unlocks the CD-ROM tray.This trace event makes that possible.
block: Do not cache device size for removable media
The block layer caches the device size to avoid doing lseek(fd, 0,SEEK_END) every time this value is needed. For removable media thedevice size becomes stale if a new medium is inserted. This patchsimply prevents device size caching for removable media....
Don't allow multiwrites against a block device without underlying medium
If the block device has been closed, we no longer have a medium to submitIO against, check for this before submitting io. This prevents a segfaultfurther in the code where we dereference elements of the block driver....
trace: Trace bdrv_aio_flush()
Add a trace event for bdrv_aio_flush() to complement the existingbdrv_aio_readv() and bdrv_aio_writev() events.
fdc: move floppy geometry guessing to block.c
Other geometry guessing functions already reside in block.c.
Remove some unused or debugging only fields.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
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: enable in_use flag
Set block device in use during block migration, disallow drive_del andbdrv_truncate for in use devices.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>Signed-off-by: Kevin Wolf <kwolf@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.
block: Use backing format driver during image creation
The backing format should be honored during image creation. For somereason we currently use the image format to open the backing file. Thisfails when the backing file has a different format than the image being...
block: delete a write-only variable
Avoid a warning with GCC 4.6.0:/src/qemu/block.c: In function 'bdrv_img_create':/src/qemu/block.c:2862:25: error: variable 'fmt' set but not used [-Werror=unused-but-set-variable]
CC: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
qemu-img.c: Re-factor img_create()
This patch re-factors img_create() moving the code doing the actualwork into block.c where it can be shared with QEMU. This is needed tobe able to create images from QEMU to be used for live snapshots.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>...
Prevent creating an image with the same filename as backing file
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
bdrv_img_create() use proper errno return values
Kevin suggested to have bdrv_img_create() return proper -errno valueson error.
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.
block: Introduce path_has_protocol() function
The bdrv_find_protocol() function returns NULL if an unknown protocolname is given. It returns the "file" protocol when the filenamecontains no protocol at all. This makes it difficult to distinguishbetween paths which contain a protocol and those which do not....
block: Fix the use of protocols in backing files
Backing filenames may contain a protocol. The code currently doesn'tconsider this case and produces filenames that embed "<protocol>:".Don't combine filenames if the backing filename contains a protocol....
block: Make bdrv_create_file() ':' handling consistent
Filenames may start with "<protocol>:" to explicitly use a protocol likenbd. Filenames with unknown protocols are rejected in most of QEMUexcept for bdrv_create_file(). Even if a file with an invalid filename...
block: fix shift in dirty bitmap calculation
Otherwise upper 32 bits of bitmap entries are not correctly calculated.
Reviewed-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
block: set sector dirty on AIO write completion
Sectors are marked dirty in the bitmap on AIO submission. This is wrongsince data has not reached storage.
Set a given sector as dirty in the dirty bitmap on AIO completion, so thatreading a sector marked as dirty is guaranteed to return uptodate data....
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....
trace: Trace bdrv_aio_{readv,writev}
Observing block layer aio readv/writev operations is useful fordebugging image formats or understanding guest disk I/O patterns.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
trace: Trace virtio-blk, multiwrite, and paio_submit
This patch adds trace events that make it possible to observevirtio-blk.
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 image re-open in bdrv_commit
Arguably we should re-open the backing file with the backing file format andnot with the format of the snapshot image.
block: Change bdrv_commit to handle multiple sectors at once
bdrv_commit copies the image to its backing file sector by sector, whichis (surprise!) relatively slow. Let's take a larger buffer and handle moresectors at once if possible.
With a 1G qcow2 file, this brought the time bdrv_commit takes down from...
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...