From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55813) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XSooj-0002LL-1I for qemu-devel@nongnu.org; Sat, 13 Sep 2014 11:00:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XSooX-00026R-OM for qemu-devel@nongnu.org; Sat, 13 Sep 2014 11:00:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:29213) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XSooX-00026D-Fc for qemu-devel@nongnu.org; Sat, 13 Sep 2014 11:00:37 -0400 From: Markus Armbruster Date: Sat, 13 Sep 2014 17:00:13 +0200 Message-Id: <1410620427-20089-10-git-send-email-armbru@redhat.com> In-Reply-To: <1410620427-20089-1-git-send-email-armbru@redhat.com> References: <1410620427-20089-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH v2 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, benoit.canet@nodalink.com, stefanha@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 --- block.c | 11 +++-------- block/block-backend.c | 13 ++++++------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/block.c b/block.c index b39e368..f59dade 100644 --- a/block.c +++ b/block.c @@ -861,7 +861,7 @@ static void bdrv_assign_node_name(BlockDriverState *bs, } /* takes care of avoiding namespaces collisions */ - if (bdrv_find(node_name)) { + if (blk_by_name(node_name)) { error_setg(errp, "node-name=%s is conflicting with a device id", node_name); return; @@ -3782,14 +3782,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 = blk_by_name(name); - 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; } /* This function is to find a node in the bs graph */ diff --git a/block/block-backend.c b/block/block-backend.c index af23d71..17f05a3 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 name", + name); + return NULL; + } blk = g_new0(BlockBackend, 1); blk->name = g_strdup(name); @@ -61,13 +67,6 @@ BlockBackend *blk_new_with_bs(const char *name, Error **errp) BlockBackend *blk; BlockDriverState *bs; - if (bdrv_find_node(name)) { - error_setg(errp, - "Device name '%s' conflicts with an existing node name", - name); - return NULL; - } - blk = blk_new(name, errp); if (!blk) { return NULL; -- 1.9.3