From: "Benoît Canet" <benoit.canet@irqsave.net>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, "Benoît Canet" <benoit.canet@irqsave.net>,
"Benoit Canet" <benoit@irqsave.net>,
mreitz@redhat.com
Subject: [Qemu-devel] [PATCH 2/2] block: Open by reference will try device then node_name.
Date: Wed, 12 Feb 2014 17:15:07 +0100 [thread overview]
Message-ID: <1392221707-12916-3-git-send-email-benoit.canet@irqsave.net> (raw)
In-Reply-To: <1392221707-12916-1-git-send-email-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>
---
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
next prev parent reply other threads:[~2014-02-12 16:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-12 16:15 [Qemu-devel] [PATCH 0/2] Make open by reference use id then node-name Benoît Canet
2014-02-12 16:15 ` [Qemu-devel] [PATCH 1/2] block: Relax bdrv_lookup_bs constraints Benoît Canet
2014-02-13 18:53 ` Max Reitz
2014-02-12 16:15 ` Benoît Canet [this message]
2014-02-13 18:54 ` [Qemu-devel] [PATCH 2/2] block: Open by reference will try device then node_name Max Reitz
2014-02-14 9:57 ` [Qemu-devel] [PATCH 0/2] Make open by reference use id then node-name Kevin Wolf
2014-02-14 16:03 ` Stefan Hajnoczi
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=1392221707-12916-3-git-send-email-benoit.canet@irqsave.net \
--to=benoit.canet@irqsave.net \
--cc=benoit@irqsave.net \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).