BlockBackend's name space is separate only to keep the initial patches simple. Time to merge the two.
Signed-off-by: Markus Armbruster <arm...@redhat.com> --- 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