From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGGtA-0006iJ-CX for qemu-devel@nongnu.org; Tue, 27 Jan 2015 19:53:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGGt7-0006Ot-6O for qemu-devel@nongnu.org; Tue, 27 Jan 2015 19:53:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:23990) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGGme-0004N7-3i for qemu-devel@nongnu.org; Tue, 27 Jan 2015 19:47:04 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0S0l2m0023772 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 27 Jan 2015 19:47:03 -0500 From: Max Reitz Date: Tue, 27 Jan 2015 14:45:46 -0500 Message-Id: <1422387983-32153-14-git-send-email-mreitz@redhat.com> In-Reply-To: <1422387983-32153-1-git-send-email-mreitz@redhat.com> References: <1422387983-32153-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH RESEND 13/50] block: Add BlockBackendRootState List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Fam Zheng , Jeff Cody , Markus Armbruster , Max Reitz , Stefan Hajnoczi , John Snow This structure will store some of the state of the root BDS if the BDS tree is removed, so that state can be restored once a new BDS tree is inserted. Signed-off-by: Max Reitz --- block/block-backend.c | 26 ++++++++++++++++++++++++++ include/block/block_int.h | 9 +++++++++ include/qemu/typedefs.h | 1 + include/sysemu/block-backend.h | 2 ++ 4 files changed, 38 insertions(+) diff --git a/block/block-backend.c b/block/block-backend.c index 2a48e82..7be03ee 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -37,6 +37,10 @@ struct BlockBackend { /* the block size for which the guest device expects atomicity */ int guest_block_size; + /* If the BDS tree is removed, some of its options are stored here (which + * can be used to restore those options in the new BDS on insert) */ + BlockBackendRootState root_state; + /* I/O stats (display with "info blockstats"). */ BlockAcctStats stats; @@ -1014,3 +1018,25 @@ int blk_load_vmstate(BlockBackend *blk, uint8_t *buf, int64_t pos, int size) { return bdrv_load_vmstate(blk->bs, buf, pos, size); } + +/* + * Updates the BlockBackendRootState object with data from the currently + * attached BlockDriverState. + */ +void blk_update_root_state(BlockBackend *blk) +{ + assert(blk->bs); + + blk->root_state.open_flags = blk->bs->open_flags; + blk->root_state.read_only = blk->bs->read_only; + blk->root_state.detect_zeroes = blk->bs->detect_zeroes; + + blk->root_state.io_limits_enabled = blk->bs->io_limits_enabled; + throttle_get_config(&blk->bs->throttle_state, + &blk->root_state.throttle_config); +} + +BlockBackendRootState *blk_get_root_state(BlockBackend *blk) +{ + return &blk->root_state; +} diff --git a/include/block/block_int.h b/include/block/block_int.h index 69668e4..91d21c5 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -406,6 +406,15 @@ struct BlockDriverState { NotifierWithReturn write_threshold_notifier; }; +struct BlockBackendRootState { + int open_flags; + bool read_only; + BlockdevDetectZeroesOptions detect_zeroes; + + bool io_limits_enabled; + ThrottleConfig throttle_config; +}; + /* Essential block drivers which must always be statically linked into qemu, and * which therefore can be accessed without using bdrv_find_format() */ diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index cde3314..39a95dd 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -11,6 +11,7 @@ typedef struct AddressSpace AddressSpace; typedef struct AioContext AioContext; typedef struct AudioState AudioState; typedef struct BlockBackend BlockBackend; +typedef struct BlockBackendRootState BlockBackendRootState; typedef struct BlockDriverState BlockDriverState; typedef struct BusClass BusClass; typedef struct BusState BusState; diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index c4a61c0..afb62e1 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -158,6 +158,8 @@ void blk_add_close_notifier(BlockBackend *blk, Notifier *notify); void blk_io_plug(BlockBackend *blk); 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_aio_get(const AIOCBInfo *aiocb_info, BlockBackend *blk, BlockCompletionFunc *cb, void *opaque); -- 2.1.0