From patchwork Wed Mar 16 18:54:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 8603401 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 089DB9F294 for ; Wed, 16 Mar 2016 19:01:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 56D2320219 for ; Wed, 16 Mar 2016 19:01:15 +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 912162020F for ; Wed, 16 Mar 2016 19:01:14 +0000 (UTC) Received: from localhost ([::1]:58282 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agGh0-0007Cf-1r for patchwork-qemu-devel@patchwork.kernel.org; Wed, 16 Mar 2016 15:01:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37140) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agGb7-0000iT-Kl for qemu-devel@nongnu.org; Wed, 16 Mar 2016 14:55:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1agGb6-0005XJ-LC for qemu-devel@nongnu.org; Wed, 16 Mar 2016 14:55:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55455) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agGb4-0005UU-8r; Wed, 16 Mar 2016 14:55:06 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id CD7997F085; Wed, 16 Mar 2016 18:55:05 +0000 (UTC) Received: from localhost (ovpn-116-135.ams2.redhat.com [10.36.116.135]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2GIt4Tv026239 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 16 Mar 2016 14:55:05 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Wed, 16 Mar 2016 19:54:35 +0100 Message-Id: <1458154485-32536-8-git-send-email-mreitz@redhat.com> In-Reply-To: <1458154485-32536-1-git-send-email-mreitz@redhat.com> References: <1458154485-32536-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Markus Armbruster , qemu-devel@nongnu.org, Stefan Hajnoczi , Max Reitz Subject: [Qemu-devel] [PATCH v4 07/17] blockdev: Rename blk_backends 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 The blk_backends list does not contain all BlockBackends but only the ones which are referenced by the monitor, and that is not necessarily true for every BlockBackend. Rename the list to monitor_block_backends to make that fact clear. Signed-off-by: Max Reitz --- block/block-backend.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index e75b8fe..3bb2a6a 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -29,7 +29,7 @@ struct BlockBackend { int refcnt; BlockDriverState *bs; DriveInfo *legacy_dinfo; /* null unless created by drive_new() */ - QTAILQ_ENTRY(BlockBackend) link; /* for blk_backends */ + QTAILQ_ENTRY(BlockBackend) monitor_link; /* for monitor_block_backends */ void *dev; /* attached device model, if any */ /* TODO change to DeviceState when all users are qdevified */ @@ -69,9 +69,10 @@ static const AIOCBInfo block_backend_aiocb_info = { static void drive_info_del(DriveInfo *dinfo); -/* All the BlockBackends (except for hidden ones) */ -static QTAILQ_HEAD(, BlockBackend) blk_backends = - QTAILQ_HEAD_INITIALIZER(blk_backends); +/* All BlockBackends referenced by the monitor and which are iterated through by + * blk_next() */ +static QTAILQ_HEAD(, BlockBackend) monitor_block_backends = + QTAILQ_HEAD_INITIALIZER(monitor_block_backends); /* * Create a new BlockBackend with @name, with a reference count of one. @@ -105,7 +106,7 @@ BlockBackend *blk_new(const char *name, Error **errp) blk->refcnt = 1; notifier_list_init(&blk->remove_bs_notifiers); notifier_list_init(&blk->insert_bs_notifiers); - QTAILQ_INSERT_TAIL(&blk_backends, blk, link); + QTAILQ_INSERT_TAIL(&monitor_block_backends, blk, monitor_link); return blk; } @@ -178,7 +179,7 @@ static void blk_delete(BlockBackend *blk) } /* Avoid double-remove after blk_hide_on_behalf_of_hmp_drive_del() */ if (blk->name[0]) { - QTAILQ_REMOVE(&blk_backends, blk, link); + QTAILQ_REMOVE(&monitor_block_backends, blk, monitor_link); } g_free(blk->name); drive_info_del(blk->legacy_dinfo); @@ -241,7 +242,7 @@ void blk_remove_all_bs(void) } /* - * Return the BlockBackend after @blk. + * Return the monitor-owned BlockBackend after @blk. * If @blk is null, return the first one. * Else, return @blk's next sibling, which may be null. * @@ -252,7 +253,8 @@ void blk_remove_all_bs(void) */ BlockBackend *blk_next(BlockBackend *blk) { - return blk ? QTAILQ_NEXT(blk, link) : QTAILQ_FIRST(&blk_backends); + return blk ? QTAILQ_NEXT(blk, monitor_link) + : QTAILQ_FIRST(&monitor_block_backends); } /* @@ -353,7 +355,7 @@ BlockBackend *blk_by_legacy_dinfo(DriveInfo *dinfo) */ void blk_hide_on_behalf_of_hmp_drive_del(BlockBackend *blk) { - QTAILQ_REMOVE(&blk_backends, blk, link); + QTAILQ_REMOVE(&monitor_block_backends, blk, monitor_link); blk->name[0] = 0; if (blk->bs) { bdrv_make_anon(blk->bs);