diff options
author | Markus Armbruster | 2014-10-07 13:59:12 +0200 |
---|---|---|
committer | Kevin Wolf | 2014-10-20 13:41:26 +0200 |
commit | 7f06d47eff9d26cca87855273f20786502f8c57e (patch) | |
tree | 747edade3b526422600216179cb32c2634a80bad /block | |
parent | block: Eliminate BlockDriverState member device_name[] (diff) | |
download | qemu-7f06d47eff9d26cca87855273f20786502f8c57e.tar.gz qemu-7f06d47eff9d26cca87855273f20786502f8c57e.tar.xz qemu-7f06d47eff9d26cca87855273f20786502f8c57e.zip |
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>
Diffstat (limited to 'block')
-rw-r--r-- | block/block-backend.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/block/block-backend.c b/block/block-backend.c index 6236b5b96d..fb91680f03 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -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; |