aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
Diffstat (limited to 'block.c')
-rw-r--r--block.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/block.c b/block.c
index f3b93c942b..fc2edd33ae 100644
--- a/block.c
+++ b/block.c
@@ -336,6 +336,17 @@ BlockDriverState *bdrv_new(const char *device_name, Error **errp)
{
BlockDriverState *bs;
+ if (bdrv_find(device_name)) {
+ error_setg(errp, "Device with id '%s' already exists",
+ device_name);
+ return NULL;
+ }
+ if (bdrv_find_node(device_name)) {
+ error_setg(errp, "Device with node-name '%s' already exists",
+ device_name);
+ return NULL;
+ }
+
bs = g_malloc0(sizeof(BlockDriverState));
QLIST_INIT(&bs->dirty_bitmaps);
pstrcpy(bs->device_name, sizeof(bs->device_name), device_name);