From: Jeff Cody <jcody@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, qemu-block@nongnu.org, jsnow@redhat.com,
armbru@redhat.com, programmingkidx@gmail.com, berto@igalia.com
Subject: [Qemu-devel] [PATCH v3 2/4] block: auto-generated node-names
Date: Mon, 12 Oct 2015 19:36:50 -0400 [thread overview]
Message-ID: <cb38aeceb10a0499590ec0f15d221c3d81adb786.1444691409.git.jcody@redhat.com> (raw)
In-Reply-To: <cover.1444691409.git.jcody@redhat.com>
In-Reply-To: <cover.1444691409.git.jcody@redhat.com>
If a node-name is not specified, automatically generate the node-name.
Generated node-names will use the "block" sub-system identifier.
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Jeff Cody <jcody@redhat.com>
---
block.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/block.c b/block.c
index 1f90b47..5947704 100644
--- a/block.c
+++ b/block.c
@@ -763,12 +763,15 @@ static void bdrv_assign_node_name(BlockDriverState *bs,
const char *node_name,
Error **errp)
{
+ char *gen_node_name = NULL;
+
if (!node_name) {
- return;
- }
-
- /* Check for empty string or invalid characters */
- if (!id_wellformed(node_name)) {
+ node_name = gen_node_name = id_generate(ID_BLOCK);
+ } else if (!id_wellformed(node_name)) {
+ /*
+ * Check for empty string or invalid characters, but not if it is
+ * generated (generated names use characters not available to the user)
+ */
error_setg(errp, "Invalid node name");
return;
}
@@ -777,18 +780,20 @@ static void bdrv_assign_node_name(BlockDriverState *bs,
if (blk_by_name(node_name)) {
error_setg(errp, "node-name=%s is conflicting with a device id",
node_name);
- return;
+ goto out;
}
/* takes care of avoiding duplicates node names */
if (bdrv_find_node(node_name)) {
error_setg(errp, "Duplicate node name");
- return;
+ goto out;
}
/* copy node name into the bs and insert it into the graph list */
pstrcpy(bs->node_name, sizeof(bs->node_name), node_name);
QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs, node_list);
+out:
+ g_free(gen_node_name);
}
static QemuOptsList bdrv_runtime_opts = {
--
1.9.3
next prev parent reply other threads:[~2015-10-12 23:37 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-12 23:36 [Qemu-devel] [PATCH v3 0/4] Jeff Cody
2015-10-12 23:36 ` [Qemu-devel] [PATCH v3 1/4] util - add automated ID generation utility Jeff Cody
2015-10-13 7:37 ` Markus Armbruster
2015-10-13 11:17 ` Jeff Cody
2015-10-13 15:26 ` Markus Armbruster
2015-10-13 16:40 ` John Snow
2015-10-13 19:25 ` Programmingkid
2015-10-12 23:36 ` Jeff Cody [this message]
2015-10-13 7:39 ` [Qemu-devel] [PATCH v3 2/4] block: auto-generated node-names Markus Armbruster
2015-10-12 23:36 ` [Qemu-devel] [PATCH v3 3/4] block: add filter for generated node-names Jeff Cody
2015-10-12 23:36 ` [Qemu-devel] [PATCH v3 4/4] qemu-iotests: update tests " Jeff Cody
2015-10-13 7:41 ` Markus Armbruster
2015-10-13 11:18 ` Jeff Cody
2015-10-13 13:03 ` [Qemu-devel] [PATCH v3 0/4] Kevin Wolf
2015-10-13 15:26 ` Markus Armbruster
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=cb38aeceb10a0499590ec0f15d221c3d81adb786.1444691409.git.jcody@redhat.com \
--to=jcody@redhat.com \
--cc=armbru@redhat.com \
--cc=berto@igalia.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=programmingkidx@gmail.com \
--cc=qemu-block@nongnu.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 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).