From patchwork Thu Mar 17 15:56:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 8612591 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 086A79FC57 for ; Thu, 17 Mar 2016 16:01:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CCBBB20375 for ; Thu, 17 Mar 2016 16:01:21 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 10A0320361 for ; Thu, 17 Mar 2016 16:01:17 +0000 (UTC) Received: from localhost ([::1]:36148 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agaMO-00027H-FM for patchwork-qemu-devel@patchwork.kernel.org; Thu, 17 Mar 2016 12:01:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37879) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agaIT-0002Kc-Q7 for qemu-devel@nongnu.org; Thu, 17 Mar 2016 11:57:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1agaIS-0001n3-Uc for qemu-devel@nongnu.org; Thu, 17 Mar 2016 11:57:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40137) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agaIK-0001iX-81; Thu, 17 Mar 2016 11:57:04 -0400 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 (Postfix) with ESMTPS id C3F26C00DDE2; Thu, 17 Mar 2016 15:57:03 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-71.ams2.redhat.com [10.36.116.71]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2HFuj1J010106; Thu, 17 Mar 2016 11:57:02 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 17 Mar 2016 16:56:26 +0100 Message-Id: <1458230202-29136-14-git-send-email-kwolf@redhat.com> In-Reply-To: <1458230202-29136-1-git-send-email-kwolf@redhat.com> References: <1458230202-29136-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PULL 13/29] blockdev: Remove blk_hide_on_behalf_of_hmp_drive_del() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Max Reitz 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 Signed-off-by: Kevin Wolf --- 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);