From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 09/18] block: Use 'detect-zeroes' option for 'blockdev-change-medium'
Date: Tue, 27 Sep 2016 15:53:52 +0200 [thread overview]
Message-ID: <1474984441-28516-10-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1474984441-28516-1-git-send-email-kwolf@redhat.com>
Instead of modifying the new BDS after it has been opened, use the newly
supported 'detect-zeroes' option in bdrv_open_common() so that all
requirements are checked (detect-zeroes=unmap requires discard=unmap).
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
block/block-backend.c | 9 ++++-----
blockdev.c | 9 ++++++---
include/sysemu/block-backend.h | 2 +-
3 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/block/block-backend.c b/block/block-backend.c
index f34bad5..639294b 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -1592,13 +1592,12 @@ void blk_update_root_state(BlockBackend *blk)
}
/*
- * Applies the information in the root state to the given BlockDriverState. This
- * does not include the flags which have to be specified for bdrv_open(), use
- * blk_get_open_flags_from_root_state() to inquire them.
+ * Returns the detect-zeroes setting to be used for bdrv_open() of a
+ * BlockDriverState which is supposed to inherit the root state.
*/
-void blk_apply_root_state(BlockBackend *blk, BlockDriverState *bs)
+bool blk_get_detect_zeroes_from_root_state(BlockBackend *blk)
{
- bs->detect_zeroes = blk->root_state.detect_zeroes;
+ return blk->root_state.detect_zeroes;
}
/*
diff --git a/blockdev.c b/blockdev.c
index 511260c..7b87bd8 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2546,6 +2546,7 @@ void qmp_blockdev_change_medium(bool has_device, const char *device,
BlockBackend *blk;
BlockDriverState *medium_bs = NULL;
int bdrv_flags;
+ bool detect_zeroes;
int rc;
QDict *options = NULL;
Error *err = NULL;
@@ -2585,8 +2586,12 @@ void qmp_blockdev_change_medium(bool has_device, const char *device,
abort();
}
+ options = qdict_new();
+ detect_zeroes = blk_get_detect_zeroes_from_root_state(blk);
+ qdict_put(options, "detect-zeroes",
+ qstring_from_str(detect_zeroes ? "on" : "off"));
+
if (has_format) {
- options = qdict_new();
qdict_put(options, "driver", qstring_from_str(format));
}
@@ -2623,8 +2628,6 @@ void qmp_blockdev_change_medium(bool has_device, const char *device,
goto fail;
}
- blk_apply_root_state(blk, medium_bs);
-
qmp_blockdev_close_tray(has_device, device, has_id, id, errp);
fail:
diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
index 24d1d85..a7993af 100644
--- a/include/sysemu/block-backend.h
+++ b/include/sysemu/block-backend.h
@@ -198,7 +198,7 @@ void blk_io_unplug(BlockBackend *blk);
BlockAcctStats *blk_get_stats(BlockBackend *blk);
BlockBackendRootState *blk_get_root_state(BlockBackend *blk);
void blk_update_root_state(BlockBackend *blk);
-void blk_apply_root_state(BlockBackend *blk, BlockDriverState *bs);
+bool blk_get_detect_zeroes_from_root_state(BlockBackend *blk);
int blk_get_open_flags_from_root_state(BlockBackend *blk);
void *blk_aio_get(const AIOCBInfo *aiocb_info, BlockBackend *blk,
--
1.8.3.1
next prev parent reply other threads:[~2016-09-27 13:54 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-27 13:53 [Qemu-devel] [PULL 00/18] Block layer patches Kevin Wolf
2016-09-27 13:53 ` [Qemu-devel] [PULL 01/18] block: reintroduce bdrv_flush_all Kevin Wolf
2016-09-27 13:53 ` [Qemu-devel] [PULL 02/18] qemu: use bdrv_flush_all for vm_stop et al Kevin Wolf
2016-09-27 13:53 ` [Qemu-devel] [PULL 03/18] block-backend: remove blk_flush_all Kevin Wolf
2016-09-27 13:53 ` [Qemu-devel] [PULL 04/18] block: Fix error path in qmp_blockdev_change_medium() Kevin Wolf
2016-09-27 13:53 ` [Qemu-devel] [PULL 05/18] block: Drop aio/cache consistency check from qmp_blockdev_add() Kevin Wolf
2016-09-27 13:53 ` [Qemu-devel] [PULL 06/18] block/qapi: Use separate options type for curl driver Kevin Wolf
2016-09-27 13:53 ` [Qemu-devel] [PULL 07/18] block/qapi: Move 'aio' option to file driver Kevin Wolf
2016-09-27 13:53 ` [Qemu-devel] [PULL 08/18] block: Parse 'detect-zeroes' in bdrv_open_common() Kevin Wolf
2016-09-27 13:53 ` Kevin Wolf [this message]
2016-09-27 13:53 ` [Qemu-devel] [PULL 10/18] block: Move 'discard' option to bdrv_open_common() Kevin Wolf
2016-10-07 9:01 ` Gerd Hoffmann
2016-10-07 10:20 ` Kevin Wolf
2016-09-27 13:53 ` [Qemu-devel] [PULL 11/18] block: Remove qemu_root_bds_opts Kevin Wolf
2016-09-27 13:53 ` [Qemu-devel] [PULL 12/18] oslib-posix: add helpers for stack alloc and free Kevin Wolf
2016-09-27 13:53 ` [Qemu-devel] [PULL 13/18] coroutine-sigaltstack: rename coroutine struct appropriately Kevin Wolf
2016-09-27 13:53 ` [Qemu-devel] [PULL 14/18] coroutine: add a macro for the coroutine stack size Kevin Wolf
2016-09-27 13:53 ` [Qemu-devel] [PULL 15/18] coroutine-ucontext: use helper for allocating stack memory Kevin Wolf
2016-09-27 13:53 ` [Qemu-devel] [PULL 16/18] coroutine-sigaltstack: " Kevin Wolf
2016-09-27 13:54 ` [Qemu-devel] [PULL 17/18] oslib-posix: add a configure switch to debug stack usage Kevin Wolf
2016-09-27 13:54 ` [Qemu-devel] [PULL 18/18] coroutine: reduce stack size to 60kB Kevin Wolf
2016-09-27 19:42 ` [Qemu-devel] [PULL 00/18] Block layer patches Peter Maydell
2016-09-28 9:37 ` Kevin Wolf
2016-09-28 14:52 ` Peter Maydell
2016-09-28 19:03 ` Peter Maydell
2016-09-29 10:25 ` Kevin Wolf
2016-09-29 17:02 ` John Snow
2016-09-29 18:17 ` Paolo Bonzini
2016-09-29 18:19 ` John Snow
2016-09-29 17:18 ` Peter Maydell
2016-09-29 18:19 ` John Snow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1474984441-28516-10-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).