]> git.proxmox.com Git - mirror_qemu.git/commitdiff
block: Open by reference will try device then node_name.
authorBenoît Canet <benoit.canet@irqsave.net>
Wed, 12 Feb 2014 16:15:07 +0000 (17:15 +0100)
committerStefan Hajnoczi <stefanha@redhat.com>
Fri, 14 Feb 2014 17:05:39 +0000 (18:05 +0100)
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
blockdev.c

diff --git a/block.c b/block.c
index ba2aecf87aca53e5ce7e23d735c42afac0398f78..8f718f9f29b1482647e956aa03636af9d1571eb4 100644 (file)
--- 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);
index ccd6a72e924b2abd31b318a507217646538e70d1..dfb5ec7529e57ca1a6b15a574aae0535a4d3d74f 100644 (file)
@@ -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));