diff mbox

quorum: add child name into filename

Message ID 56EB743E.8060500@cn.fujitsu.com
State New
Headers show

Commit Message

Wen Congyang March 18, 2016, 3:21 a.m. UTC
The monitor command 'query-block' or 'info block' will output the filename.
So we can get each children's child-name after this patch. This useful for
dynamic reconfiguration.

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
---
 block/quorum.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

Max Reitz March 23, 2016, 8:45 p.m. UTC | #1
On 18.03.2016 04:21, Wen Congyang wrote:
> The monitor command 'query-block' or 'info block' will output the filename.
> So we can get each children's child-name after this patch. This useful for
> dynamic reconfiguration.
> 
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> ---
>  block/quorum.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/block/quorum.c b/block/quorum.c
> index da15465..182766a 100644
> --- a/block/quorum.c
> +++ b/block/quorum.c
> @@ -1036,9 +1036,13 @@ static void quorum_refresh_filename(BlockDriverState *bs, QDict *options)
>  
>      children = qlist_new();
>      for (i = 0; i < s->num_children; i++) {
> -        QINCREF(s->children[i]->bs->full_open_options);
> -        qlist_append_obj(children,
> -                         QOBJECT(s->children[i]->bs->full_open_options));
> +        QDict *child_opts;
> +        const char *child_name = s->children[i]->name;
> +
> +        child_opts = qdict_clone_shallow(s->children[i]->bs->full_open_options);
> +        qdict_put_obj(child_opts, "child-name",
> +                      QOBJECT(qstring_from_str(child_name)));
> +        qlist_append_obj(children, QOBJECT(child_opts));

This QDict is supposed to contain options for reconstructing the given
BDS tree. The "child-name" option however is not a valid options for any
BDS, and giving it will result in an error.

One better place for this functionality would be to implement the
bdrv_get_specific_info() function and define an ImageInfoQuorum QAPI
object (which could contain an array of child information, with each
such object in turn containing this child name).

However, it appears to me that this is very general graph information
and actually not related to quorum. So it probably makes sense to
instead introduce a QMP command for querying the BDS graph (or the tree
starting at a user-specified node/backend). I think it would be
sufficient to just emit the node names (because every BDS has a node
name now), like so:

(Note: This is just a rough idea, maybe it's actually a horrible idea)

{ 'execute': 'query-block-node-tree',
  'arguments': { 'root': 'drive0' } }

{ 'return': {
    'node-name': 'qcow2-node',
    'children': {
        'file': {
            'node-name': 'quorum-node',
            'children': {
                'children.0': {
                    'node-name': 'file-node'
                },
                'children.1': {
                    'node-name': 'nbd-node'
                }
            }
        }
    }
} }

Maybe we have something that can provide this exact functionality
already and I'm just oblivious to it, though.

Max

>      }
>  
>      opts = qdict_new();
>
diff mbox

Patch

diff --git a/block/quorum.c b/block/quorum.c
index da15465..182766a 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -1036,9 +1036,13 @@  static void quorum_refresh_filename(BlockDriverState *bs, QDict *options)
 
     children = qlist_new();
     for (i = 0; i < s->num_children; i++) {
-        QINCREF(s->children[i]->bs->full_open_options);
-        qlist_append_obj(children,
-                         QOBJECT(s->children[i]->bs->full_open_options));
+        QDict *child_opts;
+        const char *child_name = s->children[i]->name;
+
+        child_opts = qdict_clone_shallow(s->children[i]->bs->full_open_options);
+        qdict_put_obj(child_opts, "child-name",
+                      QOBJECT(qstring_from_str(child_name)));
+        qlist_append_obj(children, QOBJECT(child_opts));
     }
 
     opts = qdict_new();