All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Anthony Liguori <aliguori@amazon.com>
Subject: [Qemu-devel] [PULL 11/11] block: Open by reference will try device then node_name.
Date: Fri, 14 Feb 2014 18:29:33 +0100	[thread overview]
Message-ID: <1392398973-15092-12-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1392398973-15092-1-git-send-email-stefanha@redhat.com>

From: Benoît Canet <benoit.canet@irqsave.net>

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 <benoit@irqsave.net>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 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 *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");
@@ -977,9 +984,8 @@ int bdrv_file_open(BlockDriverState **pbs, const char *filename,
         }
         QDECREF(options);
 
-        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 ccd6a72..dfb5ec7 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -452,6 +452,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.5.3

  parent reply	other threads:[~2014-02-14 17:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-14 17:29 [Qemu-devel] [PULL 00/11] Block patches Stefan Hajnoczi
2014-02-14 17:29 ` [Qemu-devel] [PULL 01/11] sdhci: Drop unnecessary #include Stefan Hajnoczi
2014-02-14 17:29 ` [Qemu-devel] [PULL 02/11] blockdev: Remove 'type' parameter from blockdev_init() Stefan Hajnoczi
2014-02-14 17:29 ` [Qemu-devel] [PULL 03/11] block: Add notes to iSCSI's .bdrv_open and .bdrv_reopen_prepare Stefan Hajnoczi
2014-02-14 17:29 ` [Qemu-devel] [PULL 04/11] block: Don't throw away errno via error_setg Stefan Hajnoczi
2014-02-14 17:29 ` [Qemu-devel] [PULL 05/11] block: qemu-iotests - fix test 070 (vhdx) Stefan Hajnoczi
2014-02-14 17:29 ` [Qemu-devel] [PULL 06/11] block: qemu-iotests - add vhdx log replay tests for qemu-img Stefan Hajnoczi
2014-02-14 17:29 ` [Qemu-devel] [PULL 07/11] qemu-iotests: Don't run 005 on vmdk split formats Stefan Hajnoczi
2014-02-14 17:29 ` [Qemu-devel] [PULL 08/11] block: mirror - use local_err to avoid NULL errp Stefan Hajnoczi
2014-02-14 17:29 ` [Qemu-devel] [PULL 09/11] blockdev: Fix wrong usage of QDECREF causing snapshoted quorum to crash on close Stefan Hajnoczi
2014-02-14 17:29 ` [Qemu-devel] [PULL 10/11] block: Relax bdrv_lookup_bs constraints Stefan Hajnoczi
2014-02-14 17:29 ` Stefan Hajnoczi [this message]
2014-02-15 16:37 ` [Qemu-devel] [PULL 00/11] Block patches Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1392398973-15092-12-git-send-email-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=aliguori@amazon.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.