From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42821) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xqgqp-0002m3-IL for qemu-devel@nongnu.org; Tue, 18 Nov 2014 06:21:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xqgqf-0002cZ-J7 for qemu-devel@nongnu.org; Tue, 18 Nov 2014 06:21:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56324) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xqgqf-0002bw-BY for qemu-devel@nongnu.org; Tue, 18 Nov 2014 06:21:29 -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 sAIBLSPe025454 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 18 Nov 2014 06:21:28 -0500 From: Max Reitz Date: Tue, 18 Nov 2014 12:21:16 +0100 Message-Id: <1416309679-333-4-git-send-email-mreitz@redhat.com> In-Reply-To: <1416309679-333-1-git-send-email-mreitz@redhat.com> References: <1416309679-333-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH v2 3/6] block: Add blk_add_close_notifier() for BB List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Paolo Bonzini , Markus Armbruster , Stefan Hajnoczi , Max Reitz Adding something like a "delete notifier" to a BlockBackend would not make much sense, because whoever is interested in registering there will probably hold a reference to that BlockBackend; therefore, the notifier will never be called (or only when the notifiee already relinquished its reference and thus most probably is no longer interested in that notification). Therefore, this patch just passes through the close notifier interface of the root BDS. This will be called when the device is ejected, for instance, and therefore does make sense. Signed-off-by: Max Reitz Reviewed-by: Paolo Bonzini --- block/block-backend.c | 5 +++++ include/sysemu/block-backend.h | 1 + 2 files changed, 6 insertions(+) diff --git a/block/block-backend.c b/block/block-backend.c index 7a7f690..ef16d73 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -642,6 +642,11 @@ void blk_remove_aio_context_notifier(BlockBackend *blk, detach_aio_context, opaque); } +void blk_add_close_notifier(BlockBackend *blk, Notifier *notify) +{ + bdrv_add_close_notifier(blk->bs, notify); +} + void blk_io_plug(BlockBackend *blk) { bdrv_io_plug(blk->bs); diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index d9c1337..8871a02 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -143,6 +143,7 @@ void blk_remove_aio_context_notifier(BlockBackend *blk, void *), void (*detach_aio_context)(void *), void *opaque); +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); -- 1.9.3