From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36999) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WEMbJ-0001mE-2x for qemu-devel@nongnu.org; Fri, 14 Feb 2014 12:31:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WEMbE-000542-24 for qemu-devel@nongnu.org; Fri, 14 Feb 2014 12:30:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:3744) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WEMbD-00053y-Ik for qemu-devel@nongnu.org; Fri, 14 Feb 2014 12:30:51 -0500 From: Stefan Hajnoczi Date: Fri, 14 Feb 2014 18:29:33 +0100 Message-Id: <1392398973-15092-12-git-send-email-stefanha@redhat.com> In-Reply-To: <1392398973-15092-1-git-send-email-stefanha@redhat.com> References: <1392398973-15092-1-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 11/11] 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: Peter Maydell , Anthony Liguori From: Beno=C3=AEt Canet Since we introduced node_name for named bs of the graph modify the openin= g 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 Reviewed-by: Max Reitz Signed-off-by: Stefan Hajnoczi --- block.c | 10 ++++++++-- blockdev.c | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/block.c b/block.c index ba2aecf..8f718f9 100644 --- a/block.c +++ b/block.c @@ -796,6 +796,13 @@ static int bdrv_assign_node_name(BlockDriverState *b= s, return -EINVAL; } =20 + /* takes care of avoiding namespaces collisions */ + if (bdrv_find(node_name)) { + error_setg(errp, "node-name=3D%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"); @@ -977,9 +984,8 @@ int bdrv_file_open(BlockDriverState **pbs, const char= *filename, } QDECREF(options); =20 - bs =3D bdrv_find(reference); + bs =3D 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 ccd6a72..dfb5ec7 100644 --- a/blockdev.c +++ b/blockdev.c @@ -452,6 +452,12 @@ static DriveInfo *blockdev_init(const char *file, QD= ict *bs_opts, } } =20 + if (bdrv_find_node(qemu_opts_id(opts))) { + error_setg(errp, "device id=3D%s is conflicting with a node-name= ", + qemu_opts_id(opts)); + goto early_err; + } + /* init */ dinfo =3D g_malloc0(sizeof(*dinfo)); dinfo->id =3D g_strdup(qemu_opts_id(opts)); --=20 1.8.5.3