diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2016-03-15 09:13:06 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2016-03-15 09:13:06 +0000 |
commit | 1a8b40816839f71ef2076bbd88c4aecaf5b8d75b (patch) | |
tree | ea7a584055c8d1b51030e86d6574aae0172a40ab /block/block-backend.c | |
parent | 618a5a8bc52ba0f2ecbb3dffd01e657f4d841f75 (diff) | |
parent | 0d611402a1e53a968a03c7c5e2f87114be92a319 (diff) | |
download | qemu-1a8b40816839f71ef2076bbd88c4aecaf5b8d75b.zip qemu-1a8b40816839f71ef2076bbd88c4aecaf5b8d75b.tar.gz qemu-1a8b40816839f71ef2076bbd88c4aecaf5b8d75b.tar.bz2 |
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Block layer patches
# gpg: Signature made Mon 14 Mar 2016 16:36:52 GMT using RSA key ID C88F2FD6
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>"
* remotes/kevin/tags/for-upstream: (40 commits)
iotests: Add test for QMP event rates
monitor: Use QEMU_CLOCK_VIRTUAL for the event queue in qtest mode
monitor: Separate QUORUM_REPORT_BAD events according to the node name
quorum: Fix crash in quorum_aio_cb()
iotests: Correct 081's reference output
block: Remove unused typedef of BlockDriverDirtyHandler
block: Move block dirty bitmap code to separate files
typedefs: Add BdrvDirtyBitmap
block: Include hbitmap.h in block.h
backup: Use Bitmap to replace "s->bitmap"
vpc: Use BB functions in .bdrv_create()
vmdk: Use BB functions in .bdrv_create()
vhdx: Use BB functions in .bdrv_create()
vdi: Use BB functions in .bdrv_create()
sheepdog: Use BB functions in .bdrv_create()
qed: Use BB functions in .bdrv_create()
qcow2: Use BB functions in .bdrv_create()
qcow: Use BB functions in .bdrv_create()
parallels: Use BB functions in .bdrv_create()
block: Introduce blk_set_allow_write_beyond_eof()
...
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'block/block-backend.c')
-rw-r--r-- | block/block-backend.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/block/block-backend.c b/block/block-backend.c index ebdf78a..03e71b4 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -50,6 +50,8 @@ struct BlockBackend { bool iostatus_enabled; BlockDeviceIoStatus iostatus; + bool allow_write_beyond_eof; + NotifierList remove_bs_notifiers, insert_bs_notifiers; }; @@ -579,6 +581,11 @@ void blk_iostatus_set_err(BlockBackend *blk, int error) } } +void blk_set_allow_write_beyond_eof(BlockBackend *blk, bool allow) +{ + blk->allow_write_beyond_eof = allow; +} + static int blk_check_byte_request(BlockBackend *blk, int64_t offset, size_t size) { @@ -592,17 +599,19 @@ static int blk_check_byte_request(BlockBackend *blk, int64_t offset, return -ENOMEDIUM; } - len = blk_getlength(blk); - if (len < 0) { - return len; - } - if (offset < 0) { return -EIO; } - if (offset > len || len - offset < size) { - return -EIO; + if (!blk->allow_write_beyond_eof) { + len = blk_getlength(blk); + if (len < 0) { + return len; + } + + if (offset > len || len - offset < size) { + return -EIO; + } } return 0; |