From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55995) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDcSy-0007P5-UU for qemu-devel@nongnu.org; Wed, 12 Feb 2014 11:15:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WDcSt-0006Yg-Tf for qemu-devel@nongnu.org; Wed, 12 Feb 2014 11:15:16 -0500 Received: from paradis.irqsave.net ([62.212.105.220]:49792) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDcSt-0006X8-KI for qemu-devel@nongnu.org; Wed, 12 Feb 2014 11:15:11 -0500 From: =?UTF-8?q?Beno=C3=AEt=20Canet?= Date: Wed, 12 Feb 2014 17:15:07 +0100 Message-Id: <1392221707-12916-3-git-send-email-benoit.canet@irqsave.net> In-Reply-To: <1392221707-12916-1-git-send-email-benoit.canet@irqsave.net> References: <1392221707-12916-1-git-send-email-benoit.canet@irqsave.net> Subject: [Qemu-devel] [PATCH 2/2] block: Open by reference will try device then node_name. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, =?UTF-8?q?Beno=C3=AEt=20Canet?= , Benoit Canet , mreitz@redhat.com Since we introduced node_name for named bs of the graph modify the opening by reference to use it as a fallback. This patch also enforce the separation of the device id and graph node namespaces. Signed-off-by: Benoit Canet --- block.c | 10 ++++++++-- blockdev.c | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/block.c b/block.c index 5ca901b..af22e8a 100644 --- a/block.c +++ b/block.c @@ -796,6 +796,13 @@ static int bdrv_assign_node_name(BlockDriverState *bs, return -EINVAL; } + /* takes care of avoiding namespaces collisions */ + if (bdrv_find(node_name)) { + error_setg(errp, "node-name=%s is conflicting with a device id", + node_name); + return -EINVAL; + } + /* takes care of avoiding duplicates node names */ if (bdrv_find_node(node_name)) { error_setg(errp, "Duplicate node name"); @@ -1193,9 +1200,8 @@ int bdrv_open(BlockDriverState **pbs, const char *filename, return -EINVAL; } - bs = bdrv_find(reference); + bs = bdrv_lookup_bs(reference, reference, errp); if (!bs) { - error_setg(errp, "Cannot find block device '%s'", reference); return -ENODEV; } bdrv_ref(bs); diff --git a/blockdev.c b/blockdev.c index 7b7e349..5cd50f3 100644 --- a/blockdev.c +++ b/blockdev.c @@ -463,6 +463,12 @@ static DriveInfo *blockdev_init(const char *file, QDict *bs_opts, } } + if (bdrv_find_node(qemu_opts_id(opts))) { + error_setg(errp, "device id=%s is conflicting with a node-name", + qemu_opts_id(opts)); + goto early_err; + } + /* init */ dinfo = g_malloc0(sizeof(*dinfo)); dinfo->id = g_strdup(qemu_opts_id(opts)); -- 1.8.3.2