block: Merge BlockBackend and BlockDriverState name spaces

BlockBackend's name space is separate only to keep the initial patches
simple.  Time to merge the two.

Retain bdrv_find() and bdrv_get_device_name() for now, to keep this
series manageable.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Markus Armbruster 2014-10-07 13:59:12 +02:00 committed by Kevin Wolf
parent bfb197e0d9
commit 7f06d47eff
3 changed files with 24 additions and 43 deletions

View file

@ -40,10 +40,20 @@ BlockBackend *blk_new(const char *name, Error **errp)
BlockBackend *blk;
assert(name && name[0]);
if (!id_wellformed(name)) {
error_setg(errp, "Invalid device name");
return NULL;
}
if (blk_by_name(name)) {
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);
@ -66,12 +76,7 @@ BlockBackend *blk_new_with_bs(const char *name, Error **errp)
return NULL;
}
bs = bdrv_new_root(name, errp);
if (!bs) {
blk_unref(blk);
return NULL;
}
bs = bdrv_new_root();
blk->bs = bs;
bs->blk = blk;
return blk;