Skip to contentSkip to conversation

Fix some qapi examples

PATCH Applied Victor Toso 2 participants 26 messages Mar 31, 2022 – Apr 4, 2022

lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index 0d4578bd07..efc0bae170 100644
@@ -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
#2 lore raw

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.

---
 qapi/net.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qapi/net.json +0 -0
index 0d4578bd07..efc0bae170 100644

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" } ] } }

?

#3 lore raw

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.

---
 qapi/net.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qapi/net.json +0 -0
index 0d4578bd07..efc0bae170 100644

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

Quoted 3 lines
   #                     "dnssearch": [ { "str": "example.org" } ] } }

?

Yes, my mistake. Thanks for spotting it.
I'll resend this patch shortly.

Cheers,
Victor

#4 lore raw

PATCH 1/9 qapi: fix example of netdev_add command

In reply to 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.

---
 qapi/net.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qapi/net.json +1 -1
index 0d4578bd07..b92f3f5fb4 100644
@@ -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
Reviewed-by on v1 1/9
#5 lore raw

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.

---
 qapi/net.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qapi/net.json +0 -0
index 0d4578bd07..b92f3f5fb4 100644

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:

#6 lore raw

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.

---
 qapi/net.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qapi/net.json +0 -0
index 0d4578bd07..b92f3f5fb4 100644

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:

Quoted 1 line

Thanks,
Victor

#7 lore raw

PATCH 2/9 qapi: fix examples: replay-break and replay-seek

In reply to 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.

---
 qapi/replay.json | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
qapi/replay.json +2 -2
index b4d1ba253b..351898f60d 100644
@@ -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
Reviewed-by on v1 2/9
#8 lore raw

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.

---
 qapi/replay.json | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
qapi/replay.json +1 -1
index b4d1ba253b..351898f60d 100644
@@ -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".

#9 lore raw

PATCH 3/9 qapi: fix example of query-named-block-nodes command

In reply to Victor Toso

Example 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
index 4a7a6940a3..beeb91952a 100644
@@ -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
Reviewed-by on v1 3/9
#10 lore raw

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.

---
 qapi/block-core.json | 1 +
 1 file changed, 1 insertion(+)
qapi/block-core.json +0 -0
index 4a7a6940a3..beeb91952a 100644

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,
#11 lore raw

PATCH 4/9 qapi: fix example of query-spice command

In reply to Victor Toso

Example 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
index a810ed680c..c039b8b3cb 100644
@@ -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
Reviewed-by on v1 4/9
#12 lore raw

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.

---
 qapi/ui.json | 2 ++
 1 file changed, 2 insertions(+)
qapi/ui.json +0 -0
index a810ed680c..c039b8b3cb 100644

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",
#13 lore raw

PATCH 5/9 qapi: fix example of query-vnc command

In reply to Victor Toso

The return value is missing the mandatory member @websocket. Fix it.

---
 qapi/ui.json | 1 +
 1 file changed, 1 insertion(+)
qapi/ui.json +1 -0
index c039b8b3cb..13a8bb82aa 100644
@@ -658,6 +658,7 @@
 #                "host":"127.0.0.1",
 #                "service":"50401",
 #                "family":"ipv4"
+#                "websocket":false,
 #             }
 #          ]
 #       }
Signature · 1 line
2.35.1
Reviewed-by on v1 5/9
#14 lore raw

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.

---
 qapi/ui.json | 1 +
 1 file changed, 1 insertion(+)
qapi/ui.json +0 -0
index c039b8b3cb..13a8bb82aa 100644

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,
 #             }
 #          ]
 #       }
#15 lore raw

PATCH 6/9 qapi: fix example of query-colo-status command

In reply to Victor Toso

The 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
index 092a63354b..f74777608a 100644
@@ -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
Reviewed-by on v1 6/9
#16 lore raw

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.

---
 qapi/migration.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qapi/migration.json +0 -0
index 092a63354b..f74777608a 100644

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
 ##
#17 lore raw

PATCH 7/9 qapi: fix example of trace-event-get-state command

In reply to Victor Toso

The 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
index 119509f565..6c6982a587 100644
@@ -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
Reviewed-by on v1 7/9
#18 lore raw

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.

---
 qapi/trace.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qapi/trace.json +0 -0
index 119509f565..6c6982a587 100644

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',
#19 lore raw

PATCH 8/9 qapi: fix example of query-cpus-fast command

In reply to Victor Toso

Example 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
index 9c460ec450..968f912989 100644
@@ -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
Reviewed-by on v1 8/9
#20 lore raw

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.

---
 qapi/machine.json | 2 --
 1 file changed, 2 deletions(-)
qapi/machine.json +0 -1
index 9c460ec450..968f912989 100644
@@ -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
 #         }
#21 lore raw

PATCH 9/9 qapi: fix example of query-memdev command

In reply to Victor Toso

Example 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
index 968f912989..d25a481ce4 100644
@@ -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
Reviewed-by on v1 9/9
#22 lore raw

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.

---
 qapi/machine.json | 2 ++
 1 file changed, 2 insertions(+)
qapi/machine.json +1 -0
index 968f912989..d25a481ce4 100644
@@ -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"
 #        }
#23 lore raw

[PATCH 10/9] qapi: Fix calc-dirty-rate example

In reply to Victor Toso

The 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
index f74777608a..27d7b28158 100644
@@ -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
author Reviewed-by
#24 lore raw

Re: [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": ...}.

---
 qapi/migration.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qapi/migration.json +1 -1
index f74777608a..27d7b28158 100644
@@ -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

#25 lore raw
In reply to Victor Toso
Quoted 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!