[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 54/93] block: Allow the user to define "node-name" op
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 54/93] block: Allow the user to define "node-name" option both on command line and QMP. |
Date: |
Fri, 24 Jan 2014 18:21:37 +0100 |
From: BenoƮt Canet <address@hidden>
Signed-off-by: Benoit Canet <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block.c | 35 +++++++++++++++++++++++++++++++++++
qapi-schema.json | 2 ++
2 files changed, 37 insertions(+)
diff --git a/block.c b/block.c
index 8562685..f043669 100644
--- a/block.c
+++ b/block.c
@@ -735,6 +735,33 @@ static int bdrv_open_flags(BlockDriverState *bs, int flags)
return open_flags;
}
+static int bdrv_assign_node_name(BlockDriverState *bs,
+ const char *node_name,
+ Error **errp)
+{
+ if (!node_name) {
+ return 0;
+ }
+
+ /* empty string node name is invalid */
+ if (node_name[0] == '\0') {
+ error_setg(errp, "Empty node name");
+ return -EINVAL;
+ }
+
+ /* takes care of avoiding duplicates node names */
+ if (bdrv_find_node(node_name)) {
+ error_setg(errp, "Duplicate node name");
+ return -EINVAL;
+ }
+
+ /* 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);
+
+ return 0;
+}
+
/*
* Common part for opening disk images and files
*
@@ -745,6 +772,7 @@ static int bdrv_open_common(BlockDriverState *bs,
BlockDriverState *file,
{
int ret, open_flags;
const char *filename;
+ const char *node_name = NULL;
Error *local_err = NULL;
assert(drv != NULL);
@@ -759,6 +787,13 @@ static int bdrv_open_common(BlockDriverState *bs,
BlockDriverState *file,
trace_bdrv_open_common(bs, filename ?: "", flags, drv->format_name);
+ node_name = qdict_get_try_str(options, "node-name");
+ ret = bdrv_assign_node_name(bs, node_name, errp);
+ if (ret < 0) {
+ return ret;
+ }
+ qdict_del(options, "node-name");
+
/* bdrv_open() with directly using a protocol as drv. This layer is already
* opened, so assign it to bs (while file becomes a closed
BlockDriverState)
* and return immediately. */
diff --git a/qapi-schema.json b/qapi-schema.json
index a433869..26e370b 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -4092,6 +4092,7 @@
# @id: #optional id by which the new block device can be referred to.
# This is a required option on the top level of blockdev-add, and
# currently not allowed on any other level.
+# @node-name: #optional the name of a block driver state node (Since 2.0)
# @discard: #optional discard-related options (default: ignore)
# @cache: #optional cache-related options
# @aio: #optional AIO backend (default: threads)
@@ -4107,6 +4108,7 @@
{ 'type': 'BlockdevOptionsBase',
'data': { 'driver': 'str',
'*id': 'str',
+ '*node-name': 'str',
'*discard': 'BlockdevDiscardOptions',
'*cache': 'BlockdevCacheOptions',
'*aio': 'BlockdevAioOptions',
--
1.8.1.4
- [Qemu-devel] [PULL 43/93] dataplane: fix shadowed return value, (continued)
- [Qemu-devel] [PULL 43/93] dataplane: fix shadowed return value, Kevin Wolf, 2014/01/24
- [Qemu-devel] [PULL 44/93] qcow2: fix wrong value of L1E_OFFSET_MASK, L2E_OFFSET_MASK and REFT_OFFSET_MASK, Kevin Wolf, 2014/01/24
- [Qemu-devel] [PULL 45/93] vmdk: Check for overhead when opening, Kevin Wolf, 2014/01/24
- [Qemu-devel] [PULL 46/93] qemu-progress: Drop unused include, Kevin Wolf, 2014/01/24
- [Qemu-devel] [PULL 47/93] qemu-progress: Fix progress printing on SIGUSR1, Kevin Wolf, 2014/01/24
- [Qemu-devel] [PULL 49/93] sheepdog: fix 'qemu-img map', Kevin Wolf, 2014/01/24
- [Qemu-devel] [PULL 48/93] Documentation: qemu-img: Mention SIGUSR1 progress report, Kevin Wolf, 2014/01/24
- [Qemu-devel] [PULL 51/93] vmdk: Fix format specific information (create type) for streamOptimized, Kevin Wolf, 2014/01/24
- [Qemu-devel] [PULL 50/93] drive mirror:fix memory leak, Kevin Wolf, 2014/01/24
- [Qemu-devel] [PULL 52/93] qapi: Add "backing" to BlockStats, Kevin Wolf, 2014/01/24
- [Qemu-devel] [PULL 54/93] block: Allow the user to define "node-name" option both on command line and QMP.,
Kevin Wolf <=
- [Qemu-devel] [PULL 53/93] block: Add bs->node_name to hold the name of a bs node of the bs graph., Kevin Wolf, 2014/01/24
- [Qemu-devel] [PULL 61/93] block: resize backing file image during offline commit, if necessary, Kevin Wolf, 2014/01/24
- [Qemu-devel] [PULL 62/93] block: resize backing image during active layer commit, if needed, Kevin Wolf, 2014/01/24
- [Qemu-devel] [PULL 64/93] block: Fix bdrv_commit return value, Kevin Wolf, 2014/01/24
- [Qemu-devel] [PULL 63/93] block: update block commit documentation regarding image truncation, Kevin Wolf, 2014/01/24
- [Qemu-devel] [PULL 65/93] block: Move initialisation of BlockLimits to bdrv_refresh_limits(), Kevin Wolf, 2014/01/24
- [Qemu-devel] [PULL 66/93] block: Inherit opt_transfer_length, Kevin Wolf, 2014/01/24
- [Qemu-devel] [PULL 68/93] qemu_memalign: Allow small alignments, Kevin Wolf, 2014/01/24
- [Qemu-devel] [PULL 67/93] block: Update BlockLimits when they might have changed, Kevin Wolf, 2014/01/24
- [Qemu-devel] [PULL 69/93] block: Detect unaligned length in bdrv_qiov_is_aligned(), Kevin Wolf, 2014/01/24