quorum: add child name into filename
PATCH 1/1 quorum: add child name into filename
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.
--- block/quorum.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
block/quorum.c +7 -3
@@ -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 ();
Signature · 1 line
2.5.0
Quoted 17 lines · Wen Congyang
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 <[email protected]>--- block/quorum.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)block/quorum.c +0
-0@@ -1036,9 +1036,13 @@ static void quorum_refresh_filename(BlockDriverState *bs, QDict *options) children =qlist_new ();for (i =0 ; i < s->num_children; i++) {
block/quorum.c static void quorum_refresh_filename(BlockDriverState *bs, QDict *options) · line 1045
Quoted 10 lines
block/quorum.c +7
-3-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
Quoted 4 lines
block/quorum.c +0
-0} opts =qdict_new ();