[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 13/29] blockdev: Remove blk_hide_on_behalf_of_hmp_dri
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 13/29] blockdev: Remove blk_hide_on_behalf_of_hmp_drive_del() |
Date: |
Thu, 17 Mar 2016 16:56:26 +0100 |
From: Max Reitz <address@hidden>
We can basically inline it in hmp_drive_del(); monitor_remove_blk() is
called already, so we just need to call bdrv_make_anon(), too.
Signed-off-by: Max Reitz <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/block-backend.c | 17 -----------------
blockdev.c | 11 ++++++-----
include/sysemu/block-backend.h | 2 --
3 files changed, 6 insertions(+), 24 deletions(-)
diff --git a/block/block-backend.c b/block/block-backend.c
index 9ed3912..68f3662 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -386,23 +386,6 @@ BlockBackend *blk_by_legacy_dinfo(DriveInfo *dinfo)
}
/*
- * Hide @blk.
- * @blk must not have been hidden already.
- * Make attached BlockDriverState, if any, anonymous.
- * Once hidden, @blk is invisible to all functions that don't receive
- * it as argument. For example, blk_by_name() won't return it.
- * Strictly for use by do_drive_del().
- * TODO get rid of it!
- */
-void blk_hide_on_behalf_of_hmp_drive_del(BlockBackend *blk)
-{
- monitor_remove_blk(blk);
- if (blk->bs) {
- bdrv_make_anon(blk->bs);
- }
-}
-
-/*
* Disassociates the currently associated BlockDriverState from @blk.
*/
void blk_remove_bs(BlockBackend *blk)
diff --git a/blockdev.c b/blockdev.c
index d0e3d9c..b6d2444 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2865,15 +2865,16 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict)
blk_remove_bs(blk);
}
+ /* Make the BlockBackend and the attached BlockDriverState anonymous */
monitor_remove_blk(blk);
+ if (blk_bs(blk)) {
+ bdrv_make_anon(blk_bs(blk));
+ }
- /* if we have a device attached to this BlockDriverState
- * then we need to make the drive anonymous until the device
- * can be removed. If this is a drive with no device backing
- * then we can just get rid of the block driver state right here.
+ /* If this BlockBackend has a device attached to it, its refcount will be
+ * decremented when the device is removed; otherwise we have to do so here.
*/
if (blk_get_attached_dev(blk)) {
- blk_hide_on_behalf_of_hmp_drive_del(blk);
/* Further I/O must not pause the guest */
blk_set_on_error(blk, BLOCKDEV_ON_ERROR_REPORT,
BLOCKDEV_ON_ERROR_REPORT);
diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
index 5edc427..60c4b07 100644
--- a/include/sysemu/block-backend.h
+++ b/include/sysemu/block-backend.h
@@ -77,8 +77,6 @@ BlockDriverState *blk_bs(BlockBackend *blk);
void blk_remove_bs(BlockBackend *blk);
void blk_insert_bs(BlockBackend *blk, BlockDriverState *bs);
-void blk_hide_on_behalf_of_hmp_drive_del(BlockBackend *blk);
-
void blk_set_allow_write_beyond_eof(BlockBackend *blk, bool allow);
void blk_iostatus_enable(BlockBackend *blk);
bool blk_iostatus_is_enabled(const BlockBackend *blk);
--
1.8.3.1
- [Qemu-devel] [PULL 05/29] block: Add blk_commit_all(), (continued)
- [Qemu-devel] [PULL 05/29] block: Add blk_commit_all(), Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 02/29] block: Fix memory leak in hmp_drive_add_node(), Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 04/29] block: Use blk_next() in block-backend.c, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 07/29] qapi: Drop QERR_UNKNOWN_BLOCK_FORMAT_FEATURE, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 09/29] blockdev: Rename blk_backends, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 08/29] block: Drop BB name from bad option error, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 06/29] block: Use blk_{commit, flush}_all() consistently, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 10/29] blockdev: Add list of all BlockBackends, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 11/29] blockdev: Separate BB name management, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 16/29] block: Add blk_next_root_bs(), Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 13/29] blockdev: Remove blk_hide_on_behalf_of_hmp_drive_del(),
Kevin Wolf <=
- [Qemu-devel] [PULL 15/29] block: Add bdrv_next_monitor_owned(), Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 17/29] block: Rewrite bdrv_next(), Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 14/29] block: Move some bdrv_*_all() functions to BB, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 12/29] blockdev: Split monitor reference from BB creation, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 19/29] block: Remove bdrv_states list, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 21/29] block: Use blk_co_preadv() for blk_read(), Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 18/29] block: Use bdrv_next() instead of bdrv_states, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 22/29] block: Use blk_co_pwritev() for blk_write(), Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 23/29] block: Pull up blk_read_unthrottled() implementation, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 26/29] block: Use blk_aio_prwv() for aio_read/write/write_zeroes, Kevin Wolf, 2016/03/17