[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 09/23] block: Merge BlockBackend and BlockDriverS
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PATCH v3 09/23] block: Merge BlockBackend and BlockDriverState name spaces |
Date: |
Tue, 16 Sep 2014 20:12:14 +0200 |
BlockBackend's name space is separate only to keep the initial patches
simple. Time to merge the two.
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: BenoƮt Canet <address@hidden>
---
block.c | 11 +++--------
block/block-backend.c | 13 ++++++-------
2 files changed, 9 insertions(+), 15 deletions(-)
diff --git a/block.c b/block.c
index c3fa3da..f68f06c 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;
@@ -3795,14 +3795,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 f14a291..7fd832d 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
- Re: [Qemu-devel] [PATCH v3 03/23] block: Connect BlockBackend to BlockDriverState, (continued)
- Re: [Qemu-devel] [PATCH v3 03/23] block: Connect BlockBackend to BlockDriverState, Max Reitz, 2014/09/20
- Re: [Qemu-devel] [PATCH v3 03/23] block: Connect BlockBackend to BlockDriverState, Kevin Wolf, 2014/09/22
- Re: [Qemu-devel] [PATCH v3 03/23] block: Connect BlockBackend to BlockDriverState, Markus Armbruster, 2014/09/22
- Re: [Qemu-devel] [PATCH v3 03/23] block: Connect BlockBackend to BlockDriverState, Kevin Wolf, 2014/09/23
- Re: [Qemu-devel] [PATCH v3 03/23] block: Connect BlockBackend to BlockDriverState, Markus Armbruster, 2014/09/23
- Re: [Qemu-devel] [PATCH v3 03/23] block: Connect BlockBackend to BlockDriverState, Kevin Wolf, 2014/09/23
- Re: [Qemu-devel] [PATCH v3 03/23] block: Connect BlockBackend to BlockDriverState, Markus Armbruster, 2014/09/23
[Qemu-devel] [PATCH v3 05/23] block: Code motion to get rid of stubs/blockdev.c, Markus Armbruster, 2014/09/16
[Qemu-devel] [PATCH v3 09/23] block: Merge BlockBackend and BlockDriverState name spaces,
Markus Armbruster <=
[Qemu-devel] [PATCH v3 02/23] block: New BlockBackend, Markus Armbruster, 2014/09/16
[Qemu-devel] [PATCH v3 07/23] block: Eliminate bdrv_iterate(), use bdrv_next(), Markus Armbruster, 2014/09/16