post-Eric's fixes, QAPI improvements
cover post-Eric's fixes, QAPI improvements
From: Marc-André Lureau <[email protected]>
Hi,
I have grown a qapi branch during the past 2 months that was post-poned for review until the introspection and other fixes got merged or ready.
It could be splitted roughly in 3 parts, but since they depend on each other, it make sense to send as one:
1. generate QAPI documentation from schema (1->12)
2. remove use generated qmp dispatch in monitor (13->20)
3. add some support for async commands (22->36)
1 and 2 are hopefully not controversial, however 3 was discussed previously in 'async commands with QMP' thread:
QMP was initially designed with async support, but the implementation was buggy, since the async context didn't hold the request 'id', and thus it wasn't really used, so it was removed in 65207c59d a few months ago.
However, there a valid reasons to want better async support. Many qmp operations take time, and it's not a good idea to block the monitor during this time. Also, some operations, such as screendump with QXL, have to reenter the loop in order to complete. Furthermore, the current protocol is not purely synchronous, since the client have to handle unexpected in the middle replies, such as events.
The current status-quo for async commands is to return immediately, and send loosely related events later. This is quite poor from an API point of view, and the events are not related to a previous command (they don't hold the request 'id'). They are also broadcasted, which may not make sense to other clients for various commands (all the dump & query for example) and this prevent from adding meaningful client 'id' field (since it may conflict with other clients 'id').
I propose to re-introduce a better 'async' support, where command may return with the request 'id' only to the caller, when they are finished, and not block the monitor. This will be opt-out, so existing code do not have to change. Furthermore, since reply order is not guaranteed, clients will have to have the new 'async' capability to use those async commands. This scheme is not incompatible with having additional commands to query the command status, or broadcast related events to all clients.
Marc-André Lureau (36):
qapi: add comment block before ChardevDummy
qapi: add missing @
qapi: add some line spacing to help doc parser
monitor: use qapi for qmp_capabilities command
qapi: move examples to json schema
qapi: move documentation bits in schema files
qapi: add some headings in docs
qapi: add qapi2texi script
qapi: remove qmp-events.txt
texi2pod: learn quotation, deftp and deftypefn
build-sys: generate QAPI doc based on json
build-sys: generate qmp-commands.txt
build-sys: do not generate qmp-commands-old.h
monitor: remove usage of generated marshal functions
monitor: register gen:false commands manually
qmp: register qapi commands (no middle mode)
qmp: use qmp_dispatch()
qapi: remove "middle" mode
qmp: implement qmp_query_commands without qmp_cmds
qmp: remove old qmp-commands table
misc: spelling
qmp: teach qmp_dispatch() to take a pre-filled QDict
qmp: use a return callback for the command reply
qmp: add QmpClient
qmp: introduce async command type
qmp: check that async command have an 'id'
scripts: learn 'async' qapi commands
scripts: ensure -async commands are declared async
qapi: take 'id' from request
tests: change /0.15/* tests to /qmp/*
tests: add /qmp/dispatch_cmd_async test
qmp: update qmp-spec about async capability
monitor: add 'async' capability
console: graphic_hw_update return true if async
console: add graphic_hw_update_done()
console: add screendump-async
Makefile | 43 +- Makefile.target | 7 +- docs/qmp/qmp-events.txt | 664 ----- docs/qmp/qmp-spec.txt | 17 +- hw/display/qxl-render.c | 14 +- hw/display/qxl.c | 8 +- hw/display/qxl.h | 2 +- include/qapi/qmp/dispatch.h | 29 +- include/ui/console.h | 4 +- monitor.c | 409 +-- qapi-schema.json | 1258 ++++++++- qapi/block-core.json | 456 +++- qapi/block.json | 48 +- qapi/common.json | 37 +- qapi/event.json | 211 ++ qapi/introspect.json | 2 +- qapi/qmp-dispatch.c | 92 +- qapi/qmp-registry.c | 26 +- qapi/rocker.json | 46 + qapi/trace.json | 14 + qga/main.c | 26 +- qga/qapi-schema.json | 2 + qmp-commands.hx | 4324 ------------------------------- scripts/qapi-commands.py | 156 +- scripts/qapi-introspect.py | 7 +- scripts/qapi.py | 103 +- scripts/qapi2texi.py | 293 +++ scripts/texi2pod.pl | 44 +- tests/Makefile | 1 + tests/qapi-schema/async.err | 0 tests/qapi-schema/async.exit | 1 + tests/qapi-schema/async.json | 1 + tests/qapi-schema/async.out | 5 + tests/qapi-schema/qapi-schema-test.json | 2 + tests/qapi-schema/qapi-schema-test.out | 5 + tests/qapi-schema/test-qapi.py | 6 +- tests/test-qmp-commands.c | 132 +- ui/console.c | 77 +- vl.c | 1 + 39 files changed, 3108 insertions(+), 5465 deletions(-) delete mode 100644 docs/qmp/qmp-events.txt delete mode 100644 qmp-commands.hx create mode 100755 scripts/qapi2texi.py create mode 100644 tests/qapi-schema/async.err create mode 100644 tests/qapi-schema/async.exit create mode 100644 tests/qapi-schema/async.json create mode 100644 tests/qapi-schema/async.out
Signature · 1 line
2.4.3
PATCH 1/36 qapi: add comment block before ChardevDummy
From: Marc-André Lureau <[email protected]>
This is mainly to please the doc generation that requires comment block before the declaration.
--- qapi-schema.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
qapi-schema.json +5 -1
@@ -3042,13 +3042,17 @@ { 'struct': 'ChardevRingbuf', 'data': { '*size' : 'int' } } ## +# @ChardevDummy +## +{ 'struct': 'ChardevDummy', 'data': { } } + +## # @ChardevBackend: # # Configuration info for the new chardev backend. # # Since: 1.4 (testdev since 2.2) ## -{ 'struct': 'ChardevDummy', 'data': { } } { 'union': 'ChardevBackend', 'data': { 'file' : 'ChardevFile', 'serial' : 'ChardevHostdev',
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH 01/36] qapi: add comment block before ChardevDummy
Quoted 9 lines · On 09/25/2015 08:03 AM, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
This is mainly to please the doc generation that requires comment block before the declaration.
Signed-off-by Marc-André Lureau <[email protected]>--- qapi-schema.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Could be taken through trivial branch now without waiting for pending qapi patches, hence I've added a cc.
qapi-schema.json line 3047
Quoted 12 lines
qapi-schema.json +3
-0@@ -3042,13 +3042,17 @@ { 'struct': 'ChardevRingbuf', 'data': { '*size' : 'int' } } ## +# @ChardevDummy +## +{ 'struct': 'ChardevDummy', 'data': { } }
I might eventually reach the point where we could use:
{ 'union': 'ChardevBackend', 'data': { ...
'pty': {},
... } }
instead of needing 'pty': 'ChardevDummy'. But my current pending series doesn't get us quite there yet, so it would be a separate cleanup anyways.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 2/36 qapi: add missing @
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- qapi/block.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
qapi/block.json +1 -1
@@ -6,7 +6,7 @@ { 'include': 'block-core.json' } ## -# BiosAtaTranslation: +# @BiosAtaTranslation: # # Policy that BIOS should use to interpret cylinder/head/sector # addresses. Note that Bochs BIOS and SeaBIOS will not actually
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH 02/36] qapi: add missing @
Quoted 6 lines · On 09/25/2015 08:03 AM, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>--- qapi/block.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Adding qemu-trivial; this can be taken now through trivial tree without waiting for pending qapi patches.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Michael Tokarev
AppliedRe: [Qemu-devel] [PATCH 02/36] qapi: add missing @
In reply to [email protected]Applied to -trivial, thanks!
/mjt
PATCH 3/36 qapi: add some line spacing to help doc parser
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Paragraphs are seperated by empty lines.
--- qapi-schema.json | 14 ++++++++++++++ qapi/block-core.json | 26 ++++++++++++++++++++++++++ 2 files changed, 40 insertions(+)
qapi-schema.json +14 -0
@@ -856,8 +856,11 @@ # the name resolution on the host and may be an IP address. # # @family: #optional 'ipv6' if the host is listening for IPv6 connections +# # 'ipv4' if the host is listening for IPv4 connections +# # 'unix' if the host is listening on a unix domain socket +# # 'unknown' otherwise # # @service: #optional The service name of the server's port. This may depends
@@ -865,16 +868,27 @@ # be relied on. # # @auth: #optional the current authentication type used by the server +# # 'none' if no authentication is being used +# # 'vnc' if VNC authentication is being used +# # 'vencrypt+plain' if VEncrypt is used with plain text authentication +# # 'vencrypt+tls+none' if VEncrypt is used with TLS and no authentication +# # 'vencrypt+tls+vnc' if VEncrypt is used with TLS and VNC authentication +# # 'vencrypt+tls+plain' if VEncrypt is used with TLS and plain text auth +# # 'vencrypt+x509+none' if VEncrypt is used with x509 and no auth +# # 'vencrypt+x509+vnc' if VEncrypt is used with x509 and VNC auth +# # 'vencrypt+x509+plain' if VEncrypt is used with x509 and plain text auth +# # 'vencrypt+tls+sasl' if VEncrypt is used with TLS and SASL auth +# # 'vencrypt+x509+sasl' if VEncrypt is used with x509 and SASL auth # # @clients: a list of @VncClientInfo of all currently connected clients
qapi/block-core.json +26 -0
@@ -629,7 +629,9 @@ # @password: the password to use for the device # # Returns: nothing on success +# # If @device is not a valid block device, DeviceNotFound +# # If @device is not encrypted, DeviceNotEncrypted # # Notes: Not all block formats support encryption and some that do are not
@@ -655,6 +657,7 @@ # @size: new image size in bytes # # Returns: nothing on success +# # If @device is not a valid block device, DeviceNotFound # # Since: 0.14.0
@@ -792,6 +795,7 @@ # For the arguments, see the documentation of BlockdevSnapshot. # # Returns: nothing on success +# # If @device is not a valid block device, DeviceNotFound # # Since 0.14.0
@@ -858,6 +862,7 @@ # (Since 2.1) # # If top == base, that is an error. +# # If top == active, the job will not be completed by itself, # user needs to complete the job with the block-job-complete # command after getting the ready event. (Since 2.0)
@@ -872,10 +877,15 @@ # @speed: #optional the maximum speed, in bytes per second # # Returns: Nothing on success +# # If commit or stream is already active on this device, DeviceInUse +# # If @device does not exist, DeviceNotFound +# # If image commit is not supported by this device, NotSupported +# # If @base or @top is invalid, a generic error is returned +# # If @speed is invalid, InvalidParameter # # Since: 1.3
@@ -897,6 +907,7 @@ # For the arguments, see the documentation of DriveBackup. # # Returns: nothing on success +# # If @device is not a valid block device, DeviceNotFound # # Since 1.6
@@ -982,6 +993,7 @@ # Default is true. (Since 2.4) # # Returns: nothing on success +# # If @device is not a valid block device, DeviceNotFound # # Since 1.3
@@ -1028,7 +1040,9 @@ # Create a dirty bitmap with a name on the node # # Returns: nothing on success +# # If @node is not a valid block device or node, DeviceNotFound +# # If @name is already taken, GenericError with an explanation # # Since 2.4
@@ -1042,8 +1056,11 @@ # Remove a dirty bitmap on the node # # Returns: nothing on success +# # If @node is not a valid block device or node, DeviceNotFound +# # If @name is not found, GenericError with an explanation +# # if @name is frozen by an operation, GenericError # # Since 2.4
@@ -1057,7 +1074,9 @@ # Clear (reset) a dirty bitmap on the device # # Returns: nothing on success +# # If @node is not a valid block device, DeviceNotFound +# # If @name is not found, GenericError with an explanation # # Since 2.4
@@ -1122,6 +1141,7 @@ # @group: #optional throttle group name (Since 2.4) # # Returns: Nothing on success +# # If @device is not a valid block device, DeviceNotFound # # Since: 1.1
@@ -1179,6 +1199,7 @@ # supports io-status (see BlockInfo). Since 1.3. # # Returns: Nothing on success +# # If @device does not exist, DeviceNotFound # # Since: 1.1
@@ -1202,6 +1223,7 @@ # Defaults to 0. # # Returns: Nothing on success +# # If no background operation is active on this device, DeviceNotActive # # Since: 1.1
@@ -1233,6 +1255,7 @@ # false). Since 1.3. # # Returns: Nothing on success +# # If no background operation is active on this device, DeviceNotActive # # Since: 1.1
@@ -1256,6 +1279,7 @@ # @device: the device name # # Returns: Nothing on success +# # If no background operation is active on this device, DeviceNotActive # # Since: 1.3
@@ -1276,6 +1300,7 @@ # @device: the device name # # Returns: Nothing on success +# # If no background operation is active on this device, DeviceNotActive # # Since: 1.3
@@ -1302,6 +1327,7 @@ # @device: the device name # # Returns: Nothing on success +# # If no background operation is active on this device, DeviceNotActive # # Since: 1.3
Signature · 1 line
2.4.3
PATCH 4/36 monitor: use qapi for qmp_capabilities command
In reply to [email protected]From: Marc-André Lureau <[email protected]>
This was initially done to add qmp_capabilities documentation to the schema. Then I figured it would also help to get rid of the "middle mode" monitor dispatch code.
--- monitor.c | 4 ++-- qapi-schema.json | 17 +++++++++++++++++ qmp-commands.hx | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-)
monitor.c +2 -2
@@ -568,7 +568,7 @@ static void monitor_qapi_event_init(void)qmp_event_set_func_emit (monitor_qapi_event_queue); } -static void qmp_capabilities (QDict *params,QObject **ret_data,Error **errp) +void qmp_qmp_capabilities (Error **errp) { cur_mon->qmp.in_command_mode = true; }
@@ -3539,7 +3539,7 @@ static int monitor_can_read(void *opaque)static bool invalid_qmp_mode (const Monitor *mon,const mon_cmd_t *cmd,Error **errp) { -bool is_cap = cmd->mhandler.cmd_new == qmp_capabilities; +bool is_cap = cmd->mhandler.cmd_new == qmp_marshal_qmp_capabilities;if (is_cap && mon->qmp.in_command_mode) { error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND,
qapi-schema.json +17 -0
@@ -21,6 +21,23 @@ { 'include': 'qapi/introspect.json' } ## +# @qmp_capabilities: +# +# Enable QMP capabilities. +# +# Arguments: None. +# +# Example: +# +# -> { "execute": "qmp_capabilities" } +# <- { "return": {} } +# +# Notes: This command must be issued before issuing any other command. +# +## +{ 'command': 'qmp_capabilities' } + +## # @LostTickPolicy: # # Policy for handling lost ticks in timer devices.
qmp-commands.hx +1 -1
@@ -2018,7 +2018,7 @@ EQMP .args_type = "", .params = "", .help = "enable QMP capabilities", - .mhandler.cmd_new = qmp_capabilities, + .mhandler.cmd_new = qmp_marshal_qmp_capabilities, }, SQMP
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH 04/36] monitor: use qapi for qmp_capabilities command
Quoted 21 lines · On 09/25/2015 08:03 AM, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
This was initially done to add
qmp_capabilitiesdocumentation to the schema. Then I figured it would also help to get rid of the "middle mode" monitor dispatch code.Signed-off-by Marc-André Lureau <[email protected]>--- monitor.c | 4 ++-- qapi-schema.json | 17 +++++++++++++++++ qmp-commands.hx | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-)+++
b/qapi-schema.jsonqapi-schema.json +2
-0@@ -21,6 +21,23 @@ { 'include': 'qapi/introspect.json' } ## +# @qmp_capabilities: +#
qapi-schema.json line 35
Quoted 10 lines
qapi-schema.json +10
-0+# Enable QMP capabilities. +# +# Arguments: None. +# +# Example: +# +# -> { "execute": "qmp_capabilities" } +# <- { "return": {} } +# +# Notes: This command must be issued before issuing any other command.
I'd also mention that it is only accepted once; maybe this is better?
Notes: This command is valid exactly when first connecting: it must be issued before any other command will be accepted, and will fail once the monitor is accepting other commands.
Otherwise, I'm a fan of this patch.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 5/36 qapi: move examples to json schema
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Clean-up qmp-commands.hx from examples.
--- qapi-schema.json | 1128 +++++++++++++++- qapi/block-core.json | 365 +++++ qapi/block.json | 32 + qapi/common.json | 32 + qapi/rocker.json | 43 + qapi/trace.json | 12 + qmp-commands.hx | 3617 +------------------------------------------------- 7 files changed, 1625 insertions(+), 3604 deletions(-)
qapi-schema.json +1122 -6
@@ -80,6 +80,13 @@ # Returns: nothing on success. # # Since: 0.14.0 +# +# Example: +# +# -> { "execute": "add_client", "arguments": { "protocol": "vnc", +# "fdname": "myclient" } } +# <- { "return": {} } +# ## { 'command': 'add_client', 'data': { 'protocol': 'str', 'fdname': 'str', '*skipauth': 'bool',
@@ -104,6 +111,12 @@ # Returns: @NameInfo of the guest # # Since 0.14.0 +# +# Example: +# +# -> { "execute": "query-name" } +# <- { "return": { "name": "qemu-name" } } +# ## { 'command': 'query-name', 'returns': 'NameInfo' }
@@ -128,6 +141,12 @@ # Returns: @KvmInfo # # Since: 0.14.0 +# +# Example: +# +# -> { "execute": "query-kvm" } +# <- { "return": { "enabled": true, "present": true } } +# ## { 'command': 'query-kvm', 'returns': 'KvmInfo' }
@@ -204,6 +223,12 @@ # Returns: @StatusInfo reflecting all VCPUs # # Since: 0.14.0 +# +# Example: +# +# -> { "execute": "query-status" } +# <- { "return": { "running": true, "singlestep": false, "status": "running" } } +# ## { 'command': 'query-status', 'returns': 'StatusInfo' }
@@ -228,6 +253,12 @@ # Returns: The @UuidInfo for the guest # # Since 0.14.0 +# +# Example: +# +# -> { "execute": "query-uuid" } +# <- { "return": { "UUID": "550e8400-e29b-41d4-a716-446655440000" } } +# ## { 'command': 'query-uuid', 'returns': 'UuidInfo' }
@@ -261,6 +292,30 @@ # Returns: a list of @ChardevInfo # # Since: 0.14.0 +# +# Example: +# +# -> { "execute": "query-chardev" } +# <- { +# "return": [ +# { +# "label": "charchannel0", +# "filename": "unix:/var/lib/libvirt/qemu/seabios.rhel6.agent,server", +# "frontend-open": false +# }, +# { +# "label": "charmonitor", +# "filename": "unix:/var/lib/libvirt/qemu/seabios.rhel6.monitor,server", +# "frontend-open": true +# }, +# { +# "label": "charserial0", +# "filename": "pty:/dev/pts/2", +# "frontend-open": true +# } +# ] +# } +# ## { 'command': 'query-chardev', 'returns': ['ChardevInfo'] }
@@ -283,6 +338,27 @@ # Returns: a list of @ChardevBackendInfo # # Since: 2.0 +# +# Example: +# +# -> { "execute": "query-chardev-backends" } +# <- { +# "return":[ +# { +# "name":"udp" +# }, +# { +# "name":"tcp" +# }, +# { +# "name":"unix" +# }, +# { +# "name":"spiceport" +# } +# ] +# } +# ## { 'command': 'query-chardev-backends', 'returns': ['ChardevBackendInfo'] }
@@ -321,6 +397,15 @@ # Returns: Nothing on success # # Since: 1.4 +# +# Example: +# +# -> { "execute": "ringbuf-write", +# "arguments": { "device": "foo", +# "data": "abcdefgh", +# "format": "utf8" } } +# <- { "return": {} } +# ## { 'command': 'ringbuf-write', 'data': {'device': 'str', 'data': 'str',
@@ -348,6 +433,15 @@ # Returns: data read from the device # # Since: 1.4 +# +# Example: +# +# -> { "execute": "ringbuf-read", +# "arguments": { "device": "foo", +# "size": 1000, +# "format": "utf8" } } +# <- {"return": "abcdefgh"} +# ## { 'command': 'ringbuf-read', 'data': {'device': 'str', 'size': 'int', '*format': 'DataFormat'},
@@ -372,6 +466,23 @@ # Returns: A list of @EventInfo for all supported events # # Since: 1.2.0 +# +# Example: +# +# -> { "execute": "query-events" } +# <- { +# "return":[ +# { +# "name":"SHUTDOWN" +# }, +# { +# "name":"RESET" +# } +# ] +# } +# +# Notes: This example has been shortened as the real response is too long. +# ## { 'command': 'query-events', 'returns': ['EventInfo'] }
@@ -516,6 +627,116 @@ # Returns: @MigrationInfo # # Since: 0.14.0 +# +# Example: +# +# 1. Before the first migration +# +# -> { "execute": "query-migrate" } +# <- { "return": {} } +# +# 2. Migration is done and has succeeded +# +# -> { "execute": "query-migrate" } +# <- { "return": { +# "status": "completed", +# "ram":{ +# "transferred":123, +# "remaining":123, +# "total":246, +# "total-time":12345, +# "setup-time":12345, +# "downtime":12345, +# "duplicate":123, +# "normal":123, +# "normal-bytes":123456, +# "dirty-sync-count":15 +# } +# } +# } +# +# 3. Migration is done and has failed +# +# -> { "execute": "query-migrate" } +# <- { "return": { "status": "failed" } } +# +# 4. Migration is being performed and is not a block migration: +# +# -> { "execute": "query-migrate" } +# <- { +# "return":{ +# "status":"active", +# "ram":{ +# "transferred":123, +# "remaining":123, +# "total":246, +# "total-time":12345, +# "setup-time":12345, +# "expected-downtime":12345, +# "duplicate":123, +# "normal":123, +# "normal-bytes":123456, +# "dirty-sync-count":15 +# } +# } +# } +# +# 5. Migration is being performed and is a block migration: +# +# -> { "execute": "query-migrate" } +# <- { +# "return":{ +# "status":"active", +# "ram":{ +# "total":1057024, +# "remaining":1053304, +# "transferred":3720, +# "total-time":12345, +# "setup-time":12345, +# "expected-downtime":12345, +# "duplicate":123, +# "normal":123, +# "normal-bytes":123456, +# "dirty-sync-count":15 +# }, +# "disk":{ +# "total":20971520, +# "remaining":20880384, +# "transferred":91136 +# } +# } +# } +# +# 6. Migration is being performed and XBZRLE is active: +# +# -> { "execute": "query-migrate" } +# <- { +# "return":{ +# "status":"active", +# "capabilities" : [ { "capability": "xbzrle", "state" : true } ], +# "ram":{ +# "total":1057024, +# "remaining":1053304, +# "transferred":3720, +# "total-time":12345, +# "setup-time":12345, +# "expected-downtime":12345, +# "duplicate":10, +# "normal":3333, +# "normal-bytes":3412992, +# "dirty-sync-count":15 +# }, +# "xbzrle-cache":{ +# "cache-size":67108864, +# "bytes":20971520, +# "pages":2444343, +# "cache-miss":2244, +# "cache-miss-rate":0.123, +# "overflow":34434 +# } +# } +# } +# ## { 'command': 'query-migrate', 'returns': 'MigrationInfo' }
@@ -579,7 +800,19 @@ # # @capabilities: json array of capability modifications to make # +# - "xbzrle": XBZRLE support +# - "rdma-pin-all": pin all pages when using RDMA during migration +# - "auto-converge": throttle down guest to help convergence of migration +# - "zero-blocks": compress zero blocks during block migration +# - "events": generate events for each migration state change +# # Since: 1.2 +# +# Example: +# +# -> { "execute": "migrate-set-capabilities" , "arguments": +# { "capabilities": [ { "capability": "xbzrle", "state": true } ] } } +# ## { 'command': 'migrate-set-capabilities', 'data': { 'capabilities': ['MigrationCapabilityStatus'] } }
@@ -592,6 +825,12 @@ # Returns: @MigrationCapabilitiesStatus # # Since: 1.2 +# +# Example: +# +# -> { "execute": "query-migrate-capabilities" } +# <- { "return": [ { "state": false, "capability": "xbzrle" } ] } +# ## { 'command': 'query-migrate-capabilities', 'returns': ['MigrationCapabilityStatus']}
@@ -630,6 +869,12 @@ # @decompress-threads: decompression thread count # # Since: 2.4 +# +# Example: +# +# -> { "execute": "migrate-set-parameters" , "arguments": +# { "compress-level": 1 } } +# ## { 'command': 'migrate-set-parameters', 'data': { '*compress-level': 'int',
@@ -659,6 +904,18 @@ # Returns: @MigrationParameters # # Since: 2.4 +# +# Example: +# +# -> { "execute": "query-migrate-parameters" } +# <- { +# "return": { +# "decompress-threads", 2, +# "compress-threads", 8, +# "compress-level", 1 +# } +# } +# ## { 'command': 'query-migrate-parameters', 'returns': 'MigrationParameters' }
@@ -677,6 +934,15 @@ # @cert-subject: #optional server certificate subject # # Since: 0.14.0 +# +# Example: +# +# -> { "execute": "client_migrate_info", +# "arguments": { "protocol": "spice", +# "hostname": "virt42.lab.kraxel.org", +# "port": 1234 } } +# <- { "return": {} } +# ## { 'command': 'client_migrate_info', 'data': { 'protocol': 'str', 'hostname': 'str', '*port': 'int',
@@ -709,6 +975,27 @@ # Returns: a list of @MouseInfo for each device # # Since: 0.14.0 +# +# Example: +# +# -> { "execute": "query-mice" } +# <- { +# "return":[ +# { +# "name":"QEMU Microsoft Mouse", +# "index":0, +# "current":false, +# "absolute":false +# }, +# { +# "name":"QEMU PS/2 Mouse", +# "index":1, +# "current":true, +# "absolute":true +# } +# ] +# } +# ## { 'command': 'query-mice', 'returns': ['MouseInfo'] }
@@ -759,6 +1046,31 @@ # Returns: a list of @CpuInfo for each virtual CPU # # Since: 0.14.0 +# +# Example: +# +# -> { "execute": "query-cpus" } +# <- { +# "return":[ +# { +# "CPU":0, +# "current":true, +# "halted":false, +# "qom_path":"/machine/unattached/device[0]", +# "pc":3227107138, +# "thread_id":3134 +# }, +# { +# "CPU":1, +# "current":false, +# "halted":true, +# "qom_path":"/machine/unattached/device[2]", +# "pc":7108165, +# "thread_id":3135 +# } +# ] +# } +# ## { 'command': 'query-cpus', 'returns': ['CpuInfo'] }
@@ -788,6 +1100,23 @@ # Returns: a list of @IOThreadInfo for each iothread # # Since: 2.0 +# +# Example: +# +# -> { "execute": "query-iothreads" } +# <- { +# "return":[ +# { +# "id":"iothread0", +# "thread-id":3134 +# }, +# { +# "id":"iothread1", +# "thread-id":3135 +# } +# ] +# } +# ## { 'command': 'query-iothreads', 'returns': ['IOThreadInfo'] }
@@ -982,6 +1311,27 @@ # Returns: @VncInfo # # Since: 0.14.0 +# +# Example: +# +# -> { "execute": "query-vnc" } +# <- { +# "return":{ +# "enabled":true, +# "host":"0.0.0.0", +# "service":"50402", +# "auth":"vnc", +# "family":"ipv4", +# "clients":[ +# { +# "host":"127.0.0.1", +# "service":"50401", +# "family":"ipv4" +# } +# ] +# } +# } +# ## { 'command': 'query-vnc', 'returns': 'VncInfo' }
@@ -1118,6 +1468,41 @@ # Returns: @SpiceInfo # # Since: 0.14.0 +# +# Example: +# +# -> { "execute": "query-spice" } +# <- { +# "return": { +# "enabled": true, +# "auth": "spice", +# "port": 5920, +# "tls-port": 5921, +# "host": "0.0.0.0", +# "channels": [ +# { +# "port": "54924", +# "family": "ipv4", +# "channel-type": 1, +# "connection-id": 1804289383, +# "host": "127.0.0.1", +# "channel-id": 0, +# "tls": true +# }, +# { +# "port": "36710", +# "family": "ipv4", +# "channel-type": 4, +# "connection-id": 1804289383, +# "host": "127.0.0.1", +# "channel-id": 0, +# "tls": false +# }, +# [ ... more channels follow ... ] +# ] +# } +# } +# ## { 'command': 'query-spice', 'returns': 'SpiceInfo' }
@@ -1144,6 +1529,16 @@ # If no balloon device is present, DeviceNotActive # # Since: 0.14.0 +# +# Example: +# +# -> { "execute": "query-balloon" } +# <- { +# "return":{ +# "actual":1073741824, +# } +# } +# ## { 'command': 'query-balloon', 'returns': 'BalloonInfo' }
@@ -1306,6 +1701,141 @@ # Returns: a list of @PciInfo for each PCI bus # # Since: 0.14.0 +# +# Example: +# +# -> { "execute": "query-pci" } +# <- { +# "return":[ +# { +# "bus":0, +# "devices":[ +# { +# "bus":0, +# "qdev_id":"", +# "slot":0, +# "class_info":{ +# "class":1536, +# "desc":"Host bridge" +# }, +# "id":{ +# "device":32902, +# "vendor":4663 +# }, +# "function":0, +# "regions":[ +# +# ] +# }, +# { +# "bus":0, +# "qdev_id":"", +# "slot":1, +# "class_info":{ +# "class":1537, +# "desc":"ISA bridge" +# }, +# "id":{ +# "device":32902, +# "vendor":28672 +# }, +# "function":0, +# "regions":[ +# +# ] +# }, +# { +# "bus":0, +# "qdev_id":"", +# "slot":1, +# "class_info":{ +# "class":257, +# "desc":"IDE controller" +# }, +# "id":{ +# "device":32902, +# "vendor":28688 +# }, +# "function":1, +# "regions":[ +# { +# "bar":4, +# "size":16, +# "address":49152, +# "type":"io" +# } +# ] +# }, +# { +# "bus":0, +# "qdev_id":"", +# "slot":2, +# "class_info":{ +# "class":768, +# "desc":"VGA controller" +# }, +# "id":{ +# "device":4115, +# "vendor":184 +# }, +# "function":0, +# "regions":[ +# { +# "prefetch":true, +# "mem_type_64":false, +# "bar":0, +# "size":33554432, +# "address":4026531840, +# "type":"memory" +# }, +# { +# "prefetch":false, +# "mem_type_64":false, +# "bar":1, +# "size":4096, +# "address":4060086272, +# "type":"memory" +# }, +# { +# "prefetch":false, +# "mem_type_64":false, +# "bar":6, +# "size":65536, +# "address":-1, +# "type":"memory" +# } +# ] +# }, +# { +# "bus":0, +# "qdev_id":"", +# "irq":11, +# "slot":4, +# "class_info":{ +# "class":1280, +# "desc":"RAM controller" +# }, +# "id":{ +# "device":6900, +# "vendor":4098 +# }, +# "function":0, +# "regions":[ +# { +# "bar":0, +# "size":32, +# "address":49280, +# "type":"io" +# } +# ] +# } +# ] +# } +# ] +# } +# +# Note: This example has been shortened as the real response is too long. +# ## { 'command': 'query-pci', 'returns': ['PciInfo'] }
@@ -1318,6 +1848,11 @@ # unexpected. # # Since: 0.14.0 +# +# Example: +# +# -> { "execute": "quit" } +# <- { "return": {} } ## { 'command': 'quit' }
@@ -1332,6 +1867,12 @@ # state. In "inmigrate" state, it will ensure that the guest # remains paused once migration finishes, as if the -S option was # passed on the command line. +# +# Example: +# +# -> { "execute": "stop" } +# <- { "return": {} } +# ## { 'command': 'stop' }
@@ -1341,6 +1882,12 @@ # Performs a hard reset of a guest. # # Since: 0.14.0 +# +# Example: +# +# -> { "execute": "system_reset" } +# <- { "return": {} } +# ## { 'command': 'system_reset' }
@@ -1355,6 +1902,11 @@ # returning does not indicate that a guest has accepted the request or # that it has shut down. Many guests will respond to this command by # prompting the user in some way. +# Example: +# +# -> { "execute": "system_powerdown" } +# <- { "return": {} } +# ## { 'command': 'system_powerdown' }
@@ -1379,6 +1931,11 @@ # Returns: Nothing on success # # Since 1.5 +# +# Example: +# +# -> { "execute": "cpu-add", "arguments": { "id": 2 } } +# <- { "return": {} } ## { 'command': 'cpu-add', 'data': {'id': 'int'} }
@@ -1401,6 +1958,15 @@ # Since: 0.14.0 # # Notes: Errors were not reliably returned until 1.1 +# +# Example: +# +# -> { "execute": "memsave", +# "arguments": { "val": 10, +# "size": 100, +# "filename": "/tmp/virtual-mem-dump" } } +# <- { "return": {} } +# ## { 'command': 'memsave', 'data': {'val': 'int', 'size': 'int', 'filename': 'str', '*cpu-index': 'int'} }
@@ -1421,6 +1987,15 @@ # Since: 0.14.0 # # Notes: Errors were not reliably returned until 1.1 +# +# Example: +# +# -> { "execute": "pmemsave", +# "arguments": { "val": 10, +# "size": 100, +# "filename": "/tmp/physical-mem-dump" } } +# <- { "return": {} } +# ## { 'command': 'pmemsave', 'data': {'val': 'int', 'size': 'int', 'filename': 'str'} }
@@ -1441,6 +2016,12 @@ # this case, the effect of the command is to make sure the guest # starts once migration finishes, removing the effect of the -S # command line option if it was passed. +# +# Example: +# +# -> { "execute": "cont" } +# <- { "return": {} } +# ## { 'command': 'cont' }
@@ -1452,6 +2033,12 @@ # Since: 1.1 # # Returns: nothing. +# +# Example: +# +# -> { "execute": "system_wakeup" } +# <- { "return": {} } +# ## { 'command': 'system_wakeup' }
@@ -1465,6 +2052,12 @@ # Since: 0.14.0 # # Note: prior to 2.1, this command was only supported for x86 and s390 VMs +# +# Example: +# +# -> { "execute": "inject-nmi" } +# <- { "return": {} } +# ## { 'command': 'inject-nmi' }
@@ -1485,6 +2078,12 @@ # Notes: Not all network adapters support setting link status. This command # will succeed even if the network adapter does not support link status # notification. +# +# Example: +# +# -> { "execute": "set_link", "arguments": { "name": "e1000.0", "up": false } } +# <- { "return": {} } +# ## { 'command': 'set_link', 'data': {'name': 'str', 'up': 'bool'} }
@@ -1505,6 +2104,12 @@ # size independent of this command. # # Since: 0.14.0 +# +# Example: +# +# -> { "execute": "balloon", "arguments": { "value": 536870912 } } +# <- { "return": {} } +# ## { 'command': 'balloon', 'data': {'value': 'int'} }
@@ -1543,14 +2148,43 @@ ## # @transaction # +# @actions: List of @TransactionAction: information needed for the respective +# operation +# # Executes a number of transactionable QMP commands atomically. If any # operation fails, then the entire set of actions will be abandoned and the # appropriate error returned. # -# List of: -# @TransactionAction: information needed for the respective operation +# Atomically operate on one or more block devices. The only supported operations +# for now are drive-backup, internal and external snapshotting. A list of +# dictionaries is accepted, that contains the actions to be performed. +# If there is any failure performing any of the operations, all operations +# for the group are abandoned. +# +# For external snapshots, the dictionary contains the device, the file to use for +# the new snapshot, and the format. The default format, if not specified, is +# qcow2. +# +# Each new snapshot defaults to being created by QEMU (wiping any +# contents if the file already exists), but it is also possible to reuse +# an externally-created file. In the latter case, you should ensure that +# the new image file has the same contents as the current one; QEMU cannot +# perform any meaningful check. Typically this is achieved by using the +# current image file as the backing file for the new image. +# +# On failure, the original disks pre-snapshot attempt will be used. +# +# For internal snapshots, the dictionary contains the device and the snapshot's +# name. If an internal snapshot matching name already exists, the request will +# be rejected. Only some image formats support it, for example, qcow2, rbd, +# and sheepdog. +# +# On failure, qemu will try delete the newly created internal snapshot in the +# transaction. When an I/O error occurs during deletion, the user needs to fix +# it later with qemu-img or other command. # # Returns: nothing on success +# # Errors depend on the operations of the transaction # # Note: The transaction aborts on the first failure. Therefore, there will be
@@ -1558,6 +2192,28 @@ # subsequent actions will not have been attempted. # # Since 1.1 +# +# Example: +# +# -> { "execute": "transaction", +# "arguments": { "actions": [ +# { "type": "blockdev-snapshot-sync", "data" : { "device": "ide-hd0", +# "snapshot-file": "/some/place/my-image", +# "format": "qcow2" } }, +# { "type": "blockdev-snapshot-sync", "data" : { "node-name": "myfile", +# "snapshot-file": "/some/place/my-image2", +# "snapshot-node-name": "node3432", +# "mode": "existing", +# "format": "qcow2" } }, +# { "type": "blockdev-snapshot-sync", "data" : { "device": "ide-hd1", +# "snapshot-file": "/some/place/my-image2", +# "mode": "existing", +# "format": "qcow2" } }, +# { "type": "blockdev-snapshot-internal-sync", "data" : { +# "device": "ide-hd2", +# "name": "snapshot0" } } ] } } +# <- { "return": {} } +# ## { 'command': 'transaction', 'data': { 'actions': [ 'TransactionAction' ] } }
@@ -1585,6 +2241,12 @@ # # o Commands that prompt the user for data (eg. 'cont' when the block # device is encrypted) don't currently work +# +# Example: +# +# -> { "execute": "human-monitor-command", "arguments": { "command-line": "info kvm" } } +# <- { "return": "kvm support: enabled\r\n" } +# ## { 'command': 'human-monitor-command', 'data': {'command-line': 'str', '*cpu-index': 'int'},
@@ -1600,6 +2262,12 @@ # Notes: This command succeeds even if there is no migration process running. # # Since: 0.14.0 +# +# Example: +# +# -> { "execute": "migrate_cancel" } +# <- { "return": {} } +# ## { 'command': 'migrate_cancel' }
@@ -1613,6 +2281,12 @@ # Returns: nothing on success # # Since: 0.14.0 +# +# Example: +# +# -> { "execute": "migrate_set_downtime", "arguments": { "value": 0.1 } } +# <- { "return": {} } +# ## { 'command': 'migrate_set_downtime', 'data': {'value': 'number'} }
@@ -1628,6 +2302,12 @@ # Notes: A value lesser than zero will be automatically round up to zero. # # Since: 0.14.0 +# +# Example: +# +# -> { "execute": "migrate_set_speed", "arguments": { "value": 1024 } } +# <- { "return": {} } +# ## { 'command': 'migrate_set_speed', 'data': {'value': 'int'} }
@@ -1644,6 +2324,12 @@ # Returns: nothing on success # # Since: 1.2 +# +# Example: +# +# -> { "execute": "migrate-set-cache-size", "arguments": { "value": 536870912 } } +# <- { "return": {} } +# ## { 'command': 'migrate-set-cache-size', 'data': {'value': 'int'} }
@@ -1655,6 +2341,12 @@ # Returns: XBZRLE cache size in bytes # # Since: 1.2 +# +# Example: +# +# -> { "execute": "query-migrate-cache-size" } +# <- { "return": 67108864 } +# ## { 'command': 'query-migrate-cache-size', 'returns': 'int' }
@@ -1771,6 +2463,13 @@ # If Spice is not enabled, DeviceNotFound # # Since: 0.14.0 +# +# Example: +# +# -> { "execute": "set_password", "arguments": { "protocol": "vnc", +# "password": "secret" } } +# <- { "return": {} } +# ## { 'command': 'set_password', 'data': {'protocol': 'str', 'password': 'str', '*connected': 'str'} }
@@ -1797,6 +2496,13 @@ # coordinate server time with client time. It is not recommended to # use the absolute time version of the @time parameter unless you're # sure you are on the same machine as the QEMU instance. +# +# Example: +# +# -> { "execute": "expire_password", "arguments": { "protocol": "vnc", +# "time": "+60" } } +# <- { "return": {} } +# ## { 'command': 'expire_password', 'data': {'protocol': 'str', 'time': 'str'} }
@@ -1845,6 +2551,23 @@ # for changing block devices. # # Since: 0.14.0 +# +# Example: +# +# 1. Change a removable medium +# +# -> { "execute": "change", +# "arguments": { "device": "ide1-cd0", +# "target": "/srv/images/Fedora-12-x86_64-DVD.iso" } } +# <- { "return": {} } +# +# 2. Change VNC password +# +# -> { "execute": "change", +# "arguments": { "device": "vnc", "target": "password", +# "arg": "foobar1" } } +# <- { "return": {} } +# ## { 'command': 'change', 'data': {'device': 'str', 'target': 'str', '*arg': 'str'} }
@@ -1927,6 +2650,22 @@ # Returns: nothing on success # # Since: 0.14.0 +# +# Notes: +# +# 1. The 'query-migrate' command should be used to check migration's progress +# and final result (this information is provided by the 'status' member) +# +# 2. All boolean arguments default to false +# +# 3. The user Monitor's "detach" argument is invalid in QMP and should not +# be used +# +# Example: +# +# -> { "execute": "migrate", "arguments": { "uri": "tcp:0:4446" } } +# <- { "return": {} } +# ## { 'command': 'migrate', 'data': {'uri': 'str', '*blk': 'bool', '*inc': 'bool', '*detach': 'bool' } }
@@ -1943,9 +2682,23 @@ # Returns: nothing on success # # Since: 2.3 -# Note: It's a bad idea to use a string for the uri, but it needs to stay -# compatible with -incoming and the format of the uri is already exposed -# above libvirt +# +# Note: +# +# 1. It's a bad idea to use a string for the uri, but it needs to stay +# compatible with -incoming and the format of the uri is already exposed +# above libvirt. +# +# 2. QEMU must be started with -incoming defer to allow migrate-incoming to +# be used. +# +# 3. The uri format is the same as for -incoming +# +# Example: +# +# -> { "execute": "migrate-incoming", "arguments": { "uri": "tcp::4446" } } +# <- { "return": {} } +# ## { 'command': 'migrate-incoming', 'data': {'uri': 'str' } }
@@ -1961,6 +2714,13 @@ # Returns: Nothing on success # # Since: 1.1 +# +# Example: +# +# -> { "execute": "xen-save-devices-state", +# "arguments": { "filename": "/tmp/save" } } +# <- { "return": {} } +# ## { 'command': 'xen-save-devices-state', 'data': {'filename': 'str'} }
@@ -1974,15 +2734,48 @@ # Returns: nothing # # Since: 1.3 +# +# Example: +# +# -> { "execute": "xen-set-global-dirty-log", +# "arguments": { "enable": true } } +# <- { "return": {} } +# ## { 'command': 'xen-set-global-dirty-log', 'data': { 'enable': 'bool' } } ## +# @device_add: +# +# @driver: the name of the new device's driver +# @bus: #optional the device's parent bus (device tree path) +# @id: the device's ID, must be unique +# @props: #optional a dictionary of properties to be passed to the backend +# +# Add a device. +# +# Notes: +# 1. For detailed information about this command, please refer to the +# 'docs/qdev-device-use.txt' file. +# +# 2. It's possible to list device properties by running QEMU with the +# "-device DEVICE,\?" command-line argument, where DEVICE is the device's name +# +# Example: +# +# -> { "execute": "device_add", "arguments": { "driver": "e1000", "id": "net1" } } +# <- { "return": {} } +# +## +{ 'command': 'device_add', + 'data': {'driver': 'str', 'id': 'str'}, 'gen': false } + +## # @device_del: # # Remove a device from a guest # -# @id: the name or QOM path of the device +# @id: the device's ID or QOM path # # Returns: Nothing on success # If @id is not a valid device, DeviceNotFound
@@ -1995,6 +2788,15 @@ # for all devices. # # Since: 0.14.0 +# +# Example: +# +# -> { "execute": "device_del", "arguments": { "id": "net1" } } +# <- { "return": {} } +# +# -> { "execute": "device_del", "arguments": { "id": "/machine/peripheral-anon/device[0]" } } +# <- { "return": {} } +# ## { 'command': 'device_del', 'data': {'id': 'str'} }
@@ -2060,6 +2862,12 @@ # Returns: nothing on success # # Since: 1.2 +# +# Example: +# +# -> { "execute": "dump-guest-memory", "arguments": { "protocol": "fd:dump" } } +# <- { "return": {} } +# ## { 'command': 'dump-guest-memory', 'data': { 'paging': 'bool', 'protocol': 'str', '*begin': 'int',
@@ -2085,6 +2893,13 @@ # dump-guest-memory # # Since: 2.0 +# +# Example: +# +# -> { "execute": "query-dump-guest-memory-capability" } +# <- { "return": { "formats": +# ["elf", "kdump-zlib", "kdump-lzo", "kdump-snappy"] } +# ## { 'command': 'query-dump-guest-memory-capability', 'returns': 'DumpGuestMemoryCapability' }
@@ -2099,6 +2914,11 @@ # This command is only supported on s390 architecture. # # Since: 2.5 +# Example: +# +# -> { "execute": "dump-skeys", "arguments": { "filename": "/tmp/skeys" } } +# <- { "return": {} } +# ## { 'command': 'dump-skeys', 'data': { 'filename': 'str' } }
@@ -2117,6 +2937,14 @@ # # Returns: Nothing on success # If @type is not a valid network backend, DeviceNotFound +# +# Example: +# +# -> { "execute": "netdev_add", +# "arguments": { "type": "user", "id": "netdev1", +# "dnssearch": "example.org" } } +# <- { "return": {} } +# ## { 'command': 'netdev_add', 'data': 'Netdev', 'box': true }
@@ -2131,6 +2959,12 @@ # If @id is not a valid network backend, DeviceNotFound # # Since: 0.14.0 +# +# Example: +# +# -> { "execute": "netdev_del", "arguments": { "id": "netdev1" } } +# <- { "return": {} } +# ## { 'command': 'netdev_del', 'data': {'id': 'str'} }
@@ -2149,6 +2983,13 @@ # Error if @qom-type is not a valid class name # # Since: 2.0 +# +# Example: +# +# -> { "execute": "object-add", "arguments": { "qom-type": "rng-random", "id": "rng1", +# "props": { "filename": "/dev/hwrng" } } } +# <- { "return": {} } +# ## { 'command': 'object-add', 'data': {'qom-type': 'str', 'id': 'str', '*props': 'any'} }
@@ -2164,6 +3005,12 @@ # Error if @id is not a valid id for a QOM object # # Since: 2.0 +# +# Example: +# +# -> { "execute": "object-del", "arguments": { "id": "rng1" } } +# <- { "return": {} } +# ## { 'command': 'object-del', 'data': {'id': 'str'} }
@@ -2661,8 +3508,15 @@ # Notes: If @fdname already exists, the file descriptor assigned to # it will be closed and replaced by the received file # descriptor. +# # The 'closefd' command can be used to explicitly close the # file descriptor when it is no longer needed. +# +# Example: +# +# -> { "execute": "getfd", "arguments": { "fdname": "fd1" } } +# <- { "return": {} } +# ## { 'command': 'getfd', 'data': {'fdname': 'str'} }
@@ -2694,6 +3548,12 @@ # (since 1.5.0) # # Since: 1.2.0 +# +# Example: +# +# -> { "execute": "closefd", "arguments": { "fdname": "fd1" } } +# <- { "return": {} } +# ## { 'struct': 'MachineInfo', 'data': { 'name': 'str', '*alias': 'str',
@@ -2764,6 +3624,12 @@ # If @fdset-id is not specified, a new fd set will be created. # # Since: 1.2.0 +# +# Example: +# +# -> { "execute": "add-fd", "arguments": { "fdset-id": 1 } } +# <- { "return": { "fdset-id": 1, "fd": 3 } } +# ## { 'command': 'add-fd', 'data': {'*fdset-id': 'int', '*opaque': 'str'}, 'returns': 'AddfdInfo' }
@@ -2786,6 +3652,12 @@ # # If @fd is not specified, all file descriptors in @fdset-id # will be removed. +# +# Example: +# +# -> { "execute": "remove-fd", "arguments": { "fdset-id": 1, "fd": 3 } } +# <- { "return": {} } +# ## { 'command': 'remove-fd', 'data': {'fdset-id': 'int', '*fd': 'int'} }
@@ -2828,6 +3700,37 @@ # # Note: The list of fd sets is shared by all monitor connections. # +# Example: +# +# -> { "execute": "query-fdsets" } +# <- { "return": [ +# { +# "fds": [ +# { +# "fd": 30, +# "opaque": "rdonly:/path/to/file" +# }, +# { +# "fd": 24, +# "opaque": "rdwr:/path/to/file" +# } +# ], +# "fdset-id": 1 +# }, +# { +# "fds": [ +# { +# "fd": 28 +# }, +# { +# "fd": 29 +# } +# ], +# "fdset-id": 0 +# } +# ] +# } +# ## { 'command': 'query-fdsets', 'returns': ['FdsetInfo'] }
@@ -2915,6 +3818,14 @@ # # Since: 1.3.0 # +# Example: +# +# -> { "execute": "send-key", +# "arguments": { "keys": [ { "type": "qcode", "data": "ctrl" }, +# { "type": "qcode", "data": "alt" }, +# { "type": "qcode", "data": "delete" } ] } } +# <- { "return": {} } +# ## { 'command': 'send-key', 'data': { 'keys': ['KeyValue'], '*hold-time': 'int' } }
@@ -2929,6 +3840,12 @@ # Returns: Nothing on success # # Since: 0.14.0 +# +# Example: +# +# -> { "execute": "screendump", "arguments": { "filename": "/tmp/image" } } +# <- { "return": {} } +# ## { 'command': 'screendump', 'data': {'filename': 'str'} }
@@ -3129,6 +4046,25 @@ # Returns: ChardevReturn. # # Since: 1.4 +# +# Example: +# +# -> { "execute" : "chardev-add", +# "arguments" : { "id" : "foo", +# "backend" : { "type" : "null", "data" : {} } } } +# <- { "return": {} } +# +# -> { "execute" : "chardev-add", +# "arguments" : { "id" : "bar", +# "backend" : { "type" : "file", +# "data" : { "out" : "/tmp/bar.log" } } } } +# <- { "return": {} } +# +# -> { "execute" : "chardev-add", +# "arguments" : { "id" : "baz", +# "backend" : { "type" : "pty", "data" : {} } } } +# <- { "return": { "pty" : "/dev/pty/42" } } +# ## { 'command': 'chardev-add', 'data': {'id' : 'str', 'backend' : 'ChardevBackend' },
@@ -3144,6 +4080,12 @@ # Returns: Nothing on success # # Since: 1.4 +# +# Example: +# +# -> { "execute": "chardev-remove", "arguments": { "id" : "foo" } } +# <- { "return": {} } +# ## { 'command': 'chardev-remove', 'data': {'id': 'str'} }
@@ -3166,6 +4108,12 @@ # Returns: a list of TpmModel # # Since: 1.5 +# +# Example: +# +# -> { "execute": "query-tpm-models" } +# <- { "return": [ "tpm-tis" ] } +# ## { 'command': 'query-tpm-models', 'returns': ['TpmModel'] }
@@ -3188,6 +4136,12 @@ # Returns: a list of TpmType # # Since: 1.5 +# +# Example: +# +# -> { "execute": "query-tpm-types" } +# <- { "return": [ "passthrough" ] } +# ## { 'command': 'query-tpm-types', 'returns': ['TpmType'] }
@@ -3244,6 +4198,25 @@ # Returns: @TPMInfo on success # # Since: 1.5 +# +# Example: +# +# -> { "execute": "query-tpm" } +# <- { "return": +# [ +# { "model": "tpm-tis", +# "options": +# { "type": "passthrough", +# "data": +# { "cancel-path": "/sys/class/misc/tpm0/device/cancel", +# "path": "/dev/tpm0" +# } +# }, +# "id": "tpm0" +# } +# ] +# } +# ## { 'command': 'query-tpm', 'returns': ['TPMInfo'] }
@@ -3370,6 +4343,27 @@ # @option). Returns an error if the given @option doesn't exist. # # Since 1.5 +# +# Example: +# +# -> { "execute": "query-command-line-options", "arguments": { "option": "option-rom" } } +# <- { "return": [ +# { +# "parameters": [ +# { +# "name": "romfile", +# "type": "string" +# }, +# { +# "name": "bootindex", +# "type": "number" +# } +# ], +# "option": "option-rom" +# } +# ] +# } +# ## {'command': 'query-command-line-options', 'data': { '*option': 'str' }, 'returns': ['CommandLineOptionInfo'] }
@@ -3481,6 +4475,36 @@ # isn't a NIC. # # Since: 1.6 +# +# Example: +# +# -> { "execute": "query-rx-filter", "arguments": { "name": "vnet0" } } +# <- { "return": [ +# { +# "promiscuous": true, +# "name": "vnet0", +# "main-mac": "52:54:00:12:34:56", +# "unicast": "normal", +# "vlan": "normal", +# "vlan-table": [ +# 4, +# 0 +# ], +# "unicast-table": [ +# ], +# "multicast": "normal", +# "multicast-overflow": false, +# "unicast-overflow": false, +# "multicast-table": [ +# "01:00:5e:00:00:01", +# "33:33:00:00:00:01", +# "33:33:ff:12:34:56" +# ], +# "broadcast-allowed": false +# } +# ] +# } +# ## { 'command': 'query-rx-filter', 'data': { '*name': 'str' }, 'returns': ['RxFilterInfo'] }
@@ -3593,6 +4617,42 @@ # # Note: this command is experimental, and not a stable API. # +# Example: +# +# Press left mouse button. +# +# -> { "execute": "x-input-send-event", +# "arguments": { "console": 0, +# "events": [ { "type": "btn", +# "data" : { "down": true, "button": "Left" } } ] } } +# <- { "return": {} } +# +# -> { "execute": "x-input-send-event", +# "arguments": { "console": 0, +# "events": [ { "type": "btn", +# "data" : { "down": false, "button": "Left" } } ] } } +# <- { "return": {} } +# +# 2. Press ctrl-alt-del. +# +# -> { "execute": "x-input-send-event", +# "arguments": { "console": 0, "events": [ +# { "type": "key", "data" : { "down": true, +# "key": {"type": "qcode", "data": "ctrl" } } }, +# { "type": "key", "data" : { "down": true, +# "key": {"type": "qcode", "data": "alt" } } }, +# { "type": "key", "data" : { "down": true, +# "key": {"type": "qcode", "data": "delete" } } } ] } } +# <- { "return": {} } +# +# 3. Move mouse pointer to absolute coordinates (20000, 400). +# +# -> { "execute": "x-input-send-event" , +# "arguments": { "console": 0, "events": [ +# { "type": "abs", "data" : { "axis": "X", "value" : 20000 } }, +# { "type": "abs", "data" : { "axis": "Y", "value" : 400 } } ] } } +# <- { "return": {} } +# ## { 'command': 'x-input-send-event', 'data': { '*console':'int', 'events': [ 'InputEvent' ] } }
@@ -3691,6 +4751,30 @@ # Returns: a list of @Memdev. # # Since: 2.1 +# +# Example: +# +# -> { "execute": "query-memdev" } +# <- { "return": [ +# { +# "size": 536870912, +# "merge": false, +# "dump": true, +# "prealloc": false, +# "host-nodes": [0, 1], +# "policy": "bind" +# }, +# { +# "size": 536870912, +# "merge": false, +# "dump": true, +# "prealloc": true, +# "host-nodes": [2, 3], +# "policy": "preferred" +# } +# ] +# } +# ## { 'command': 'query-memdev', 'returns': ['Memdev'] }
@@ -3744,6 +4828,22 @@ # Lists available memory devices and their state # # Since: 2.1 +# +# Example: +# +# -> { "execute": "query-memory-devices" } +# <- { "return": [ { "data": +# { "addr": 5368709120, +# "hotpluggable": true, +# "hotplugged": true, +# "id": "d1", +# "memdev": "/objects/memX", +# "node": 0, +# "size": 1073741824, +# "slot": 0}, +# "type": "dimm" +# } ] } +# ## { 'command': 'query-memory-devices', 'returns': ['MemoryDeviceInfo'] }
@@ -3785,6 +4885,16 @@ # which might be reported via _OST method # # Since: 2.1 +# +# Example: +# +# -> { "execute": "query-acpi-ospm-status" } +# <- { "return": [ { "device": "d1", "slot": "0", "slot-type": "DIMM", "source": 1, "status": 0}, +# { "slot": "1", "slot-type": "DIMM", "source": 0, "status": 0}, +# { "slot": "2", "slot-type": "DIMM", "source": 0, "status": 0}, +# { "slot": "3", "slot-type": "DIMM", "source": 0, "status": 0} +# ]} +# ## { 'command': 'query-acpi-ospm-status', 'returns': ['ACPIOSTInfo'] }
@@ -3851,6 +4961,12 @@ # command. # # Since: 2.1 +# +# Example: +# +# -> { "execute": "rtc-reset-reinjection" } +# <- { "return": {} } +# ## { 'command': 'rtc-reset-reinjection' }
qapi/block-core.json +365 -0
473 lines not on this page · raw message
qapi/block.json +32 -0
@@ -71,6 +71,15 @@ # BlockFormatFeatureNotSupported # # Since 1.7 +# +# Example: +# +# -> { "execute": "blockdev-snapshot-internal-sync", +# "arguments": { "device": "ide-hd0", +# "name": "snapshot0" } +# } +# <- { "return": {} } +# ## { 'command': 'blockdev-snapshot-internal-sync', 'data': 'BlockdevSnapshotInternal' }
@@ -97,6 +106,24 @@ # If @id and @name are both not specified, GenericError # # Since 1.7 +# +# Example: +# +# -> { "execute": "blockdev-snapshot-delete-internal-sync", +# "arguments": { "device": "ide-hd0", +# "name": "snapshot0" } +# } +# <- { "return": { +# "id": "1", +# "name": "snapshot0", +# "vm-state-size": 0, +# "date-sec": 1000012, +# "date-nsec": 10, +# "vm-clock-sec": 100, +# "vm-clock-nsec": 20 +# } +# } +# ## { 'command': 'blockdev-snapshot-delete-internal-sync', 'data': { 'device': 'str', '*id': 'str', '*name': 'str'},
@@ -118,6 +145,11 @@ # Notes: Ejecting a device will no media results in success # # Since: 0.14.0 +# +# Example: +# +# -> { "execute": "eject", "arguments": { "device": "ide1-cd0" } } +# <- { "return": {} } ## { 'command': 'eject', 'data': {'device': 'str', '*force': 'bool'} }
qapi/common.json +32 -0
@@ -74,6 +74,21 @@ # Returns: A @VersionInfo object describing the current version of QEMU. # # Since: 0.14.0 +# +# Example: +# +# -> { "execute": "query-version" } +# <- { +# "return":{ +# "qemu":{ +# "major":0, +# "minor":11, +# "micro":5 +# }, +# "package":"" +# } +# } +# ## { 'command': 'query-version', 'returns': 'VersionInfo' }
@@ -96,6 +111,23 @@ # Returns: A list of @CommandInfo for all supported commands # # Since: 0.14.0 +# +# Example: +# +# -> { "execute": "query-commands" } +# <- { +# "return":[ +# { +# "name":"query-balloon" +# }, +# { +# "name":"system_powerdown" +# } +# ] +# } +# +# Note: This example has been shortened as the real response is too long. +# ## { 'command': 'query-commands', 'returns': ['CommandInfo'] }
qapi/rocker.json +43 -0
67 lines not on this page · raw message
qapi/trace.json +12 -0
@@ -45,6 +45,12 @@ # Returns: a list of @TraceEventInfo for the matching events # # Since 2.2 +# +# Example: +# +# -> { "execute": "trace-event-get-state", "arguments": { "name": "qemu_memalign" } } +# <- { "return": [ { "name": "qemu_memalign", "state": "disabled" } ] } +# ## { 'command': 'trace-event-get-state', 'data': {'name': 'str'},
@@ -60,6 +66,12 @@ # @ignore-unavailable: #optional Do not match unavailable events with @name. # # Since 2.2 +# +# Example: +# +# -> { "execute": "trace-event-set-state", "arguments": { "name": "qemu_memalign", "enable": "true" } } +# <- { "return": {} } +# ## { 'command': 'trace-event-set-state', 'data': {'name': 'str', 'enable': 'bool', '*ignore-unavailable': 'bool'} }
qmp-commands.hx +19 -3598
735 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.4.3
Part of the diff is not shown here. View the raw message.
Re: [Qemu-devel] [PATCH 05/36] qapi: move examples to json schema
Quoted 5 lines · On 09/25/2015 08:03 AM, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Clean-up qmp-commands.hx from examples.
Signed-off-by Marc-André Lureau <[email protected]>
Quoted 9 lines
--- qapi-schema.json | 1128 +++++++++++++++- qapi/block-core.json | 365 +++++ qapi/block.json | 32 + qapi/common.json | 32 + qapi/rocker.json | 43 + qapi/trace.json | 12 + qmp-commands.hx | 3617 +------------------------------------------------- 7 files changed, 1625 insertions(+), 3604 deletions(-)
Mammoth patch.
I don't know if it would make sense to break it into smaller pieces (say 10 or so related commands per patch) - more emails, but each email is more reviewable, and the review can be divided among the various maintainers that implement those various commands.
Or even if there were an easy way to automate the diff to prove that every example was exactly moved, regardless of whether the example is correct.
I'm not necessarily opposed to keeping it as one big patch, just that it is a big commitment to review. And I do like where we end up, it's just that I'm worried about making sure we don't regress along the way (particularly if other QMP command examples are introduced along the way before this gets merged - we already had a recent example of a regression in -help output for PCI devices due to text being added to one file in parallel with another patch that moved the text between files).
Also, I'd love to see docs/qapi-code-gen.txt updated to list Example: as a proper part of a sample qapi listing.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 6/36 qapi: move documentation bits in schema files
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Moving the remaining bits of documentation to the schema files.
--- qapi-schema.json | 48 ++++++++++++++++++++++++++++++++++++++++++- qmp-commands.hx | 62 -------------------------------------------------------- 2 files changed, 47 insertions(+), 63 deletions(-)
qapi-schema.json +47 -1
@@ -1,6 +1,52 @@ # -*- Mode: Python -*- +## +# = Introduction +# +# This document describes all commands currently supported by QMP. +# +# Most of the time their usage is exactly the same as in the user Monitor, this +# means that any other document which also describe commands (the manpage, +# QEMU's manual, etc) can and should be consulted. +# +# QMP has two types of commands: regular and query commands. Regular commands +# usually change the Virtual Machine's state someway, while query commands just +# return information. The sections below are divided accordingly. +# +# It's important to observe that all communication examples are formatted in +# a reader-friendly way, so that they're easier to understand. However, in real +# protocol usage, they're emitted as a single line. +# +# Also, the following notation is used to denote data flow: +# +# Example: +# +# | -> data issued by the Client +# | <- Server data response +# +# Please, refer to the QMP specification (QMP/qmp-spec.txt) for detailed +# information on the Server command and response formats. +# +# = Stability Considerations +# +# The current QMP command set (described in this file) may be useful for a +# number of use cases, however it's limited and several commands have bad +# defined semantics, specially with regard to command completion. +# +# These problems are going to be solved incrementally in the next QEMU releases +# and we're going to establish a deprecation policy for badly defined commands. +# +# If you're planning to adopt QMP, please observe the following: +# +# 1. The deprecation policy will take effect and be documented soon, please +# check the documentation of each used command as soon as a new release of +# QEMU is available +# +# 2. DO NOT rely on anything which is not explicit documented +# +# 3. Errors, in special, are not documented. Applications should NOT check +# for specific errors classes or data (it's strongly recommended to only +# check for the "error" key) # -# QAPI Schema # QAPI common definitions { 'include': 'qapi/common.json' }
qmp-commands.hx +0 -62
65 lines not on this page · raw message
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH 06/36] qapi: move documentation bits in schema files
Quoted 18 lines · On 09/25/2015 08:03 AM, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Moving the remaining bits of documentation to the schema files.
Signed-off-by Marc-André Lureau <[email protected]>--- qapi-schema.json | 48 ++++++++++++++++++++++++++++++++++++++++++- qmp-commands.hx | 62 -------------------------------------------------------- 2 files changed, 47 insertions(+), 63 deletions(-)qapi-schema.json +2
-0@@ -1,6 +1,52 @@ # -*- Mode: Python -*- +## +# = Introduction
qapi-schema.json line 13
Quoted 10 lines
qapi-schema.json +10
-0+# +# This document describes all commands currently supported by QMP. +# +# Most of the time their usage is exactly the same as in the user Monitor, this +# means that any other document which also describe commands (the manpage, +# QEMU's manual, etc) can and should be consulted. +# +# QMP has two types of commands: regular and query commands. Regular commands +# usually change the Virtual Machine's state someway, while query commands just +# return information. The sections below are divided accordingly.
Do we really still have that clean division?
qapi-schema.json line 17
Quoted 4 lines
qapi-schema.json +4
-0+# +# It's important to observe that all communication examples are formatted in +# a reader-friendly way, so that they're easier to understand. However, in real +# protocol usage, they're emitted as a single line.
The server replies in a single line, but the client is free to send in multiple lines.
qapi-schema.json line 27
Quoted 10 lines
qapi-schema.json +10
-0+# +# Also, the following notation is used to denote data flow: +# +# Example: +# +# | -> data issued by the Client +# | <- Server data response +# +# Please, refer to the QMP specification (QMP/qmp-spec.txt) for detailed +# information on the Server command and response formats.
Stale comment, pointing to the wrong file name (commit 7537fe04 moved it from QMP/ to docs/qmp/) (and Markus has a patch pending that moves it from docs/qmp/qmp-spec.txt to docs/qmp-spec.txt).
qapi-schema.json line 36
Quoted 9 lines
qapi-schema.json +9
-0+# +# = Stability Considerations +# +# The current QMP command set (described in this file) may be useful for a +# number of use cases, however it's limited and several commands have bad +# defined semantics, specially with regard to command completion. +# +# These problems are going to be solved incrementally in the next QEMU releases +# and we're going to establish a deprecation policy for badly defined commands.
Wow - some of this stuff has bit-rotted over time. I don't know how much command completion we support for QMP (I guess it depends whether you are using qmp-shell or a straight monitor connection), and while we do still have badly defined commands, they are now the exception and we have made a lot of progress in fixing things.
qapi-schema.json line 42
Quoted 6 lines
qapi-schema.json +6
-0+# +# If you're planning to adopt QMP, please observe the following: +# +# 1. The deprecation policy will take effect and be documented soon, please +# check the documentation of each used command as soon as a new release of +# QEMU is available
Umm, we still don't have a documented deprecation policy.
qapi-schema.json line 44
Quoted 2 lines
qapi-schema.json +2
-0+# +# 2. DO NOT rely on anything which is not explicit documented
s/explicit/explicitly/
Quoted 9 lines
qapi-schema.json +4
-1+# +# 3. Errors, in special, are not documented. Applications should NOT check +# for specific errors classes or data (it's strongly recommended to only +# check for the "error" key) # -# QAPI Schema # QAPI common definitions { 'include': 'qapi/common.json' }
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH 06/36] qapi: move documentation bits in schema files
----- Original Message -----
Quoted 27 lines · On 09/25/2015 08:03 AM, [email protected] wrote:
Quoted 26 lines
From: Marc-André Lureau <[email protected]>
Moving the remaining bits of documentation to the schema files.
Signed-off-by Marc-André Lureau <[email protected]>--- qapi-schema.json | 48 ++++++++++++++++++++++++++++++++++++++++++- qmp-commands.hx | 62 -------------------------------------------------------- 2 files changed, 47 insertions(+), 63 deletions(-)qapi-schema.json +6
-0@@ -1,6 +1,52 @@ # -*- Mode: Python -*- +## +# = Introduction +# +# This document describes all commands currently supported by QMP. +# +# Most of the time their usage is exactly the same as in the user Monitor,this
qapi-schema.json +2
-0+# means that any other document which also describe commands (the manpage, +# QEMU's manual, etc) can and should be consulted.
Quoted 8 lines
Quoted 6 lines
qapi-schema.json +2
-0+# +# QMP has two types of commands: regular and query commands. Regularcommands
+# usually change the Virtual Machine's state someway, while query commands just
+# return information. The sections below are divided accordingly.Do we really still have that clean division?
snip
Could we leave the content change for a later patch? The point was not to rewrite the documentation, but simply to move it.
Re: [Qemu-devel] [PATCH 06/36] qapi: move documentation bits in schema files
Quoted 15 lines · Marc-André Lureau
----- Original Message -----
Quoted 12 lines · On 09/25/2015 08:03 AM, [email protected] wrote:
Quoted 11 lines
From: Marc-André Lureau <[email protected]>
Moving the remaining bits of documentation to the schema files.
Signed-off-by Marc-André Lureau <[email protected]>--- qapi-schema.json | 48 ++++++++++++++++++++++++++++++++++++++++++- qmp-commands.hx | 62 -------------------------------------------------------- 2 files changed, 47 insertions(+), 63 deletions(-)
Quoted 5 lines
Quoted 1 line
Do we really still have that clean division?
snip
Could we leave the content change for a later patch? The point was not to rewrite the documentation, but simply to move it.
Probably fine that way, but I also don't want to forget about the content change (so even if it is not done in this patch, it should still be part of the series).
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 7/36 qapi: add some headings in docs
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Add some missing double-#, the doc parser can't easily distinguish doc comments from comments to be ignored otherwise.
Also add some more section headings.
--- qapi-schema.json | 12 ++++++++++-- qapi/block-core.json | 6 ++++-- qapi/block.json | 5 +++-- qapi/common.json | 5 +++-- qapi/event.json | 5 +++++ qapi/rocker.json | 3 +++ qapi/trace.json | 2 ++ qga/qapi-schema.json | 2 ++ 8 files changed, 32 insertions(+), 8 deletions(-)
qapi-schema.json +10 -2
@@ -67,6 +67,9 @@ { 'include': 'qapi/introspect.json' } ## +# = QMP commands + +## # @qmp_capabilities: # # Enable QMP capabilities.
@@ -107,6 +110,7 @@ { 'enum': 'LostTickPolicy', 'data': ['discard', 'delay', 'merge', 'slew' ] } +## # @add_client # # Allow client connections for VNC, Spice and socket based
@@ -590,6 +594,7 @@ 'cache-miss': 'int', 'cache-miss-rate': 'number', 'overflow': 'int' } } +## # @MigrationStatus: # # An enumeration of migration status.
@@ -880,6 +885,7 @@ ## { 'command': 'query-migrate-capabilities', 'returns': ['MigrationCapabilityStatus']} +## # @MigrationParameter # # Migration parameters enumeration
@@ -903,7 +909,7 @@ { 'enum': 'MigrationParameter', 'data': ['compress-level', 'compress-threads', 'decompress-threads'] } -# +## # @migrate-set-parameters # # Set the following migration parameters
@@ -927,7 +933,7 @@ '*compress-threads': 'int', '*decompress-threads': 'int'} } -# +## # @MigrationParameters # # @compress-level: compression level
@@ -2748,6 +2754,7 @@ ## { 'command': 'migrate-incoming', 'data': {'uri': 'str' } } +## # @xen-save-devices-state: # # Save the state of all devices to file. The RAM and the block devices
@@ -3639,6 +3646,7 @@ ## { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'] } +## # @AddfdInfo: # # Information about a file descriptor that was added to an fd set.
qapi/block-core.json +4 -2
@@ -1,6 +1,7 @@ # -*- Mode: Python -*- -# -# QAPI block core definitions (vm unrelated) + +## +# == QAPI block core definitions (vm unrelated) # QAPI common definitions { 'include': 'common.json' }
@@ -2440,6 +2441,7 @@ 'offset': 'int', 'speed' : 'int' } } +## # @PreallocMode # # Preallocation mode of QEMU image file
qapi/block.json +3 -2
@@ -1,6 +1,7 @@ # -*- Mode: Python -*- -# -# QAPI block definitions (vm related) + +## +# = QAPI block definitions (vm related) # QAPI block core definitions { 'include': 'block-core.json' }
qapi/common.json +3 -2
@@ -1,6 +1,7 @@ # -*- Mode: Python -*- -# -# QAPI common definitions + +## +# = QAPI common definitions ## # @ErrorClass
qapi/event.json +5 -0
@@ -1,3 +1,8 @@ +# -*- Mode: Python -*- + +## +# = Events + ## # @SHUTDOWN #
qapi/rocker.json +3 -0
@@ -1,4 +1,7 @@ ## +# = Rocker API + +## # @Rocker: # # Rocker switch information.
qapi/trace.json +2 -0
@@ -5,6 +5,8 @@ # This work is licensed under the terms of the GNU GPL, version 2 or later. # See the COPYING file in the top-level directory. +## +# = Tracing commands ## # @TraceEventState:
qga/qapi-schema.json +2 -0
@@ -808,6 +808,7 @@ { 'command': 'guest-set-user-password', 'data': { 'username': 'str', 'password': 'str', 'crypted': 'bool' } } +## # @GuestMemoryBlock: # # @phys-index: Arbitrary guest-specific unique identifier of the MEMORY BLOCK.
@@ -907,6 +908,7 @@ 'data': {'mem-blks': ['GuestMemoryBlock'] }, 'returns': ['GuestMemoryBlockResponse'] } +## # @GuestMemoryBlockInfo: # # @size: the size (in bytes) of the guest memory blocks,
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH 07/36] qapi: add some headings in docs
Quoted 9 lines · On 09/25/2015 08:03 AM, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Add some missing double-#, the doc parser can't easily distinguish doc comments from comments to be ignored otherwise.
Also add some more section headings.
Signed-off-by Marc-André Lureau <[email protected]>---
Adding qemu-trivial; this can (mostly) be taken without waiting for pending qapi patches, as it is a consistency cleanup.
qapi-schema.json line 73
Quoted 9 lines
+++
b/qapi-schema.jsonqapi-schema.json +3
-0@@ -67,6 +67,9 @@ { 'include': 'qapi/introspect.json' } ## +# = QMP commands + +## # @qmp_capabilities:
well, except that you'd want to rebase the cleanups in this patch to occur before your other patches which are NOT trivial (while I'm in favor of documenting qmp_capabilities in qapi-schema.json, that one is not a trivial patch)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 8/36 qapi: add qapi2texi script
In reply to [email protected]From: Marc-André Lureau <[email protected]>
As the name suggests, the qapi2texi script converts JSON QAPI description into a standalone texi file suitable for different target formats.
It parses the following kind of blocks with some little variations:
##
# = Section
# == Subsection
#
# Some text foo with *emphasis*
# 1. with a list
# 2. like that
#
# And some code:
# | <- do this
# | -> get that
#
##
##
# @symbol
#
# Symbol body ditto ergo sum. Foo bar
# baz ding.
#
# @arg: foo
# @arg: #optional foo
#
# Returns: returns bla bla
#
# Or bla blah
#
# Since: version
# Notes: notes, comments can have
# - itemized list
# - like this
#
# and continue...
#
# Example:
#
# -> { "execute": "quit" }
# <- { "return": {} }
#
##Thanks to the json declaration, it's able to give extra information about the type of arguments and return value expected.
--- scripts/qapi.py | 88 +++++++++++++++- scripts/qapi2texi.py | 293 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 379 insertions(+), 2 deletions(-) create mode 100755 scripts/qapi2texi.py
scripts/qapi.py +86 -2
@@ -112,6 +112,67 @@ class QAPIExprError(Exception): "%s:%d: %s" % (self.info['file'], self.info['line'], self.msg) +class QAPIDoc: + def __init__(self, comment): + self.symbol = None + self.comment = "" + self.args = OrderedDict() + self.meta = OrderedDict() + self.section = None + + for line in comment.split('\n'): + sline = ' '.join(line.split()) + split = sline.split(' ', 1) + key = split[0].rstrip(':') + + if line.startswith(" @"): + key = key[1:] + sline = split[1] if len(split) > 1 else "" + if self.symbol is None: + self.symbol = key + else: + self.start_section(self.args, key) + elif self.symbol and \ + key in ("Since", "Returns", "Notes", "Note", "Example"): + sline = split[1] if len(split) > 1 else "" + line = None + self.start_section(self.meta, key) + + if self.section and self.section[1] == "Example": + self.append_comment(line) + else: + self.append_comment(sline) + + self.end_section() + + def append_comment(self, line): + if line is None: + return + if self.section is not None: + if self.section[-1] == "" and line == "": + self.end_section() + else: + self.section.append(line) + elif self.comment == "": + self.comment = line + else: + self.comment += "\n" + line + + def end_section(self): + if self.section is not None: + dic = self.section[0] + key = self.section[1] + doc = "\n".join(self.section[2:]) + if key != "Example": + doc = doc.strip() + dic[key] = doc + self.section = None + + def start_section(self, dic, key): + self.end_section() + self.section = [dic, key] # .. remaining elems will be the doc + + class QAPISchemaParser(object): def __init__(self, fp, previously_included=[], incl_info=None):
@@ -127,11 +188,14 @@ class QAPISchemaParser(object): self.line = 1 self.line_pos = 0 self.exprs = [] + self.comment = None + self.apidoc = incl_info['doc'] if incl_info else [] self.accept() while self.tok is not None: expr_info = {'file': fname, 'line': self.line, - 'parent': self.incl_info} + 'parent': self.incl_info, 'doc': self.apidoc} + self.apidoc = [] expr = self.get_expr(False) if isinstance(expr, dict) and "include" in expr: if len(expr) != 1:
@@ -152,6 +216,8 @@ class QAPISchemaParser(object): inf = inf['parent'] # skip multiple include of the same file if incl_abs_fname in previously_included: + expr_info['doc'].extend(self.apidoc) + self.apidoc = expr_info['doc'] continue try: fobj = open(incl_abs_fname, 'r')
@@ -166,6 +232,12 @@ class QAPISchemaParser(object): 'info': expr_info} self.exprs.append(expr_elem) + def append_doc(self): + if self.comment: + apidoc = QAPIDoc(self.comment) + self.apidoc.append(apidoc) + self.comment = None + def accept(self): while True: self.tok = self.src[self.cursor]
@@ -174,8 +246,20 @@ class QAPISchemaParser(object): self.val = None if self.tok == '#': - self.cursor = self.src.find('\n', self.cursor) + end = self.src.find('\n', self.cursor) + line = self.src[self.cursor:end+1] + # start a comment section after ## + if line[0] == "#": + if self.comment is None: + self.comment = "" + # skip modeline + elif line.find("-*") == -1 and self.comment is not None: + self.comment += line + if self.src[end] == "\n" and self.src[end+1] == "\n": + self.append_doc() + self.cursor = end elif self.tok in ['{', '}', ':', ',', '[', ']']: + self.append_doc() return elif self.tok == "'": string = ''
scripts/qapi2texi.py new file +293 -0
293 lines not on this page · raw message
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH 08/36] qapi: add qapi2texi script
Quoted 8 lines · On 09/25/2015 08:03 AM, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
As the name suggests, the qapi2texi script converts JSON QAPI description into a standalone texi file suitable for different target formats.
It parses the following kind of blocks with some little variations:
Quoted 11 lines
##
# = Section
# == Subsection
#
# Some text foo with *emphasis*
# 1. with a list
# 2. like that
#
# And some code:
# | <- do this
# | -> get that
Backwards; you mean:
# | -> send this
# | <- get that
Quoted 5 lines
# Example:
#
# -> { "execute": "quit" }
# <- { "return": {} }
#
but this one is right.
I'd love to have this formalized semantics of what you plan to parse documented in docs/qapi-code-gen.txt, as a reference we can point to for new commands that don't comply.
Quoted 9 lines
Thanks to the json declaration, it's able to give extra information about the type of arguments and return value expected.
Signed-off-by Marc-André Lureau <[email protected]>--- scripts/qapi.py | 88 +++++++++++++++- scripts/qapi2texi.py | 293 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 379 insertions(+), 2 deletions(-) create mode 100755 scripts/qapi2texi.py
I will forbear the actual review detailed for now, in part because it may need another rebase, but the idea seems nice. But I'll do a quick read-through review:
scripts/qapi.py class QAPIExprError(Exception): · line 115
Quoted 10 lines
scripts/qapi.py +1
-0@@ -112,6 +112,67 @@ class QAPIExprError(Exception): "%s:%d: %s" % (self.info['file'], self.info['line'], self.msg) +class QAPIDoc:
Use the new-style class inheritance (as in "class QAPIDoc(object):")
scripts/qapi.py line 4
Quoted 6 lines
scripts/qapi.py +5
-0+++ b/scripts/qapi2texi.py@@ -0,0 +1,293 @@ +#!/usr/bin/env python +# QAPI texi generator +# +# This work is licensed under the terms of the GNU GPL, version 2.
Can we please use GPLv2+ for this file? GPLv2-only is a pain (yes, qapi.py is stuck there unless someone does legwork to see if former contributors don't mind relaxing it, but that doesn't mean we have to repeat the mistake)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 9/36 qapi: remove qmp-events.txt
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Move the examples in the json file with the rest of the documentation to avoid duplication.
--- docs/qmp/qmp-events.txt | 664 ------------------------------------------------ qapi/block-core.json | 59 ++++- qapi/block.json | 9 + qapi/event.json | 206 +++++++++++++++ 4 files changed, 272 insertions(+), 666 deletions(-) delete mode 100644 docs/qmp/qmp-events.txt
docs/qmp/qmp-events.txt deleted +0 -664
@@ -1,664 +0,0 @@ - QEMU Machine Protocol Events - ============================ - -ACPI_DEVICE_OST ---------------- - -Emitted when guest executes ACPI _OST method. - - - data: ACPIOSTInfo type as described in qapi-schema.json - -{ "event": "ACPI_DEVICE_OST", - "data": { "device": "d1", "slot": "0", "slot-type": "DIMM", "source": 1, "status": 0 } } - -BALLOON_CHANGE --------------- - -Emitted when the guest changes the actual BALLOON level. This -value is equivalent to the 'actual' field return by the -'query-balloon' command - -Data: - -- "actual": actual level of the guest memory balloon in bytes (json-number) - -Example: - -{ "event": "BALLOON_CHANGE", - "data": { "actual": 944766976 }, - "timestamp": { "seconds": 1267020223, "microseconds": 435656 } } - -BLOCK_IMAGE_CORRUPTED ---------------------- - -Emitted when a disk image is being marked corrupt. The image can be -identified by its device or node name. The 'device' field is always -present for compatibility reasons, but it can be empty ("") if the -image does not have a device name associated. - -Data: - -- "device": Device name (json-string) -- "node-name": Node name (json-string, optional) -- "msg": Informative message (e.g., reason for the corruption) - (json-string) -- "offset": If the corruption resulted from an image access, this - is the host's access offset into the image - (json-int, optional) -- "size": If the corruption resulted from an image access, this - is the access size (json-int, optional) - -Example: - -{ "event": "BLOCK_IMAGE_CORRUPTED", - "data": { "device": "ide0-hd0", "node-name": "node0", - "msg": "Prevented active L1 table overwrite", "offset": 196608, - "size": 65536 }, - "timestamp": { "seconds": 1378126126, "microseconds": 966463 } } - -BLOCK_IO_ERROR --------------- - -Emitted when a disk I/O error occurs. - -Data: - -- "device": device name (json-string) -- "operation": I/O operation (json-string, "read" or "write") -- "action": action that has been taken, it's one of the following (json-string): - "ignore": error has been ignored - "report": error has been reported to the device - "stop": the VM is going to stop because of the error - -Example: - -{ "event": "BLOCK_IO_ERROR", - "data": { "device": "ide0-hd1", - "operation": "write", - "action": "stop" }, - "timestamp": { "seconds": 1265044230, "microseconds": 450486 } } - -Note: If action is "stop", a STOP event will eventually follow the -BLOCK_IO_ERROR event. - -BLOCK_JOB_CANCELLED -------------------- - -Emitted when a block job has been cancelled. - -Data: - -- "type": Job type (json-string; "stream" for image streaming - "commit" for block commit) -- "device": Device name (json-string) -- "len": Maximum progress value (json-int) -- "offset": Current progress value (json-int) - On success this is equal to len. - On failure this is less than len. -- "speed": Rate limit, bytes per second (json-int) - -Example: - -{ "event": "BLOCK_JOB_CANCELLED", - "data": { "type": "stream", "device": "virtio-disk0", - "len": 10737418240, "offset": 134217728, - "speed": 0 }, - "timestamp": { "seconds": 1267061043, "microseconds": 959568 } } - -BLOCK_JOB_COMPLETED -------------------- - -Emitted when a block job has completed. - -Data: - -- "type": Job type (json-string; "stream" for image streaming - "commit" for block commit) -- "device": Device name (json-string) -- "len": Maximum progress value (json-int) -- "offset": Current progress value (json-int) - On success this is equal to len. - On failure this is less than len. -- "speed": Rate limit, bytes per second (json-int) -- "error": Error message (json-string, optional) - Only present on failure. This field contains a human-readable - error message. There are no semantics other than that streaming - has failed and clients should not try to interpret the error - string. - -Example: - -{ "event": "BLOCK_JOB_COMPLETED", - "data": { "type": "stream", "device": "virtio-disk0", - "len": 10737418240, "offset": 10737418240, - "speed": 0 }, - "timestamp": { "seconds": 1267061043, "microseconds": 959568 } } - -BLOCK_JOB_ERROR ---------------- - -Emitted when a block job encounters an error. - -Data: - -- "device": device name (json-string) -- "operation": I/O operation (json-string, "read" or "write") -- "action": action that has been taken, it's one of the following (json-string): - "ignore": error has been ignored, the job may fail later - "report": error will be reported and the job canceled - "stop": error caused job to be paused - -Example: - -{ "event": "BLOCK_JOB_ERROR", - "data": { "device": "ide0-hd1", - "operation": "write", - "action": "stop" }, - "timestamp": { "seconds": 1265044230, "microseconds": 450486 } } - -BLOCK_JOB_READY ---------------- - -Emitted when a block job is ready to complete. - -Data: - -- "type": Job type (json-string; "stream" for image streaming - "commit" for block commit) -- "device": Device name (json-string) -- "len": Maximum progress value (json-int) -- "offset": Current progress value (json-int) - On success this is equal to len. - On failure this is less than len. -- "speed": Rate limit, bytes per second (json-int) - -Example: - -{ "event": "BLOCK_JOB_READY", - "data": { "device": "drive0", "type": "mirror", "speed": 0, - "len": 2097152, "offset": 2097152 } - "timestamp": { "seconds": 1265044230, "microseconds": 450486 } } - -Note: The "ready to complete" status is always reset by a BLOCK_JOB_ERROR -event. - -DEVICE_DELETED --------------- - -Emitted whenever the device removal completion is acknowledged -by the guest. -At this point, it's safe to reuse the specified device ID. -Device removal can be initiated by the guest or by HMP/QMP commands. - -Data: - -- "device": device name (json-string, optional) -- "path": device path (json-string) - -{ "event": "DEVICE_DELETED", - "data": { "device": "virtio-net-pci-0", - "path": "/machine/peripheral/virtio-net-pci-0" }, - "timestamp": { "seconds": 1265044230, "microseconds": 450486 } } - -DEVICE_TRAY_MOVED ------------------ - -It's emitted whenever the tray of a removable device is moved by the guest -or by HMP/QMP commands. - -Data: - -- "device": device name (json-string) -- "tray-open": true if the tray has been opened or false if it has been closed - (json-bool) - -{ "event": "DEVICE_TRAY_MOVED", - "data": { "device": "ide1-cd0", - "tray-open": true - }, - "timestamp": { "seconds": 1265044230, "microseconds": 450486 } } - -GUEST_PANICKED --------------- - -Emitted when guest OS panic is detected. - -Data: - -- "action": Action that has been taken (json-string, currently always "pause"). - -Example: - -{ "event": "GUEST_PANICKED", - "data": { "action": "pause" } } - -MEM_UNPLUG_ERROR --------------------- -Emitted when memory hot unplug error occurs. - -Data: - -- "device": device name (json-string) -- "msg": Informative message (e.g., reason for the error) (json-string) - -Example: - -{ "event": "MEM_UNPLUG_ERROR" - "data": { "device": "dimm1", - "msg": "acpi: device unplug for unsupported device" - }, - "timestamp": { "seconds": 1265044230, "microseconds": 450486 } } - -NIC_RX_FILTER_CHANGED ---------------------- - -The event is emitted once until the query command is executed, -the first event will always be emitted. - -Data: - -- "name": net client name (json-string) -- "path": device path (json-string) - -{ "event": "NIC_RX_FILTER_CHANGED", - "data": { "name": "vnet0", - "path": "/machine/peripheral/vnet0/virtio-backend" }, - "timestamp": { "seconds": 1368697518, "microseconds": 326866 } } -} - -POWERDOWN ---------- - -Emitted when the Virtual Machine is powered down through the power -control system, such as via ACPI. - -Data: None. - -Example: - -{ "event": "POWERDOWN", - "timestamp": { "seconds": 1267040730, "microseconds": 682951 } } - -QUORUM_FAILURE --------------- - -Emitted by the Quorum block driver if it fails to establish a quorum. - -Data: - -- "reference": device name if defined else node name. -- "sector-num": Number of the first sector of the failed read operation. -- "sectors-count": Failed read operation sector count. - -Example: - -{ "event": "QUORUM_FAILURE", - "data": { "reference": "usr1", "sector-num": 345435, "sectors-count": 5 }, - "timestamp": { "seconds": 1344522075, "microseconds": 745528 } } - -QUORUM_REPORT_BAD ------------------ - -Emitted to report a corruption of a Quorum file. - -Data: - -- "error": Error message (json-string, optional) - Only present on failure. This field contains a human-readable - error message. There are no semantics other than that the - block layer reported an error and clients should not try to - interpret the error string. -- "node-name": The graph node name of the block driver state. -- "sector-num": Number of the first sector of the failed read operation. -- "sectors-count": Failed read operation sector count. - -Example: - -{ "event": "QUORUM_REPORT_BAD", - "data": { "node-name": "1.raw", "sector-num": 345435, "sectors-count": 5 }, - "timestamp": { "seconds": 1344522075, "microseconds": 745528 } } - -RESET ------ - -Emitted when the Virtual Machine is reset. - -Data: None. - -Example: - -{ "event": "RESET", - "timestamp": { "seconds": 1267041653, "microseconds": 9518 } } - -RESUME ------- - -Emitted when the Virtual Machine resumes execution. - -Data: None. - -Example: - -{ "event": "RESUME", - "timestamp": { "seconds": 1271770767, "microseconds": 582542 } } - -RTC_CHANGE ----------- - -Emitted when the guest changes the RTC time. - -Data: - -- "offset": Offset between base RTC clock (as specified by -rtc base), and -new RTC clock value (json-number) - -Example: - -{ "event": "RTC_CHANGE", - "data": { "offset": 78 }, - "timestamp": { "seconds": 1267020223, "microseconds": 435656 } } - -SHUTDOWN --------- - -Emitted when the Virtual Machine has shut down, indicating that qemu -is about to exit. - -Data: None. - -Example: - -{ "event": "SHUTDOWN", - "timestamp": { "seconds": 1267040730, "microseconds": 682951 } } - -Note: If the command-line option "-no-shutdown" has been specified, a STOP -event will eventually follow the SHUTDOWN event. - -SPICE_CONNECTED ---------------- - -Emitted when a SPICE client connects. - -Data: - -- "server": Server information (json-object) - - "host": IP address (json-string) - - "port": port number (json-string) - - "family": address family (json-string, "ipv4" or "ipv6") -- "client": Client information (json-object) - - "host": IP address (json-string) - - "port": port number (json-string) - - "family": address family (json-string, "ipv4" or "ipv6") - -Example: - -{ "timestamp": {"seconds": 1290688046, "microseconds": 388707}, - "event": "SPICE_CONNECTED", - "data": { - "server": { "port": "5920", "family": "ipv4", "host": "127.0.0.1"}, - "client": {"port": "52873", "family": "ipv4", "host": "127.0.0.1"} -}} - -SPICE_DISCONNECTED ------------------- - -Emitted when a SPICE client disconnects. - -Data: - -- "server": Server information (json-object) - - "host": IP address (json-string) - - "port": port number (json-string) - - "family": address family (json-string, "ipv4" or "ipv6") -- "client": Client information (json-object) - - "host": IP address (json-string) - - "port": port number (json-string) - - "family": address family (json-string, "ipv4" or "ipv6") - -Example: - -{ "timestamp": {"seconds": 1290688046, "microseconds": 388707}, - "event": "SPICE_DISCONNECTED", - "data": { - "server": { "port": "5920", "family": "ipv4", "host": "127.0.0.1"}, - "client": {"port": "52873", "family": "ipv4", "host": "127.0.0.1"} -}} - -SPICE_INITIALIZED ------------------ - -Emitted after initial handshake and authentication takes place (if any) -and the SPICE channel is up and running - -Data: - -- "server": Server information (json-object) - - "host": IP address (json-string) - - "port": port number (json-string) - - "family": address family (json-string, "ipv4" or "ipv6") - - "auth": authentication method (json-string, optional) -- "client": Client information (json-object) - - "host": IP address (json-string) - - "port": port number (json-string) - - "family": address family (json-string, "ipv4" or "ipv6") - - "connection-id": spice connection id. All channels with the same id - belong to the same spice session (json-int) - - "channel-type": channel type. "1" is the main control channel, filter for - this one if you want track spice sessions only (json-int) - - "channel-id": channel id. Usually "0", might be different needed when - multiple channels of the same type exist, such as multiple - display channels in a multihead setup (json-int) - - "tls": whevener the channel is encrypted (json-bool) - -Example: - -{ "timestamp": {"seconds": 1290688046, "microseconds": 417172}, - "event": "SPICE_INITIALIZED", - "data": {"server": {"auth": "spice", "port": "5921", - "family": "ipv4", "host": "127.0.0.1"}, - "client": {"port": "49004", "family": "ipv4", "channel-type": 3, - "connection-id": 1804289383, "host": "127.0.0.1", - "channel-id": 0, "tls": true} -}} - -SPICE_MIGRATE_COMPLETED ------------------------ - -Emitted when SPICE migration has completed - -Data: None. - -Example: - -{ "timestamp": {"seconds": 1290688046, "microseconds": 417172}, - "event": "SPICE_MIGRATE_COMPLETED" } - -MIGRATION ---------- - -Emitted when a migration event happens - -Data: None. - - - "status": migration status - See MigrationStatus in ~/qapi-schema.json for possible values - -Example: - -{"timestamp": {"seconds": 1432121972, "microseconds": 744001}, - "event": "MIGRATION", "data": {"status": "completed"}} - -STOP ----- - -Emitted when the Virtual Machine is stopped. - -Data: None. - -Example: - -{ "event": "STOP", - "timestamp": { "seconds": 1267041730, "microseconds": 281295 } } - -SUSPEND -------- - -Emitted when guest enters S3 state. - -Data: None. - -Example: - -{ "event": "SUSPEND", - "timestamp": { "seconds": 1344456160, "microseconds": 309119 } } - -SUSPEND_DISK ------------- - -Emitted when the guest makes a request to enter S4 state. - -Data: None. - -Example: - -{ "event": "SUSPEND_DISK", - "timestamp": { "seconds": 1344456160, "microseconds": 309119 } } - -Note: QEMU shuts down when entering S4 state. - -VNC_CONNECTED -------------- - -Emitted when a VNC client establishes a connection. - -Data: - -- "server": Server information (json-object) - - "host": IP address (json-string) - - "service": port number (json-string) - - "family": address family (json-string, "ipv4" or "ipv6") - - "auth": authentication method (json-string, optional) -- "client": Client information (json-object) - - "host": IP address (json-string) - - "service": port number (json-string) - - "family": address family (json-string, "ipv4" or "ipv6") - -Example: - -{ "event": "VNC_CONNECTED", - "data": { - "server": { "auth": "sasl", "family": "ipv4", - "service": "5901", "host": "0.0.0.0" }, - "client": { "family": "ipv4", "service": "58425", - "host": "127.0.0.1" } }, - "timestamp": { "seconds": 1262976601, "microseconds": 975795 } } - - -Note: This event is emitted before any authentication takes place, thus -the authentication ID is not provided. - -VNC_DISCONNECTED ----------------- - -Emitted when the connection is closed. - -Data: - -- "server": Server information (json-object) - - "host": IP address (json-string) - - "service": port number (json-string) - - "family": address family (json-string, "ipv4" or "ipv6") - - "auth": authentication method (json-string, optional) -- "client": Client information (json-object) - - "host": IP address (json-string) - - "service": port number (json-string) - - "family": address family (json-string, "ipv4" or "ipv6") - - "x509_dname": TLS dname (json-string, optional) - - "sasl_username": SASL username (json-string, optional) - -Example: - -{ "event": "VNC_DISCONNECTED", - "data": { - "server": { "auth": "sasl", "family": "ipv4", - "service": "5901", "host": "0.0.0.0" }, - "client": { "family": "ipv4", "service": "58425", - "host": "127.0.0.1", "sasl_username": "luiz" } }, - "timestamp": { "seconds": 1262976601, "microseconds": 975795 } } - -VNC_INITIALIZED ---------------- - -Emitted after authentication takes place (if any) and the VNC session is -made active. - -Data: - -- "server": Server information (json-object) - - "host": IP address (json-string) - - "service": port number (json-string) - - "family": address family (json-string, "ipv4" or "ipv6") - - "auth": authentication method (json-string, optional) -- "client": Client information (json-object) - - "host": IP address (json-string) - - "service": port number (json-string) - - "family": address family (json-string, "ipv4" or "ipv6") - - "x509_dname": TLS dname (json-string, optional) - - "sasl_username": SASL username (json-string, optional) - -Example: - -{ "event": "VNC_INITIALIZED", - "data": { - "server": { "auth": "sasl", "family": "ipv4", - "service": "5901", "host": "0.0.0.0"}, - "client": { "family": "ipv4", "service": "46089", - "host": "127.0.0.1", "sasl_username": "luiz" } }, - "timestamp": { "seconds": 1263475302, "microseconds": 150772 } } - -VSERPORT_CHANGE ---------------- - -Emitted when the guest opens or closes a virtio-serial port. - -Data: - -- "id": device identifier of the virtio-serial port (json-string) -- "open": true if the guest has opened the virtio-serial port (json-bool) - -Example: - -{ "event": "VSERPORT_CHANGE", - "data": { "id": "channel0", "open": true }, - "timestamp": { "seconds": 1401385907, "microseconds": 422329 } } - -WAKEUP ------- - -Emitted when the guest has woken up from S3 and is running. - -Data: None. - -Example: - -{ "event": "WAKEUP", - "timestamp": { "seconds": 1344522075, "microseconds": 745528 } } - -WATCHDOG --------- - -Emitted when the watchdog device's timer is expired. - -Data: - -- "action": Action that has been taken, it's one of the following (json-string): - "reset", "shutdown", "poweroff", "pause", "debug", or "none" - -Example: - -{ "event": "WATCHDOG", - "data": { "action": "reset" }, - "timestamp": { "seconds": 1267061043, "microseconds": 959568 } } - -Note: If action is "reset", "shutdown", or "pause" the WATCHDOG event is -followed respectively by the RESET, SHUTDOWN, or STOP events.
qapi/block-core.json +57 -2
104 lines not on this page · raw message
qapi/block.json +9 -0
@@ -208,6 +208,15 @@ # @tray-open: true if the tray has been opened or false if it has been closed # # Since: 1.1 +# +# Example: +# +# <- { "event": "DEVICE_TRAY_MOVED", +# "data": { "device": "ide1-cd0", +# "tray-open": true +# }, +# "timestamp": { "seconds": 1265044230, "microseconds": 450486 } } +# ## { 'event': 'DEVICE_TRAY_MOVED', 'data': { 'device': 'str', 'tray-open': 'bool' } }
qapi/event.json +206 -0
368 lines not on this page · raw message
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH 09/36] qapi: remove qmp-events.txt
Quoted 5 lines · On 09/25/2015 08:03 AM, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Move the examples in the json file with the rest of the documentation to avoid duplication.
Quoted 8 lines
Signed-off-by Marc-André Lureau <[email protected]>--- docs/qmp/qmp-events.txt | 664 ------------------------------------------------ qapi/block-core.json | 59 ++++- qapi/block.json | 9 + qapi/event.json | 206 +++++++++++++++ 4 files changed, 272 insertions(+), 666 deletions(-) delete mode 100644 docs/qmp/qmp-events.txt
Another big patch; not sure if it is worth splitting to ease review by sharing the review load across multiple emails. But not quite as daunting as the qmp-commands.hx content move. It will be a while before I have a good stretch of time to commit to the actual review to make sure nothing gets dropped, but I'm in favor of the idea.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 10/36 texi2pod: learn quotation, deftp and deftypefn
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Learn a few more markups used for API documentation.
--- scripts/texi2pod.pl | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-)
scripts/texi2pod.pl +43 -1
@@ -37,6 +37,7 @@ $inf = ""; $ibase = ""; @ipath = (); $encoding = undef; +@args = (); while ($_ = shift) { if (/^-D(.*)$/) {
@@ -162,7 +163,8 @@ while(<$inf>) { if ($ended =~ /^(?:ifset|ifclear|ignore|menu|iftex)$/) { $skipping = pop @skstack; next; - } elsif ($ended =~ /^(?:example|smallexample|display)$/) { + } elsif ($ended =~ /^(?:example|smallexample|display + |quotation|deftp|deftypefn)$/x) { $shift = ""; $_ = ""; # need a paragraph break } elsif ($ended =~ /^(?:itemize|enumerate|[fv]?table)$/) {
@@ -323,6 +325,46 @@ while(<$inf>) { $_ = "\n=item ".join (" : ", @columns)."\n"; }; + /^\@(quotation)\s*(.+)?$/ and do { + push @endwstack, $endw; + $endw = $1; + $_ = "\n$2:" + }; + + /^{(.*)}$|^(.*)$/ and $#args > 0 and do { + $kind = $args[0]; + $arguments = $1 // ""; + if ($endw eq "deftypefn") { + $ret = $args[1]; + $fname = "B<$args[2]>"; + $_ = $ret ? "$ret " : ""; + $_ .= "$fname $arguments ($kind)"; + } else { + $_ = "B<$args[1]> ($kind)\n\n$arguments"; + } + @args = (); + }; + + /^\@(deftp)\s*(.+)?$/ and do { + push @endwstack, $endw; + $endw = $1; + $arg = $2; + $arg =~ s/{([^}]*)}/$1/g; + $arg =~ s/\@$//; + @args = split (/ /, $arg); + $_ = ""; + }; + + /^\@(deftypefn)\s*(.+)?$/ and do { + push @endwstack, $endw; + $endw = $1; + $arg = $2; + $arg =~ s/{([^}]*)}/$1/g; + $arg =~ s/\@$//; + @args = split (/ /, $arg); + $_ = ""; + }; + /^\@itemx?\s*(.+)?$/ and do { if (defined $1) { # Entity escapes prevent munging by the <> processing below.
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH 10/36] texi2pod: learn quotation, deftp and deftypefn
Quoted 8 lines · On 09/25/2015 08:03 AM, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Learn a few more markups used for API documentation.
Signed-off-by Marc-André Lureau <[email protected]>--- scripts/texi2pod.pl | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-)
This file was originally from gcc (we forked it from a point before gcc upstream made theirs GPLv3). Are your additions written from scratch, or are they copied from somewhere else like gcc? Might be nice to be explicit in your commit message.
I'm not the best perl reviewer, but the obvious test is whether the resulting output file looks clean; offhand that seems to be the case, but I'm not confident enough to leave R-b on this pass of reviews.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 11/36 build-sys: generate QAPI doc based on json
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Learn to generate info/html/pdf/man documentation for QEMU and agent QMP APIs.
This allows to provide missing agent documentation, and should help getting rid of the duplicate documentation in qmp-commands.hx.
--- Makefile | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-)
Makefile +30 -6
@@ -91,7 +91,7 @@ HELPERS-$(CONFIG_LINUX) = qemu-bridge-helper$(EXESUF) ifdef BUILD_DOCS DOCS=qemu-doc.html qemu-tech.html qemu.1 qemu-img.1 qemu-nbd.8 qemu-ga.8 -DOCS+=qmp-commands.txt +DOCS+=qmp-commands.txt qemu-qapi.7 qemu-ga-qapi.7 ifdef CONFIG_LINUX DOCS+=kvm_stat.1 endif
@@ -249,6 +249,7 @@ qemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated gen-out-type = $(subst .,-,$(suffix $@)) qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py +qapi-py += $(SRC_PATH)/scripts/qapi2texi.py qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\ $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
@@ -363,7 +364,7 @@ distclean: clean rm -f qemu-doc.vr rm -f config.log rm -f linux-headers/asm - rm -f qemu-tech.info qemu-tech.aux qemu-tech.cp qemu-tech.dvi qemu-tech.fn qemu-tech.info qemu-tech.ky qemu-tech.log qemu-tech.pdf qemu-tech.pg qemu-tech.toc qemu-tech.tp qemu-tech.vr + rm -f qemu-tech.info qemu-tech.aux qemu-tech.cp qemu-tech.dvi qemu-tech.fn qemu-tech.info qemu-tech..ky qemu-tech.log qemu-tech.pdf qemu-tech.pg qemu-tech.toc qemu-tech.tp qemu-tech.vr qemu-qapi.info qemu-qapi.aux qemu-qapi.cp qemu-qapi.dvi qemu-qapi.fn qemu-qapi.info qemu-qapi..ky qemu-qapi.log qemu-qapi.pdf qemu-qapi.pg qemu-qapi.toc qemu-qapi.tp qemu-qapi.vr qemu-ga-qapi.info qemu-ga-qapi.aux qemu-ga-qapi.cp qemu-ga-qapi.dvi qemu-ga-qapi.fn qemu-ga-qapi.info qemu-ga-qapi..ky qemu-ga-qapi.log qemu-ga-qapi.pdf qemu-ga-qapi.pg qemu-ga-qapi.toc qemu-ga-qapi.tp qemu-ga-qapi.vr for d in $(TARGET_DIRS); do \ rm -rf $$d || exit 1 ; \ done
@@ -408,6 +409,7 @@ ifneq ($(TOOLS),) $(INSTALL_DATA) qemu-img.1 "$(DESTDIR)$(mandir)/man1" $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8" $(INSTALL_DATA) qemu-nbd.8 "$(DESTDIR)$(mandir)/man8" + $(INSTALL_DATA) qemu-qapi.7 qemu-ga-qapi.7 "$(DESTDIR)$(mandir)/man7" endif ifneq (,$(findstring qemu-ga,$(TOOLS))) $(INSTALL_DATA) qemu-ga.8 "$(DESTDIR)$(mandir)/man8"
@@ -529,6 +531,16 @@ qmp-commands.txt: $(SRC_PATH)/qmp-commands.hx qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@," GEN $@") +qemu-qapi.texi: $(qapi-modules) $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi2texi.py \ + "QEMU QAPI Reference Manual" $(VERSION) qemu-qapi \ + $< > $@," GEN $@") + +qemu-ga-qapi.texi: $(SRC_PATH)/qga/qapi-schema.json $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi2texi.py \ + "QEMU Guest Agent QAPI Reference Manual" $(VERSION) qemu-ga-qapi \ + $< > $@," GEN $@") + qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi qemu-monitor-info.texi $(call quiet-command, \ perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu.pod && \
@@ -559,16 +571,28 @@ qemu-ga.8: qemu-ga.texi $(POD2MAN) --section=8 --center=" " --release=" " qemu-ga.pod > $@, \ " GEN $@") +qemu-qapi.7: qemu-qapi.texi + $(call quiet-command, \ + perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu-qapi.pod && \ + $(POD2MAN) --section=7 --center=" " --release=" " qemu-qapi.pod > $@, \ + " GEN $@") + +qemu-ga-qapi.7: qemu-ga-qapi.texi + $(call quiet-command, \ + perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu-ga-qapi.pod && \ + $(POD2MAN) --section=7 --center=" " --release=" " qemu-ga-qapi.pod > $@, \ + " GEN $@") + kvm_stat.1: scripts/kvm/kvm_stat.texi $(call quiet-command, \ perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< kvm_stat.pod && \ $(POD2MAN) --section=1 --center=" " --release=" " kvm_stat.pod > $@, \ " GEN $@") -dvi: qemu-doc.dvi qemu-tech.dvi -html: qemu-doc.html qemu-tech.html -info: qemu-doc.info qemu-tech.info -pdf: qemu-doc.pdf qemu-tech.pdf +dvi: qemu-doc.dvi qemu-tech.dvi qemu-qapi.dvi +html: qemu-doc.html qemu-tech.html qemu-qapi.html +info: qemu-doc.info qemu-tech.info qemu-qapi.info +pdf: qemu-doc.pdf qemu-tech.pdf qemu-qapi.pdf qemu-doc.dvi qemu-doc.html qemu-doc.info qemu-doc.pdf: \ qemu-img.texi qemu-nbd.texi qemu-options.texi \
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH 11/36] build-sys: generate QAPI doc based on json
Quoted 6 lines · On 09/25/2015 08:03 AM, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Learn to generate info/html/pdf/man documentation for QEMU and agent QMP APIs.
This allows to provide missing agent documentation, and should help
"allows to" is not idiomatic English (it is missing a subject of who is being allowed). Better would be either:
This allows us to provide missing agent documentation, This provides missing agent documentation,
although I'd lean to the shorter form.
Makefile distclean: clean · line 367
Quoted 12 lines
getting rid of the duplicate documentation in qmp-commands.hx.
Signed-off-by Marc-André Lureau <[email protected]>--- Makefile | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-)Makefile +1
-1@@ -363,7 +364,7 @@ distclean: clean rm -f qemu-doc.vr rm -f config.log rm -f linux-headers/asm - rm -f qemu-tech.info qemu-tech.aux qemu-tech.cp qemu-tech.dvi qemu-tech.fn qemu-tech.info qemu-tech.ky qemu-tech.log qemu-tech.pdf qemu-tech.pg qemu-tech.toc qemu-tech.tp qemu-tech.vr + rm -f qemu-tech.info qemu-tech.aux qemu-tech.cp qemu-tech.dvi qemu-tech.fn qemu-tech.info qemu-tech..ky qemu-tech.log qemu-tech.pdf qemu-tech.pg qemu-tech.toc qemu-tech.tp qemu-tech.vr qemu-qapi.info qemu-qapi.aux qemu-qapi.cp qemu-qapi.dvi qemu-qapi.fn qemu-qapi.info qemu-qapi..ky qemu-qapi.log qemu-qapi.pdf qemu-qapi.pg qemu-qapi.toc qemu-qapi.tp qemu-qapi.vr qemu-ga-qapi.info qemu-ga-qapi.aux qemu-ga-qapi.cp qemu-ga-qapi.dvi qemu-ga-qapi.fn qemu-ga-qapi.info qemu-ga-qapi..ky qemu-ga-qapi.log qemu-ga-qapi.pdf qemu-ga-qapi.pg qemu-ga-qapi.toc qemu-ga-qapi.tp qemu-ga-qapi.vr
This line is now way long; can we use \ continuation to split it into something easier to manage?
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 12/36 build-sys: generate qmp-commands.txt
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Not sure this is really necessary, but it's easy to provide
--- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Makefile +3 -2
@@ -525,8 +525,9 @@ qemu-monitor.texi: $(SRC_PATH)/hmp-commands.hx qemu-monitor-info.texi: $(SRC_PATH)/hmp-commands-info.hx $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@," GEN $@") -qmp-commands.txt: $(SRC_PATH)/qmp-commands.hx - $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -q < $< > $@," GEN $@") +qmp-commands.txt: qemu-qapi.texi + $(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --plaintext $< -o $@, \ + " GEN $@") qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@," GEN $@")
Signature · 1 line
2.4.3
PATCH 13/36 build-sys: do not generate qmp-commands-old.h
In reply to [email protected]From: Marc-André Lureau <[email protected]>
It's static file now.
--- Makefile.target | 7 +- qmp-commands-old.h | 683 +++++++++++++++++++++++++++++++++++++++++++++++++++++ qmp-commands.hx | 683 ----------------------------------------------------- 3 files changed, 685 insertions(+), 688 deletions(-) create mode 100644 qmp-commands-old.h delete mode 100644 qmp-commands.hx
Makefile.target +2 -5
@@ -154,7 +154,7 @@ else obj-y += hw/$(TARGET_BASE_ARCH)/ endif -GENERATED_HEADERS += hmp-commands.h hmp-commands-info.h qmp-commands-old.h +GENERATED_HEADERS += hmp-commands.h hmp-commands-info.h endif # CONFIG_SOFTMMU
@@ -205,13 +205,10 @@ hmp-commands.h: $(SRC_PATH)/hmp-commands.hx hmp-commands-info.h: $(SRC_PATH)/hmp-commands-info.hx $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@," GEN $(TARGET_DIR)$@") -qmp-commands-old.h: $(SRC_PATH)/qmp-commands.hx - $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@," GEN $(TARGET_DIR)$@") - clean: rm -f *.a *~ $(PROGS) rm -f $(shell find . -name '*.[od]') - rm -f hmp-commands.h qmp-commands-old.h gdbstub-xml.c + rm -f hmp-commands.h gdbstub-xml.c ifdef CONFIG_TRACE_SYSTEMTAP rm -f *.stp endif
qmp-commands-old.h new file +683 -0
683 lines not on this page · raw message
qmp-commands.hx deleted +0 -683
683 lines not on this page · raw message
Signature · 1 line
2.4.3
PATCH 14/36 monitor: remove usage of generated marshal functions
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Once the middle mode is removed, the generated marshal functions will no longer be exported.
--- monitor.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
monitor.c +11 -6
@@ -76,6 +76,7 @@#include "qapi-event.h" #include "qmp-introspect.h" #include "sysemu/block-backend.h" +#include "qapi/qmp/dispatch.h" /* for hmp_info_irq/pic */ #if defined(TARGET_SPARC )
@@ -3536,21 +3537,21 @@ static int monitor_can_read(void *opaque)return (mon->suspend_cnt ==0 ) ?1 :0 ; } -static bool invalid_qmp_mode (const Monitor *mon,const mon_cmd_t *cmd, +static bool invalid_qmp_mode (const Monitor *mon,const gchar *cmd,Error **errp) { -bool is_cap = cmd->mhandler.cmd_new == qmp_marshal_qmp_capabilities; +bool is_cap = !g_strcmp0 (cmd,"qmp_capabilities" );if (is_cap && mon->qmp.in_command_mode) {error_set (errp,ERROR_CLASS_COMMAND_NOT_FOUND ,"Capabilities negotiation is already complete, command " -"'%s' ignored" , cmd->name); +"'%s' ignored" , cmd);return true; }if (!is_cap && !mon->qmp.in_command_mode) {error_set (errp,ERROR_CLASS_COMMAND_NOT_FOUND ,"Expecting capabilities negotiation with " -"'qmp_capabilities' before command '%s'" , cmd->name); +"'qmp_capabilities' before command '%s'" , cmd);return true; }return false;
@@ -3841,7 +3842,7 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens) "The command %s has not been found", cmd_name); goto err_out; } -if (invalid_qmp_mode (mon, cmd, &local_err)) { +if (invalid_qmp_mode (mon, cmd_name, &local_err)) { goto err_out; }
@@ -3926,9 +3927,13 @@ void monitor_resume(Monitor *mon)static QObject *get_qmp_greeting (void ) { +QmpCommand *cmd;QObject *ver =NULL ; -qmp_marshal_query_version (NULL , &ver,NULL ); + cmd =qmp_find_command ("query-version" ); +assert (cmd && cmd->fn); + cmd->fn (NULL , &ver,NULL ); +return qobject_from_jsonf ("{'QMP':{'version': %p,'capabilities': []}}" ,ver); }
Signature · 1 line
2.4.3
PATCH 15/36 monitor: register gen:false commands manually
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Since some commands are using 'gen': false, they are not registered automatically by the generator. Register manually instead.
--- monitor.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
monitor.c +10 -0
@@ -945,6 +945,16 @@ static void qmp_query_qmp_schema(QDict *qdict, QObject **ret_data, *ret_data =qobject_from_json (qmp_schema_json); } +static void qmp_init_marshal (void ) +{ +qmp_register_command ("query-qmp-schema" , qmp_query_qmp_schema, +QCO_NO_OPTIONS ); +qmp_register_command ("device_add" , qmp_device_add, +QCO_NO_OPTIONS ); +} + +qapi_init (qmp_init_marshal); +/* set the current CPU defined by the user */ int monitor_set_cpu (int cpu_index) {
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH 15/36] monitor: register gen:false commands manually
Quoted 15 lines · On 09/25/2015 08:03 AM, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Since some commands are using 'gen': false, they are not registered automatically by the generator. Register manually instead.
Signed-off-by Marc-André Lureau <[email protected]>--- monitor.c | 10 ++++++++++ 1 file changed, 10 insertions(+)monitor.c +0
-0
monitor.c static void qmp_query_qmp_schema(QDict *qdict, QObject **ret_data, · line 954
Quoted 10 lines
monitor.c +7
-0@@ -945,6 +945,16 @@ static void qmp_query_qmp_schema(QDict *qdict, QObject **ret_data, *ret_data =qobject_from_json (qmp_schema_json); } +static void qmp_init_marshal (void ) +{ +qmp_register_command ("query-qmp-schema" , qmp_query_qmp_schema, +QCO_NO_OPTIONS ); +qmp_register_command ("device_add" , qmp_device_add, +QCO_NO_OPTIONS ); +}
device_add wasn't even mentioned in a *.json file before your series.
/me goes and looks
Oh, you sneakily added it in "qapi: move examples to json schema". Please separate that into its own patch, as it is more than just moving examples.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 16/36 qmp: register qapi commands (no middle mode)
In reply to [email protected]From: Marc-André Lureau <[email protected]>
The marshal functions are no longer exported, they are registered in the dispatch table instead. The following patches will make use of qmp_dispatch(). This patch temporarily breaks qmp/hmp commands.
--- Makefile | 2 +- qmp-commands-old.h | 129 ----------------------------------------------------- vl.c | 1 + 3 files changed, 2 insertions(+), 130 deletions(-)
Makefile +1 -1
@@ -289,7 +289,7 @@ $(qapi-modules) $(SRC_PATH)/scripts/qapi-event.py $(qapi-py) qmp-commands.h qmp-marshal.c :\ $(qapi-modules) $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \ - $(gen-out-type) -o "." -m $<, \ + $(gen-out-type) -o "." $<, \ " GEN $@") qmp-introspect.h qmp-introspect.c :\ $(qapi-modules) $(SRC_PATH)/scripts/qapi-introspect.py $(qapi-py)
qmp-commands-old.h +0 -129
681 lines not on this page · raw message
vl.c +1 -0
@@ -2966,6 +2966,7 @@ int main(int argc, char **argv, char **envp)g_mem_set_vtable (&mem_trace);module_call_init (MODULE_INIT_QOM ); +module_call_init (MODULE_INIT_QAPI );qemu_add_opts (&qemu_drive_opts);qemu_add_drive_opts (&qemu_legacy_drive_opts);
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH 16/36] qmp: register qapi commands (no middle mode)
Quoted 5 lines · On 09/25/2015 08:03 AM, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
The marshal functions are no longer exported, they are registered in the dispatch table instead. The following patches will make use of
qmp_dispatch(). This patch temporarily breaks qmp/hmp commands.
Should this be squashed with the patch that fixes things?
Quoted 26 lines
Signed-off-by Marc-André Lureau <[email protected]>--- Makefile | 2 +- qmp-commands-old.h | 129 ----------------------------------------------------- vl.c | 1 + 3 files changed, 2 insertions(+), 130 deletions(-)Makefile +1
-1@@ -289,7 +289,7 @@ $(qapi-modules) $(SRC_PATH)/scripts/qapi-event.py $(qapi-py) qmp-commands.h qmp-marshal.c :\ $(qapi-modules) $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \ - $(gen-out-type) -o "." -m $<, \ + $(gen-out-type) -o "." $<, \ " GEN $@") qmp-introspect.h qmp-introspect.c :\ $(qapi-modules) $(SRC_PATH)/scripts/qapi-introspect.py $(qapi-py)qmp-commands-old.h +0
-0
qmp-commands-old.h line 9
Quoted 9 lines
qmp-commands-old.h +0
-2@@ -1,279 +1,225 @@ { .name = "quit", .args_type = "", - .mhandler.cmd_new = qmp_marshal_quit, }, { .name = "eject", .args_type = "force:-f,device:B", - .mhandler.cmd_new = qmp_marshal_eject,
Do we still need .args_type? Can it be generated instead of maintained by hand?
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 17/36 qmp: use qmp_dispatch()
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Replace the old "middle mode" dispatch code using the manually maintained table by the one generated by qapi scripts.
--- monitor.c | 316 +++++++------------------------------------------------------- 1 file changed, 34 insertions(+), 282 deletions(-)
monitor.c +34 -282
@@ -166,7 +166,6 @@ struct MonFdset { }; typedef struct { - QObject *id; JSONMessageParser parser; /* * When a client connects, we're in capabilities negotiation mode.
@@ -397,49 +396,6 @@ static void monitor_json_emitter(Monitor *mon, const QObject *data)QDECREF (json); } -static QDict *build_qmp_error_dict (Error *err) -{ -QObject *obj; - - obj =qobject_from_jsonf ("{ 'error': { 'class': %s, 'desc': %s } }" , - ErrorClass_lookup[error_get_class (err)], -error_get_pretty (err)); - -return qobject_to_qdict (obj); -} - -static void monitor_protocol_emitter (Monitor *mon,QObject *data, -Error *err) -{ -QDict *qmp; - -trace_monitor_protocol_emitter (mon); - -if (!err) { -/* success response */ - qmp =qdict_new (); -if (data) { -qobject_incref (data); -qdict_put_obj (qmp,"return" , data); - }else { -/* return an empty QDict by default */ -qdict_put (qmp,"return" ,qdict_new ()); - } - }else { -/* error response */ - qmp =build_qmp_error_dict (err); - } - -if (mon->qmp.id) { -qdict_put_obj (qmp,"id" , mon->qmp.id); - mon->qmp.id =NULL ; - } - -monitor_json_emitter (mon,QOBJECT (qmp)); -QDECREF (qmp); -} - -static MonitorQAPIEventState monitor_qapi_event_state[QAPI_EVENT_MAX ];/*
@@ -2436,11 +2392,6 @@ static const mon_cmd_t *search_dispatch_table(const mon_cmd_t *disp_table,return NULL ; } -static const mon_cmd_t *qmp_find_cmd (const char *cmdname) -{ -return search_dispatch_table (qmp_cmds, cmdname); -} -/* * Parse command name from @cmdp according to command table @table. * If blank, return NULL.
@@ -3568,199 +3519,6 @@ static bool invalid_qmp_mode(const Monitor *mon, const gchar *cmd, }/* -* Argument validation rules: -* -* 1. The argument must exist in cmd_args qdict -* 2. The argument type must be the expected one -* -* Special case: If the argument doesn't exist in cmd_args and -* the QMP_ACCEPT_UNKNOWNS flag is set, then the -* checking is skipped for it. -*/ -static void check_client_args_type (const QDict *client_args, -const QDict *cmd_args,int flags, -Error **errp) -{ -const QDictEntry *ent; - -for (ent =qdict_first (client_args); ent;ent =qdict_next (client_args,ent)){ -QObject *obj; -QString *arg_type; -const QObject *client_arg =qdict_entry_value (ent); -const char *client_arg_name =qdict_entry_key (ent); - - obj =qdict_get (cmd_args, client_arg_name); -if (!obj) { -if (flags &QMP_ACCEPT_UNKNOWNS ) { -/* handler accepts unknowns */ -continue ; - } -/* client arg doesn't exist */ -error_setg (errp,QERR_INVALID_PARAMETER , client_arg_name); -return ; - } - - arg_type =qobject_to_qstring (obj); -assert (arg_type !=NULL ); - -/* check if argument's type is correct */ -switch (qstring_get_str (arg_type)[0 ]) { -case 'F' : -case 'B' : -case 's' : -if (qobject_type (client_arg) !=QTYPE_QSTRING ) { -error_setg (errp,QERR_INVALID_PARAMETER_TYPE , - client_arg_name,"string" ); -return ; - } -break ; -case 'i' : -case 'l' : -case 'M' : -case 'o' : -if (qobject_type (client_arg) !=QTYPE_QINT ) { -error_setg (errp,QERR_INVALID_PARAMETER_TYPE , - client_arg_name,"int" ); -return ; - } -break ; -case 'T' : -if (qobject_type (client_arg) !=QTYPE_QINT && -qobject_type (client_arg) !=QTYPE_QFLOAT ) { -error_setg (errp,QERR_INVALID_PARAMETER_TYPE , - client_arg_name,"number" ); -return ; - } -break ; -case 'b' : -case '-' : -if (qobject_type (client_arg) !=QTYPE_QBOOL ) { -error_setg (errp,QERR_INVALID_PARAMETER_TYPE , - client_arg_name,"bool" ); -return ; - } -break ; -case 'O' : -assert (flags &QMP_ACCEPT_UNKNOWNS ); -break ; -case 'q' : -/* Any QObject can be passed. */ -break ; -case '/' : -case '.' : -/* -* These types are not supported by QMP and thus are not -* handled here. Fall through. -*/ -default : -abort (); - } - } -} - -/* -* - Check if the client has passed all mandatory args -* - Set special flags for argument validation -*/ -static void check_mandatory_args (const QDict *cmd_args, -const QDict *client_args,int *flags, -Error **errp) -{ -const QDictEntry *ent; - -for (ent =qdict_first (cmd_args); ent; ent =qdict_next (cmd_args, ent)) { -const char *cmd_arg_name =qdict_entry_key (ent); -QString *type =qobject_to_qstring (qdict_entry_value (ent)); -assert (type !=NULL ); - -if (qstring_get_str (type)[0 ] =='O' ) { -assert ((*flags &QMP_ACCEPT_UNKNOWNS ) ==0 ); - *flags |=QMP_ACCEPT_UNKNOWNS ; - }else if (qstring_get_str (type)[0 ] !='-' && -qstring_get_str (type)[1 ] !='?' && - !qdict_haskey (client_args, cmd_arg_name)) { -error_setg (errp,QERR_MISSING_PARAMETER , cmd_arg_name); -return ; - } - } -} - -static QDict *qdict_from_args_type (const char *args_type) -{ -int i; -QDict *qdict; -QString *key, *type, *cur_qs; - -assert (args_type !=NULL ); - - qdict =qdict_new (); - -if (args_type ==NULL || args_type[0 ] =='\0' ) { -/* no args, empty qdict */ - goto out; - } - - key =qstring_new (); - type =qstring_new (); - - cur_qs = key; - -for (i =0 ;; i++) { -switch (args_type[i]) { -case ',' : -case '\0' : -qdict_put (qdict,qstring_get_str (key), type); -QDECREF (key); -if (args_type[i] =='\0' ) { - goto out; - } - type =qstring_new ();/* qdict has ref */ - cur_qs = key =qstring_new (); -break ; -case ':' : - cur_qs = type; -break ; -default : -qstring_append_chr (cur_qs, args_type[i]); -break ; - } - } - -out: -return qdict; -} - -/* -* Client argument checking rules: -* -* 1. Client must provide all mandatory arguments -* 2. Each argument provided by the client must be expected -* 3. Each argument provided by the client must have the type expected -* by the command -*/ -static void qmp_check_client_args (const mon_cmd_t *cmd,QDict *client_args, -Error **errp) -{ -Error *err =NULL ; -int flags; -QDict *cmd_args; - - cmd_args =qdict_from_args_type (cmd->args_type); - - flags =0 ; -check_mandatory_args (cmd_args, client_args, &flags, &err); -if (err) { - goto out; - } - -check_client_args_type (client_args, cmd_args, flags, &err); - -out: -error_propagate (errp, err); -QDECREF (cmd_args); -} - -/* * Input object checking rules * * 1. Input object must be a dict
@@ -3818,64 +3576,58 @@ static QDict *qmp_check_input_obj(QObject *input_obj, Error **errp)static void handle_qmp_command (JSONMessageParser *parser,QList *tokens) { -Error *local_err =NULL ; -QObject *obj, *data; -QDict *input, *args; -const mon_cmd_t *cmd; +QObject *req, *rsp =NULL , *id =NULL ; +QDict *qdict =NULL ;const char *cmd_name;Monitor *mon = cur_mon; +Error *err =NULL ; - args = input =NULL ; - data =NULL ; - - obj =json_parser_parse (tokens,NULL ); -if (!obj) { -// FIXME: should be triggered in json_parser_parse() -error_setg (&local_err,QERR_JSON_PARSING ); + req =json_parser_parse_err (tokens,NULL , &err); +if (err || !req ||qobject_type (req) !=QTYPE_QDICT ) { +if (!err) { +error_setg (&err,QERR_JSON_PARSING ); + } goto err_out; } - input =qmp_check_input_obj (obj, &local_err); -if (!input) { -qobject_decref (obj); + qdict =qmp_check_input_obj (req, &err); +if (!qdict) { goto err_out; } - mon->qmp.id =qdict_get (input,"id" ); -qobject_incref (mon->qmp.id); + id =qdict_get (qdict,"id" ); +qobject_incref (id); +qdict_del (qdict,"id" ); - cmd_name =qdict_get_str (input,"execute" ); + cmd_name =qdict_get_str (qdict,"execute" );trace_handle_qmp_command (mon, cmd_name); - cmd =qmp_find_cmd (cmd_name); -if (!cmd) { -error_set (&local_err,ERROR_CLASS_COMMAND_NOT_FOUND , -"The command %s has not been found" , cmd_name); - goto err_out; - } -if (invalid_qmp_mode (mon, cmd_name, &local_err)) { + +if (invalid_qmp_mode (mon, cmd_name, &err)) { goto err_out; } - obj =qdict_get (input,"arguments" ); -if (!obj) { - args =qdict_new (); - }else { - args =qobject_to_qdict (obj); -QINCREF (args); - } + rsp =qmp_dispatch (req); -qmp_check_client_args (cmd, args, &local_err); -if (local_err) { - goto err_out; +err_out: +if (err) { + qdict =qdict_new (); +qdict_put_obj (qdict,"error" ,qmp_build_error_object (err)); +error_free (err); + rsp =QOBJECT (qdict); } - cmd->mhandler.cmd_new (args, &data, &local_err); +if (rsp) { +if (id) { +qdict_put_obj (qobject_to_qdict (rsp),"id" , id); + id =NULL ; + } -err_out: -monitor_protocol_emitter (mon, data, local_err); -qobject_decref (data); -QDECREF (input); -QDECREF (args); +monitor_json_emitter (mon, rsp); + } + +qobject_decref (id); +qobject_decref (rsp); +qobject_decref (req); }static void monitor_qmp_read (void *opaque,const uint8_t *buf,int size)
Signature · 1 line
2.4.3
PATCH 18/36 qapi: remove "middle" mode
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Now that the register function is always generated, we can remove the so-called "middle" mode to the generator script.
--- scripts/qapi-commands.py | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-)
scripts/qapi-commands.py +5 -24
@@ -179,17 +179,8 @@ out: def gen_marshal_proto(name): - ret = 'void qmp_marshal_%s(QDict *args, QObject **ret, Error **errp)' % c_name(name) - if not middle_mode: - ret = 'static ' + ret - return ret - - -def gen_marshal_decl(name): - return mcgen(''' -%(proto)s; -''', - proto=gen_marshal_proto(name)) + return 'static void qmp_marshal_%s' % c_name(name) + \ + '(QDict *args, QObject **ret, Error **errp)' def gen_marshal(name, arg_type, box, ret_type):
@@ -263,8 +254,7 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor): self._visited_ret_types = set() def visit_end(self): - if not middle_mode: - self.defn += gen_registry(self._regy) + self.defn += gen_registry(self._regy) self._regy = None self._visited_ret_types = None
@@ -276,21 +266,12 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor): if ret_type and ret_type not in self._visited_ret_types: self._visited_ret_types.add(ret_type) self.defn += gen_marshal_output(ret_type) - if middle_mode: - self.decl += gen_marshal_decl(name) self.defn += gen_marshal(name, arg_type, box, ret_type) - if not middle_mode: - self._regy += gen_register_command(name, success_response) - + self._regy += gen_register_command(name, success_response) -middle_mode = False (input_file, output_dir, do_c, do_h, prefix, opts) = \ - parse_command_line("m", ["middle"]) - -for o, a in opts: - if o in ("-m", "--middle"): - middle_mode = True + parse_command_line() c_comment = ''' /*
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH 18/36] qapi: remove "middle" mode
Quoted 9 lines · On 09/25/2015 08:03 AM, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Now that the register function is always generated, we can remove the so-called "middle" mode to the generator script.
Signed-off-by Marc-André Lureau <[email protected]>--- scripts/qapi-commands.py | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-)
Yay. Although I haven't closely reviewed this one, I like the concept.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 19/36 qmp: implement qmp_query_commands without qmp_cmds
In reply to [email protected]From: Marc-André Lureau <[email protected]>
So we can get rid of the static qmp_cmds table.
--- monitor.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-)
monitor.c +14 -11
@@ -850,21 +850,24 @@ static void hmp_info_help(Monitor *mon, const QDict *qdict)help_cmd (mon,"info" ); } -CommandInfoList *qmp_query_commands (Error **errp) +static void query_commands_cb (QmpCommand *cmd,void *opaque) { -CommandInfoList *info, *cmd_list =NULL ; -const mon_cmd_t *cmd; +CommandInfoList *info, **list = opaque; -for (cmd = qmp_cmds; cmd->name !=NULL ; cmd++) { - info =g_malloc0 (sizeof (*info)); - info->value =g_malloc0 (sizeof (*info->value)); - info->value->name =g_strdup (cmd->name); + info =g_malloc0 (sizeof (*info)); + info->value =g_malloc0 (sizeof (*info->value)); + info->value->name =g_strdup (cmd->name); + info->next = *list; + *list = info; +} - info->next = cmd_list; - cmd_list = info; - } +CommandInfoList *qmp_query_commands (Error **errp) +{ +CommandInfoList *list =NULL ; + +qmp_for_each_command (query_commands_cb, &list); -return cmd_list; +return list; }EventInfoList *qmp_query_events (Error **errp)
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH 19/36] qmp: implement qmp_query_commands without qmp_cmds
Quoted 8 lines · On 09/25/2015 08:03 AM, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
So we can get rid of the static
qmp_cmdstable.Signed-off-by Marc-André Lureau <[email protected]>--- monitor.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 20/36 qmp: remove old qmp-commands table
In reply to [email protected]From: Marc-André Lureau <[email protected]>
The table is no longer used.
--- monitor.c | 7 - qmp-commands-old.h | 554 ----------------------------------------------------- 2 files changed, 561 deletions(-) delete mode 100644 qmp-commands-old.h
monitor.c +0 -7
@@ -225,8 +225,6 @@ static int mon_refcount;static mon_cmd_t mon_cmds[];static mon_cmd_t info_cmds[]; -static const mon_cmd_t qmp_cmds[]; -Monitor *cur_mon; static void monitor_command_cb(void *opaque, const char *cmdline,
@@ -2048,11 +2046,6 @@ static mon_cmd_t mon_cmds[] = { { NULL, NULL, }, }; -static const mon_cmd_t qmp_cmds[] = { -#include "qmp-commands-old.h" - {/* NULL */ }, -}; -/*******************************************************************/ static const char *pch;
qmp-commands-old.h deleted +0 -554
554 lines not on this page · raw message
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH 20/36] qmp: remove old qmp-commands table
Quoted 10 lines · On 09/25/2015 08:03 AM, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
The table is no longer used.
Signed-off-by Marc-André Lureau <[email protected]>--- monitor.c | 7 - qmp-commands-old.h | 554 ----------------------------------------------------- 2 files changed, 561 deletions(-) delete mode 100644 qmp-commands-old.h
Nice!
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 21/36 misc: spelling
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- monitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
monitor.c +1 -1
@@ -306,7 +306,7 @@ static void monitor_flush_locked(Monitor *mon)return ; }if (rc >0 ) { -/* partinal write */ +/* partial write */ QString *tmp =qstring_from_str (buf + rc);QDECREF (mon->outbuf); mon->outbuf = tmp;
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH 21/36] misc: spelling
Quoted 5 lines · On 09/25/2015 08:03 AM, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
--- monitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Trivial, can be applied now without waiting for pending qapi patches.
Quoted 15 lines
monitor.c +1
-1@@ -306,7 +306,7 @@ static void monitor_flush_locked(Monitor *mon)return ; }if (rc >0 ) { -/* partinal write */ +/* partial write */ QString *tmp =qstring_from_str (buf + rc);QDECREF (mon->outbuf); mon->outbuf = tmp;
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Michael Tokarev
AppliedRe: [Qemu-devel] [PATCH 21/36] misc: spelling
Quoted 10 lines · Eric Blake
Quoted 5 lines · On 09/25/2015 08:03 AM, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
--- monitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Trivial, can be applied now without waiting for pending qapi patches.
Reviewed-by Eric Blake <[email protected]>
Note there's no S-o-b line in the original patch (whole series, looks like). Hopefully it is okay for such a really trivial patch :)
Applied, thanks!
/mjt
Re: [Qemu-devel] [PATCH 21/36] misc: spelling
Quoted 10 lines · Michael Tokarev
Quoted 9 lines · Eric Blake
Quoted 5 lines · On 09/25/2015 08:03 AM, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
--- monitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Trivial, can be applied now without waiting for pending qapi patches.
Quoted 7 lines
Quoted 1 line
Reviewed-by Eric Blake <[email protected]>Note there's no S-o-b line in the original patch (whole series, looks like). Hopefully it is okay for such a really trivial patch :)
Applied, thanks!
It may be legally safe, but do we really want to engage in judging whether patches are copyrightable or not? Besides, it sets a bad example.
Marc-André, please repost your patches ready for -trivial with your S-o-B, cc: qemu-trivial.
Re: [Qemu-devel] [PATCH 21/36] misc: spelling
05.10.2015 08:09, Markus Armbruster пишет:
Quoted 5 lines
Quoted 3 lines · Michael Tokarev
Quoted 2 lines · Eric Blake
Quoted 1 line · On 09/25/2015 08:03 AM, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
[]
Quoted 11 lines
Quoted 7 lines
Quoted 1 line
Reviewed-by Eric Blake <[email protected]>Note there's no S-o-b line in the original patch (whole series, looks like). Hopefully it is okay for such a really trivial patch :)
Applied, thanks!
It may be legally safe, but do we really want to engage in judging whether patches are copyrightable or not? Besides, it sets a bad example.
Sometimes I question our own sanity. Even for a trivial spelling fix we require significantly more beaurocracy(sp) than the fix is worth, and want formal rules instead of using common sense. This is a common trend in the world, to formalize everything instead of thinking, the world is becoming "candy". This reminded me an old movie, "Demolition Man", -- the cops in the future reads instructions about what to do in each situation they happened to come. But oh well, no one want to take responsibility, that's okay ;)
Sorry for somewhat non-technical answer, I'll revert this patch, waiting for more beaurocracy.
Quoted 2 lines
Marc-André, please repost your patches ready for -trivial with your S-o-B, cc: qemu-trivial.
Mind you, it was a large series, with wasn't intended for -trivial at all. That's more rules and more beaurocracy. And many other patches in that series didn't have s-o-b line too.
Thanks,
/mjt
Re: [Qemu-devel] [PATCH 21/36] misc: spelling
Quoted 28 lines · Michael Tokarev
05.10.2015 08:09, Markus Armbruster пишет:
Quoted 5 lines
Quoted 3 lines · Michael Tokarev
Quoted 2 lines · Eric Blake
Quoted 1 line · On 09/25/2015 08:03 AM, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
[]
Quoted 11 lines
Quoted 7 lines
Quoted 1 line
Reviewed-by Eric Blake <[email protected]>Note there's no S-o-b line in the original patch (whole series, looks like). Hopefully it is okay for such a really trivial patch :)
Applied, thanks!
It may be legally safe, but do we really want to engage in judging whether patches are copyrightable or not? Besides, it sets a bad example.
Sometimes I question our own sanity. Even for a trivial spelling fix we require significantly more beaurocracy(sp) than the fix is worth, and want formal rules instead of using common sense. This is a common trend in the world, to formalize everything instead of thinking, the world is becoming "candy". This reminded me an old movie, "Demolition Man", -- the cops in the future reads instructions about what to do in each situation they happened to come. But oh well, no one want to take responsibility, that's okay ;)
Quoted 2 lines
Sorry for somewhat non-technical answer, I'll revert this patch, waiting for more beaurocracy.
Well, it could be worse, it could be CLA and copyright assignment. S-o-B is probably the most lightweight thing we can do to stay on relatively solid legal ground.
In my opinion, applying the "must have S-o-B" rule unthinkingly is less effort than trying to identify cases where we can do without.
Quoted 6 lines
Quoted 2 lines
Marc-André, please repost your patches ready for -trivial with your S-o-B, cc: qemu-trivial.
Mind you, it was a large series, with wasn't intended for -trivial at all. That's more rules and more beaurocracy. And many other patches in that series didn't have s-o-b line too.
Chances are these patches really need it, so Marc-André has to repost his series anyway.
PATCH 22/36 qmp: teach qmp_dispatch() to take a pre-filled QDict
In reply to [email protected]From: Marc-André Lureau <[email protected]>
In order to prepare for the async support, give an optionnal qdict for the dispatch call to be used for the reply. The qemu monitor will have the request "id" pre-filled.
--- include/qapi/qmp/dispatch.h | 2 +- monitor.c | 24 ++++++++++-------------- qapi/qmp-dispatch.c | 5 ++--- qga/main.c | 2 +- tests/test-qmp-commands.c | 6 +++--- 5 files changed, 17 insertions(+), 22 deletions(-)
include/qapi/qmp/dispatch.h +1 -1
@@ -44,7 +44,7 @@ typedef struct QmpCommandvoid qmp_register_command (const char *name,QmpCommandFunc *fn,QmpCommandOptions options);QmpCommand *qmp_find_command (const char *name); -QObject *qmp_dispatch (QObject *request); +QObject *qmp_dispatch (QObject *request,QDict *rsp);void qmp_disable_command (const char *name);void qmp_enable_command (const char *name);bool qmp_command_is_enabled (const QmpCommand *cmd);
monitor.c +10 -14
@@ -3572,12 +3572,13 @@ static QDict *qmp_check_input_obj(QObject *input_obj, Error **errp)static void handle_qmp_command (JSONMessageParser *parser,QList *tokens) { -QObject *req, *rsp =NULL , *id =NULL ; -QDict *qdict =NULL ; +QObject *req, *rsp, *id =NULL ; +QDict *qdict, *rqdict =qdict_new ();const char *cmd_name;Monitor *mon = cur_mon;Error *err =NULL ; + rsp =QOBJECT (rqdict); req =json_parser_parse_err (tokens,NULL , &err);if (err || !req ||qobject_type (req) !=QTYPE_QDICT ) {if (!err) {
@@ -3592,8 +3593,11 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens) } id =qdict_get (qdict,"id" ); -qobject_incref (id); -qdict_del (qdict,"id" ); +if (id) { +qobject_incref (id); +qdict_del (qdict,"id" ); +qdict_put_obj (rqdict,"id" , id); + } cmd_name =qdict_get_str (qdict,"execute" );trace_handle_qmp_command (mon, cmd_name);
@@ -3602,26 +3606,18 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens) goto err_out; } - rsp =qmp_dispatch (req); + rsp =qmp_dispatch (req, rqdict); err_out:if (err) { - qdict =qdict_new (); -qdict_put_obj (qdict,"error" ,qmp_build_error_object (err)); +qdict_put_obj (rqdict,"error" ,qmp_build_error_object (err));error_free (err); - rsp =QOBJECT (qdict); }if (rsp) { -if (id) { -qdict_put_obj (qobject_to_qdict (rsp),"id" , id); - id =NULL ; - } -monitor_json_emitter (mon, rsp); } -qobject_decref (id);qobject_decref (rsp);qobject_decref (req); }
qapi/qmp-dispatch.c +2 -3
@@ -118,15 +118,14 @@ QObject *qmp_build_error_object(Error *err) error_get_pretty(err)); } -QObject *qmp_dispatch (QObject *request) +QObject *qmp_dispatch (QObject *request,QDict *rsp) {Error *err =NULL ;QObject *ret; -QDict *rsp; ret =do_qmp_dispatch (request, &err); - rsp =qdict_new (); + rsp = rsp ?:qdict_new ();if (err) {qdict_put_obj (rsp,"error" ,qmp_build_error_object (err));error_free (err);
qga/main.c +1 -1
@@ -553,7 +553,7 @@ static void process_command(GAState *s, QDict *req)g_assert (req);g_debug ("processing command" ); - rsp =qmp_dispatch (QOBJECT (req)); + rsp =qmp_dispatch (QOBJECT (req),NULL );if (rsp) { ret =send_response (s, rsp);if (ret) {
tests/test-qmp-commands.c +3 -3
@@ -85,7 +85,7 @@ static void test_dispatch_cmd(void)qdict_put_obj (req,"execute" ,QOBJECT (qstring_from_str ("user_def_cmd" ))); - resp =qmp_dispatch (QOBJECT (req)); + resp =qmp_dispatch (QOBJECT (req),NULL );assert (resp !=NULL );assert (!qdict_haskey (qobject_to_qdict (resp),"error" ));
@@ -101,7 +101,7 @@ static void test_dispatch_cmd_error(void)qdict_put_obj (req,"execute" ,QOBJECT (qstring_from_str ("user_def_cmd2" ))); - resp =qmp_dispatch (QOBJECT (req)); + resp =qmp_dispatch (QOBJECT (req),NULL );assert (resp !=NULL );assert (qdict_haskey (qobject_to_qdict (resp),"error" ));
@@ -115,7 +115,7 @@ static QObject *test_qmp_dispatch(QDict *req)QDict *resp;QObject *ret; - resp_obj =qmp_dispatch (QOBJECT (req)); + resp_obj =qmp_dispatch (QOBJECT (req),NULL );assert (resp_obj); resp =qobject_to_qdict (resp_obj);assert (resp && !qdict_haskey (resp,"error" ));
Signature · 1 line
2.4.3
PATCH 23/36 qmp: use a return callback for the command reply
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Introduce QmpDispatchReturn, a callback called when a command reply is ready to be sent. Future patches will extend the concept to allow async replies.
QmpReturn and associated functions is used internally for sync fonctions, but will be the basis of a async context (the dispatch return callback and the top response dict).
--- include/qapi/qmp/dispatch.h | 14 +++++++++++-- monitor.c | 13 ++++++++---- qapi/qmp-dispatch.c | 51 ++++++++++++++++++++++++++++++++++----------- qga/main.c | 22 +++++++++---------- tests/test-qmp-commands.c | 42 ++++++++++++++++++++----------------- 5 files changed, 94 insertions(+), 48 deletions(-)
include/qapi/qmp/dispatch.h +12 -2
@@ -18,6 +18,14 @@#include "qapi/qmp/qdict.h" #include "qapi/error.h" +typedef void (QmpDispatchReturn ) (QObject *rsp,void *opaque); + +typedef struct QmpReturn { +QDict *rsp; +QmpDispatchReturn *return_cb; +void *opaque; +}QmpReturn ; +typedef void (QmpCommandFunc )(QDict *,QObject **,Error **); typedef enum QmpCommandType
@@ -44,7 +52,8 @@ typedef struct QmpCommandvoid qmp_register_command (const char *name,QmpCommandFunc *fn,QmpCommandOptions options);QmpCommand *qmp_find_command (const char *name); -QObject *qmp_dispatch (QObject *request,QDict *rsp); +void qmp_dispatch (QObject *request,QDict *rsp, +QmpDispatchReturn *return_cb,void *opaque);void qmp_disable_command (const char *name);void qmp_enable_command (const char *name);bool qmp_command_is_enabled (const QmpCommand *cmd);
@@ -53,6 +62,7 @@ bool qmp_has_success_response(const QmpCommand *cmd);QObject *qmp_build_error_object (Error *err);typedef void (*qmp_cmd_callback_fn )(QmpCommand *cmd,void *opaque);void qmp_for_each_command (qmp_cmd_callback_fn fn,void *opaque); +void qmp_return (QmpReturn *qret,QObject *cmd_rsp); +void qmp_return_error (QmpReturn *qret,Error *err);#endif -
monitor.c +9 -4
@@ -3570,6 +3570,13 @@ static QDict *qmp_check_input_obj(QObject *input_obj, Error **errp)return input_dict; } +static void qmp_dispatch_return (QObject *rsp,void *opaque) +{ +Monitor *mon = opaque; + +monitor_json_emitter (mon, rsp); +} +static void handle_qmp_command (JSONMessageParser *parser,QList *tokens) {QObject *req, *rsp, *id =NULL ;
@@ -3606,15 +3613,13 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens) goto err_out; } - rsp =qmp_dispatch (req, rqdict); +qmp_dispatch (req, rqdict, qmp_dispatch_return, mon); + rsp =NULL ; err_out:if (err) {qdict_put_obj (rqdict,"error" ,qmp_build_error_object (err));error_free (err); - } - -if (rsp) {monitor_json_emitter (mon, rsp); }
qapi/qmp-dispatch.c +39 -12
69 lines not on this page · raw message
qga/main.c +11 -11
@@ -546,21 +546,21 @@ static int send_response(GAState *s, QObject *payload)return 0 ; } -static void process_command (GAState *s,QDict *req) +static void dispatch_return_cb (QObject *rsp,void *opaque) { -QObject *rsp =NULL ; -int ret; +GAState *s = opaque; +int ret =send_response (s, rsp); + +if (ret) { +g_warning ("error sending response: %s" ,strerror (ret)); + } +} +static void process_command (GAState *s,QDict *req) +{g_assert (req);g_debug ("processing command" ); - rsp =qmp_dispatch (QOBJECT (req),NULL ); -if (rsp) { - ret =send_response (s, rsp); -if (ret) { -g_warning ("error sending response: %s" ,strerror (ret)); - } -qobject_decref (rsp); - } +qmp_dispatch (QOBJECT (req),NULL , dispatch_return_cb, s); }/* handle requests/control events coming in over the channel */
tests/test-qmp-commands.c +23 -19
76 lines not on this page · raw message
Signature · 1 line
2.4.3
PATCH 24/36 qmp: add QmpClient
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Add a new QmpClient structure holding the dispatch return callback and the list of pending QmpReturns.
When a client disconnects, call qmp_client_destroy(). This will remove all pending returns from the client list, and prevent a reply from being sent later to new clients. That way clients will only receive reply they expect, and not one from a previous client.
--- include/qapi/qmp/dispatch.h | 20 +++++++++++++++----- monitor.c | 9 ++++++--- qapi/qmp-dispatch.c | 33 +++++++++++++++++++++++++++------ qga/main.c | 10 ++++++---- tests/test-qmp-commands.c | 31 ++++++++++++++++++++++--------- 5 files changed, 76 insertions(+), 27 deletions(-)
include/qapi/qmp/dispatch.h +15 -5
@@ -18,14 +18,23 @@#include "qapi/qmp/qdict.h" #include "qapi/error.h" -typedef void (QmpDispatchReturn ) (QObject *rsp,void *opaque); +typedef struct QmpClient QmpClient ; + +typedef void (QmpDispatchReturn ) (QmpClient *client,QObject *rsp);typedef struct QmpReturn {QDict *rsp; -QmpDispatchReturn *return_cb; -void *opaque; +QmpClient *client; + +QLIST_ENTRY (QmpReturn) link; }QmpReturn ; +struct QmpClient { +QmpDispatchReturn *return_cb; + + QLIST_HEAD(, QmpReturn) pending; +}; +typedef void (QmpCommandFunc )(QDict *,QObject **,Error **); typedef enum QmpCommandType
@@ -52,8 +61,9 @@ typedef struct QmpCommandvoid qmp_register_command (const char *name,QmpCommandFunc *fn,QmpCommandOptions options);QmpCommand *qmp_find_command (const char *name); -void qmp_dispatch (QObject *request,QDict *rsp, -QmpDispatchReturn *return_cb,void *opaque); +void qmp_client_init (QmpClient *client,QmpDispatchReturn *return_cb); +void qmp_client_destroy (QmpClient *client); +void qmp_dispatch (QmpClient *client,QObject *request,QDict *rsp);void qmp_disable_command (const char *name);void qmp_enable_command (const char *name);bool qmp_command_is_enabled (const QmpCommand *cmd);
monitor.c +6 -3
@@ -173,6 +173,7 @@ typedef struct {* mode. */ bool in_command_mode;/* are we in command mode? */ +QmpClient client; } MonitorQMP;/*
@@ -3570,9 +3571,9 @@ static QDict *qmp_check_input_obj(QObject *input_obj, Error **errp)return input_dict; } -static void qmp_dispatch_return (QObject *rsp,void *opaque) +static void qmp_dispatch_return (QmpClient *client,QObject *rsp) { -Monitor *mon = opaque; +Monitor *mon =container_of (client, Monitor, qmp.client);monitor_json_emitter (mon, rsp); }
@@ -3613,7 +3614,7 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens) goto err_out; } -qmp_dispatch (req, rqdict, qmp_dispatch_return, mon); +qmp_dispatch (&mon->qmp.client, req, rqdict); rsp =NULL ; err_out:
@@ -3714,6 +3715,7 @@ static void monitor_qmp_event(void *opaque, int event)json_message_parser_init (&mon->qmp.parser, handle_qmp_command); mon_refcount--;monitor_fdsets_cleanup (); +qmp_client_destroy (&mon->qmp.client);break ; } }
@@ -3848,6 +3850,7 @@ void monitor_init(CharDriverState *chr, int flags) monitor_qmp_event, mon);qemu_chr_fe_set_echo (chr, true);json_message_parser_init (&mon->qmp.parser, handle_qmp_command); +qmp_client_init (&mon->qmp.client, qmp_dispatch_return); }else {qemu_chr_add_handlers (chr, monitor_can_read, monitor_read, monitor_event, mon);
qapi/qmp-dispatch.c +27 -6
@@ -121,9 +121,13 @@ QObject *qmp_build_error_object(Error *err)static void do_qmp_return (QmpReturn *qret) {QDict *rsp = qret->rsp; +QmpClient *client = qret->client; - qret->return_cb (QOBJECT (rsp), qret->opaque); +if (client) { + client->return_cb (client,QOBJECT (rsp)); + } +QLIST_REMOVE (qret, link);qobject_decref (QOBJECT (rsp));g_free (qret); }
@@ -143,25 +147,42 @@ void qmp_return_error(QmpReturn *qret, Error *err)do_qmp_return (qret); } -void qmp_dispatch (QObject *request,QDict *rsp, -QmpDispatchReturn *return_cb,void *opaque) +void qmp_client_init (QmpClient *client,QmpDispatchReturn *return_cb) +{ + client->return_cb = return_cb; +QLIST_INIT (&client->pending); +} + +void qmp_client_destroy (QmpClient *client) +{ +QmpReturn *ret, *next; + + QLIST_FOREACH_SAFE(ret, &client->pending, link, next) { + ret->client =NULL ; +QLIST_REMOVE (ret, link); + } +} + +void qmp_dispatch (QmpClient *client,QObject *request,QDict *rsp) {Error *err =NULL ;QmpReturn *qret =g_new0 (QmpReturn,1 );QObject *ret; -assert (return_cb); +assert (client); qret->rsp = rsp ?:qdict_new (); - qret->return_cb = return_cb; - qret->opaque = opaque; + qret->client = client; +QLIST_INSERT_HEAD (&client->pending, qret, link); ret =do_qmp_dispatch (request, qret, &err);if (err) {assert (!ret);qmp_return_error (qret, err); +return ; }else if (ret) {qmp_return (qret, ret); +return ; } }
qga/main.c +6 -4
@@ -93,6 +93,7 @@ struct GAState {#endif gchar *pstate_filepath;GAPersistentState pstate; +QmpClient client; };struct GAState *ga_state;
@@ -546,9 +547,9 @@ static int send_response(GAState *s, QObject *payload)return 0 ; } -static void dispatch_return_cb (QObject *rsp,void *opaque) +static void dispatch_return_cb (QmpClient *client,QObject *rsp) { -GAState *s = opaque; +GAState *s =container_of (client, GAState, client);int ret =send_response (s, rsp);if (ret) {
@@ -560,7 +561,7 @@ static void process_command(GAState *s, QDict *req) {g_assert (req);g_debug ("processing command" ); -qmp_dispatch (QOBJECT (req),NULL , dispatch_return_cb, s); +qmp_dispatch (&ga_state->client,QOBJECT (req),NULL ); }/* handle requests/control events coming in over the channel */
@@ -1293,6 +1294,7 @@ static int run_agent(GAState *s, GAConfig *config)ga_command_state_init_all (s->command_state);json_message_parser_init (&s->parser, process_event); ga_state = s; +qmp_client_init (&s->client, dispatch_return_cb);#ifndef _WIN32if (!register_signal_handlers ()) {g_critical ("failed to register signal handlers" );
@@ -1390,7 +1392,7 @@ end:g_list_foreach (config->blacklist, free_blacklist_entry,NULL );g_free (s->pstate_filepath);g_free (s->state_filepath_isfrozen); - +qmp_client_destroy (&s->client);if (config->daemonize) {unlink (config->pid_filepath); }
tests/test-qmp-commands.c +22 -9
@@ -76,7 +76,7 @@ __org_qemu_x_Union1 *qmp___org_qemu_x_command(__org_qemu_x_EnumList *a,return ret; } -static void dispatch_cmd_return (QObject *resp,void *opaque) +static void dispatch_cmd_return (QmpClient *client,QObject *resp) {assert (resp !=NULL );assert (!qdict_haskey (qobject_to_qdict (resp),"error" ));
@@ -85,16 +85,20 @@ static void dispatch_cmd_return(QObject *resp, void *opaque)/* test commands with no input and no return value */ static void test_dispatch_cmd (void ) { +QmpClient client;QDict *req =qdict_new (); -qdict_put_obj (req,"execute" ,QOBJECT (qstring_from_str ("user_def_cmd" ))); +qmp_client_init (&client, dispatch_cmd_return); -qmp_dispatch (QOBJECT (req),NULL , dispatch_cmd_return,NULL ); +qdict_put_obj (req,"execute" ,QOBJECT (qstring_from_str ("user_def_cmd" ))); +qmp_dispatch (&client,QOBJECT (req),NULL );QDECREF (req); + +qmp_client_destroy (&client); } -static void dispatch_cmd_error_return (QObject *resp,void *opaque) +static void dispatch_cmd_error_return (QmpClient *client,QObject *resp) {assert (resp !=NULL );assert (qdict_haskey (qobject_to_qdict (resp),"error" ));
@@ -103,18 +107,22 @@ static void dispatch_cmd_error_return(QObject *resp, void *opaque)/* test commands that return an error due to invalid parameters */ static void test_dispatch_cmd_error (void ) { +QmpClient client;QDict *req =qdict_new (); -qdict_put_obj (req,"execute" ,QOBJECT (qstring_from_str ("user_def_cmd2" ))); +qmp_client_init (&client, dispatch_cmd_error_return); -qmp_dispatch (QOBJECT (req),NULL , dispatch_cmd_error_return,NULL ); +qdict_put_obj (req,"execute" ,QOBJECT (qstring_from_str ("user_def_cmd2" ))); +qmp_dispatch (&client,QOBJECT (req),NULL );QDECREF (req); + +qmp_client_destroy (&client); }static QObject *ret; -static void qmp_dispatch_return (QObject *resp_obj,void *opaque) +static void qmp_dispatch_return (QmpClient *client,QObject *resp_obj) {QDict *resp =qobject_to_qdict (resp_obj);assert (resp && !qdict_haskey (resp,"error" ));
@@ -125,7 +133,13 @@ static void qmp_dispatch_return(QObject *resp_obj, void *opaque)static QObject *test_qmp_dispatch (QDict *req) { -qmp_dispatch (QOBJECT (req),NULL , qmp_dispatch_return,NULL ); +QmpClient client; + +qmp_client_init (&client, qmp_dispatch_return); + +qmp_dispatch (&client,QOBJECT (req),NULL ); + +qmp_client_destroy (&client);return ret; }
@@ -243,7 +257,6 @@ static void test_dealloc_partial(void)qapi_free_UserDefTwo (ud2); } -int main (int argc,char **argv) {g_test_init (&argc, &argv,NULL );
Signature · 1 line
2.4.3
PATCH 25/36 qmp: introduce async command type
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Learn a new type of command, QmpCommandFuncAsync. They can return later thanks to QmpReturn. This commit introduces the new types and register functions.
--- include/qapi/qmp/dispatch.h | 5 +++++ qapi/qmp-dispatch.c | 3 +++ qapi/qmp-registry.c | 26 ++++++++++++++++++++++---- 3 files changed, 30 insertions(+), 4 deletions(-)
include/qapi/qmp/dispatch.h +5 -0
@@ -36,10 +36,12 @@ struct QmpClient { };typedef void (QmpCommandFunc )(QDict *,QObject **,Error **); +typedef void (QmpCommandFuncAsync )(QDict *,QmpReturn *);typedef enum QmpCommandType {QCT_NORMAL , +QCT_ASYNC , }QmpCommandType ; typedef enum QmpCommandOptions
@@ -53,6 +55,7 @@ typedef struct QmpCommandconst char *name;QmpCommandType type;QmpCommandFunc *fn; +QmpCommandFuncAsync *fn_async;QmpCommandOptions options;QTAILQ_ENTRY (QmpCommand) node;bool enabled;
@@ -60,6 +63,8 @@ typedef struct QmpCommandvoid qmp_register_command (const char *name,QmpCommandFunc *fn,QmpCommandOptions options); +void qmp_register_async_command (const char *name,QmpCommandFuncAsync *fn, +QmpCommandOptions options);QmpCommand *qmp_find_command (const char *name);void qmp_client_init (QmpClient *client,QmpDispatchReturn *return_cb);void qmp_client_destroy (QmpClient *client);
qapi/qmp-dispatch.c +3 -0
@@ -104,6 +104,9 @@ static QObject *do_qmp_dispatch(QObject *request, QmpReturn *qret, Error **errp) ret =QOBJECT (qdict_new ()); }break ; +case QCT_ASYNC : + cmd->fn_async (args, qret); +break ; }QDECREF (args);
qapi/qmp-registry.c +22 -4
@@ -19,17 +19,35 @@ static QTAILQ_HEAD(QmpCommandList, QmpCommand) qmp_commands =QTAILQ_HEAD_INITIALIZER (qmp_commands); -void qmp_register_command (const char *name,QmpCommandFunc *fn, -QmpCommandOptions options) +static QmpCommand *qmp_command_new (const char *name, +QmpCommandOptions options) {QmpCommand *cmd =g_malloc0 (sizeof (*cmd)); cmd->name = name; - cmd->type =QCT_NORMAL ; - cmd->fn = fn; cmd->enabled = true; cmd->options = options;QTAILQ_INSERT_TAIL (&qmp_commands, cmd, node); + +return cmd; +} + +void qmp_register_command (const char *name,QmpCommandFunc *fn, +QmpCommandOptions options) +{ +QmpCommand *cmd =qmp_command_new (name, options); + + cmd->type =QCT_NORMAL ; + cmd->fn = fn; +} + +void qmp_register_async_command (const char *name,QmpCommandFuncAsync *fn, +QmpCommandOptions options) +{ +QmpCommand *cmd =qmp_command_new (name, options); + + cmd->type =QCT_ASYNC ; + cmd->fn_async = fn; }QmpCommand *qmp_find_command (const char *name)
Signature · 1 line
2.4.3
PATCH 26/36 qmp: check that async command have an 'id'
In reply to [email protected]From: Marc-André Lureau <[email protected]>
The async support mandates that request have an 'id' (see documentation in following patch).
--- qapi/qmp-dispatch.c | 5 +++++ 1 file changed, 5 insertions(+)
qapi/qmp-dispatch.c +5 -0
@@ -105,6 +105,11 @@ static QObject *do_qmp_dispatch(QObject *request, QmpReturn *qret, Error **errp) }break ;case QCT_ASYNC : +if (!qdict_haskey (qret->rsp,"id" )) { +error_setg (errp,"An async command requires an 'id'" ); +break ; + } + cmd->fn_async (args, qret);break ; }
Signature · 1 line
2.4.3
PATCH 27/36 scripts: learn 'async' qapi commands
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Commands with the 'async' key will be registered as async type (see previous commit), and will allow a synchronous (in command cb) or asynchronous return (when ready, in idle etc).
Ex:
{ 'command': 'foo-async, 'data': {'arg': 'str'}, async: true }
--- qapi/introspect.json | 2 +- scripts/qapi-commands.py | 133 +++++++++++++++++++++++++++++++++-------- scripts/qapi-introspect.py | 7 ++- scripts/qapi.py | 14 +++-- tests/Makefile | 1 + tests/qapi-schema/async.err | 0 tests/qapi-schema/async.exit | 1 + tests/qapi-schema/async.json | 1 + tests/qapi-schema/async.out | 5 ++ tests/qapi-schema/test-qapi.py | 6 +- 10 files changed, 133 insertions(+), 37 deletions(-) create mode 100644 tests/qapi-schema/async.err create mode 100644 tests/qapi-schema/async.exit create mode 100644 tests/qapi-schema/async.json create mode 100644 tests/qapi-schema/async.out
qapi/introspect.json +1 -1
@@ -259,7 +259,7 @@ # Since: 2.5 ## { 'struct': 'SchemaInfoCommand', - 'data': { 'arg-type': 'str', 'ret-type': 'str' } } + 'data': { 'arg-type': 'str', 'ret-type': 'str', 'async': 'bool' } } ## # @SchemaInfoEvent
scripts/qapi-commands.py +107 -26
211 lines not on this page · raw message
scripts/qapi-introspect.py +5 -2
@@ -29,6 +29,8 @@ def to_json(obj, level=0): to_json(obj[key], level + 1)) for key in sorted(obj.keys())] ret = '{' + ', '.join(elts) + '}' + elif isinstance(obj, bool): + ret = 'true' if obj else 'false' else: assert False # not implemented if level == 1:
@@ -154,12 +156,13 @@ const char %(c_name)s[] = %(c_string)s; for m in variants.variants]}) def visit_command(self, name, info, arg_type, ret_type, - gen, success_response, box): + gen, success_response, box, async): arg_type = arg_type or self._schema.the_empty_object_type ret_type = ret_type or self._schema.the_empty_object_type self._gen_json(name, 'command', {'arg-type': self._use_type(arg_type), - 'ret-type': self._use_type(ret_type)}) + 'ret-type': self._use_type(ret_type), + 'async': async}) def visit_event(self, name, info, arg_type, box): arg_type = arg_type or self._schema.the_empty_object_type
scripts/qapi.py +9 -5
@@ -822,7 +822,8 @@ def check_exprs(exprs): add_struct(expr, info) elif 'command' in expr: check_keys(expr_elem, 'command', [], - ['data', 'returns', 'gen', 'success-response', 'box']) + ['data', 'returns', 'gen', 'success-response', 'box', + 'async']) add_name(expr['command'], info, 'command') elif 'event' in expr: check_keys(expr_elem, 'event', [], ['data', 'box'])
@@ -911,7 +912,7 @@ class QAPISchemaVisitor(object): pass def visit_command(self, name, info, arg_type, ret_type, - gen, success_response, box): + gen, success_response, box, async): pass def visit_event(self, name, info, arg_type, box):
@@ -1194,7 +1195,7 @@ class QAPISchemaAlternateType(QAPISchemaType): class QAPISchemaCommand(QAPISchemaEntity): def __init__(self, name, info, arg_type, ret_type, gen, success_response, - box): + box, async): QAPISchemaEntity.__init__(self, name, info) assert not arg_type or isinstance(arg_type, str) assert not ret_type or isinstance(ret_type, str)
@@ -1205,6 +1206,7 @@ class QAPISchemaCommand(QAPISchemaEntity): self.gen = gen self.success_response = success_response self.box = box + self.async = async def check(self, schema): if self._arg_type_name:
@@ -1219,7 +1221,8 @@ class QAPISchemaCommand(QAPISchemaEntity): def visit(self, visitor): visitor.visit_command(self.name, self._info, self.arg_type, self.ret_type, - self.gen, self.success_response, self.box) + self.gen, self.success_response, self.box, + self.async) class QAPISchemaEvent(QAPISchemaEntity):
@@ -1399,6 +1402,7 @@ class QAPISchema(object): data = expr.get('data') rets = expr.get('returns') gen = expr.get('gen', True) + async = expr.get('async', False) success_response = expr.get('success-response', True) box = expr.get('box', False) if isinstance(data, dict):
@@ -1410,7 +1414,7 @@ class QAPISchema(object): assert len(rets) == 1 rets = self._make_array_type(rets[0]) self._def_entity(QAPISchemaCommand(name, info, data, rets, gen, - success_response, box)) + success_response, box, async)) def _def_event(self, expr, info): name = expr['event']
tests/Makefile +1 -0
@@ -245,6 +245,7 @@ qapi-schema += args-member-unknown.json qapi-schema += args-name-clash.json qapi-schema += args-union.json qapi-schema += args-unknown.json +qapi-schema += async.json qapi-schema += bad-base.json qapi-schema += bad-data.json qapi-schema += bad-ident.json
tests/qapi-schema/async.err new file +0 -0
tests/qapi-schema/async.exit new file +1 -0
@@ -0,0 +1 @@ +0
tests/qapi-schema/async.json new file +1 -0
@@ -0,0 +1 @@ +{ 'command': 'screendump-async', 'data': {'filename': 'str'}, 'async': true }
tests/qapi-schema/async.out new file +5 -0
@@ -0,0 +1,5 @@ +object :empty +object :obj-screendump-async-arg + member filename: str optional=False +command screendump-async :obj-screendump-async-arg -> None + gen=True success_response=True box=False async
tests/qapi-schema/test-qapi.py +3 -3
@@ -36,11 +36,11 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor): self._print_variants(variants) def visit_command(self, name, info, arg_type, ret_type, - gen, success_response, box): + gen, success_response, box, async): print 'command %s %s -> %s' % \ (name, arg_type and arg_type.name, ret_type and ret_type.name) - print ' gen=%s success_response=%s box=%s' % (gen, success_response, - box) + print ' gen=%s success_response=%s box=%s%s' % \ + (gen, success_response, box, ' async' if async else '') def visit_event(self, name, info, arg_type, box): print 'event %s %s' % (name, arg_type and arg_type.name)
Signature · 1 line
2.4.3
PATCH 28/36 scripts: ensure -async commands are declared async
In reply to [email protected]From: Marc-André Lureau <[email protected]>
We could have arbitrary async command name, but it make sense to use a specific name to avoid confusion.
--- scripts/qapi.py | 1 + 1 file changed, 1 insertion(+)
scripts/qapi.py +1 -0
@@ -1209,6 +1209,7 @@ class QAPISchemaCommand(QAPISchemaEntity): self.async = async def check(self, schema): + assert self.name.endswith("-async") == self.async if self._arg_type_name: self.arg_type = schema.lookup_type(self._arg_type_name) assert isinstance(self.arg_type, QAPISchemaObjectType)
Signature · 1 line
2.4.3
PATCH 29/36 qapi: take 'id' from request
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Copy 'id' from request to reply dict. This can be done earlier, such as done by the monitor (because the qemu monitor may reply directly without qmp_dispatch), but is now done as well in qmp_dispatch() as convenience for other users such as QGA and tests.
--- qapi/qmp-dispatch.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
qapi/qmp-dispatch.c +10 -1
@@ -175,7 +175,8 @@ void qmp_dispatch(QmpClient *client, QObject *request, QDict *rsp) {Error *err =NULL ;QmpReturn *qret =g_new0 (QmpReturn,1 ); -QObject *ret; +QObject *ret, *id; +QDict *req;assert (client);
@@ -183,6 +184,14 @@ void qmp_dispatch(QmpClient *client, QObject *request, QDict *rsp) qret->client = client;QLIST_INSERT_HEAD (&client->pending, qret, link); + req =qobject_to_qdict (request); + id =qdict_get (req,"id" ); +if (id) { +qobject_incref (id); +qdict_del (req,"id" ); +qdict_put_obj (qret->rsp,"id" , id); + } + ret =do_qmp_dispatch (request, qret, &err);if (err) {
Signature · 1 line
2.4.3
PATCH 30/36 tests: change /0.15/* tests to /qmp/*
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Presumably 0.15 was the version it was first introduced, but qmp keeps evolving. There is no point in having that version has test prefix, qmp makes more sense.
--- tests/test-qmp-commands.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
tests/test-qmp-commands.c +5 -5
@@ -261,11 +261,11 @@ int main(int argc, char **argv) {g_test_init (&argc, &argv,NULL ); -g_test_add_func ("/0.15/dispatch_cmd" , test_dispatch_cmd); -g_test_add_func ("/0.15/dispatch_cmd_error" , test_dispatch_cmd_error); -g_test_add_func ("/0.15/dispatch_cmd_io" , test_dispatch_cmd_io); -g_test_add_func ("/0.15/dealloc_types" , test_dealloc_types); -g_test_add_func ("/0.15/dealloc_partial" , test_dealloc_partial); +g_test_add_func ("/qmp/dispatch_cmd" , test_dispatch_cmd); +g_test_add_func ("/qmp/dispatch_cmd_error" , test_dispatch_cmd_error); +g_test_add_func ("/qmp/dispatch_cmd_io" , test_dispatch_cmd_io); +g_test_add_func ("/qmp/dealloc_types" , test_dealloc_types); +g_test_add_func ("/qmp/dealloc_partial" , test_dealloc_partial);module_call_init (MODULE_INIT_QAPI );g_test_run ();
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH 30/36] tests: change /0.15/* tests to /qmp/*
Quoted 5 lines · On 09/25/2015 08:03 AM, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Presumably 0.15 was the version it was first introduced, but qmp keeps evolving. There is no point in having that version has test prefix, qmp makes more sense.
s/has/be the/
Quoted 5 lines
Signed-off-by Marc-André Lureau <[email protected]>--- tests/test-qmp-commands.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 31/36 tests: add /qmp/dispatch_cmd_async test
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Check that async disaptch works.
--- tests/qapi-schema/qapi-schema-test.json | 2 ++ tests/qapi-schema/qapi-schema-test.out | 5 +++ tests/test-qmp-commands.c | 61 +++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+)
tests/qapi-schema/qapi-schema-test.json +2 -0
@@ -107,6 +107,8 @@ { 'command': 'guest-sync', 'data': { 'arg': 'any' }, 'returns': 'any' } { 'command': 'boxed', 'box': true, 'data': 'UserDefZero' } { 'command': 'boxed2', 'data': 'UserDefNativeListUnion', 'box': true } +{ 'command': 'user-async', 'data': { 'a': 'int', '*b': 'int' }, + 'returns': 'UserDefB', 'async': true } # For testing integer range flattening in opts-visitor. The following schema # corresponds to the option format:
tests/qapi-schema/qapi-schema-test.out +5 -0
@@ -48,6 +48,9 @@ object :obj-uint64List-wrapper member data: uint64List optional=False object :obj-uint8List-wrapper member data: uint8List optional=False +object :obj-user-async-arg + member a: int optional=False + member b: int optional=True object :obj-user_def_cmd1-arg member ud1a: UserDefOne optional=False object :obj-user_def_cmd2-arg
@@ -196,6 +199,8 @@ command boxed2 UserDefNativeListUnion -> None gen=True success_response=True box=True command guest-sync :obj-guest-sync-arg -> any gen=True success_response=True box=False +command user-async :obj-user-async-arg -> UserDefB + gen=True success_response=True box=False async command user_def_cmd None -> None gen=True success_response=True box=False command user_def_cmd1 :obj-user_def_cmd1-arg -> None
tests/test-qmp-commands.c +61 -0
91 lines not on this page · raw message
Signature · 1 line
2.4.3
PATCH 32/36 qmp: update qmp-spec about async capability
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- docs/qmp/qmp-spec.txt | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
docs/qmp/qmp-spec.txt +15 -2
@@ -83,9 +83,22 @@ The greeting message format is: 2.2.1 Capabilities ------------------ -As of the date this document was last revised, no server or client -capability strings have been defined. +- "async" +If both the server and the client have the "async" capability, then +the client is allowed to send async commands. An async command is a +regular command with the "id" member mandatory (see 2.3), but the +response may be delayed. + +The client must match the incoming responses with the "id" member +associated with the command. + +The client is allowed to make requests while previous requests are +pending. The responses may come out of order. + +When a client is disconnected, the pending commands are not +necessarily cancelled. However, future clients will not get replies +from commands they didn't make. 2.3 Issuing Commands --------------------
Signature · 1 line
2.4.3
PATCH 33/36 monitor: add 'async' capability
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Existing clients may not handle async replies very well. In order to avoid the potential issues, let's introduce a capability that the client must declare in order to make use of async commands.
Eventually, client should already handle unexpected events after a command is sent, instead of the reply. It shouldn't be much more complicated to handle unmatched returns from previous async commands.
--- monitor.c | 28 ++++++++++++++++++++++++++-- qapi-schema.json | 16 ++++++++++++++-- 2 files changed, 40 insertions(+), 4 deletions(-)
monitor.c +26 -2
@@ -524,8 +524,31 @@ static void monitor_qapi_event_init(void)qmp_event_set_func_emit (monitor_qapi_event_queue); } -void qmp_qmp_capabilities (Error **errp) +static void disable_async (QmpCommand *cmd,void *opaque) { +if (cmd->type ==QCT_ASYNC ) { + cmd->enabled = FALSE; + } +} + +void qmp_qmp_capabilities (bool has_capabilities, +QMPCapabilityList *capabilities,Error **errp) +{ +bool has_async = false; + +if (has_capabilities) { +while (capabilities) { +if (capabilities->value ==QMP_CAPABILITY_ASYNC ) { + has_async = true; + } + capabilities = capabilities->next; + } + } + +if (!has_async) { +qmp_for_each_command (disable_async,NULL ); + } + cur_mon->qmp.in_command_mode = true; }
@@ -3694,7 +3717,8 @@ static QObject *get_qmp_greeting(void)assert (cmd && cmd->fn); cmd->fn (NULL , &ver,NULL ); -return qobject_from_jsonf ("{'QMP':{'version': %p,'capabilities': []}}" ,ver); +return qobject_from_jsonf ("{'QMP':{'version': %p,'capabilities': [" +"'async']}}" , ver); }static void monitor_qmp_event (void *opaque,int event)
qapi-schema.json +14 -2
@@ -70,11 +70,23 @@ # = QMP commands ## +# @QMPCapability +# +# QMP protocol capabilities +# +# @async: enables async messages +# +# Since: 2.5 +## +{ 'enum': 'QMPCapability', + 'data': ['async'] } + +## # @qmp_capabilities: # # Enable QMP capabilities. # -# Arguments: None. +# @capabilities: #optional an array of QMPCapability # # Example: #
@@ -84,7 +96,7 @@ # Notes: This command must be issued before issuing any other command. # ## -{ 'command': 'qmp_capabilities' } +{ 'command': 'qmp_capabilities', 'data': { '*capabilities': ['QMPCapability'] } } ## # @LostTickPolicy:
Signature · 1 line
2.4.3
PATCH 34/36 console: graphic_hw_update return true if async
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Let the caller know if the update is immediate or async.
--- hw/display/qxl-render.c | 5 +++-- hw/display/qxl.c | 8 ++++---- hw/display/qxl.h | 2 +- include/ui/console.h | 3 ++- ui/console.c | 14 ++++++++++++-- 5 files changed, 22 insertions(+), 10 deletions(-)
hw/display/qxl-render.c +3 -2
@@ -162,7 +162,7 @@ static void qxl_render_update_area_unlocked(PCIQXLDevice *qxl)* callbacks are called by spice_server thread, deferring to bh called from the * io thread. */ -void qxl_render_update (PCIQXLDevice *qxl) +bool qxl_render_update (PCIQXLDevice *qxl) {QXLCookie *cookie;
@@ -171,7 +171,7 @@ void qxl_render_update(PCIQXLDevice *qxl)if (!runstate_is_running () || !qxl->guest_primary.commands) {qxl_render_update_area_unlocked (qxl);qemu_mutex_unlock (&qxl->ssd.lock); -return ; +return false; } qxl->guest_primary.commands =0 ;
@@ -182,6 +182,7 @@ void qxl_render_update(PCIQXLDevice *qxl)qxl_set_rect_to_surface (qxl, &cookie->u.render.area);qxl_spice_update_area (qxl,0 , &cookie->u.render.area,NULL ,0 ,1 /* clear_dirty_region */ ,QXL_ASYNC , cookie); +return true; }void qxl_render_update_area_bh (void *opaque)
hw/display/qxl.c +4 -4
@@ -134,7 +134,7 @@ static void qxl_reset_memslots(PCIQXLDevice *d);static void qxl_reset_surfaces (PCIQXLDevice *d);static void qxl_ring_set_dirty (PCIQXLDevice *qxl); -static void qxl_hw_update (void *opaque); +static bool qxl_hw_update_async (void *opaque);void qxl_set_guest_bug (PCIQXLDevice *qxl,const char *msg, ...) {
@@ -1086,7 +1086,7 @@ static const QXLInterface qxl_interface = { };static const GraphicHwOps qxl_ops = { - .gfx_update = qxl_hw_update, + .gfx_update_async = qxl_hw_update_async, };static void qxl_enter_vga_mode (PCIQXLDevice *d)
@@ -1775,11 +1775,11 @@ static void qxl_send_events(PCIQXLDevice *d, uint32_t events)/* graphics console */ -static void qxl_hw_update (void *opaque) +static bool qxl_hw_update_async (void *opaque) {PCIQXLDevice *qxl = opaque; -qxl_render_update (qxl); +return qxl_render_update (qxl); }static void qxl_dirty_surfaces (PCIQXLDevice *qxl)
hw/display/qxl.h +1 -1
@@ -166,7 +166,7 @@ int qxl_log_command(PCIQXLDevice *qxl, const char *ring, QXLCommandExt *ext);/* qxl-render.c */ void qxl_render_resize (PCIQXLDevice *qxl); -void qxl_render_update (PCIQXLDevice *qxl); +bool qxl_render_update (PCIQXLDevice *qxl);int qxl_render_cursor (PCIQXLDevice *qxl,QXLCommandExt *ext);void qxl_render_update_area_done (PCIQXLDevice *qxl,QXLCookie *cookie);void qxl_render_update_area_bh (void *opaque);
include/ui/console.h +2 -1
@@ -297,6 +297,7 @@ static inline void console_write_ch(console_ch_t *dest, uint32_t ch) typedef struct GraphicHwOps { void (*invalidate)(void *opaque); void (*gfx_update)(void *opaque); + bool (*gfx_update_async)(void *opaque); void (*text_update)(void *opaque, console_ch_t *text); void (*update_interval)(void *opaque, uint64_t interval); int (*ui_info)(void *opaque, uint32_t head, QemuUIInfo *info);
@@ -309,7 +310,7 @@ void graphic_console_set_hwops(QemuConsole *con,const GraphicHwOps *hw_ops, void *opaque); -void graphic_hw_update (QemuConsole *con); +bool graphic_hw_update (QemuConsole *con);void graphic_hw_invalidate (QemuConsole *con);void graphic_hw_text_update (QemuConsole *con,console_ch_t *chardata);
ui/console.c +12 -2
@@ -250,14 +250,24 @@ static void gui_setup_refresh(DisplayState *ds) ds->have_text = have_text; } -void graphic_hw_update (QemuConsole *con) +bool graphic_hw_update (QemuConsole *con) {if (!con) { con = active_console; } -if (con && con->hw_ops->gfx_update) { + +if (!con) { +return false; + } + +if (con->hw_ops->gfx_update_async) { +return con->hw_ops->gfx_update_async (con->hw); + }else if (con->hw_ops->gfx_update) { con->hw_ops->gfx_update (con->hw); +return false; } + +return false; }void graphic_hw_invalidate (QemuConsole *con)
Signature · 1 line
2.4.3
PATCH 35/36 console: add graphic_hw_update_done()
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Add a function to be called when an async graphic update is done.
--- hw/display/qxl-render.c | 9 +++++++-- include/ui/console.h | 1 + ui/console.c | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-)
hw/display/qxl-render.c +7 -2
@@ -105,7 +105,7 @@ static void qxl_render_update_area_unlocked(PCIQXLDevice *qxl) qxl->guest_primary.surface.mem, MEMSLOT_GROUP_GUEST);if (!qxl->guest_primary.data) { -return ; + goto end; }qxl_set_rect_to_surface (qxl, &qxl->dirty[0 ]); qxl->num_dirty_rects =1 ;
@@ -133,7 +133,7 @@ static void qxl_render_update_area_unlocked(PCIQXLDevice *qxl) }if (!qxl->guest_primary.data) { -return ; + goto end; }for (i =0 ; i < qxl->num_dirty_rects; i++) {if (qemu_spice_rect_is_empty (qxl->dirty+i)) {
@@ -154,6 +154,11 @@ static void qxl_render_update_area_unlocked(PCIQXLDevice *qxl) qxl->dirty[i].bottom - qxl->dirty[i].top); } qxl->num_dirty_rects =0 ; + +end: +if (qxl->render_update_cookie_num ==0 ) { +graphic_hw_update_done (qxl->ssd.dcl.con); + } }/*
include/ui/console.h +1 -0
@@ -311,6 +311,7 @@ void graphic_console_set_hwops(QemuConsole *con, void *opaque);bool graphic_hw_update (QemuConsole *con); +void graphic_hw_update_done (QemuConsole *con);void graphic_hw_invalidate (QemuConsole *con);void graphic_hw_text_update (QemuConsole *con,console_ch_t *chardata);
ui/console.c +4 -0
@@ -250,6 +250,10 @@ static void gui_setup_refresh(DisplayState *ds) ds->have_text = have_text; } +void graphic_hw_update_done (QemuConsole *con) +{ +} +bool graphic_hw_update (QemuConsole *con) {if (!con) {
Signature · 1 line
2.4.3
PATCH 36/36 console: add screendump-async
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Learn a new async command to make a correct screendump.
Fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=1230527
--- qapi-schema.json | 21 +++++++++++++++++++- ui/console.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-)
qapi-schema.json +20 -1
@@ -3899,7 +3899,7 @@ ## # @screendump: # -# Write a PPM of the VGA screen to a file. +# Write a PPM of the first console to a file. # # @filename: the path of a new PPM file to store the image #
@@ -3916,6 +3916,25 @@ { 'command': 'screendump', 'data': {'filename': 'str'} } ## +# @screendump-async: +# +# Write a PPM of the first console to a file. +# +# @filename: the path of a new PPM file to store the image +# +# Returns: Nothing on success +# +# Since: 2.5 +# +# Example: +# +# -> { "execute": "screendump-async", "arguments": { "filename": "/tmp/image" }, id: X } +# <- { "return": {}, id: X } +# +## +{ 'command': 'screendump-async', 'data': {'filename': 'str'}, 'async': true } + +## # @ChardevFile: # # Configuration info for file chardevs.
ui/console.c +59 -0
97 lines not on this page · raw message
Signature · 1 line
2.4.3
Quoted 7 lines · On 09/25/2015 08:03 AM, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Hi,
I have grown a qapi branch during the past 2 months that was post-poned for review until the introspection and other fixes got merged or ready.
For other reviewer's convenience, it looks like this is at git fetch https://github.com/elmarco/qemu.git qapi
Quoted 2 lines
It could be splitted roughly in 3 parts, but since they depend on each
s/splitted/split/
Quoted 7 lines
other, it make sense to send as one:
1. generate QAPI documentation from schema (1->12)
2. remove use generated qmp dispatch in monitor (13->20)
3. add some support for async commands (22->36)1 and 2 are hopefully not controversial, however 3 was discussed previously in 'async commands with QMP' thread:
For today, I'm just doing a quick look over parts 1 and 2.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Hi
----- Original Message -----
Quoted 12 lines · On 09/25/2015 08:03 AM, [email protected] wrote:
Quoted 7 lines
From: Marc-André Lureau <[email protected]>
Hi,
I have grown a qapi branch during the past 2 months that was post-poned for review until the introspection and other fixes got merged or ready.
For other reviewer's convenience, it looks like this is at git fetch https://github.com/elmarco/qemu.git qapi
right, I just updated the branch with this latest series.
cheers
Quoted 8 lines · [email protected] writes:
From: Marc-André Lureau <[email protected]>
Hi,
I have grown a qapi branch during the past 2 months that was post-poned for review until the introspection and other fixes got merged or ready.
Quoted 8 lines
It could be splitted roughly in 3 parts, but since they depend on each other, it make sense to send as one:
1. generate QAPI documentation from schema (1->12)
2. remove use generated qmp dispatch in monitor (13->20)
3. add some support for async commands (22->36)1 and 2 are hopefully not controversial, however 3 was discussed previously in 'async commands with QMP' thread:
Parts 1 and 2 sound enticing!
Quoted 20 lines
QMP was initially designed with async support, but the implementation was buggy, since the async context didn't hold the request 'id', and thus it wasn't really used, so it was removed in
65207c59da few months ago.However, there a valid reasons to want better async support. Many qmp operations take time, and it's not a good idea to block the monitor during this time. Also, some operations, such as screendump with QXL, have to reenter the loop in order to complete. Furthermore, the current protocol is not purely synchronous, since the client have to handle unexpected in the middle replies, such as events.
The current status-quo for async commands is to return immediately, and send loosely related events later. This is quite poor from an API point of view, and the events are not related to a previous command (they don't hold the request 'id'). They are also broadcasted, which may not make sense to other clients for various commands (all the dump & query for example) and this prevent from adding meaningful client 'id' field (since it may conflict with other clients 'id').
Quoted 8 lines
I propose to re-introduce a better 'async' support, where command may return with the request 'id' only to the caller, when they are finished, and not block the monitor. This will be opt-out, so existing code do not have to change. Furthermore, since reply order is not guaranteed, clients will have to have the new 'async' capability to use those async commands. This scheme is not incompatible with having additional commands to query the command status, or broadcast related events to all clients.
This needs thought, and probably some debate.
With Eric's series and yours on top I'm again thoroughly swamped. My current idea to avoid despair and ensure progress is to doggedly review some patches every day, and not think about the length of the queue.
Unfortunately, that means it'll take me a while to reach part 3.