From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52741) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XTxF9-0003W5-Ga for qemu-devel@nongnu.org; Tue, 16 Sep 2014 14:12:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XTxF3-0003F4-4c for qemu-devel@nongnu.org; Tue, 16 Sep 2014 14:12:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58260) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XTxF2-0003DY-SQ for qemu-devel@nongnu.org; Tue, 16 Sep 2014 14:12:41 -0400 From: Markus Armbruster Date: Tue, 16 Sep 2014 20:12:14 +0200 Message-Id: <1410891148-28849-10-git-send-email-armbru@redhat.com> In-Reply-To: <1410891148-28849-1-git-send-email-armbru@redhat.com> References: <1410891148-28849-1-git-send-email-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v3 09/23] block: Merge BlockBackend and BlockDriverState name spaces List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, famz@redhat.com, benoit.canet@nodalink.com, stefanha@redhat.com, mreitz@redhat.com BlockBackend's name space is separate only to keep the initial patches simple. Time to merge the two. Signed-off-by: Markus Armbruster Reviewed-by: Beno=C3=AEt Canet --- block.c | 11 +++-------- block/block-backend.c | 13 ++++++------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/block.c b/block.c index c3fa3da..f68f06c 100644 --- a/block.c +++ b/block.c @@ -861,7 +861,7 @@ static void bdrv_assign_node_name(BlockDriverState *b= s, } =20 /* takes care of avoiding namespaces collisions */ - if (bdrv_find(node_name)) { + if (blk_by_name(node_name)) { error_setg(errp, "node-name=3D%s is conflicting with a device id= ", node_name); return; @@ -3795,14 +3795,9 @@ void bdrv_iterate_format(void (*it)(void *opaque, = const char *name), /* This function is to find block backend bs */ BlockDriverState *bdrv_find(const char *name) { - BlockDriverState *bs; + BlockBackend *blk =3D blk_by_name(name); =20 - QTAILQ_FOREACH(bs, &bdrv_states, device_list) { - if (!strcmp(name, bdrv_get_device_name(bs))) { - return bs; - } - } - return NULL; + return blk ? blk_bs(blk) : NULL; } =20 /* This function is to find a node in the bs graph */ diff --git a/block/block-backend.c b/block/block-backend.c index f14a291..7fd832d 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -44,6 +44,12 @@ BlockBackend *blk_new(const char *name, Error **errp) error_setg(errp, "Device with id '%s' already exists", name); return NULL; } + if (bdrv_find_node(name)) { + error_setg(errp, + "Device name '%s' conflicts with an existing node nam= e", + name); + return NULL; + } =20 blk =3D g_new0(BlockBackend, 1); blk->name =3D g_strdup(name); @@ -61,13 +67,6 @@ BlockBackend *blk_new_with_bs(const char *name, Error = **errp) BlockBackend *blk; BlockDriverState *bs; =20 - if (bdrv_find_node(name)) { - error_setg(errp, - "Device name '%s' conflicts with an existing node nam= e", - name); - return NULL; - } - blk =3D blk_new(name, errp); if (!blk) { return NULL; --=20 1.9.3