Fix some qapi examples
cover Fix some qapi examples
Hi,
I did another iteration of adding the examples in the qapi documentation as unit tests in another project and found a few that could be updated.
Feel free to cherry-pick them. Happy to rework it if needed.
Victor Toso (9):
qapi: fix example of netdev_add command
qapi: fix examples: replay-break and replay-seek
qapi: fix example of query-named-block-nodes command
qapi: fix example of query-spice command
qapi: fix example of query-vnc command
qapi: fix example of query-colo-status command
qapi: fix example of trace-event-get-state command
qapi: fix example of query-cpus-fast command
qapi: fix example of query-memdev command
qapi/block-core.json | 1 + qapi/machine.json | 4 ++-- qapi/migration.json | 2 +- qapi/net.json | 2 +- qapi/replay.json | 4 ++-- qapi/trace.json | 2 +- qapi/ui.json | 3 +++ 7 files changed, 11 insertions(+), 7 deletions(-)
Signature · 1 line
2.35.1
PATCH 1/9 qapi: fix example of netdev_add command
Example output has the optional member @dnssearch as string type. It should be an array of strings instead. Fix it.
For reference, see NetdevUserOptions.
--- qapi/net.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
qapi/net.json +1 -1
@@ -51,7 +51,7 @@ # # -> { "execute": "netdev_add", # "arguments": { "type": "user", "id": "netdev1", -# "dnssearch": "example.org" } } +# "dnssearch": [ "example.org" ] } } # <- { "return": {} } # ##
Signature · 1 line
2.35.1
Re: [PATCH v1 1/9] qapi: fix example of netdev_add command
Quoted 15 lines · Victor Toso
Example output has the optional member @dnssearch as string type. It should be an array of strings instead. Fix it.
For reference, see NetdevUserOptions.
Signed-off-by Victor Toso <[email protected]>--- qapi/net.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)qapi/net.json +0
-0
qapi/net.json line 57
Quoted 8 lines
qapi/net.json +1
-1@@ -51,7 +51,7 @@ # # -> { "execute": "netdev_add", # "arguments": { "type": "user", "id": "netdev1", -# "dnssearch": "example.org" } } +# "dnssearch": [ "example.org" ] } } # <- { "return": {} } # ##
Uh, @dnssearch is ['String']... shouldn't this be something like
# "dnssearch": [ { "str": "example.org" } ] } }
?
Re: [PATCH v1 1/9] qapi: fix example of netdev_add command
Hi,
Quoted 28 lines · Markus Armbruster
Quoted 15 lines · Victor Toso
Example output has the optional member @dnssearch as string type. It should be an array of strings instead. Fix it.
For reference, see NetdevUserOptions.
Signed-off-by Victor Toso <[email protected]>--- qapi/net.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)qapi/net.json +0
-0qapi/net.json line 57
Quoted 8 lines
qapi/net.json +1
-1@@ -51,7 +51,7 @@ # # -> { "execute": "netdev_add", # "arguments": { "type": "user", "id": "netdev1", -# "dnssearch": "example.org" } } +# "dnssearch": [ "example.org" ] } } # <- { "return": {} } # ##Uh, @dnssearch is ['String']... shouldn't this be something like
Quoted 3 lines
# "dnssearch": [ { "str": "example.org" } ] } }?
Yes, my mistake. Thanks for spotting it.
I'll resend this patch shortly.
Cheers,
Victor
PATCH 1/9 qapi: fix example of netdev_add command
In reply to Victor TosoExample output has the optional member @dnssearch as string type. It should be an array of strings instead. Fix it.
For reference, see NetdevUserOptions.
--- qapi/net.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
qapi/net.json +1 -1
@@ -51,7 +51,7 @@ # # -> { "execute": "netdev_add", # "arguments": { "type": "user", "id": "netdev1", -# "dnssearch": "example.org" } } +# "dnssearch": [ { "str": "example.org" } ] } } # <- { "return": {} } # ##
Signature · 1 line
2.35.1
Re: [PATCH v1.1 1/9] qapi: fix example of netdev_add command
Quoted 2 lines · Victor Toso
Example output has the optional member @dnssearch as string type. It should be an array of strings instead. Fix it.
"of String objects". Happy to fix this in my tree.
Quoted 13 lines
For reference, see NetdevUserOptions.
Signed-off-by Victor Toso <[email protected]>--- qapi/net.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)qapi/net.json +0
-0
qapi/net.json line 57
Quoted 8 lines
qapi/net.json +1
-1@@ -51,7 +51,7 @@ # # -> { "execute": "netdev_add", # "arguments": { "type": "user", "id": "netdev1", -# "dnssearch": "example.org" } } +# "dnssearch": [ { "str": "example.org" } ] } } # <- { "return": {} } # ##
Preferably with the commit message tweak:
Re: [PATCH v1.1 1/9] qapi: fix example of netdev_add command
Hi,
Quoted 6 lines · Markus Armbruster
Quoted 2 lines · Victor Toso
Example output has the optional member @dnssearch as string type. It should be an array of strings instead. Fix it.
"of String objects". Happy to fix this in my tree.
Sure
Quoted 24 lines
Quoted 14 lines
For reference, see NetdevUserOptions.
Signed-off-by Victor Toso <[email protected]>--- qapi/net.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)qapi/net.json +0
-0qapi/net.json line 57
Quoted 8 lines
qapi/net.json +1
-1@@ -51,7 +51,7 @@ # # -> { "execute": "netdev_add", # "arguments": { "type": "user", "id": "netdev1", -# "dnssearch": "example.org" } } +# "dnssearch": [ { "str": "example.org" } ] } } # <- { "return": {} } # ##Preferably with the commit message tweak:
Quoted 1 line
Reviewed-by Markus Armbruster <[email protected]>
Thanks,
Victor
PATCH 2/9 qapi: fix examples: replay-break and replay-seek
In reply to Victor TosoBoth examples outputs are using @data member for the arguments. This is wrong. The expected member for the QMP is @arguments. Fix it.
--- qapi/replay.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
qapi/replay.json +2 -2
@@ -81,7 +81,7 @@ # # Example: # -# -> { "execute": "replay-break", "data": { "icount": 220414 } } +# -> { "execute": "replay-break", "arguments": { "icount": 220414 } } # ## { 'command': 'replay-break', 'data': { 'icount': 'int' } }
@@ -117,6 +117,6 @@ # # Example: # -# -> { "execute": "replay-seek", "data": { "icount": 220414 } } +# -> { "execute": "replay-seek", "arguments": { "icount": 220414 } } ## { 'command': 'replay-seek', 'data': { 'icount': 'int' } }
Signature · 1 line
2.35.1
Re: [PATCH v1 2/9] qapi: fix examples: replay-break and replay-seek
Quoted 22 lines · Victor Toso
Both examples outputs are using @data member for the arguments. This is wrong. The expected member for the QMP is @arguments. Fix it.
Signed-off-by Victor Toso <[email protected]>--- qapi/replay.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)qapi/replay.json +1
-1@@ -81,7 +81,7 @@ # # Example: # -# -> { "execute": "replay-break", "data": { "icount": 220414 } } +# -> { "execute": "replay-break", "arguments": { "icount": 220414 } } # ## { 'command': 'replay-break', 'data': { 'icount': 'int' } }
qapi/replay.json line 122
Quoted 7 lines
qapi/replay.json +1
-1@@ -117,6 +117,6 @@ # # Example: # -# -> { "execute": "replay-seek", "data": { "icount": 220414 } } +# -> { "execute": "replay-seek", "arguments": { "icount": 220414 } } ## { 'command': 'replay-seek', 'data': { 'icount': 'int' } }
I should've flagged these when I reviewed commit b1ca53224a "qapi/migration: Fix examples document wrong field name for arguments".
PATCH 3/9 qapi: fix example of query-named-block-nodes command
In reply to Victor TosoExample output is missing mandatory member @detect_zeroes. Fix it.
--- qapi/block-core.json | 1 + 1 file changed, 1 insertion(+)
qapi/block-core.json +1 -0
@@ -1776,6 +1776,7 @@ # "file":"disks/test.qcow2", # "node-name": "my-node", # "backing_file_depth":1, +# "detect_zeroes":"off", # "bps":1000000, # "bps_rd":0, # "bps_wr":0,
Signature · 1 line
2.35.1
Re: [PATCH v1 3/9] qapi: fix example of query-named-block-nodes command
Quoted 12 lines · Victor Toso
Example output is missing mandatory member @detect_zeroes. Fix it.
Signed-off-by Victor Toso <[email protected]>--- qapi/block-core.json | 1 + 1 file changed, 1 insertion(+)qapi/block-core.json +0
-0
qapi/block-core.json line 1782
Quoted 7 lines
qapi/block-core.json +1
-0@@ -1776,6 +1776,7 @@ # "file":"disks/test.qcow2", # "node-name": "my-node", # "backing_file_depth":1, +# "detect_zeroes":"off", # "bps":1000000, # "bps_rd":0, # "bps_wr":0,
PATCH 4/9 qapi: fix example of query-spice command
In reply to Victor TosoExample output is missing mandatory members @migrated and @mouse-mode. Fix it.
--- qapi/ui.json | 2 ++ 1 file changed, 2 insertions(+)
qapi/ui.json +2 -0
@@ -324,8 +324,10 @@ # "enabled": true, # "auth": "spice", # "port": 5920, +# "migrated":false, # "tls-port": 5921, # "host": "0.0.0.0", +# "mouse-mode":"client", # "channels": [ # { # "port": "54924",
Signature · 1 line
2.35.1
Re: [PATCH v1 4/9] qapi: fix example of query-spice command
Quoted 13 lines · Victor Toso
Example output is missing mandatory members @migrated and @mouse-mode. Fix it.
Signed-off-by Victor Toso <[email protected]>--- qapi/ui.json | 2 ++ 1 file changed, 2 insertions(+)qapi/ui.json +0
-0
qapi/ui.json line 333
Quoted 10 lines
qapi/ui.json +2
-0@@ -324,8 +324,10 @@ # "enabled": true, # "auth": "spice", # "port": 5920, +# "migrated":false, # "tls-port": 5921, # "host": "0.0.0.0", +# "mouse-mode":"client", # "channels": [ # { # "port": "54924",
PATCH 5/9 qapi: fix example of query-vnc command
In reply to Victor TosoThe return value is missing the mandatory member @websocket. Fix it.
--- qapi/ui.json | 1 + 1 file changed, 1 insertion(+)
qapi/ui.json +1 -0
@@ -658,6 +658,7 @@ # "host":"127.0.0.1", # "service":"50401", # "family":"ipv4" +# "websocket":false, # } # ] # }
Signature · 1 line
2.35.1
Re: [PATCH v1 5/9] qapi: fix example of query-vnc command
Quoted 12 lines · Victor Toso
The return value is missing the mandatory member @websocket. Fix it.
Signed-off-by Victor Toso <[email protected]>--- qapi/ui.json | 1 + 1 file changed, 1 insertion(+)qapi/ui.json +0
-0
qapi/ui.json line 664
Quoted 7 lines
qapi/ui.json +1
-0@@ -658,6 +658,7 @@ # "host":"127.0.0.1", # "service":"50401", # "family":"ipv4" +# "websocket":false, # } # ] # }
PATCH 6/9 qapi: fix example of query-colo-status command
In reply to Victor TosoThe example output is missing the mandatory member @last-mode in the return value. Fix it.
--- qapi/migration.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
qapi/migration.json +1 -1
@@ -1679,7 +1679,7 @@ # Example: # # -> { "execute": "query-colo-status" } -# <- { "return": { "mode": "primary", "reason": "request" } } +# <- { "return": { "mode": "primary", "last-mode": "none", "reason": "request" } } # # Since: 3.1 ##
Signature · 1 line
2.35.1
Re: [PATCH v1 6/9] qapi: fix example of query-colo-status command
Quoted 13 lines · Victor Toso
The example output is missing the mandatory member @last-mode in the return value. Fix it.
Signed-off-by Victor Toso <[email protected]>--- qapi/migration.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)qapi/migration.json +0
-0
qapi/migration.json line 1685
Quoted 8 lines
qapi/migration.json +1
-1@@ -1679,7 +1679,7 @@ # Example: # # -> { "execute": "query-colo-status" } -# <- { "return": { "mode": "primary", "reason": "request" } } +# <- { "return": { "mode": "primary", "last-mode": "none", "reason": "request" } } # # Since: 3.1 ##
PATCH 7/9 qapi: fix example of trace-event-get-state command
In reply to Victor TosoThe example output is missing the mandatory member @vcpu. Fix it.
--- qapi/trace.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
qapi/trace.json +1 -1
@@ -69,7 +69,7 @@ # # -> { "execute": "trace-event-get-state", # "arguments": { "name": "qemu_memalign" } } -# <- { "return": [ { "name": "qemu_memalign", "state": "disabled" } ] } +# <- { "return": [ { "name": "qemu_memalign", "state": "disabled", "vcpu": false } ] } # ## { 'command': 'trace-event-get-state',
Signature · 1 line
2.35.1
Re: [PATCH v1 7/9] qapi: fix example of trace-event-get-state command
Quoted 12 lines · Victor Toso
The example output is missing the mandatory member @vcpu. Fix it.
Signed-off-by Victor Toso <[email protected]>--- qapi/trace.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)qapi/trace.json +0
-0
qapi/trace.json line 75
Quoted 8 lines
qapi/trace.json +1
-1@@ -69,7 +69,7 @@ # # -> { "execute": "trace-event-get-state", # "arguments": { "name": "qemu_memalign" } } -# <- { "return": [ { "name": "qemu_memalign", "state": "disabled" } ] } +# <- { "return": [ { "name": "qemu_memalign", "state": "disabled", "vcpu": false } ] } # ## { 'command': 'trace-event-get-state',
PATCH 8/9 qapi: fix example of query-cpus-fast command
In reply to Victor TosoExample output contains member @arch that was removed in 445a5b4087 "machine: remove 'arch' field from 'query-cpus-fast' QMP command". Fix it.
--- qapi/machine.json | 2 -- 1 file changed, 2 deletions(-)
qapi/machine.json +0 -2
@@ -109,7 +109,6 @@ # "socket-id": 0 # }, # "qom-path": "/machine/unattached/device[0]", -# "arch":"x86", # "target":"x86_64", # "cpu-index": 0 # },
@@ -121,7 +120,6 @@ # "socket-id": 1 # }, # "qom-path": "/machine/unattached/device[2]", -# "arch":"x86", # "target":"x86_64", # "cpu-index": 1 # }
Signature · 1 line
2.35.1
Re: [PATCH v1 8/9] qapi: fix example of query-cpus-fast command
Quoted 22 lines · Victor Toso
Example output contains member @arch that was removed in
445a5b4087"machine: remove 'arch' field from 'query-cpus-fast' QMP command". Fix it.Signed-off-by Victor Toso <[email protected]>--- qapi/machine.json | 2 -- 1 file changed, 2 deletions(-)qapi/machine.json +0
-1@@ -109,7 +109,6 @@ # "socket-id": 0 # }, # "qom-path": "/machine/unattached/device[0]", -# "arch":"x86", # "target":"x86_64", # "cpu-index": 0 # },
qapi/machine.json line 125
Quoted 7 lines
qapi/machine.json +0
-1@@ -121,7 +120,6 @@ # "socket-id": 1 # }, # "qom-path": "/machine/unattached/device[2]", -# "arch":"x86", # "target":"x86_64", # "cpu-index": 1 # }
PATCH 9/9 qapi: fix example of query-memdev command
In reply to Victor TosoExample output is missing mandatory argument @share for the return JSON object. Add it.
--- qapi/machine.json | 2 ++ 1 file changed, 2 insertions(+)
qapi/machine.json +2 -0
@@ -839,6 +839,7 @@ # "merge": false, # "dump": true, # "prealloc": false, +# "share": false, # "host-nodes": [0, 1], # "policy": "bind" # },
@@ -847,6 +848,7 @@ # "merge": false, # "dump": true, # "prealloc": true, +# "share": false, # "host-nodes": [2, 3], # "policy": "preferred" # }
Signature · 1 line
2.35.1
Re: [PATCH v1 9/9] qapi: fix example of query-memdev command
Quoted 21 lines · Victor Toso
Example output is missing mandatory argument @share for the return JSON object. Add it.
Signed-off-by Victor Toso <[email protected]>--- qapi/machine.json | 2 ++ 1 file changed, 2 insertions(+)qapi/machine.json +1
-0@@ -839,6 +839,7 @@ # "merge": false, # "dump": true, # "prealloc": false, +# "share": false, # "host-nodes": [0, 1], # "policy": "bind" # },
qapi/machine.json line 854
Quoted 7 lines
qapi/machine.json +1
-0@@ -847,6 +848,7 @@ # "merge": false, # "dump": true, # "prealloc": true, +# "share": false, # "host-nodes": [2, 3], # "policy": "preferred" # }
[PATCH 10/9] qapi: Fix calc-dirty-rate example
In reply to Victor TosoThe example shows {"command": ...}, which is wrong. Fix it to {"execute": ...}.
--- qapi/migration.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
qapi/migration.json +1 -1
@@ -1845,7 +1845,7 @@ # Since: 5.2 # # Example: -# {"command": "calc-dirty-rate", "arguments": {"calc-time": 1, +# {"execute": "calc-dirty-rate", "arguments": {"calc-time": 1, # 'sample-pages': 512} } # ##
Signature · 1 line
2.35.1
Victor Toso
Reviewed-byRe: [PATCH 10/9] qapi: Fix calc-dirty-rate example
Quoted 23 lines · Markus Armbruster
The example shows {"command": ...}, which is wrong. Fix it to {"execute": ...}.
Signed-off-by Markus Armbruster <[email protected]>--- qapi/migration.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)qapi/migration.json +1
-1@@ -1845,7 +1845,7 @@ # Since: 5.2 # # Example: -# {"command": "calc-dirty-rate", "arguments": {"calc-time": 1, +# {"execute": "calc-dirty-rate", "arguments": {"calc-time": 1, # 'sample-pages': 512} } # ##Signature · 1 line
2.35.1
Cheers,
Victor
Markus Armbruster
AppliedQuoted 6 lines · Victor Toso
Hi,
I did another iteration of adding the examples in the qapi documentation as unit tests in another project and found a few that could be updated.
Feel free to cherry-pick them. Happy to rework it if needed.
Queued, thanks!