From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47333) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFpKL-0006ZU-Iu for qemu-devel@nongnu.org; Mon, 26 Jan 2015 14:28:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YFpKF-0001iQ-Dq for qemu-devel@nongnu.org; Mon, 26 Jan 2015 14:28:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53819) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFpKF-0001iA-4e for qemu-devel@nongnu.org; Mon, 26 Jan 2015 14:27:55 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0QJRrrT028076 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 26 Jan 2015 14:27:54 -0500 From: Max Reitz Date: Mon, 26 Jan 2015 14:27:30 -0500 Message-Id: <1422300468-16216-4-git-send-email-mreitz@redhat.com> In-Reply-To: <1422300468-16216-1-git-send-email-mreitz@redhat.com> References: <1422300468-16216-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH 03/21] block: Add bdrv_close_all() notifiers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Markus Armbruster , Stefan Hajnoczi , Max Reitz This adds a list of notifiers to be invoked on bdrv_close_all(). Signed-off-by: Max Reitz --- block.c | 10 ++++++++++ include/block/block.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/block.c b/block.c index b7e631c..3adb724 100644 --- a/block.c +++ b/block.c @@ -104,6 +104,9 @@ static void bdrv_reset_dirty(BlockDriverState *bs, int64_t cur_sector, /* If non-zero, use only whitelisted block drivers */ static int use_bdrv_whitelist; +static NotifierList close_all_notifiers = + NOTIFIER_LIST_INITIALIZER(close_all_notifiers); + #ifdef _WIN32 static int is_windows_drive_prefix(const char *filename) { @@ -1913,6 +1916,8 @@ void bdrv_close_all(void) { BlockDriverState *bs; + notifier_list_notify(&close_all_notifiers, NULL); + QTAILQ_FOREACH(bs, &bdrv_states, device_list) { AioContext *aio_context = bdrv_get_aio_context(bs); @@ -1922,6 +1927,11 @@ void bdrv_close_all(void) } } +void bdrv_add_close_all_notifier(Notifier *notifier) +{ + notifier_list_add(&close_all_notifiers, notifier); +} + /* Check if any requests are in-flight (including throttled requests) */ static bool bdrv_requests_pending(BlockDriverState *bs) { diff --git a/include/block/block.h b/include/block/block.h index fa9dfd5..301baac 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -539,4 +539,6 @@ void bdrv_io_plug(BlockDriverState *bs); void bdrv_io_unplug(BlockDriverState *bs); void bdrv_flush_io_queue(BlockDriverState *bs); +void bdrv_add_close_all_notifier(Notifier *notifier); + #endif -- 2.1.0