add direct support of event in qapi schema
Subsystems (2)
v6 cover add direct support of event in qapi schema
This series add support for tag/keyword 'event' in qapi-schema. A new file was created to store some helper functions in patch 2, patch 4 is the test case, patch 5 is a convert example.
The implemention is done by generate API and a batch of parameters for each event define, it doesn't generate a struture and visit function in the background for every event, so it doesn't support nested structure in the define to avoid trouble. A callback layer is added to control the behavior. More detail can be found in patch 3's message and incode comments.
v2:
Address Luiz's comments:
patch 3: rename *err to *local_err, do not initialize *qmp = NULL, create
a new function qmp_build_evet_dict().
Other change:
reorgnized script in patch 3, it have a clear three steps, see patch 3's
incode comments.
v3:
Address Luiz's comments:
2/5: use -1 when fail to get host timestamp.
3/5: typo fix and better incode comments. all unchanged functions are moved
into qmp-event.c, from generated file. To do so without include issue, 'int' was used intead of 'enum' in function prototype declaration, since the 'enum' define is a generated type.
Address Eric's comments:
2/5: use -1 when fail to get host timestamp.
3/5: typo fix, add docs/qapi-code-gen.txt.
4/5: typo fix, verify no other fields in member 'timestamp'. 5/5: add doc in qapi-schema.json.
fix license, all script using GPL2, all C code use LGPL, just as other
similar files in upstream.
v4:
Address Eric's comments:
2/5: typo fix, add copyright declaration, use a static function pointer
instead of a struct in C file, assign -1 in two line of codes to avoid issue when tv_sec and tv_usec are not in same data width, fix indention.
3/5: typo fix, add copyright declaration.
4/5: add copyright declaration, simplify string compare with
"d->result = g_strcmp0(...) == 0;", add check for tv_usec's range and value.
Other:
3/5: all error check code was moved from qapi-event.py to qapi.py, and it
reports better message with line number info. Added related test case.
Note:
Benoit's series which track input file better seems not the final version,
so I didn't rebase this series ontop for now, will do it once Benoit's ones get ACKed.
v5:
Address Eric and Markus's comments:
2/28: use uint64_t for both sec and usec, to avoid type cast issue in printf. Other:
Remove RFC, add full coversion by patch 5-28.
3/28: add prefix for event enum type name, to avoid double define of
QAPIEvent in test code.
v6:
Address Eric's comments:
3/29: employ modularization mechnism of schema file of Lluís series, removeerror_is_set() usage.
4/29: Makefile change for Lluís series.
5/29: separate patch for refactoring the existing schema defines, improve doc
for @service in VncBasicInfo.
7/29-28/29: define and convert event caller one by one.
Other change:
6/29: new way to add event emit implemention. In v5 it breaks old event
mechnism, in v6 it touch nothing of old event mechnism but add a new set of functions for new event mechnism.
7/29: Add new file qapi-event.json to store event defines, and all type
defines goes into qapi-schema.json.
29/29: related clean up change.
Note:
I have no way to verify target-s390x/kvm.c touched by patch 27/29, andblock/quorum.c touched by patch 28/29, need a confirm from whom has the test env.
Wenchao Xia (29):
1 os-posix: include sys/time.h
2 qapi: add event helper functions
3 qapi script: add event support
4 test: add test cases for qapi event
5 qapi: adjust existing defines
6 monitor: add an implemention as qapi event emit method 7 qapi: add new schema file qapi-event.json
8 qapi event: convert SHUTDOWN
9 qapi event: convert POWERDOWN
10 qapi event: convert RESET
11 qapi event: convert STOP
12 qapi event: convert RESUME
13 qapi event: convert SUSPEND
14 qapi event: convert SUSPEND_DISK
15 qapi event: convert WAKEUP
16 qapi event: convert RTC_CHANGE
17 qapi event: convert WATCHDOG
18 qapi event: convert DEVICE_DELETED
19 qapi event: convert DEVICE_TRAY_MOVED
20 qapi event: convert BLOCK_IO_ERROR and BLOCK_JOB_ERROR 21 qapi event: convert BLOCK_IMAGE_CORRUPTED
22 qapi event: convert other BLOCK_JOB events
23 qapi event: convert NIC_RX_FILTER_CHANGED
24 qapi event: convert VNC events
25 qapi event: convert SPICE events
26 qapi event: convert BALLOON_CHANGE
27 qapi event: convert GUEST_PANICKED
28 qapi event: convert QUORUM events
29 qapi event: clean up
Makefile | 21 +- Makefile.objs | 2 +- balloon.c | 13 - block.c | 68 +--- block/backup.c | 2 +- block/mirror.c | 9 +- block/qcow2-refcount.c | 14 +- block/quorum.c | 25 +- block/stream.c | 4 +- blockdev.c | 12 +- blockjob.c | 53 ++-- cpus.c | 5 +- docs/qapi-code-gen.txt | 18 + docs/qmp/qmp-events.txt | 541 ------------------------------ hmp.c | 5 +- hw/acpi/core.c | 4 +- hw/block/virtio-blk.c | 6 +- hw/core/qdev.c | 12 +- hw/ide/core.c | 6 +- hw/misc/pvpanic.c | 13 +- hw/net/virtio-net.c | 13 +- hw/ppc/spapr_rtas.c | 3 +- hw/scsi/scsi-disk.c | 6 +- hw/timer/mc146818rtc.c | 3 +- hw/virtio/virtio-balloon.c | 6 +- hw/watchdog/watchdog.c | 23 +- include/block/block.h | 4 - include/block/block_int.h | 3 - include/block/blockjob.h | 17 +- include/monitor/monitor.h | 40 --- include/qapi/qmp-event.h | 27 ++ include/qemu/sockets.h | 3 +- include/sysemu/balloon.h | 2 - include/sysemu/os-posix.h | 2 + include/sysemu/sysemu.h | 2 - monitor.c | 185 +++-------- qapi-event.json | 452 +++++++++++++++++++++++++ qapi-schema.json | 178 +++++++++-- qapi/Makefile.objs | 1 + qapi/qmp-event.c | 74 ++++ scripts/qapi-event.py | 369 ++++++++++++++++++++ scripts/qapi.py | 12 + stubs/Makefile.objs | 1 - stubs/mon-protocol-event.c | 6 - target-s390x/kvm.c | 8 +- tests/Makefile | 18 +- tests/qapi-schema/event-nest-struct.err | 1 + tests/qapi-schema/event-nest-struct.exit | 1 + tests/qapi-schema/event-nest-struct.json | 2 + tests/qapi-schema/qapi-schema-test.json | 12 + tests/qapi-schema/qapi-schema-test.out | 10 +- tests/test-qmp-event.c | 265 +++++++++++++++ trace-events | 4 + ui/spice-core.c | 77 +++-- ui/vnc.c | 120 ++++---- ui/vnc.h | 4 +- util/qemu-sockets.c | 10 +- vl.c | 22 +- 58 files changed, 1732 insertions(+), 1087 deletions(-) delete mode 100644 docs/qmp/qmp-events.txt create mode 100644 include/qapi/qmp-event.h create mode 100644 qapi-event.json create mode 100644 qapi/qmp-event.c create mode 100644 scripts/qapi-event.py delete mode 100644 stubs/mon-protocol-event.c create mode 100644 tests/qapi-schema/event-nest-struct.err create mode 100644 tests/qapi-schema/event-nest-struct.exit create mode 100644 tests/qapi-schema/event-nest-struct.json create mode 100644 tests/qapi-schema/event-nest-struct.out create mode 100644 tests/test-qmp-event.c
PATCH v6 1/29 os-posix: include sys/time.h
Since gettimeofday() is used in this header file as a macro define, include the function's define header file, to avoid compile warning when other file include os-posix.h.
--- include/sysemu/os-posix.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
include/sysemu/os-posix.h +2 -0
@@ -26,6 +26,8 @@#ifndef QEMU_OS_POSIX_H #define QEMU_OS_POSIX_H +#include <sys/time.h> +void os_set_line_buffering (void );void os_set_proc_name (const char *s);void os_setup_signal_handling (void );
Signature · 1 line
1.7.1
PATCH v6 2/29 qapi: add event helper functions
In reply to Wenchao XiaThis file holds some functions that do not need to be generated.
--- include/qapi/qmp-event.h | 27 +++++++++++++++++ qapi/Makefile.objs | 1 + qapi/qmp-event.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+), 0 deletions(-) create mode 100644 include/qapi/qmp-event.h create mode 100644 qapi/qmp-event.c
include/qapi/qmp-event.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* QMP Event related +* +* Copyright (c) 2014 Wenchao Xia +* +* Authors: +* Wenchao Xia <[email protected]> +* +* This work is licensed under the terms of the GNU LGPL, version 2.1 or later. +* See the COPYING.LIB file in the top-level directory. +* +*/ + +#ifndef QMP_EVENT_H +#define QMP_EVENT_H + +#include "qapi/error.h" +#include "qapi/qmp/qdict.h" + +typedef void (*QMPEventFuncEmit )(int event_kind,QDict *dict,Error **errp); + +void qmp_event_set_func_emit (QMPEventFuncEmit emit); + +QMPEventFuncEmit qmp_event_get_func_emit (void ); + +QDict *qmp_event_build_dict (const char *event_name); +#endif
qapi/Makefile.objs +1 -0
@@ -3,3 +3,4 @@ util-obj-y += qmp-output-visitor.o qmp-registry.o qmp-dispatch.o util-obj-y += string-input-visitor.o string-output-visitor.o util-obj-y += opts-visitor.o +util-obj-y += qmp-event.o
qapi/qmp-event.c new file +74 -0
74 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v6 3/29 qapi script: add event support
In reply to Wenchao Xiaqapi-event.py will parse the schema and generate qapi-event.c, then the API in qapi-event.c can be used to handle event in qemu code. All API have prefix "qapi_event".
The script mainly includes two parts: generate API for each event define, generate an enum type for all defined events.
Since in some cases the real emit behavior may change, for example, qemu-img would not send a event, a callback layer is used to control the behavior. As a result, the stubs at compile time can be saved, the binding of block layer code and monitor code will become looser.
--- Makefile | 11 +- Makefile.objs | 2 +- docs/qapi-code-gen.txt | 18 ++ scripts/qapi-event.py | 369 ++++++++++++++++++++++++++++++ scripts/qapi.py | 12 + tests/Makefile | 2 +- tests/qapi-schema/event-nest-struct.err | 1 + tests/qapi-schema/event-nest-struct.exit | 1 + tests/qapi-schema/event-nest-struct.json | 2 + 9 files changed, 413 insertions(+), 5 deletions(-) create mode 100644 scripts/qapi-event.py create mode 100644 tests/qapi-schema/event-nest-struct.err create mode 100644 tests/qapi-schema/event-nest-struct.exit create mode 100644 tests/qapi-schema/event-nest-struct.json create mode 100644 tests/qapi-schema/event-nest-struct.out
Makefile +8 -3
@@ -45,8 +45,8 @@ endif endif GENERATED_HEADERS = config-host.h qemu-options.def -GENERATED_HEADERS += qmp-commands.h qapi-types.h qapi-visit.h -GENERATED_SOURCES += qmp-marshal.c qapi-types.c qapi-visit.c +GENERATED_HEADERS += qmp-commands.h qapi-types.h qapi-visit.h qapi-event.h +GENERATED_SOURCES += qmp-marshal.c qapi-types.c qapi-visit.c qapi-event.c GENERATED_HEADERS += trace/generated-events.h GENERATED_SOURCES += trace/generated-events.c
@@ -202,7 +202,7 @@ Makefile: $(version-obj-y) $(version-lobj-y) # Build libraries libqemustub.a: $(stub-obj-y) -libqemuutil.a: $(util-obj-y) qapi-types.o qapi-visit.o +libqemuutil.a: $(util-obj-y) qapi-types.o qapi-visit.o qapi-event.o block-modules = $(foreach o,$(block-obj-m),"$(basename $(subst /,-,$o))",) NULL util/module.o-cflags = -D'CONFIG_BLOCK_MODULES=$(block-modules)'
@@ -256,6 +256,11 @@ $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \ $(gen-out-type) -o "." -b -i $<, \ " GEN $@") +qapi-event.c qapi-event.h :\ +$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-event.py $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-event.py \ + $(gen-out-type) -o "." -b -i $<, \ + " GEN $@") qmp-commands.h qmp-marshal.c :\ $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \
Makefile.objs +1 -1
@@ -12,7 +12,7 @@ block-obj-y += main-loop.o iohandler.o qemu-timer.o block-obj-$(CONFIG_POSIX) += aio-posix.o block-obj-$(CONFIG_WIN32) += aio-win32.o block-obj-y += block/ -block-obj-y += qapi-types.o qapi-visit.o +block-obj-y += qapi-types.o qapi-visit.o qapi-event.o block-obj-y += qemu-io-cmds.o block-obj-y += qemu-coroutine.o qemu-coroutine-lock.o qemu-coroutine-io.o
docs/qapi-code-gen.txt +18 -0
@@ -215,6 +215,24 @@ An example command is: 'data': { 'arg1': 'str', '*arg2': 'str' }, 'returns': 'str' } +=== Events === + +Events are defined with key word 'event'. When 'data' is also specified, +additional info will be carried on. Finally there will be C API generated +in qapi-event.h, and when called by QEMU code, a message with timestamp will +be emitted on the wire. If timestamp is -1, it means failure to retrieve host +time. + +An example event is: + +{ 'event': 'EVENT_C', + 'data': { '*a': 'int', 'b': 'str' } } + +Resulting in this JSON object: + +{ "event": "EVENT_C", + "data": { "b": "test string" }, + "timestamp": { "seconds": 1267020223, "microseconds": 435656 } } == Code generation ==
scripts/qapi-event.py new file +369 -0
369 lines not on this page · raw message
scripts/qapi.py +12 -0
@@ -248,6 +248,16 @@ def discriminator_find_enum_define(expr): return find_enum(discriminator_type) +def check_event(expr, expr_info): + params = expr.get('data') + if params: + for argname, argentry, optional, structured in parse_args(params): + if structured: + raise QAPIExprError(expr_info, + "Nested structure define in event is not " + "supported now, event '%s', argname '%s'" + % (expr['event'], argname)) + def check_union(expr, expr_info): name = expr['union'] base = expr.get('base')
@@ -311,6 +321,8 @@ def check_exprs(schema): expr = expr_elem['expr'] if expr.has_key('union'): check_union(expr, expr_elem['info']) + if expr.has_key('event'): + check_event(expr, expr_elem['info']) def parse_schema(input_file): try:
tests/Makefile +1 -1
@@ -198,7 +198,7 @@ check-qapi-schema-y := $(addprefix tests/qapi-schema/, \ include-simple.json include-relpath.json include-format-err.json \ include-non-file.json include-no-file.json include-before-err.json \ include-nested-err.json include-self-cycle.json include-cycle.json \ - include-repetition.json) + include-repetition.json event-nest-struct.json) GENERATED_HEADERS += tests/test-qapi-types.h tests/test-qapi-visit.h tests/test-qmp-commands.h
tests/qapi-schema/event-nest-struct.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/event-nest-struct.json:1: Nested structure define in event is not supported now, event 'EVENT_A', argname 'a'
tests/qapi-schema/event-nest-struct.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/event-nest-struct.json new file +2 -0
@@ -0,0 +1,2 @@ +{ 'event': 'EVENT_A', + 'data': { 'a' : { 'string' : 'str', 'integer': 'int' }, 'b' : 'str' } }
tests/qapi-schema/event-nest-struct.out new file +0 -0
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH V6 03/29] qapi script: add event support
Quoted 2 lines · Wenchao Xia
qapi-event.pywill parse the schema and generateqapi-event.c, then the API inqapi-event.ccan be used to handle event in qemu code.
s/event in/events in/
Quoted 12 lines
All API have prefix "
qapi_event".The script mainly includes two parts: generate API for each event define, generate an enum type for all defined events.
Since in some cases the real emit behavior may change, for example, qemu-img would not send a event, a callback layer is used to control the behavior. As a result, the stubs at compile time can be saved, the binding of block layer code and monitor code will become looser.
Signed-off-by Wenchao Xia <[email protected]>
Quoted 16 lines
--- Makefile | 11 +- Makefile.objs | 2 +- docs/qapi-code-gen.txt | 18 ++ scripts/qapi-event.py | 369 ++++++++++++++++++++++++++++++ scripts/qapi.py | 12 + tests/Makefile | 2 +- tests/qapi-schema/event-nest-struct.err | 1 + tests/qapi-schema/event-nest-struct.exit | 1 + tests/qapi-schema/event-nest-struct.json | 2 + 9 files changed, 413 insertions(+), 5 deletions(-) create mode 100644 scripts/qapi-event.py create mode 100644 tests/qapi-schema/event-nest-struct.err create mode 100644 tests/qapi-schema/event-nest-struct.exit create mode 100644 tests/qapi-schema/event-nest-struct.json create mode 100644 tests/qapi-schema/event-nest-struct.out
My python is weak, but I did apply this patch (or rather, used Paolo's rebase of this patch) to test the generated files.
At this point, I'm interested in seeing the series go in sooner rather than later, and my findings below are minor enough that I'm okay fixing them in a followup patch rather than waiting for a respin of the whole series.
Your patch fails to update .gitignore for the new generated files:
Untracked files:
(use "git add <file>..." to include in what will be committed)
qapi-event.c
qapi-event.h
docs/qapi-code-gen.txt An example command is: · line 221
Quoted 5 lines
+=== Events ===
docs/qapi-code-gen.txt +3
-0+ +Events are defined with key word 'event'. When 'data' is also specified, +additional info will be carried on. Finally there will be C API generated
s/carried on/included in the event/
scripts/qapi-event.py line 20
Quoted 4 lines
+++
b/scripts/qapi-event.pyscripts/qapi-event.py new file +3
-0+ +def _generate_event_api_name(event_name, params): + api_name = "void qapi_event_send_%s(" % c_fun(event_name).lower();
As of this commit, no events using qapi_event_send are generated yet. I'm trusting that this code works, but I reserve the right to revisit this patch later once I look at later patches and see what the generated code is doing there. But for now, the generated code has merely:
const char *QAPIEvent_lookup[] = {
NULL,
};
which looks correct, even if a bit sparse :)
scripts/qapi.py def discriminator_find_enum_define(expr): · line 258
Quoted 13 lines
+++
b/scripts/qapi.pyscripts/qapi.py +8
-0@@ -248,6 +248,16 @@ def discriminator_find_enum_define(expr): return find_enum(discriminator_type) +def check_event(expr, expr_info): + params = expr.get('data') + if params: + for argname, argentry, optional, structured in parse_args(params): + if structured: + raise QAPIExprError(expr_info, + "Nested structure define in event is not " + "supported now, event '%s', argname '%s'"
s/ now// - we don't EVER want to support nested structures in events (for that matter, I've been arguing in other threads that we want to completely ditch support for nested structures to simplify the generator code-base and make it possible to cleanly support argument defaults).
tests/qapi-schema/event-nest-struct.err line 1
Quoted 3 lines
tests/qapi-schema/event-nest-struct.err new file +2
-0+++ b/tests/qapi-schema/event-nest-struct.err@@ -0,0 +1 @@ +tests/qapi-schema/event-nest-struct.json:1: Nested structure define in event is not supported now, event 'EVENT_A', argname 'a'
Of course, if you tweak the message above, you'll also have to tweak this test. But thanks for adding a test!
Since I'm okay saving the cleanups mentioned above for a followup-patch, and assuming I don't revisit this file:
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH V6 03/29] qapi script: add event support
In reply to Wenchao XiaQuoted 4 lines · Wenchao Xia
qapi-event.pywill parse the schema and generateqapi-event.c, then the API inqapi-event.ccan be used to handle event in qemu code. All API have prefix "qapi_event".
As promised, a revisit of the generator code now that I've looked at more of it in use. And since I've identified enough elsewhere that warrants a series respin to v7, you should squash in fixes for these issues:
scripts/qapi-event.py line 48
Quoted 5 lines
+++
b/scripts/qapi-event.pyscripts/qapi-event.py new file +3
-0+ +def generate_event_implement(api_name, event_name, params): + # step 1: declare and variables
s/and/any/
Review
Quoted 2 lines
(quoted diff) +2
-0+ + /* Fake visit, as if all member are under a structure */
s/member/members/
See also my comments on 16/29 - what if you change the generator to use &error_abort instead of futzing around with local_error? After all, the qmp_output_visitor doesn't ever set errp; and all of your callers silently ignore errp even if it were to be set. Which makes sense, since events are best-effort anyways (it's not like you are building up a reply to a synchronous command, so you really don't have anyone to inform about the failed event short of sending yet another event - but if the first event failed, then your attempt to send another event to inform about the failure is probably doomed).
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH V6 03/29] qapi script: add event support
In reply to Wenchao XiaQuoted 16 lines · Wenchao Xia
qapi-event.pywill parse the schema and generateqapi-event.c, then the API inqapi-event.ccan be used to handle event in qemu code. All API have prefix "qapi_event".The script mainly includes two parts: generate API for each event define, generate an enum type for all defined events.
Since in some cases the real emit behavior may change, for example, qemu-img would not send a event, a callback layer is used to control the behavior. As a result, the stubs at compile time can be saved, the binding of block layer code and monitor code will become looser.
+++
b/scripts/qapi-event.py
scripts/qapi-event.py line 10
Quoted 10 lines
scripts/qapi-event.py new file +10
-0@@ -0,0 +1,369 @@ +# +# QAPI event generator +# +# Copyright (c) 2014 Wenchao Xia +# +# Authors: +# Wenchao Xia <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2. +# See the COPYING file in the top-level directory.
Any reason this can't be GPLv2+ instead of GPLv2-only?
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH V6 03/29] qapi script: add event support
Il 18/06/2014 05:33, Eric Blake ha scritto:
Quoted 3 lines
Quoted 2 lines
scripts/qapi-event.py line 10
Quoted 2 lines
scripts/qapi-event.py new file +2
-0+# This work is licensed under the terms of the GNU GPL, version 2. +# See the COPYING file in the top-level directory.Any reason this can't be GPLv2+ instead of GPLv2-only?
I suppose because it copies parts of other qapi-* scripts. :(
Paolo
Re: [Qemu-devel] [PATCH V6 03/29] qapi script: add event support
Quoted 8 lines · Paolo Bonzini
Il 18/06/2014 05:33, Eric Blake ha scritto:
Quoted 3 lines
Quoted 2 lines
scripts/qapi-event.py line 10
Quoted 2 lines
scripts/qapi-event.py new file +2
-0+# This work is licensed under the terms of the GNU GPL, version 2. +# See the COPYING file in the top-level directory.Any reason this can't be GPLv2+ instead of GPLv2-only?
I suppose because it copies parts of other qapi-* scripts. :(
Paolo
Yes, feel free to change the license.
Re: [Qemu-devel] [PATCH V6 03/29] qapi script: add event support
In reply to Wenchao XiaQuoted 11 lines · Wenchao Xia
qapi-event.pywill parse the schema and generateqapi-event.c, then the API inqapi-event.ccan be used to handle event in qemu code. All API have prefix "qapi_event".The script mainly includes two parts: generate API for each event define, generate an enum type for all defined events.
scripts/qapi-event.py new file +3
-0+def _generate_event_api_name(event_name, params): + api_name = "void qapi_event_send_%s(" % c_fun(event_name).lower(); + l = len(api_name)
scripts/qapi-event.py line 31
Quoted 10 lines
scripts/qapi-event.py new file +10
-0+ + if params: + for argname, argentry, optional, structured in parse_args(params): + if optional: + api_name += "bool has_%s,\n" % c_var(argname) + api_name += "".ljust(l) + + if argentry == "str": + api_name += "const " + api_name += "%s %s,\n" % (c_type(argentry), c_var(argname))
This may need to be rebased or have a followup patch based on Amos' work:
https://lists.gnu.org/archive/html/qemu-devel/2014-06/msg02387.html
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v6 4/29 test: add test cases for qapi event
In reply to Wenchao XiaThese cases will verify whether the expected qdict is built.
--- tests/Makefile | 16 ++- tests/qapi-schema/qapi-schema-test.json | 12 ++ tests/qapi-schema/qapi-schema-test.out | 10 +- tests/test-qmp-event.c | 265 +++++++++++++++++++++++++++++++ 4 files changed, 298 insertions(+), 5 deletions(-) create mode 100644 tests/test-qmp-event.c
tests/Makefile +13 -3
@@ -27,6 +27,8 @@ check-unit-y += tests/test-string-input-visitor$(EXESUF) gcov-files-test-string-input-visitor-y = qapi/string-input-visitor.c check-unit-y += tests/test-string-output-visitor$(EXESUF) gcov-files-test-string-output-visitor-y = qapi/string-output-visitor.c +check-unit-y += tests/test-qmp-event$(EXESUF) +gcov-files-test-qmp-event-y += qapi/qmp-event.c check-unit-y += tests/test-opts-visitor$(EXESUF) gcov-files-test-opts-visitor-y = qapi/opts-visitor.c check-unit-y += tests/test-coroutine$(EXESUF)
@@ -200,7 +202,8 @@ check-qapi-schema-y := $(addprefix tests/qapi-schema/, \ include-nested-err.json include-self-cycle.json include-cycle.json \ include-repetition.json event-nest-struct.json) -GENERATED_HEADERS += tests/test-qapi-types.h tests/test-qapi-visit.h tests/test-qmp-commands.h +GENERATED_HEADERS += tests/test-qapi-types.h tests/test-qapi-visit.h \ + tests/test-qmp-commands.h tests/test-qapi-event.h test-obj-y = tests/check-qint.o tests/check-qstring.o tests/check-qdict.o \ tests/check-qlist.o tests/check-qfloat.o tests/check-qjson.o \
@@ -209,9 +212,10 @@ test-obj-y = tests/check-qint.o tests/check-qstring.o tests/check-qdict.o \ tests/test-qmp-input-visitor.o tests/test-qmp-input-strict.o \ tests/test-qmp-commands.o tests/test-visitor-serialization.o \ tests/test-x86-cpuid.o tests/test-mul64.o tests/test-int128.o \ - tests/test-opts-visitor.o + tests/test-opts-visitor.o tests/test-qmp-event.o -test-qapi-obj-y = tests/test-qapi-visit.o tests/test-qapi-types.o +test-qapi-obj-y = tests/test-qapi-visit.o tests/test-qapi-types.o \ + tests/test-qapi-event.o $(test-obj-y): QEMU_INCLUDES += -Itests QEMU_CFLAGS += -I$(SRC_PATH)/tests
@@ -263,9 +267,15 @@ $(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-com $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \ $(gen-out-type) -o tests -p "test-" -i $<, \ " GEN $@") +tests/test-qapi-event.c tests/test-qapi-event.h :\ +$(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-event.py + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-event.py \ + $(gen-out-type) -o tests -p "test-" -i $<, \ + " GEN $@") tests/test-string-output-visitor$(EXESUF): tests/test-string-output-visitor.o $(test-qapi-obj-y) libqemuutil.a libqemustub.a tests/test-string-input-visitor$(EXESUF): tests/test-string-input-visitor.o $(test-qapi-obj-y) libqemuutil.a libqemustub.a +tests/test-qmp-event$(EXESUF): tests/test-qmp-event.o $(test-qapi-obj-y) libqemuutil.a libqemustub.a tests/test-qmp-output-visitor$(EXESUF): tests/test-qmp-output-visitor.o $(test-qapi-obj-y) libqemuutil.a libqemustub.a tests/test-qmp-input-visitor$(EXESUF): tests/test-qmp-input-visitor.o $(test-qapi-obj-y) libqemuutil.a libqemustub.a tests/test-qmp-input-strict$(EXESUF): tests/test-qmp-input-strict.o $(test-qapi-obj-y) libqemuutil.a libqemustub.a
tests/qapi-schema/qapi-schema-test.json +12 -0
@@ -89,3 +89,15 @@ '*u16' : [ 'uint16' ], '*i64x': 'int' , '*u64x': 'uint64' } } + +# testing event +{ 'type': 'EventStructOne', + 'data': { 'struct1': 'UserDefOne', 'string': 'str', '*enum2': 'EnumOne' } } + +{ 'event': 'EVENT_A' } +{ 'event': 'EVENT_B', + 'data': { } } +{ 'event': 'EVENT_C', + 'data': { '*a': 'int', '*b': 'UserDefOne', 'c': 'str' } } +{ 'event': 'EVENT_D', + 'data': { 'a' : 'EventStructOne', 'b' : 'str', '*c': 'str', '*enum3': 'EnumOne' } }
tests/qapi-schema/qapi-schema-test.out +8 -2
@@ -15,7 +15,12 @@ OrderedDict([('command', 'user_def_cmd1'), ('data', OrderedDict([('ud1a', 'UserDefOne')]))]), OrderedDict([('command', 'user_def_cmd2'), ('data', OrderedDict([('ud1a', 'UserDefOne'), ('*ud1b', 'UserDefOne')])), ('returns', 'UserDefTwo')]), OrderedDict([('command', 'user_def_cmd3'), ('data', OrderedDict([('a', 'int'), ('*b', 'int')])), ('returns', 'int')]), - OrderedDict([('type', 'UserDefOptions'), ('data', OrderedDict([('*i64', ['int']), ('*u64', ['uint64']), ('*u16', ['uint16']), ('*i64x', 'int'), ('*u64x', 'uint64')]))])] + OrderedDict([('type', 'UserDefOptions'), ('data', OrderedDict([('*i64', ['int']), ('*u64', ['uint64']), ('*u16', ['uint16']), ('*i64x', 'int'), ('*u64x', 'uint64')]))]), + OrderedDict([('type', 'EventStructOne'), ('data', OrderedDict([('struct1', 'UserDefOne'), ('string', 'str'), ('*enum2', 'EnumOne')]))]), + OrderedDict([('event', 'EVENT_A')]), + OrderedDict([('event', 'EVENT_B'), ('data', OrderedDict())]), + OrderedDict([('event', 'EVENT_C'), ('data', OrderedDict([('*a', 'int'), ('*b', 'UserDefOne'), ('c', 'str')]))]), + OrderedDict([('event', 'EVENT_D'), ('data', OrderedDict([('a', 'EventStructOne'), ('b', 'str'), ('*c', 'str'), ('*enum3', 'EnumOne')]))])] [{'enum_name': 'EnumOne', 'enum_values': ['value1', 'value2', 'value3']}, {'enum_name': 'UserDefUnionKind', 'enum_values': None}, {'enum_name': 'UserDefAnonUnionKind', 'enum_values': None},
@@ -28,4 +33,5 @@ OrderedDict([('type', 'UserDefA'), ('data', OrderedDict([('boolean', 'bool')]))]), OrderedDict([('type', 'UserDefB'), ('data', OrderedDict([('integer', 'int')]))]), OrderedDict([('type', 'UserDefUnionBase'), ('data', OrderedDict([('string', 'str'), ('enum1', 'EnumOne')]))]), - OrderedDict([('type', 'UserDefOptions'), ('data', OrderedDict([('*i64', ['int']), ('*u64', ['uint64']), ('*u16', ['uint16']), ('*i64x', 'int'), ('*u64x', 'uint64')]))])] + OrderedDict([('type', 'UserDefOptions'), ('data', OrderedDict([('*i64', ['int']), ('*u64', ['uint64']), ('*u16', ['uint16']), ('*i64x', 'int'), ('*u64x', 'uint64')]))]), + OrderedDict([('type', 'EventStructOne'), ('data', OrderedDict([('struct1', 'UserDefOne'), ('string', 'str'), ('*enum2', 'EnumOne')]))])]
tests/test-qmp-event.c new file +265 -0
265 lines not on this page · raw message
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH V6 04/29] test: add test cases for qapi event
Quoted 13 lines · Wenchao Xia
These cases will verify whether the expected qdict is built.
Signed-off-by Wenchao Xia <[email protected]>--- tests/Makefile | 16 ++- tests/qapi-schema/qapi-schema-test.json | 12 ++ tests/qapi-schema/qapi-schema-test.out | 10 +- tests/test-qmp-event.c | 265 +++++++++++++++++++++++++++++++ 4 files changed, 298 insertions(+), 5 deletions(-) create mode 100644 tests/test-qmp-event.c
Review
Quoted 2 lines
(quoted diff) +2
-0+ + /* Verify that we have timestamp, then remove it to compare other field */
s/field/fields/
Minor enough to include that as part of your followup patch to the whole series.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v6 5/29 qapi: adjust existing defines
In reply to Wenchao XiaIn order to let event defines use existing types later, instead of redefine new ones, some old type defines for spice and vnc are changed, and BlockErrorAction is moved from block.h to qapi schema. Note that BlockErrorAction is not merged with BlockdevOnError.
One thing not perfect is that, VncInfo should be foldered but may break API stability.
--- block.c | 17 ++++--- block/backup.c | 2 +- block/mirror.c | 7 ++- block/stream.c | 4 +- blockjob.c | 11 ++-- hmp.c | 5 +- hw/block/virtio-blk.c | 6 +- hw/ide/core.c | 6 +- hw/scsi/scsi-disk.c | 6 +- include/block/block.h | 4 -- include/qemu/sockets.h | 2 + qapi-schema.json | 126 ++++++++++++++++++++++++++++++++++++++---------- ui/spice-core.c | 7 ++- ui/vnc.c | 9 ++-- util/qemu-sockets.c | 10 ++++ 15 files changed, 156 insertions(+), 66 deletions(-)
block.c +9 -8
@@ -2140,13 +2140,13 @@ void bdrv_emit_qmp_error_event(const BlockDriverState *bdrv,const char *action_str;switch (action) { -case BDRV_ACTION_REPORT : +case BLOCK_ERROR_ACTION_REPORT : action_str ="report" ;break ; -case BDRV_ACTION_IGNORE : +case BLOCK_ERROR_ACTION_IGNORE : action_str ="ignore" ;break ; -case BDRV_ACTION_STOP : +case BLOCK_ERROR_ACTION_STOP : action_str ="stop" ;break ;default :
@@ -3599,13 +3599,14 @@ BlockErrorAction bdrv_get_error_action(BlockDriverState *bs, bool is_read, int eswitch (on_err) {case BLOCKDEV_ON_ERROR_ENOSPC : -return (error ==ENOSPC ) ?BDRV_ACTION_STOP :BDRV_ACTION_REPORT ; +return (error ==ENOSPC ) ? +BLOCK_ERROR_ACTION_STOP :BLOCK_ERROR_ACTION_REPORT ;case BLOCKDEV_ON_ERROR_STOP : -return BDRV_ACTION_STOP ; +return BLOCK_ERROR_ACTION_STOP ;case BLOCKDEV_ON_ERROR_REPORT : -return BDRV_ACTION_REPORT ; +return BLOCK_ERROR_ACTION_REPORT ;case BLOCKDEV_ON_ERROR_IGNORE : -return BDRV_ACTION_IGNORE ; +return BLOCK_ERROR_ACTION_IGNORE ;default :abort (); }
@@ -3620,7 +3621,7 @@ void bdrv_error_action(BlockDriverState *bs, BlockErrorAction action, {assert (error >=0 );bdrv_emit_qmp_error_event (bs,QEVENT_BLOCK_IO_ERROR , action, is_read); -if (action ==BDRV_ACTION_STOP ) { +if (action ==BLOCK_ERROR_ACTION_STOP ) {vm_stop (RUN_STATE_IO_ERROR );bdrv_iostatus_set_err (bs, error); }
block/backup.c +1 -1
@@ -325,7 +325,7 @@ static void coroutine_fn backup_run(void *opaque)/* Depending on error action, fail now or retry cluster */ BlockErrorAction action =backup_error_action (job, error_is_read, -ret); -if (action ==BDRV_ACTION_REPORT ) { +if (action ==BLOCK_ERROR_ACTION_REPORT ) {break ; }else { start--;
block/mirror.c +4 -3
@@ -118,7 +118,7 @@ static void mirror_write_complete(void *opaque, int ret)bdrv_set_dirty (source, op->sector_num, op->nb_sectors); action =mirror_error_action (s, false, -ret); -if (action ==BDRV_ACTION_REPORT && s->ret >=0 ) { +if (action ==BLOCK_ERROR_ACTION_REPORT && s->ret >=0 ) { s->ret = ret; } }
@@ -135,7 +135,7 @@ static void mirror_read_complete(void *opaque, int ret)bdrv_set_dirty (source, op->sector_num, op->nb_sectors); action =mirror_error_action (s, true, -ret); -if (action ==BDRV_ACTION_REPORT && s->ret >=0 ) { +if (action ==BLOCK_ERROR_ACTION_REPORT && s->ret >=0 ) { s->ret = ret; }
@@ -415,7 +415,8 @@ static void coroutine_fn mirror_run(void *opaque)trace_mirror_before_flush (s); ret =bdrv_flush (s->target);if (ret <0 ) { -if (mirror_error_action (s, false, -ret) ==BDRV_ACTION_REPORT ) { +if (mirror_error_action (s, false, -ret) == +BLOCK_ERROR_ACTION_REPORT ) { goto immediate_exit; } }else {
block/stream.c +2 -2
@@ -159,14 +159,14 @@ wait:BlockErrorAction action =block_job_error_action (&s->common, s->common.bs, s->on_error, true, -ret); -if (action ==BDRV_ACTION_STOP ) { +if (action ==BLOCK_ERROR_ACTION_STOP ) { n =0 ;continue ; }if (error ==0 ) { error = ret; } -if (action ==BDRV_ACTION_REPORT ) { +if (action ==BLOCK_ERROR_ACTION_REPORT ) {break ; } }
blockjob.c +6 -5
@@ -262,22 +262,23 @@ BlockErrorAction block_job_error_action(BlockJob *job, BlockDriverState *bs,switch (on_err) {case BLOCKDEV_ON_ERROR_ENOSPC : - action = (error ==ENOSPC ) ?BDRV_ACTION_STOP :BDRV_ACTION_REPORT ; + action = (error ==ENOSPC ) ? +BLOCK_ERROR_ACTION_STOP :BLOCK_ERROR_ACTION_REPORT ;break ;case BLOCKDEV_ON_ERROR_STOP : - action =BDRV_ACTION_STOP ; + action =BLOCK_ERROR_ACTION_STOP ;break ;case BLOCKDEV_ON_ERROR_REPORT : - action =BDRV_ACTION_REPORT ; + action =BLOCK_ERROR_ACTION_REPORT ;break ;case BLOCKDEV_ON_ERROR_IGNORE : - action =BDRV_ACTION_IGNORE ; + action =BLOCK_ERROR_ACTION_IGNORE ;break ;default :abort (); }bdrv_emit_qmp_error_event (job->bs,QEVENT_BLOCK_JOB_ERROR , action, is_read); -if (action ==BDRV_ACTION_STOP ) { +if (action ==BLOCK_ERROR_ACTION_STOP ) {block_job_pause (job);block_job_iostatus_set_err (job, error);if (bs != job->bs) {
hmp.c +3 -2
@@ -463,7 +463,8 @@ void hmp_info_vnc(Monitor *mon, const QDict *qdict)for (client = info->clients; client; client = client->next) {monitor_printf (mon,"Client:\n" );monitor_printf (mon," address: %s:%s\n" , - client->value->host, client->value->service); + client->value->base->host, + client->value->base->service);monitor_printf (mon," x509_dname: %s\n" , client->value->x509_dname ? client->value->x509_dname :"none" );
@@ -511,7 +512,7 @@ void hmp_info_spice(Monitor *mon, const QDict *qdict)for (chan = info->channels; chan; chan = chan->next) {monitor_printf (mon,"Channel:\n" );monitor_printf (mon," address: %s:%s%s\n" , - chan->value->host, chan->value->port, + chan->value->base->host, chan->value->base->port, chan->value->tls ?" [tls]" :"" );monitor_printf (mon," session: %" PRId64"\n" , chan->value->connection_id);
hw/block/virtio-blk.c +3 -3
@@ -57,17 +57,17 @@ static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error,BlockErrorAction action =bdrv_get_error_action (req->dev->bs, is_read, error);VirtIOBlock *s = req->dev; -if (action ==BDRV_ACTION_STOP ) { +if (action ==BLOCK_ERROR_ACTION_STOP ) { req->next = s->rq; s->rq = req; - }else if (action ==BDRV_ACTION_REPORT ) { + }else if (action ==BLOCK_ERROR_ACTION_REPORT ) {virtio_blk_req_complete (req,VIRTIO_BLK_S_IOERR );bdrv_acct_done (s->bs, &req->acct);g_free (req); }bdrv_error_action (s->bs, action, is_read, error); -return action !=BDRV_ACTION_IGNORE ; +return action !=BLOCK_ERROR_ACTION_IGNORE ; }static void virtio_blk_rw_complete (void *opaque,int ret)
hw/ide/core.c +3 -3
@@ -596,10 +596,10 @@ static int ide_handle_rw_error(IDEState *s, int error, int op)bool is_read = (op &BM_STATUS_RETRY_READ ) !=0 ;BlockErrorAction action =bdrv_get_error_action (s->bs, is_read, error); -if (action ==BDRV_ACTION_STOP ) { +if (action ==BLOCK_ERROR_ACTION_STOP ) { s->bus->dma->ops->set_unit (s->bus->dma, s->unit); s->bus->error_status = op; - }else if (action ==BDRV_ACTION_REPORT ) { + }else if (action ==BLOCK_ERROR_ACTION_REPORT ) {if (op &BM_STATUS_DMA_RETRY ) {dma_buf_commit (s);ide_dma_error (s);
@@ -608,7 +608,7 @@ static int ide_handle_rw_error(IDEState *s, int error, int op) } }bdrv_error_action (s->bs, action, is_read, error); -return action !=BDRV_ACTION_IGNORE ; +return action !=BLOCK_ERROR_ACTION_IGNORE ; }void ide_dma_cb (void *opaque,int ret)
hw/scsi/scsi-disk.c +3 -3
@@ -419,7 +419,7 @@ static int scsi_handle_rw_error(SCSIDiskReq *r, int error)SCSIDiskState *s =DO_UPCAST (SCSIDiskState, qdev, r->req.dev);BlockErrorAction action =bdrv_get_error_action (s->qdev.conf.bs, is_read, error); -if (action ==BDRV_ACTION_REPORT ) { +if (action ==BLOCK_ERROR_ACTION_REPORT ) {switch (error) {case ENOMEDIUM :scsi_check_condition (r,SENSE_CODE (NO_MEDIUM ));
@@ -439,10 +439,10 @@ static int scsi_handle_rw_error(SCSIDiskReq *r, int error) } }bdrv_error_action (s->qdev.conf.bs, action, is_read, error); -if (action ==BDRV_ACTION_STOP ) { +if (action ==BLOCK_ERROR_ACTION_STOP ) {scsi_req_retry (&r->req); } -return action !=BDRV_ACTION_IGNORE ; +return action !=BLOCK_ERROR_ACTION_IGNORE ; }static void scsi_write_complete (void * opaque,int ret)
include/block/block.h +0 -4
@@ -150,10 +150,6 @@ typedef enum {#define BDRV_BLOCK_ALLOCATED 0x10#define BDRV_BLOCK_OFFSET_MASK BDRV_SECTOR_MASK -typedef enum { -BDRV_ACTION_REPORT ,BDRV_ACTION_IGNORE ,BDRV_ACTION_STOP -}BlockErrorAction ; - typedef QSIMPLEQ_HEAD(BlockReopenQueue, BlockReopenQueueEntry) BlockReopenQueue; typedef struct BDRVReopenState {
include/qemu/sockets.h +2 -0
@@ -29,6 +29,7 @@ int inet_aton(const char *cp, struct in_addr *ia);#include "qemu/option.h" #include "qapi/error.h" #include "qapi/qmp/qerror.h" +#include "qapi-types.h" extern QemuOptsList socket_optslist;
@@ -61,6 +62,7 @@ int inet_nonblocking_connect(const char *str,int inet_dgram_opts (QemuOpts *opts,Error **errp);const char *inet_strfamily (int family); +NetworkAddressFamily inet_netfamily (int family);int unix_listen_opts (QemuOpts *opts,Error **errp);int unix_listen (const char *path,char *ostr,int olen,Error **errp);
qapi-schema.json +101 -25
167 lines not on this page · raw message
ui/spice-core.c +4 -3
@@ -391,15 +391,16 @@ static SpiceChannelList *qmp_query_spice_channels(void) chan =g_malloc0 (sizeof (*chan)); chan->value =g_malloc0 (sizeof (*chan->value)); + chan->value->base =g_malloc0 (sizeof (*chan->value->base)); paddr = (struct sockaddr *)&item->info->paddr_ext; plen = item->info->plen_ext;getnameinfo (paddr, plen, host,sizeof (host), port,sizeof (port),NI_NUMERICHOST |NI_NUMERICSERV ); - chan->value->host =g_strdup (host); - chan->value->port =g_strdup (port); - chan->value->family =g_strdup (inet_strfamily (paddr->sa_family)); + chan->value->base->host =g_strdup (host); + chan->value->base->port =g_strdup (port); + chan->value->base->family =inet_netfamily (paddr->sa_family); chan->value->connection_id = item->info->connection_id; chan->value->channel_type = item->info->type;
ui/vnc.c +5 -4
@@ -321,9 +321,10 @@ static VncClientInfo *qmp_query_vnc_client(const VncState *client) } info =g_malloc0 (sizeof (*info)); - info->host =g_strdup (host); - info->service =g_strdup (serv); - info->family =g_strdup (inet_strfamily (sa.ss_family)); + info->base =g_malloc0 (sizeof (*info->base)); + info->base->host =g_strdup (host); + info->base->service =g_strdup (serv); + info->base->family =inet_netfamily (sa.ss_family);#ifdef CONFIG_VNC_TLS if (client->tls.session && client->tls.dname) {
@@ -398,7 +399,7 @@ VncInfo *qmp_query_vnc(Error **errp) info->service =g_strdup (serv); info->has_family = true; - info->family =g_strdup (inet_strfamily (sa.ss_family)); + info->family =inet_netfamily (sa.ss_family); info->has_auth = true; info->auth =g_strdup (vnc_auth_name (vnc_display));
util/qemu-sockets.c +10 -0
@@ -104,6 +104,16 @@ const char *inet_strfamily(int family)return "unknown" ; } +NetworkAddressFamily inet_netfamily (int family) +{ +switch (family) { +case PF_INET6 :return NETWORK_ADDRESS_FAMILY_IPV6 ; +case PF_INET :return NETWORK_ADDRESS_FAMILY_IPV4 ; +case PF_UNIX :return NETWORK_ADDRESS_FAMILY_UNIX ; + } +return NETWORK_ADDRESS_FAMILY_UNKNOWN ; +} +int inet_listen_opts (QemuOpts *opts,int port_offset,Error **errp) {struct addrinfo ai,*res,*e;
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH V6 05/29] qapi: adjust existing defines
Quoted 4 lines · Wenchao Xia
In order to let event defines use existing types later, instead of redefine new ones, some old type defines for spice and vnc are changed, and BlockErrorAction is moved from
block.hto qapi schema. Note that BlockErrorAction is not merged with BlockdevOnError.
If you were to respin this, I'd split it into two - one part moving BlockErrorAction from block.h into the schema, and the other tweaking spice and vnc schema members. But at this point, I'm more interested in getting it into the tree than worrying about another round of delays for a respin.
Quoted 2 lines
One thing not perfect is that, VncInfo should be foldered but may break
s/that,/that/
"foldered" is not a word, but off-hand I have no idea what you meant. [1]
Quoted 16 lines
API stability.
Signed-off-by Wenchao Xia <[email protected]>--- block.c | 17 ++++--- block/backup.c | 2 +- block/mirror.c | 7 ++- block/stream.c | 4 +- blockjob.c | 11 ++-- hmp.c | 5 +- hw/block/virtio-blk.c | 6 +- hw/ide/core.c | 6 +- hw/scsi/scsi-disk.c | 6 +- include/block/block.h | 4 -- include/qemu/sockets.h | 2 + qapi-schema.json | 126 ++++++++++++++++++++++++++++++++++++++----------
Of course, some of this is in qapi/block-core.json now; but Paolo's rebased series picked up on that.
Quoted 19 lines
ui/spice-core.c | 7 ++- ui/vnc.c | 9 ++-- util/qemu-sockets.c | 10 ++++ 15 files changed, 156 insertions(+), 66 deletions(-)+++
b/qapi-schema.jsonqapi-schema.json +5
-2@@ -1163,21 +1163,59 @@ { 'command': 'query-blockstats', 'returns': ['BlockStats'] } ## -# @VncClientInfo: +# @NetworkAddressFamily # -# Information about a connected VNC client. +# The network address family +# +# @ipv4: IPV4 family +#
qapi-schema.json line 1181
Quoted 10 lines
qapi-schema.json +10
-0+# @ipv6: IPV6 family +# +# @unix: unix socket +# +# @unknown: otherwise +# +# Since: 2.1 +## +{ 'enum': 'NetworkAddressFamily', + 'data': [ 'ipv4', 'ipv6', 'unix', 'unknown' ] }
Nice. Conversion of 'str' to 'NetworkAddressFamily' has no impact to the on-the-wire format, but makes us have better type safety.
Quoted 8 lines
qapi-schema.json +4
-2+ +## +# @VncBasicInfo # -# @host: The host name of the client. QEMU tries to resolve this to a DNS name -# when possible. +# The basic information for vnc network connection #
qapi-schema.json line 1190
Quoted 10 lines
qapi-schema.json +2
-7-# @family: 'ipv6' if the client is connected via IPv6 and TCP -# 'ipv4' if the client is connected via IPv4 and TCP -# 'unix' if the client is connected via a unix domain socket -# 'unknown' otherwise +# @host: IP address # -# @service: The service name of the client's port. This may depends on the -# host system's service database so symbolic names should not be -# relied on. +# @service: The service name of vnc port. This may depend on the host system's
s/of/of the/
Quoted 7 lines
qapi-schema.json +7
-0+# service database so symbolic names should not be relied on. +# +# @family: address family +# +# Since: 2.1 +## +{ 'type': 'VncBasicInfo',
qapi-schema.json line 1207
Quoted 10 lines
qapi-schema.json +10
-0+ 'data': { 'host': 'str', + 'service': 'str', + 'family': 'NetworkAddressFamily' } } + +## +# @VncServerInfo +# +# The network connection information for server +# +# @auth: #optional, authentication method
I wonder if this parameter should eventually be converted to an enum rather than open-coded str, but that doesn't need to happen right away.
Quoted 15 lines
qapi-schema.json +11
-0+# +# Since: 2.1 +## +{ 'type': 'VncServerInfo', + 'base': 'VncBasicInfo', + 'data': { '*auth': 'str' } } + +## +# @VncClientInfo: +# +# Information about a connected VNC client. # # @x509_dname: #optional If x509 authentication is in use, the Distinguished # Name of the client.
qapi-schema.json line 1230
Quoted 7 lines
qapi-schema.json +2
-2@@ -1188,8 +1226,8 @@ # Since: 0.14.0 ## { 'type': 'VncClientInfo', - 'data': {'host': 'str', 'family': 'str', 'service': 'str', - '*x509_dname': 'str', '*sasl_username': 'str'} } + 'base': 'VncBasicInfo', + 'data': { '*x509_dname' : 'str', '*sasl_username': 'str' } }
Spurious addition of spaces; s/ :/:/ in your cleanup patch.
qapi-schema.json line 1271
Quoted 11 lines
qapi-schema.json +2
-1## # @VncInfo:@@ -1228,7 +1266,8 @@ # Since: 0.14.0 ## { 'type': 'VncInfo', - 'data': {'enabled': 'bool', '*host': 'str', '*family': 'str', + 'data': {'enabled': 'bool', '*host': 'str', + '*family': 'NetworkAddressFamily', '*service': 'str', '*auth': 'str', '*clients': ['VncClientInfo']} }
[1] Okay, I think I see what you meant in your commit message. You did NOT convert 'VncInfo' to use 'VncBasicInfo' as a base class, because you were worried about whether it would break things. And your worry is justified - VncBasicInfo marks 'host', 'family', and 'service' as manadatory, while 'VncInfo' marks them as optional.
If VncInfo is only used on the output side of commands (which indeed appears to be the case - it is only used as the return of 'query-vnc'), then converting from optional to mandatory is fine from the backwards-compatibility aspect; the only question is whether the existing code for query-vnc has sane defaults for those three fields in the case where it was previously omitting them. If you choose to make that change, do it as a followup patch. This patch is fine. And now that I understand your concern, I'd rewrite that paragraph in the commit message to this (and either Paolo can rebase it back into his github tree, or whoever applies the patches can make the tweak when adding my R-b):
At this point, VncInfo is not made a child of VncBasicInfo, due to the difference in mandatory vs. optional parameters.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v6 6/29 monitor: add an implemention as qapi event emit method
In reply to Wenchao XiaNow monitor has been hooked on the new event mechanism, so the patches later can convert event callers one by one. Most code are copied from old monitor_protocol_* functions with some modification.
Note that two build time warnings will be raised after this patch. One is caused by no caller of monitor_qapi_event_throttle(), the other one is caused by QAPI_EVENT_MAX = 0. They will be fixed automatically after full event conversion later.
--- monitor.c | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- trace-events | 4 ++ 2 files changed, 131 insertions(+), 1 deletions(-)
monitor.c +127 -1
@@ -69,6 +69,8 @@#include "qmp-commands.h" #include "hmp.h" #include "qemu/thread.h" +#include "qapi/qmp-event.h" +#include "qapi-event.h" /* for pic/irq_info */ #if defined(TARGET_SPARC )
@@ -185,6 +187,14 @@ typedef struct MonitorEventState {QObject *data;/* Event pending delayed dispatch */ } MonitorEventState; +typedef struct MonitorQAPIEventState { +QAPIEvent event;/* Event being tracked */ +int64_t rate;/* Period over which to throttle. 0 to disable */ +int64_t last;/* Time at which event was last emitted */ +QEMUTimer *timer;/* Timer for handling delayed events */ +QObject *data;/* Event pending delayed dispatch */ +}MonitorQAPIEventState ; +struct Monitor {CharDriverState *chr;int mux_out;
@@ -489,6 +499,122 @@ static const char *monitor_event_names[] = { QEMU_BUILD_BUG_ON(ARRAY_SIZE(monitor_event_names) != QEVENT_MAX)static MonitorEventState monitor_event_state[QEVENT_MAX ]; +static MonitorQAPIEventState monitor_qapi_event_state[QAPI_EVENT_MAX ]; + +/* +* Emits the event to every monitor instance, @event is only used for trace +*/ +static void monitor_qapi_event_emit (QAPIEvent event,QObject *data) +{ +Monitor *mon; + +trace_monitor_qapi_event_emit (event, data); + QLIST_FOREACH(mon, &mon_list, entry) { +if (monitor_ctrl_mode (mon) &&qmp_cmd_mode (mon)) { +monitor_json_emitter (mon, data); + } + } +} + +/* +* Queue a new event for emission to Monitor instances, +* applying any rate limiting if required. +*/ +static void +monitor_qapi_event_queue (int event_kind,QDict *data,Error **errp) +{ +MonitorQAPIEventState *evstate; +assert (event_kind <QAPI_EVENT_MAX ); +QAPIEvent event = (QAPIEvent )event_kind; +int64_t now =qemu_clock_get_ns (QEMU_CLOCK_REALTIME ); + + evstate = &(monitor_qapi_event_state[event]); +trace_monitor_qapi_event_queue (event, + data, + evstate->rate, + evstate->last, + now); + +/* Rate limit of 0 indicates no throttling */ +if (!evstate->rate) { +monitor_qapi_event_emit (event,QOBJECT (data)); + evstate->last = now; + }else { +int64_t delta = now - evstate->last; +if (evstate->data || + delta < evstate->rate) { +/* If there's an existing event pending, replace +* it with the new event, otherwise schedule a +* timer for delayed emission +*/ +if (evstate->data) { +qobject_decref (evstate->data); + }else { +int64_t then = evstate->last + evstate->rate; +timer_mod_ns (evstate->timer, then); + } + evstate->data =QOBJECT (data); +qobject_incref (evstate->data); + }else { +monitor_qapi_event_emit (event,QOBJECT (data)); + evstate->last = now; + } + } +} + +/* +* The callback invoked by QemuTimer when a delayed +* event is ready to be emitted +*/ +static void monitor_qapi_event_handler (void *opaque) +{ +MonitorQAPIEventState *evstate = opaque; +int64_t now =qemu_clock_get_ns (QEMU_CLOCK_REALTIME ); + + +trace_monitor_qapi_event_handler (evstate->event, + evstate->data, + evstate->last, + now); +if (evstate->data) { +monitor_qapi_event_emit (evstate->event, evstate->data); +qobject_decref (evstate->data); + evstate->data =NULL ; + } + evstate->last = now; +} + +/* +* @event: the event ID to be limited +* @rate: the rate limit in milliseconds +* +* Sets a rate limit on a particular event, so no +* more than 1 event will be emitted within @rate +* milliseconds +*/ +static void monitor_qapi_event_throttle (QAPIEvent event,int64_t rate) +{ +MonitorQAPIEventState *evstate; +assert (event <QAPI_EVENT_MAX ); + + evstate = &(monitor_qapi_event_state[event]); + +trace_monitor_qapi_event_throttle (event, rate); + evstate->event = event; + evstate->rate = rate *SCALE_MS ; + evstate->last =0 ; + evstate->data =NULL ; + evstate->timer =timer_new (QEMU_CLOCK_REALTIME , +SCALE_MS , + monitor_qapi_event_handler, + evstate); +} + +static void monitor_qapi_event_init (void ) +{ +qmp_event_set_func_emit (monitor_qapi_event_queue); +} +/* * Emits the event to every monitor instance
@@ -507,7 +633,6 @@ monitor_protocol_event_emit(MonitorEvent event, } } -/* * Queue a new event for emission to Monitor instances, * applying any rate limiting if required.
@@ -5169,6 +5294,7 @@ void monitor_init(CharDriverState *chr, int flags)if (is_first_init) {monitor_protocol_event_init (); +monitor_qapi_event_init ();sortcmdlist (); is_first_init =0 ; }
trace-events +4 -0
@@ -932,6 +932,10 @@ monitor_protocol_event_handler(uint32_t event, void *data, uint64_t last, uint64 monitor_protocol_event_emit(uint32_t event, void *data) "event=%d data=%p" monitor_protocol_event_queue(uint32_t event, void *data, uint64_t rate, uint64_t last, uint64_t now) "event=%d data=%p rate=%" PRId64 " last=%" PRId64 " now=%" PRId64 monitor_protocol_event_throttle(uint32_t event, uint64_t rate) "event=%d rate=%" PRId64 +monitor_qapi_event_emit(uint32_t event, void *data) "event=%d data=%p" +monitor_qapi_event_queue(uint32_t event, void *data, uint64_t rate, uint64_t last, uint64_t now) "event=%d data=%p rate=%" PRId64 " last=%" PRId64 " now=%" PRId64 +monitor_qapi_event_handler(uint32_t event, void *data, uint64_t last, uint64_t now) "event=%d data=%p last=%" PRId64 " now=%" PRId64 +monitor_qapi_event_throttle(uint32_t event, uint64_t rate) "event=%d rate=%" PRId64 # hw/net/opencores_eth.c open_eth_mii_write(unsigned idx, uint16_t v) "MII[%02x] <- %04x"
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH V6 06/29] monitor: add an implemention as qapi event emit method
On 06/05/2014 06:22 AM, Wenchao Xia wrote:
In the subject: s/as/of/
Quoted 1 line
Now monitor has been hooked on the new event mechanism, so the patches
s/Now/The/
Quoted 1 line
later can convert event callers one by one. Most code are copied from
s/the patches later/that later patches/
s/are/is/
Quoted 6 lines
old monitor_protocol_* functions with some modification.
Note that two build time warnings will be raised after this patch. One is caused by no caller of
monitor_qapi_event_throttle(), the other one is caused byQAPI_EVENT_MAX= 0. They will be fixed automatically after full event conversion later.
I only got one of those two warnings, about the unused function. What compiler and options are you using to get a warning about QAPI_EVENT_MAX?. Furthermore, since the default 'configure' turns warnings into errors, this would be a build-breaker that hurts 'git bisect'. I think it's easy enough to avoid, if you would please squash this in:
monitor.c +1 -0
@@ -594,6 +594,7 @@ static void monitor_qapi_event_handler(void *opaque)* more than 1 event will be emitted within @rate * milliseconds */ +__attribute__((unused))/* FIXME remove once in use */ static void monitor_qapi_event_throttle (QAPIEvent event,int64_t rate) {MonitorQAPIEventState *evstate;
You can then remove that attribute later in 29/29 when you delete everything else about the older implementation.
At this point, I think we're racking up enough fixes to be worth a v7 respin (particularly since avoiding 'git bisect' breakage cannot be done as a followup patch, but has to be done in-place in the series).
Review
Quoted 13 lines
Signed-off-by Wenchao Xia <[email protected]>--- monitor.c | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- trace-events | 4 ++ 2 files changed, 131 insertions(+), 1 deletions(-)(quoted diff) +4
-0+typedef struct MonitorQAPIEventState { + QAPIEvent event; /* Event being tracked */ + int64_t rate; /* Period over which to throttle. 0 to disable */ + int64_t last; /* Time at which event was last emitted */
in what unit? [1]...
Review
Quoted 2 lines
(quoted diff) +2
-0+ QEMUTimer *timer; /* Timer for handling delayed events */ + QObject *data; /* Event pending delayed dispatch */
Any reason the comments aren't aligned?
Review static const char *monitor_event_names[] = { · line 502
Quoted 10 lines
(quoted diff) +3
-0+} MonitorQAPIEventState; + struct Monitor { CharDriverState *chr; int mux_out;@@ -489,6 +499,122 @@ static const char *monitor_event_names[] = { QEMU_BUILD_BUG_ON(ARRAY_SIZE(monitor_event_names) != QEVENT_MAX) static MonitorEventState monitor_event_state[QEVENT_MAX]; +static MonitorQAPIEventState monitor_qapi_event_state[QAPI_EVENT_MAX];
If you are still seeing a compiler warning about allocating an array of size 0, you could likewise try this hack:
/* FIXME Hack a minimum array size until we have events */ static MonitorQAPIEventState monitor_qapi_event_state[QAPI_EVENT_MAX + !QAPI_EVENT_MAX];
and likewise clean that up in 29/29
Review static const char *monitor_event_names[] = { · line 504
Quoted 2 lines
(quoted diff) +2
-0+static void +monitor_qapi_event_queue(int event_kind, QDict *data, Error **errp)
This is not the usual formatting in qemu.
Review static const char *monitor_event_names[] = { · line 507
Quoted 3 lines
(quoted diff) +3
-0+{ + MonitorQAPIEventState *evstate; + assert(event_kind < QAPI_EVENT_MAX);
This doesn't filter out negative values for event_kind. Is it worth the extra paranoia to either make event_kind unsigned, or to assert that event_kind >= 0?
Review static const char *monitor_event_names[] = { · line 508
Quoted 1 line
(quoted diff) +1
-0+ QAPIEvent event = (QAPIEvent)event_kind;
Why are we casting here? Would it not make more sense to change the signature in patch 2/29 to use the enum type from the get-go?
typedef void (*QMPEventFuncEmit)(QAPIEvent event_kind, QDict *dict, Error **errp);
and adjust the signature of this function to match
Review static const char *monitor_event_names[] = { · line 509
Quoted 1 line
(quoted diff) +1
-0+ int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
...[1] okay, it looks like 'rate' and 'last' are specified in nanoseconds. Worth documenting in their declaration above. Particularly since [1]...
Review static const char *monitor_event_names[] = { · line 516
Quoted 7 lines
(quoted diff) +7
-0+static void monitor_qapi_event_handler(void *opaque) +{ + MonitorQAPIEventState *evstate = opaque; + int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); + + + trace_monitor_qapi_event_handler(evstate->event,
Why the double blank line?
Review static const char *monitor_event_names[] = { · line 526
Quoted 10 lines
(quoted diff) +10
-0+ +/* + * @event: the event ID to be limited + * @rate: the rate limit in milliseconds + * + * Sets a rate limit on a particular event, so no + * more than 1 event will be emitted within @rate + * milliseconds + */ +static void monitor_qapi_event_throttle(QAPIEvent event, int64_t rate)
...[1] this function is documented in milliseconds, not nanoseconds, and you are scaling internally.
Review static const char *monitor_event_names[] = { · line 535
Quoted 9 lines
(quoted diff) +9
-0+{ + MonitorQAPIEventState *evstate; + assert(event < QAPI_EVENT_MAX); + + evstate = &(monitor_qapi_event_state[event]); + + trace_monitor_qapi_event_throttle(event, rate); + evstate->event = event; + evstate->rate = rate * SCALE_MS;
This value can overflow if a user passes in an insanely large rate. Do we care?
Review monitor_protocol_event_emit(MonitorEvent event, · line 636
Quoted 13 lines
(quoted diff) +6
-1+ evstate->last = 0; + evstate->data = NULL; + evstate->timer = timer_new(QEMU_CLOCK_REALTIME, + SCALE_MS, + monitor_qapi_event_handler, + evstate);@@ -507,7 +633,6 @@ monitor_protocol_event_emit(MonitorEvent event, } } - /*
Why the spurious line deletion?
Review monitor_protocol_event_handler(uint32_t event, void *data, uint64_t last, uint64 · line 938
Quoted 9 lines
(quoted diff) +5
-0+++ b/trace-events@@ -932,6 +932,10 @@ monitor_protocol_event_handler(uint32_t event, void *data, uint64_t last, uint64 monitor_protocol_event_emit(uint32_t event, void *data) "event=%d data=%p" monitor_protocol_event_queue(uint32_t event, void *data, uint64_t rate, uint64_t last, uint64_t now) "event=%d data=%p rate=%" PRId64 " last=%" PRId64 " now=%" PRId64 monitor_protocol_event_throttle(uint32_t event, uint64_t rate) "event=%d rate=%" PRId64 +monitor_qapi_event_emit(uint32_t event, void *data) "event=%d data=%p" +monitor_qapi_event_queue(uint32_t event, void *data, uint64_t rate, uint64_t last, uint64_t now) "event=%d data=%p rate=%" PRId64 " last=%" PRId64 " now=%" PRId64 +monitor_qapi_event_handler(uint32_t event, void *data, uint64_t last, uint64_t now) "event=%d data=%p last=%" PRId64 " now=%" PRId64 +monitor_qapi_event_throttle(uint32_t event, uint64_t rate) "event=%d rate=%" PRId64
Any reason you wanted to invent four new trace names, even though the existing 4 traces have the same signatures? I'm wondering whether it would have just been better to use the old trace names.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH V6 06/29] monitor: add an implemention as qapi event emit method
Quoted 21 lines · Eric Blake
On 06/05/2014 06:22 AM, Wenchao Xia wrote:
In the subject: s/as/of/
Quoted 1 line
Now monitor has been hooked on the new event mechanism, so the patches
s/Now/The/
Quoted 1 line
later can convert event callers one by one. Most code are copied from
s/the patches later/that later patches/
s/are/is/
Quoted 6 lines
old monitor_protocol_* functions with some modification.
Note that two build time warnings will be raised after this patch. One is caused by no caller of
monitor_qapi_event_throttle(), the other one is caused byQAPI_EVENT_MAX= 0. They will be fixed automatically after full event conversion later.
Quoted 7 lines
I only got one of those two warnings, about the unused function. What compiler and options are you using to get a warning about
QAPI_EVENT_MAX?. Furthermore, since the default 'configure' turns warnings into errors, this would be a build-breaker that hurts 'git bisect'. I think it's easy enough to avoid, if you would please squash this in:
The QAPI_EVENT_MAX = 0 cause a warning for code:
monitor_qapi_event_throttle(QAPIEvent event, int64_t rate)
{
....
assert(event < QAPI_EVENT_MAX);
}which is always false now. Perhaps change it as
assert((int)event < QAPI_EVENT_MAX);
?
Quoted 14 lines
monitor.c +1
-0@@ -594,6 +594,7 @@ static void monitor_qapi_event_handler(void *opaque)* more than 1 event will be emitted within @rate * milliseconds */ +__attribute__((unused))/* FIXME remove once in use */ static void monitor_qapi_event_throttle (QAPIEvent event,int64_t rate) {MonitorQAPIEventState *evstate;
Quoted 7 lines
You can then remove that attribute later in 29/29 when you delete everything else about the older implementation.
At this point, I think we're racking up enough fixes to be worth a v7 respin (particularly since avoiding 'git bisect' breakage cannot be done as a followup patch, but has to be done in-place in the series).
Thanks for tipping, it is a good way to go.
Quoted 14 lines
Review
Quoted 13 lines
Signed-off-by Wenchao Xia <[email protected]>--- monitor.c | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- trace-events | 4 ++ 2 files changed, 131 insertions(+), 1 deletions(-)(quoted diff) +4
-0+typedef struct MonitorQAPIEventState { + QAPIEvent event; /* Event being tracked */ + int64_t rate; /* Period over which to throttle. 0 to disable */ + int64_t last; /* Time at which event was last emitted */
Quoted 6 lines
in what unit? [1]...
Review
Quoted 2 lines
(quoted diff) +2
-0+ QEMUTimer *timer; /* Timer for handling delayed events */ + QObject *data; /* Event pending delayed dispatch */Any reason the comments aren't aligned?
Will fix.
Quoted 19 lines
Review static const char *monitor_event_names[] = { · line 502
Quoted 11 lines
(quoted diff) +3
-0+} MonitorQAPIEventState; + struct Monitor { CharDriverState *chr; int mux_out;@@ -489,6 +499,122 @@ static const char *monitor_event_names[] = { QEMU_BUILD_BUG_ON(ARRAY_SIZE(monitor_event_names) != QEVENT_MAX) static MonitorEventState monitor_event_state[QEVENT_MAX]; +static MonitorQAPIEventState monitor_qapi_event_state[QAPI_EVENT_MAX];If you are still seeing a compiler warning about allocating an array of size 0, you could likewise try this hack:
/* FIXME Hack a minimum array size until we have events */ static MonitorQAPIEventState monitor_qapi_event_state[QAPI_EVENT_MAX + !QAPI_EVENT_MAX];
Quoted 6 lines
and likewise clean that up in 29/29
Review static const char *monitor_event_names[] = { · line 504
Quoted 2 lines
(quoted diff) +2
-0+static void +monitor_qapi_event_queue(int event_kind, QDict *data, Error **errp)This is not the usual formatting in qemu.
Fixing it.
Quoted 9 lines
Review static const char *monitor_event_names[] = { · line 507
Quoted 4 lines
(quoted diff) +3
-0+{ + MonitorQAPIEventState *evstate; + assert(event_kind < QAPI_EVENT_MAX);This doesn't filter out negative values for
event_kind. Is it worth the extra paranoia to either makeevent_kindunsigned, or to assert thatevent_kind>= 0?
Build waring will be raised for QAPI_EVENT_MAX = 0, same as above,
any better way to solve?
Quoted 10 lines
Review static const char *monitor_event_names[] = { · line 508
Quoted 1 line
(quoted diff) +1
-0+ QAPIEvent event = (QAPIEvent)event_kind;Why are we casting here? Would it not make more sense to change the signature in patch 2/29 to use the enum type from the get-go?
typedef void (*QMPEventFuncEmit)(QAPIEvent
event_kind, QDict *dict, Error **errp);and adjust the signature of this function to match
Since QAPIEvent is generated by qapi-event.py, and they are
different in qemu code and test code, so there will be conflict in test code which include qmp-event.h:
in qemu:qmp-event.h include qapi-event.h
in test:qmp-event.h include test-qapi-event.h
For simple I just used int type instead of QAPIEvent type.
To use QAPIEvent in declaration, I think there would be some
tricks in test, and doc that using qapi-event.h define in qmp-event.c may break test code, the encapsulation is not very goood.
Quoted 6 lines
Review static const char *monitor_event_names[] = { · line 509
Quoted 1 line
(quoted diff) +1
-0+ int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);...[1] okay, it looks like 'rate' and 'last' are specified in nanoseconds. Worth documenting in their declaration above. Particularly since [1]...
Quoted 10 lines
Review static const char *monitor_event_names[] = { · line 516
Quoted 7 lines
(quoted diff) +7
-0+static void monitor_qapi_event_handler(void *opaque) +{ + MonitorQAPIEventState *evstate = opaque; + int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); + + + trace_monitor_qapi_event_handler(evstate->event,Why the double blank line?
Copied code, will fix.
Quoted 14 lines
Review static const char *monitor_event_names[] = { · line 526
Quoted 10 lines
(quoted diff) +10
-0+ +/* + * @event: the event ID to be limited + * @rate: the rate limit in milliseconds + * + * Sets a rate limit on a particular event, so no + * more than 1 event will be emitted within @rate + * milliseconds + */ +static void monitor_qapi_event_throttle(QAPIEvent event, int64_t rate)...[1] this function is documented in milliseconds, not nanoseconds, and you are scaling internally.
Quoted 13 lines
Review static const char *monitor_event_names[] = { · line 535
Quoted 9 lines
(quoted diff) +9
-0+{ + MonitorQAPIEventState *evstate; + assert(event < QAPI_EVENT_MAX); + + evstate = &(monitor_qapi_event_state[event]); + + trace_monitor_qapi_event_throttle(event, rate); + evstate->event = event; + evstate->rate = rate * SCALE_MS;This value can overflow if a user passes in an insanely large rate. Do we care?
There is not much existing caller, maybe we can change it as
nonoseconds.
Quoted 7 lines
Quoted 6 lines
(quoted diff) +6
-0+ evstate->last = 0; + evstate->data = NULL; + evstate->timer = timer_new(QEMU_CLOCK_REALTIME, + SCALE_MS, + monitor_qapi_event_handler, + evstate);
Quoted 9 lines
Review monitor_protocol_event_emit(MonitorEvent event, · line 636
Quoted 6 lines
(quoted diff) +0
-1@@ -507,7 +633,6 @@ monitor_protocol_event_emit(MonitorEvent event, } } - /*Why the spurious line deletion?
Will remove.
Quoted 5 lines
Quoted 5 lines
(quoted diff) +1
-0+++ b/trace-events@@ -932,6 +932,10 @@ monitor_protocol_event_handler(uint32_t event, void *data, uint64_t last, uint64 monitor_protocol_event_emit(uint32_t event, void *data) "event=%d data=%p" monitor_protocol_event_queue(uint32_t event, void *data, uint64_t rate, uint64_t last, uint64_t now) "event=%d data=%p rate=%" PRId64 " last=%" PRId64 " now=%" PRId64 monitor_protocol_event_throttle(uint32_t event, uint64_t rate) "event=%d rate=%" PRId64
Quoted 9 lines
Review monitor_protocol_event_handler(uint32_t event, void *data, uint64_t last, uint64 · line 938
Quoted 4 lines
(quoted diff) +4
-0+monitor_qapi_event_emit(uint32_t event, void *data) "event=%d data=%p" +monitor_qapi_event_queue(uint32_t event, void *data, uint64_t rate, uint64_t last, uint64_t now) "event=%d data=%p rate=%" PRId64 " last=%" PRId64 " now=%" PRId64 +monitor_qapi_event_handler(uint32_t event, void *data, uint64_t last, uint64_t now) "event=%d data=%p last=%" PRId64 " now=%" PRId64 +monitor_qapi_event_throttle(uint32_t event, uint64_t rate) "event=%d rate=%" PRId64Any reason you wanted to invent four new trace names, even though the existing 4 traces have the same signatures? I'm wondering whether it would have just been better to use the old trace names.
The old trace functions are still in use of old event code,
so I added fource new ones. The old ones should be removed in cleanup patch.
PATCH v6 7/29 qapi: add new schema file qapi-event.json
In reply to Wenchao Xia--- Makefile | 12 ++++++++---- qapi-schema.json | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 qapi-event.json
Makefile +8 -4
@@ -247,22 +247,26 @@ $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) " GEN $@") qapi-types.c qapi-types.h :\ -$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) +$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi-event.json \ +$(SRC_PATH)/scripts/qapi-types.py $(qapi-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \ $(gen-out-type) -o "." -b -i $<, \ " GEN $@") qapi-visit.c qapi-visit.h :\ -$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) +$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi-event.json \ +$(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \ $(gen-out-type) -o "." -b -i $<, \ " GEN $@") qapi-event.c qapi-event.h :\ -$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-event.py $(qapi-py) +$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi-event.json \ +$(SRC_PATH)/scripts/qapi-event.py $(qapi-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-event.py \ $(gen-out-type) -o "." -b -i $<, \ " GEN $@") qmp-commands.h qmp-marshal.c :\ -$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) +$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi-event.json \ +$(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \ $(gen-out-type) -o "." -m -i $<, \ " GEN $@")
qapi-event.json new file +0 -0
qapi-schema.json +2 -0
@@ -4798,3 +4798,5 @@ ## { 'enum': 'BlockErrorAction', 'data': [ 'ignore', 'report', 'stop' ] } + +{ 'include': 'qapi-event.json' }
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH V6 07/29] qapi: add new schema file qapi-event.json
Quoted 12 lines · Wenchao Xia
Signed-off-by Wenchao Xia <[email protected]>--- Makefile | 12 ++++++++---- qapi-schema.json | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 qapi-event.jsonMakefile +0
-0
Makefile $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) · line 251
Quoted 6 lines
Makefile +2
-1@@ -247,22 +247,26 @@ $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) " GEN $@") qapi-types.c qapi-types.h :\ -$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) +$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi-event.json \ +$(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
Please rebase this on top of Max's fix to add $(qapi-modules):
https://lists.gnu.org/archive/html/qemu-devel/2014-06/msg01838.html
qapi-event.json
Quoted 3 lines
qapi-event.json new file +0
-0
Probably better to name this file qapi/event.json, to go alongside the other sub-files we have already created.
qapi-schema.json line 4802
Quoted 10 lines
qapi-schema.json +2
-0@@ -4798,3 +4798,5 @@ ## { 'enum': 'BlockErrorAction', 'data': [ 'ignore', 'report', 'stop' ] } + +{ 'include': 'qapi-event.json' }
Rather than putting this at the bottom of the file, would it make sense to put it at the top next to the other 'include' directives?
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH V6 07/29] qapi: add new schema file qapi-event.json
Quoted 9 lines · Eric Blake
Quoted 7 lines · Wenchao Xia
Signed-off-by Wenchao Xia <[email protected]>--- Makefile | 12 ++++++++---- qapi-schema.json | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 qapi-event.json
Quoted 6 lines
qapi-event.json
Quoted 3 lines
qapi-event.json new file +0
-0Probably better to name this file
qapi/event.json, to go alongside the other sub-files we have already created.
Also, I forgot to mention - adding an empty file to qemu.git is unusual. When you respin, make the file non-empty by at least giving it a decent comment at the top stating the purpose of the file. You could even add in a copyright/license comment, if we had any agreement on what to use (but that's already a different thread, since I already pointed out on Benoit's work to split out several .json files that we don't have any example to choose from).
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v6 8/29 qapi event: convert SHUTDOWN
In reply to Wenchao XiaThis patch also eliminates build time warning caused by QAPI_EVENT_MAX = 0.
--- docs/qmp/qmp-events.txt | 15 --------------- qapi-event.json | 12 ++++++++++++ vl.c | 3 ++- 3 files changed, 14 insertions(+), 16 deletions(-)
docs/qmp/qmp-events.txt +0 -15
@@ -304,21 +304,6 @@ Example: "data": { "offset": 78 }, "timestamp": { "seconds": 1267020223, "microseconds": 435656 } } -SHUTDOWN --------- - -Emitted when the Virtual Machine is powered down. - -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, SPICE_DISCONNECTED -----------------------------------
qapi-event.json +12 -0
@@ -0,0 +1,12 @@ +## +# @SHUTDOWN +# +# Emitted when the virtual machine shutdown, qemu terminated the emulation and +# is about to exit. +# +# Note: If the command-line option "-no-shutdown" has been specified, qemu will +# not exit, and a STOP event will eventually follow the SHUTDOWN event +# +# Since: 2.1 +## +{ 'event': 'SHUTDOWN' }
vl.c +2 -1
@@ -117,6 +117,7 @@ int main(int argc, char **argv)#include "ui/qemu-spice.h" #include "qapi/string-input-visitor.h" #include "qom/object_interfaces.h" +#include "qapi-event.h" #define DEFAULT_RAM_SIZE 128
@@ -2028,7 +2029,7 @@ static bool main_loop_should_exit(void) }if (qemu_shutdown_requested ()) {qemu_kill_report (); -monitor_protocol_event (QEVENT_SHUTDOWN ,NULL ); +qapi_event_send_shutdown (NULL );if (no_shutdown) {vm_stop (RUN_STATE_SHUTDOWN ); }else {
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH V6 08/29] qapi event: convert SHUTDOWN
Quoted 2 lines · Wenchao Xia
This patch also eliminates build time warning caused by
QAPI_EVENT_MAX= 0.
I still don't know why I wasn't seeing a warning for that, but agree this cleans it up (or whichever event gets converted first, as there aren't really any dependency restrictions in the order in which you do conversions). If you do follow my suggestion of adding a workaround in 6/29 to avoid build warnings, then don't undo it here, but save it until 29/29; that way, no one individual conversion is doing more work than any other.
Quoted 7 lines
Signed-off-by Wenchao Xia <[email protected]>--- docs/qmp/qmp-events.txt | 15 --------------- qapi-event.json | 12 ++++++++++++ vl.c | 3 ++- 3 files changed, 14 insertions(+), 16 deletions(-)
Yay - I finally have enough to see what code gets generated in 3/29. The qapi-event.h header now has:
void qapi_event_send_shutdown(Error **errp);
extern const char *QAPIEvent_lookup[];
typedef enum QAPIEvent
{
QAPI_EVENT_SHUTDOWN = 0,
QAPI_EVENT_MAX = 1,
} QAPIEvent;
and the .c file has:
void qapi_event_send_shutdown(Error **errp)
{
QDict *qmp;
Error *local_err = NULL;
QMPEventFuncEmit emit;
emit = qmp_event_get_func_emit();
if (!emit) {
return;
}
qmp = qmp_event_build_dict("SHUTDOWN");
emit(QAPI_EVENT_SHUTDOWN, qmp, &local_err);
error_propagate(errp, local_err);
QDECREF(qmp);
}Looks good, for a data-free event (I guess I'll have to wait till later in the series to see what gets generated for an event with data). Hmm, I wonder if patch 3/29 should have also modified docs/qapi-code-gen.txt to show a sample generated function.
docs/qmp/qmp-events.txt line 5
Quoted 11 lines
docs/qmp/qmp-events.txt +6
-2- -Emitted when the Virtual Machine is powered down. +++ b/qapi-event.json@@ -0,0 +1,12 @@ +## +# @SHUTDOWN +# +# Emitted when the virtual machine shutdown, qemu terminated the emulation and +# is about to exit.
Different wording than the text it replaces, and the grammar is a bit unusual. Maybe:
Emitted when the virtual machine has shut down, indicating that qemu is about to exit.
vl.c static bool main_loop_should_exit(void) · line 2032
Quoted 4 lines
vl.c +1
-1if (qemu_shutdown_requested ()) {qemu_kill_report (); -monitor_protocol_event (QEVENT_SHUTDOWN ,NULL ); +qapi_event_send_shutdown (NULL );
Note that the two NULLs serve different purposes. In the old code, NULL meant there was no additional data. In the new code, NULL indicates that we are ignoring the possibility for error. I wonder if it would be better to pass &error_abort instead of NULL? For that matter, I just re-read 6/29 - the one implementation we have of an emit function (monitor_qapi_event_queue) never sets errp. Is it better to just consider events as best-effort, and completely ditch the errp parameter from the emit callback typedef in 2/29, since it looks like you intend to pass NULL for all clients of the callback?
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH V6 08/29] qapi event: convert SHUTDOWN
Quoted 54 lines · Eric Blake
Quoted 2 lines · Wenchao Xia
This patch also eliminates build time warning caused by
QAPI_EVENT_MAX= 0.I still don't know why I wasn't seeing a warning for that, but agree this cleans it up (or whichever event gets converted first, as there aren't really any dependency restrictions in the order in which you do conversions). If you do follow my suggestion of adding a workaround in 6/29 to avoid build warnings, then don't undo it here, but save it until 29/29; that way, no one individual conversion is doing more work than any other.
Quoted 7 lines
Signed-off-by Wenchao Xia <[email protected]>--- docs/qmp/qmp-events.txt | 15 --------------- qapi-event.json | 12 ++++++++++++ vl.c | 3 ++- 3 files changed, 14 insertions(+), 16 deletions(-)Yay - I finally have enough to see what code gets generated in 3/29. The
qapi-event.hheader now has:void
qapi_event_send_shutdown(Error **errp);extern const char *QAPIEvent_lookup[];
typedef enum QAPIEvent
{
QAPI_EVENT_SHUTDOWN= 0,
QAPI_EVENT_MAX= 1,
} QAPIEvent;and the .c file has:
void
qapi_event_send_shutdown(Error **errp){ QDict *qmp; Error *local_err = NULL; QMPEventFuncEmit emit; emit = qmp_event_get_func_emit(); if (!emit) { return; } qmp = qmp_event_build_dict("SHUTDOWN"); emit(QAPI_EVENT_SHUTDOWN, qmp, &local_err); error_propagate(errp, local_err); QDECREF(qmp); }
Quoted 5 lines
Looks good, for a data-free event (I guess I'll have to wait till later in the series to see what gets generated for an event with data). Hmm, I wonder if patch 3/29 should have also modified
docs/qapi-code-gen.txtto show a sample generated function.
Will add doc part.
Quoted 23 lines
docs/qmp/qmp-events.txt line 5
Quoted 11 lines
docs/qmp/qmp-events.txt +6
-2- -Emitted when the Virtual Machine is powered down. +++ b/qapi-event.json@@ -0,0 +1,12 @@ +## +# @SHUTDOWN +# +# Emitted when the virtual machine shutdown, qemu terminated the emulation and +# is about to exit.Different wording than the text it replaces, and the grammar is a bit unusual. Maybe:
Emitted when the virtual machine has shut down, indicating that qemu is about to exit.
vl.c static bool main_loop_should_exit(void) · line 2032
Quoted 4 lines
vl.c +1
-1if (qemu_shutdown_requested ()) {qemu_kill_report (); -monitor_protocol_event (QEVENT_SHUTDOWN ,NULL ); +qapi_event_send_shutdown (NULL );
Quoted 10 lines
Note that the two NULLs serve different purposes. In the old code, NULL meant there was no additional data. In the new code, NULL indicates that we are ignoring the possibility for error. I wonder if it would be better to pass
&error_abortinstead of NULL? For that matter, I just re-read 6/29 - the one implementation we have of an emit function (monitor_qapi_event_queue) never sets errp. Is it better to just consider events as best-effort, and completely ditch the errp parameter from the emit callback typedef in 2/29, since it looks like you intend to pass NULL for all clients of the callback?
It make things simple, I will remove &errp in next version.
PATCH v6 9/29 qapi event: convert POWERDOWN
In reply to Wenchao XiaThere is no existing comments for POWERDOWN in doc/qmp/qmp-events.txt, so no change on it like other conversion patch.
--- qapi-event.json | 10 ++++++++++ vl.c | 2 +- 2 files changed, 11 insertions(+), 1 deletions(-)
qapi-event.json +10 -0
@@ -10,3 +10,13 @@ # Since: 2.1 ## { 'event': 'SHUTDOWN' } + +## +# @POWERDOWN +# +# Emitted when the virtual machine is powered down through the power control +# system, such as via ACPI. +# +# Since: 2.1 +## +{ 'event': 'POWERDOWN' }
vl.c +1 -1
@@ -1991,7 +1991,7 @@ void qemu_system_shutdown_request(void)static void qemu_system_powerdown (void ) { -monitor_protocol_event (QEVENT_POWERDOWN ,NULL ); +qapi_event_send_powerdown (NULL );notifier_list_notify (&powerdown_notifiers,NULL ); }
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH V6 09/29] qapi event: convert POWERDOWN
Quoted 2 lines · Wenchao Xia
There is no existing comments for POWERDOWN in
doc/qmp/qmp-events.txt, so no change on it like other conversion patch.
Oddly enough, POWERDOWN _is_ documented in docs/qmp/qmp-spec.txt, but that reference doesn't need updating with this conversion.
Quoted 9 lines
Signed-off-by Wenchao Xia <[email protected]>--- qapi-event.json | 10 ++++++++++ vl.c | 2 +- 2 files changed, 11 insertions(+), 1 deletions(-)+++
b/vl.c
vl.c void qemu_system_shutdown_request(void) · line 1994
Quoted 5 lines
vl.c +1
-1@@ -1991,7 +1991,7 @@ void qemu_system_shutdown_request(void)static void qemu_system_powerdown (void ) { -monitor_protocol_event (QEVENT_POWERDOWN ,NULL ); +qapi_event_send_powerdown (NULL );
Modulo my comment in 8/29 on whether we even need an errp argument,
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v6 10/29 qapi event: convert RESET
In reply to Wenchao Xia--- docs/qmp/qmp-events.txt | 12 ------------ qapi-event.json | 9 +++++++++ vl.c | 2 +- 3 files changed, 10 insertions(+), 13 deletions(-)
docs/qmp/qmp-events.txt +0 -12
@@ -264,18 +264,6 @@ Example: "data": { "node-name": "1.raw", "sector-num": 345435, "sector-count": 5 }, "timestamp": { "seconds": 1344522075, "microseconds": 745528 } } -RESET ------ - -Emitted when the Virtual Machine is reseted. - -Data: None. - -Example: - -{ "event": "RESET", - "timestamp": { "seconds": 1267041653, "microseconds": 9518 } } - RESUME ------
qapi-event.json +9 -0
@@ -20,3 +20,12 @@ # Since: 2.1 ## { 'event': 'POWERDOWN' } + +## +# @RESET +# +# Emitted when the virtual machine is reset +# +# Since: 2.1 +## +{ 'event': 'RESET' }
vl.c +1 -1
@@ -1907,7 +1907,7 @@ void qemu_system_reset(bool report)qemu_devices_reset (); }if (report) { -monitor_protocol_event (QEVENT_RESET ,NULL ); +qapi_event_send_reset (NULL ); }cpu_synchronize_all_post_reset (); }
Signature · 1 line
1.7.1
PATCH v6 11/29 qapi event: convert STOP
In reply to Wenchao Xia--- cpus.c | 5 +++-- docs/qmp/qmp-events.txt | 12 ------------ qapi-event.json | 9 +++++++++ 3 files changed, 12 insertions(+), 14 deletions(-)
cpus.c +3 -2
@@ -25,7 +25,7 @@/* Needed early for CONFIG_BSD etc. */ #include "config-host.h" -#include "monitor/monitor.h" +#include "qapi/qmp/qerror.h" #include "sysemu/sysemu.h" #include "exec/gdbstub.h" #include "sysemu/dma.h"
@@ -38,6 +38,7 @@#include "qemu/main-loop.h" #include "qemu/bitmap.h" #include "qemu/seqlock.h" +#include "qapi-event.h" #ifndef _WIN32#include "qemu/compatfd.h"
@@ -530,7 +531,7 @@ static int do_vm_stop(RunState state)pause_all_vcpus ();runstate_set (state);vm_state_notify (0 , state); -monitor_protocol_event (QEVENT_STOP ,NULL ); +qapi_event_send_stop (NULL ); }bdrv_drain_all ();
docs/qmp/qmp-events.txt +0 -12
@@ -354,18 +354,6 @@ Example: "channel-id": 0, "tls": true} }} -STOP ----- - -Emitted when the Virtual Machine is stopped. - -Data: None. - -Example: - -{ "event": "STOP", - "timestamp": { "seconds": 1267041730, "microseconds": 281295 } } - SUSPEND -------
qapi-event.json +9 -0
@@ -29,3 +29,12 @@ # Since: 2.1 ## { 'event': 'RESET' } + +## +# @STOP +# +# Emitted when the virtual machine is stopped +# +# Since: 2.1 +## +{ 'event': 'STOP' }
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH V6 11/29] qapi event: convert STOP
Quoted 9 lines · Wenchao Xia
Signed-off-by Wenchao Xia <[email protected]>--- cpus.c | 5 +++-- docs/qmp/qmp-events.txt | 12 ------------ qapi-event.json | 9 +++++++++ 3 files changed, 12 insertions(+), 14 deletions(-)
cpus.c static int do_vm_stop(RunState state) · line 534
Quoted 5 lines
cpus.c +1
-1@@ -530,7 +531,7 @@ static int do_vm_stop(RunState state)pause_all_vcpus ();runstate_set (state);vm_state_notify (0 , state); -monitor_protocol_event (QEVENT_STOP ,NULL ); +qapi_event_send_stop (NULL );
Same comments from earlier about not needing errp argument
qapi-event.json line 38
Quoted 12 lines
qapi-event.json +8
-0+++ b/qapi-event.json@@ -29,3 +29,12 @@ # Since: 2.1 ## { 'event': 'RESET' } + +## +# @STOP +# +# Emitted when the virtual machine is stopped +# +# Since: 2.1
0.14.0
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH V6 11/29] qapi event: convert STOP
Il 13/06/2014 22:29, Eric Blake ha scritto:
Quoted 5 lines
Quoted 4 lines
qapi-event.json line 38
Quoted 4 lines
qapi-event.json +4
-0+# +# Emitted when the virtual machine is stopped +# +# Since: 2.10.14.0
0.12.0, actually:
$ git describe --contains b1a15e7eaafba8f26e2263b1a9b6e6d40e585e72 v0.12.0-rc0~187
Paolo
Re: [Qemu-devel] [PATCH V6 11/29] qapi event: convert STOP
Quoted 11 lines · Paolo Bonzini
Il 13/06/2014 22:29, Eric Blake ha scritto:
Quoted 5 lines
Quoted 4 lines
qapi-event.json line 38
Quoted 4 lines
qapi-event.json +4
-0+# +# Emitted when the virtual machine is stopped +# +# Since: 2.10.14.0
0.12.0, actually:
$ git describe --contains b1a15e7eaafba8f26e2263b1a9b6e6d40e585e72 v0.12.0-rc0~187
But nothing else in qapi-schema.json mentions anything earlier than 0.14. True, QMP was first started in the 0.12 timeframe, but upstream libvirt refuses to use QMP for anything earlier than qemu 0.15, unless libvirt was able to probe that enough additional functionality of QMP was backported to make it useful (thus it supports RHEL 6's qemu 0.12+).
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v6 12/29 qapi event: convert RESUME
In reply to Wenchao Xia--- docs/qmp/qmp-events.txt | 12 ------------ qapi-event.json | 9 +++++++++ vl.c | 2 +- 3 files changed, 10 insertions(+), 13 deletions(-)
docs/qmp/qmp-events.txt +0 -12
@@ -264,18 +264,6 @@ Example: "data": { "node-name": "1.raw", "sector-num": 345435, "sector-count": 5 }, "timestamp": { "seconds": 1344522075, "microseconds": 745528 } } -RESUME ------- - -Emitted when the Virtual Machine resumes execution. - -Data: None. - -Example: - -{ "event": "RESUME", - "timestamp": { "seconds": 1271770767, "microseconds": 582542 } } - RTC_CHANGE ----------
qapi-event.json +9 -0
@@ -38,3 +38,12 @@ # Since: 2.1 ## { 'event': 'STOP' } + +## +# @RESUME +# +# Emitted when the virtual machine resumes execution +# +# Since: 2.1 +## +{ 'event': 'RESUME' }
vl.c +1 -1
@@ -1755,7 +1755,7 @@ void vm_start(void)runstate_set (RUN_STATE_RUNNING );vm_state_notify (1 ,RUN_STATE_RUNNING );resume_all_vcpus (); -monitor_protocol_event (QEVENT_RESUME ,NULL ); +qapi_event_send_resume (NULL ); } }
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH V6 12/29] qapi event: convert RESUME
Quoted 8 lines · Wenchao Xia
Signed-off-by Wenchao Xia <[email protected]>--- docs/qmp/qmp-events.txt | 12 ------------ qapi-event.json | 9 +++++++++ vl.c | 2 +- 3 files changed, 10 insertions(+), 13 deletions(-)
qapi-event.json line 47
Quoted 6 lines
qapi-event.json +6
-0+## +# @RESUME +# +# Emitted when the virtual machine resumes execution +# +# Since: 2.1
0.14.0
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v6 13/29 qapi event: convert SUSPEND
In reply to Wenchao Xia--- docs/qmp/qmp-events.txt | 12 ------------ qapi-event.json | 10 ++++++++++ vl.c | 2 +- 3 files changed, 11 insertions(+), 13 deletions(-)
docs/qmp/qmp-events.txt +0 -12
@@ -342,18 +342,6 @@ Example: "channel-id": 0, "tls": true} }} -SUSPEND -------- - -Emitted when guest enters S3 state. - -Data: None. - -Example: - -{ "event": "SUSPEND", - "timestamp": { "seconds": 1344456160, "microseconds": 309119 } } - SUSPEND_DISK ------------
qapi-event.json +10 -0
@@ -47,3 +47,13 @@ # Since: 2.1 ## { 'event': 'RESUME' } + +## +# @SUSPEND +# +# Emitted when guest enters a hardware suspension state, for example, S3 state, +# which is sometimes called standby state +# +# Since: 2.1 +## +{ 'event': 'SUSPEND' }
vl.c +1 -1
@@ -1928,7 +1928,7 @@ static void qemu_system_suspend(void)pause_all_vcpus ();notifier_list_notify (&suspend_notifiers,NULL );runstate_set (RUN_STATE_SUSPENDED ); -monitor_protocol_event (QEVENT_SUSPEND ,NULL ); +qapi_event_send_suspend (NULL ); }void qemu_system_suspend_request (void )
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH V6 13/29] qapi event: convert SUSPEND
Quoted 8 lines · Wenchao Xia
Signed-off-by Wenchao Xia <[email protected]>--- docs/qmp/qmp-events.txt | 12 ------------ qapi-event.json | 10 ++++++++++ vl.c | 2 +- 3 files changed, 11 insertions(+), 13 deletions(-)
qapi-event.json line 57
Quoted 7 lines
qapi-event.json +7
-0+## +# @SUSPEND +# +# Emitted when guest enters a hardware suspension state, for example, S3 state, +# which is sometimes called standby state +# +# Since: 2.1
1.1
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v6 14/29 qapi event: convert SUSPEND_DISK
In reply to Wenchao Xia--- docs/qmp/qmp-events.txt | 14 -------------- hw/acpi/core.c | 4 ++-- qapi-event.json | 12 ++++++++++++ 3 files changed, 14 insertions(+), 16 deletions(-)
docs/qmp/qmp-events.txt +0 -14
@@ -342,20 +342,6 @@ Example: "channel-id": 0, "tls": true} }} -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 -------------
hw/acpi/core.c +2 -2
@@ -22,11 +22,11 @@#include "hw/hw.h" #include "hw/i386/pc.h" #include "hw/acpi/acpi.h" -#include "monitor/monitor.h" #include "qemu/config-file.h" #include "qapi/opts-visitor.h" #include "qapi/dealloc-visitor.h" #include "qapi-visit.h" +#include "qapi-event.h" struct acpi_table_header {uint16_t _length;/* our length, not actual part of the hdr */
@@ -550,7 +550,7 @@ static void acpi_pm1_cnt_write(ACPIREGS *ar, uint16_t val)break ;default :if (sus_typ == ar->pm1.cnt.s4_val) {/* S4 request */ -monitor_protocol_event (QEVENT_SUSPEND_DISK ,NULL ); +qapi_event_send_suspend_disk (NULL );qemu_system_shutdown_request (); }break ;
qapi-event.json +12 -0
@@ -57,3 +57,15 @@ # Since: 2.1 ## { 'event': 'SUSPEND' } + +## +# @SUSPEND_DISK +# +# Emitted when guest enters a hardware suspension state with data saved on +# disk, for example, S4 state, which is sometimes called hibernate state +# +# Note: QEMU shuts down (similar to event @SHUTDOWN) when entering this state +# +# Since: 2.1 +## +{ 'event': 'SUSPEND_DISK' }
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH V6 14/29] qapi event: convert SUSPEND_DISK
Quoted 13 lines · Wenchao Xia
Signed-off-by Wenchao Xia <[email protected]>--- docs/qmp/qmp-events.txt | 14 -------------- hw/acpi/core.c | 4 ++-- qapi-event.json | 12 ++++++++++++ 3 files changed, 14 insertions(+), 16 deletions(-)+++
b/qapi-event.jsonqapi-event.json +0
-0@@ -57,3 +57,15 @@ # Since: 2.1 ## { 'event': 'SUSPEND' }
qapi-event.json line 69
Quoted 10 lines
qapi-event.json +10
-0+ +## +# @SUSPEND_DISK +# +# Emitted when guest enters a hardware suspension state with data saved on +# disk, for example, S4 state, which is sometimes called hibernate state +# +# Note: QEMU shuts down (similar to event @SHUTDOWN) when entering this state +# +# Since: 2.1
1.2
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v6 15/29 qapi event: convert WAKEUP
In reply to Wenchao Xia--- docs/qmp/qmp-events.txt | 12 ------------ qapi-event.json | 9 +++++++++ vl.c | 2 +- 3 files changed, 10 insertions(+), 13 deletions(-)
docs/qmp/qmp-events.txt +0 -12
@@ -432,18 +432,6 @@ Example: "host": "127.0.0.1", "sasl_username": "luiz" } }, "timestamp": { "seconds": 1263475302, "microseconds": 150772 } } -WAKEUP ------- - -Emitted when the guest has woken up from S3 and is running. - -Data: None. - -Example: - -{ "event": "WAKEUP", - "timestamp": { "seconds": 1344522075, "microseconds": 745528 } } - WATCHDOG --------
qapi-event.json +9 -0
@@ -69,3 +69,12 @@ # Since: 2.1 ## { 'event': 'SUSPEND_DISK' } + +## +# @WAKEUP +# +# Emitted when the guest has woken up from suspend state and is running +# +# Since: 2.1 +## +{ 'event': 'WAKEUP' }
vl.c +1 -1
@@ -2052,7 +2052,7 @@ static bool main_loop_should_exit(void)notifier_list_notify (&wakeup_notifiers, &wakeup_reason); wakeup_reason =QEMU_WAKEUP_REASON_NONE ;resume_all_vcpus (); -monitor_protocol_event (QEVENT_WAKEUP ,NULL ); +qapi_event_send_wakeup (NULL ); }if (qemu_powerdown_requested ()) {qemu_system_powerdown ();
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH V6 15/29] qapi event: convert WAKEUP
Quoted 8 lines · Wenchao Xia
Signed-off-by Wenchao Xia <[email protected]>--- docs/qmp/qmp-events.txt | 12 ------------ qapi-event.json | 9 +++++++++ vl.c | 2 +- 3 files changed, 10 insertions(+), 13 deletions(-)
qapi-event.json line 78
Quoted 6 lines
qapi-event.json +6
-0+## +# @WAKEUP +# +# Emitted when the guest has woken up from suspend state and is running +# +# Since: 2.1
1.1
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v6 16/29 qapi event: convert RTC_CHANGE
In reply to Wenchao XiaThis patch also eliminates build time warning caused by no caller of monitor_qapi_event_throttle().
--- docs/qmp/qmp-events.txt | 16 ---------------- hw/ppc/spapr_rtas.c | 3 ++- hw/timer/mc146818rtc.c | 3 ++- include/sysemu/sysemu.h | 2 -- monitor.c | 4 +++- qapi-event.json | 13 +++++++++++++ vl.c | 9 --------- 7 files changed, 20 insertions(+), 30 deletions(-)
docs/qmp/qmp-events.txt +0 -16
@@ -264,22 +264,6 @@ Example: "data": { "node-name": "1.raw", "sector-num": 345435, "sector-count": 5 }, "timestamp": { "seconds": 1344522075, "microseconds": 745528 } } -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 } } - SPICE_CONNECTED, SPICE_DISCONNECTED -----------------------------------
hw/ppc/spapr_rtas.c +2 -1
@@ -32,6 +32,7 @@#include "hw/ppc/spapr.h" #include "hw/ppc/spapr_vio.h" +#include "qapi-event.h" #include <libfdt.h>
@@ -93,7 +94,7 @@ static void rtas_set_time_of_day(PowerPCCPU *cpu, sPAPREnvironment *spapr, tm.tm_sec =rtas_ld (args,5 );/* Just generate a monitor event for the change */ -rtc_change_mon_event (&tm); +qapi_event_send_rtc_change (qemu_timedate_diff (&tm),NULL ); spapr->rtc_offset =qemu_timedate_diff (&tm);rtas_st (rets,0 ,RTAS_OUT_SUCCESS );
hw/timer/mc146818rtc.c +2 -1
@@ -26,6 +26,7 @@#include "sysemu/sysemu.h" #include "hw/timer/mc146818rtc.h" #include "qapi/visitor.h" +#include "qapi-event.h" #ifdef TARGET_I386 #include "hw/i386/apic.h"
@@ -530,7 +531,7 @@ static void rtc_set_time(RTCState *s) s->base_rtc =mktimegm (&tm); s->last_update =qemu_clock_get_ns (rtc_clock); -rtc_change_mon_event (&tm); +qapi_event_send_rtc_change (qemu_timedate_diff (&tm),NULL ); }static void rtc_set_cmos (RTCState *s,const struct tm *tm)
include/sysemu/sysemu.h +0 -2
@@ -189,8 +189,6 @@ void do_usb_add(Monitor *mon, const QDict *qdict);void do_usb_del (Monitor *mon,const QDict *qdict);void usb_info (Monitor *mon,const QDict *qdict); -void rtc_change_mon_event (struct tm *tm); -void add_boot_device_path (int32_t bootindex,DeviceState *dev,const char *suffix);char *get_boot_devices_list (size_t *size,bool ignore_suffixes);
monitor.c +3 -1
@@ -612,6 +612,9 @@ static void monitor_qapi_event_throttle(QAPIEvent event, int64_t rate)static void monitor_qapi_event_init (void ) { +/* Limit RTC & BALLOON events to 1 per second */ +monitor_qapi_event_throttle (QAPI_EVENT_RTC_CHANGE ,1000 ); +qmp_event_set_func_emit (monitor_qapi_event_queue); }
@@ -737,7 +740,6 @@ monitor_protocol_event_throttle(MonitorEvent event,static void monitor_protocol_event_init (void ) {/* Limit RTC & BALLOON events to 1 per second */ -monitor_protocol_event_throttle (QEVENT_RTC_CHANGE ,1000 );monitor_protocol_event_throttle (QEVENT_BALLOON_CHANGE ,1000 );monitor_protocol_event_throttle (QEVENT_WATCHDOG ,1000 );/* limit the rate of quorum events to avoid hammering the management */
qapi-event.json +13 -0
@@ -78,3 +78,16 @@ # Since: 2.1 ## { 'event': 'WAKEUP' } + +## +# @RTC_CHANGE +# +# Emitted when the guest changes the RTC time. +# +# @offset: offset between base RTC clock (as specified by -rtc base), and +# new RTC clock value +# +# Since: 2.1 +## +{ 'event': 'RTC_CHANGE', + 'data': { 'offset': 'int' } }
vl.c +0 -9
@@ -727,15 +727,6 @@ int qemu_timedate_diff(struct tm *tm)return seconds -time (NULL ); } -void rtc_change_mon_event (struct tm *tm) -{ -QObject *data; - - data =qobject_from_jsonf ("{ 'offset': %d }" ,qemu_timedate_diff (tm)); -monitor_protocol_event (QEVENT_RTC_CHANGE , data); -qobject_decref (data); -} -static void configure_rtc_date_offset (const char *startdate,int legacy) {time_t rtc_start_date;
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH V6 16/29] qapi event: convert RTC_CHANGE
Quoted 2 lines · Wenchao Xia
This patch also eliminates build time warning caused by no caller of
monitor_qapi_event_throttle().
Again, my suggestion on 6/29 could avoid that warning; if you use that workaround, don't clean it until 29/29, but you can drop this paragraph of this commit.
Quoted 12 lines
Signed-off-by Wenchao Xia <[email protected]>--- docs/qmp/qmp-events.txt | 16 ---------------- hw/ppc/spapr_rtas.c | 3 ++- hw/timer/mc146818rtc.c | 3 ++- include/sysemu/sysemu.h | 2 -- monitor.c | 4 +++- qapi-event.json | 13 +++++++++++++ vl.c | 9 --------- 7 files changed, 20 insertions(+), 30 deletions(-)
Yay - the first event with data, so I get to see what the generator does.
The .h file shows this signature:
Quoted 2 lines
Quoted 2 lines
void qapi_event_send_rtc_change(int64_t offset,
Error **errp);
and the .c has this code:
Quoted 17 lines
Quoted 17 lines
void qapi_event_send_rtc_change(int64_t offset,
Error **errp){ QDict *qmp; Error *local_err = NULL; QMPEventFuncEmit emit; QmpOutputVisitor *qov; Visitor *v; QObject *obj; emit = qmp_event_get_func_emit(); if (!emit) { return; } qmp = qmp_event_build_dict("RTC_CHANGE");
Quoted 7 lines
Quoted 7 lines
qov = qmp_output_visitor_new(); g_assert(qov); v = qmp_output_get_visitor(qov); g_assert(v); /* Fake visit, as if all member are under a structure */
Grammar error; guess I have more comments on 3/29.
Quoted 4 lines
Quoted 4 lines
visit_start_struct(v, NULL, "", "RTC_CHANGE", 0, &local_err); if (local_err) { goto clean; }
Hmm, qmp_output_start_struct() never sets errp.
Quoted 5 lines
Quoted 5 lines
visit_type_int(v, &offset, "offset", &local_err); if (local_err) { goto clean; }
Likewise, qmp_output_type_int never sets errp.
Quoted 5 lines
Quoted 5 lines
visit_end_struct(v, &local_err); if (local_err) { goto clean; }
And neither does qmp_end_struct.
Quoted 6 lines
Quoted 6 lines
obj = qmp_output_get_qobject(qov); g_assert(obj != NULL); qdict_put_obj(qmp, "data", obj); emit(QAPI_EVENT_RTC_CHANGE, qmp, &local_err);
And I already mentioned earlier that the only implementation of the emit() callback never sets local_err (and probably doesn't even need it as a parameter).
Quoted 6 lines
Quoted 6 lines
clean:
qmp_output_visitor_cleanup(qov); error_propagate(errp, local_err); QDECREF(qmp); }
If you change the earlier 3 instances to just use visit_...(, &error_abort), you can completely ditch the local_err variable, drop the
clean: label, and overall have a much shorter generated function.
hw/ppc/spapr_rtas.c static void rtas_set_time_of_day(PowerPCCPU *cpu, sPAPREnvironment *spapr, · line 98
Quoted 7 lines
hw/ppc/spapr_rtas.c +1
-1@@ -93,7 +94,7 @@ static void rtas_set_time_of_day(PowerPCCPU *cpu, sPAPREnvironment *spapr, tm.tm_sec =rtas_ld (args,5 );/* Just generate a monitor event for the change */ -rtc_change_mon_event (&tm); +qapi_event_send_rtc_change (qemu_timedate_diff (&tm),NULL ); spapr->rtc_offset =qemu_timedate_diff (&tm);
Eww. This makes me worry whether grabbing qemu_timedate_diff() two times in a row may cause a different value to be reported than what is stored locally. Please grab it only once into a local variable, then copy that value into both locations.
Once again, all callers of qapi_event_send_rtc_change() are passing a NULL errp to silently ignore errors; and I just audited that no errors happen anyways.
monitor.c static void monitor_qapi_event_throttle(QAPIEvent event, int64_t rate) · line 615
Quoted 6 lines
monitor.c +2
-0+++ b/monitor.c@@ -612,6 +612,9 @@ static void monitor_qapi_event_throttle(QAPIEvent event, int64_t rate)static void monitor_qapi_event_init (void ) { +/* Limit RTC & BALLOON events to 1 per second */
Comment is a bit misleading until a later patch converts balloon events,...
monitor.c monitor_protocol_event_throttle(MonitorEvent event, · line 744
Quoted 12 lines
monitor.c +2
-1+monitor_qapi_event_throttle (QAPI_EVENT_RTC_CHANGE ,1000 ); +qmp_event_set_func_emit (monitor_qapi_event_queue); }@@ -737,7 +740,6 @@ monitor_protocol_event_throttle(MonitorEvent event,static void monitor_protocol_event_init (void ) {/* Limit RTC & BALLOON events to 1 per second */ -monitor_protocol_event_throttle (QEVENT_RTC_CHANGE ,1000 );monitor_protocol_event_throttle (QEVENT_BALLOON_CHANGE ,1000 );monitor_protocol_event_throttle (QEVENT_WATCHDOG ,1000 );
...furthermore, the OLD comment was wrong (it forgot about the watchdog event). You could get around that by rewording the comment to just say 'limit guest-triggerable events to 1 per second' without calling out what those events are.
qapi-event.json line 90
Quoted 8 lines
qapi-event.json +8
-0+# @RTC_CHANGE +# +# Emitted when the guest changes the RTC time. +# +# @offset: offset between base RTC clock (as specified by -rtc base), and +# new RTC clock value +# +# Since: 2.1
0.14.0
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH V6 16/29] qapi event: convert RTC_CHANGE
Quoted 116 lines · Eric Blake
Quoted 2 lines · Wenchao Xia
This patch also eliminates build time warning caused by no caller of
monitor_qapi_event_throttle().Again, my suggestion on 6/29 could avoid that warning; if you use that workaround, don't clean it until 29/29, but you can drop this paragraph of this commit.
Quoted 12 lines
Signed-off-by Wenchao Xia <[email protected]>--- docs/qmp/qmp-events.txt | 16 ---------------- hw/ppc/spapr_rtas.c | 3 ++- hw/timer/mc146818rtc.c | 3 ++- include/sysemu/sysemu.h | 2 -- monitor.c | 4 +++- qapi-event.json | 13 +++++++++++++ vl.c | 9 --------- 7 files changed, 20 insertions(+), 30 deletions(-)Yay - the first event with data, so I get to see what the generator does.
The .h file shows this signature:
Quoted 2 lines
Quoted 2 lines
void qapi_event_send_rtc_change(int64_t offset,
Error **errp);and the .c has this code:
Quoted 17 lines
Quoted 17 lines
void qapi_event_send_rtc_change(int64_t offset,
Error **errp){ QDict *qmp; Error *local_err = NULL; QMPEventFuncEmit emit; QmpOutputVisitor *qov; Visitor *v; QObject *obj; emit = qmp_event_get_func_emit(); if (!emit) { return; } qmp = qmp_event_build_dict("RTC_CHANGE");Quoted 7 lines
Quoted 7 lines
qov = qmp_output_visitor_new(); g_assert(qov); v = qmp_output_get_visitor(qov); g_assert(v); /* Fake visit, as if all member are under a structure */Grammar error; guess I have more comments on 3/29.
Quoted 4 lines
Quoted 4 lines
visit_start_struct(v, NULL, "", "RTC_CHANGE", 0, &local_err); if (local_err) { goto clean; }Hmm,
qmp_output_start_struct()never sets errp.Quoted 5 lines
Quoted 5 lines
visit_type_int(v, &offset, "offset", &local_err); if (local_err) { goto clean; }Likewise,
qmp_output_type_intnever sets errp.Quoted 5 lines
Quoted 5 lines
visit_end_struct(v, &local_err); if (local_err) { goto clean; }And neither does
qmp_end_struct.Quoted 6 lines
Quoted 6 lines
obj = qmp_output_get_qobject(qov); g_assert(obj != NULL); qdict_put_obj(qmp, "data", obj); emit(QAPI_EVENT_RTC_CHANGE, qmp, &local_err);And I already mentioned earlier that the only implementation of the
emit()callback never setslocal_err(and probably doesn't even need it as a parameter).Quoted 6 lines
Quoted 6 lines
clean:
qmp_output_visitor_cleanup(qov); error_propagate(errp, local_err); QDECREF(qmp); }If you change the earlier 3 instances to just use visit_...(,
&error_abort), you can completely ditch thelocal_errvariable, drop the
clean: label, and overall have a much shorter generated function.hw/ppc/spapr_rtas.c static void rtas_set_time_of_day(PowerPCCPU *cpu, sPAPREnvironment *spapr, · line 98
Quoted 7 lines
hw/ppc/spapr_rtas.c +1
-1@@ -93,7 +94,7 @@ static void rtas_set_time_of_day(PowerPCCPU *cpu, sPAPREnvironment *spapr, tm.tm_sec =rtas_ld (args,5 );/* Just generate a monitor event for the change */ -rtc_change_mon_event (&tm); +qapi_event_send_rtc_change (qemu_timedate_diff (&tm),NULL ); spapr->rtc_offset =qemu_timedate_diff (&tm);Eww. This makes me worry whether grabbing
qemu_timedate_diff()two times in a row may cause a different value to be reported than what is stored locally. Please grab it only once into a local variable, then copy that value into both locations.
Quoted 4 lines
Once again, all callers of
qapi_event_send_rtc_change()are passing a NULL errp to silently ignore errors; and I just audited that no errors happen anyways.
Fixing it.
Quoted 9 lines
monitor.c static void monitor_qapi_event_throttle(QAPIEvent event, int64_t rate) · line 615
Quoted 6 lines
monitor.c +2
-0+++ b/monitor.c@@ -612,6 +612,9 @@ static void monitor_qapi_event_throttle(QAPIEvent event, int64_t rate)static void monitor_qapi_event_init (void ) { +/* Limit RTC & BALLOON events to 1 per second */ Comment is a bit misleading until a later patch converts balloon events,...
Oops, good catch, will fix it.
Quoted 29 lines
monitor.c monitor_protocol_event_throttle(MonitorEvent event, · line 744
Quoted 12 lines
monitor.c +2
-1+monitor_qapi_event_throttle (QAPI_EVENT_RTC_CHANGE ,1000 ); +qmp_event_set_func_emit (monitor_qapi_event_queue); }@@ -737,7 +740,6 @@ monitor_protocol_event_throttle(MonitorEvent event,static void monitor_protocol_event_init (void ) {/* Limit RTC & BALLOON events to 1 per second */ -monitor_protocol_event_throttle (QEVENT_RTC_CHANGE ,1000 );monitor_protocol_event_throttle (QEVENT_BALLOON_CHANGE ,1000 );monitor_protocol_event_throttle (QEVENT_WATCHDOG ,1000 );...furthermore, the OLD comment was wrong (it forgot about the watchdog event). You could get around that by rewording the comment to just say 'limit guest-triggerable events to 1 per second' without calling out what those events are.
qapi-event.json line 90
Quoted 8 lines
qapi-event.json +8
-0+# @RTC_CHANGE +# +# Emitted when the guest changes the RTC time. +# +# @offset: offset between base RTC clock (as specified by -rtc base), and +# new RTC clock value +# +# Since: 2.10.14.0
Re: [Qemu-devel] [PATCH V6 16/29] qapi event: convert RTC_CHANGE
Il 15/06/2014 02:38, Wenchao Xia ha scritto:
Quoted 7 lines
Quoted 5 lines
Once again, all callers of
qapi_event_send_rtc_change()are passing a NULL errp to silently ignore errors; and I just audited that no errors happen anyways.Fixing it.
No, please don't. I prefer the way you did it in v6.
Paolo
Re: [Qemu-devel] [PATCH V6 16/29] qapi event: convert RTC_CHANGE
In reply to Eric BlakeIl 13/06/2014 23:27, Eric Blake ha scritto:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
visit_start_struct(v, NULL, "", "RTC_CHANGE", 0, &local_err); if (local_err) { goto clean; }
Quoted 9 lines
Hmm,
qmp_output_start_struct()never sets errp.Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
visit_type_int(v, &offset, "offset", &local_err); if (local_err) { goto clean; }Likewise,
qmp_output_type_intnever sets errp.
I think it is better to produce correct error propagation even if it is unused. We could add range-checking of enums, for example.
I guess all the NULLs for errp could become &error_abort, but it can be done after the merge.
Paolo
Re: [Qemu-devel] [PATCH V6 16/29] qapi event: convert RTC_CHANGE
In reply to Eric BlakeIl 13/06/2014 23:27, Eric Blake ha scritto:
Quoted 9 lines
Quoted 8 lines
qapi-event.json line 90
Quoted 8 lines
qapi-event.json +8
-0+# @RTC_CHANGE +# +# Emitted when the guest changes the RTC time. +# +# @offset: offset between base RTC clock (as specified by -rtc base), and +# new RTC clock value +# +# Since: 2.10.14.0
0.13.0 :)
Re: [Qemu-devel] [PATCH V6 16/29] qapi event: convert RTC_CHANGE
Quoted 7 lines · Paolo Bonzini
Il 13/06/2014 23:27, Eric Blake ha scritto:
Quoted 6 lines
Quoted 6 lines
qapi-event.json
Quoted 5 lines
qapi-event.json +5
-0+# @RTC_CHANGE +# +# Emitted when the guest changes the RTC time. +# +# @offset: offset between base RTC clock (as specified by -rtcbase), and
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines
qapi-event.json line 90
Quoted 3 lines
qapi-event.json +3
-0+# new RTC clock value +# +# Since: 2.10.14.0
0.13.0 :)
Again, since nothing else in QAPI documents anything earlier than 0.14, I'm not sure it's worth caring about whether 0.13 supported a particular event.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v6 17/29 qapi event: convert WATCHDOG
In reply to Wenchao Xia--- docs/qmp/qmp-events.txt | 19 ------------------- hw/watchdog/watchdog.c | 23 +++++++---------------- monitor.c | 2 +- qapi-event.json | 15 +++++++++++++++ qapi-schema.json | 24 ++++++++++++++++++++++++ 5 files changed, 47 insertions(+), 36 deletions(-)
docs/qmp/qmp-events.txt +0 -19
@@ -415,22 +415,3 @@ Example: "client": { "family": "ipv4", "service": "46089", "host": "127.0.0.1", "sasl_username": "luiz" } }, "timestamp": { "seconds": 1263475302, "microseconds": 150772 } } - -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.
hw/watchdog/watchdog.c +7 -16
@@ -24,9 +24,9 @@#include "qemu/config-file.h" #include "qemu/queue.h" #include "qapi/qmp/types.h" -#include "monitor/monitor.h" #include "sysemu/sysemu.h" #include "sysemu/watchdog.h" +#include "qapi-event.h" /* Possible values for action parameter. */ #define WDT_RESET 1/* Hard reset. */
@@ -101,15 +101,6 @@ int select_watchdog_action(const char *p)return 0 ; } -static void watchdog_mon_event (const char *action) -{ -QObject *data; - - data =qobject_from_jsonf ("{ 'action': %s }" , action); -monitor_protocol_event (QEVENT_WATCHDOG , data); -qobject_decref (data); -} -/* This actually performs the "action" once a watchdog has expired, * ie. reboot, shutdown, exit, etc. */
@@ -117,31 +108,31 @@ void watchdog_perform_action(void) {switch (watchdog_action) {case WDT_RESET :/* same as 'system_reset' in monitor */ -watchdog_mon_event ("reset" ); +qapi_event_send_watchdog (WATCHDOG_EXPIRATION_ACTION_RESET ,NULL );qemu_system_reset_request ();break ;case WDT_SHUTDOWN :/* same as 'system_powerdown' in monitor */ -watchdog_mon_event ("shutdown" ); +qapi_event_send_watchdog (WATCHDOG_EXPIRATION_ACTION_SHUTDOWN ,NULL );qemu_system_powerdown_request ();break ;case WDT_POWEROFF :/* same as 'quit' command in monitor */ -watchdog_mon_event ("poweroff" ); +qapi_event_send_watchdog (WATCHDOG_EXPIRATION_ACTION_POWEROFF ,NULL );exit (0 );case WDT_PAUSE :/* same as 'stop' command in monitor */ -watchdog_mon_event ("pause" ); +qapi_event_send_watchdog (WATCHDOG_EXPIRATION_ACTION_PAUSE ,NULL );vm_stop (RUN_STATE_WATCHDOG );break ;case WDT_DEBUG : -watchdog_mon_event ("debug" ); +qapi_event_send_watchdog (WATCHDOG_EXPIRATION_ACTION_DEBUG ,NULL );fprintf (stderr,"watchdog: timer fired\n" );break ;case WDT_NONE : -watchdog_mon_event ("none" ); +qapi_event_send_watchdog (WATCHDOG_EXPIRATION_ACTION_NONE ,NULL );break ; } }
monitor.c +1 -1
@@ -614,6 +614,7 @@ static void monitor_qapi_event_init(void) {/* Limit RTC & BALLOON events to 1 per second */ monitor_qapi_event_throttle (QAPI_EVENT_RTC_CHANGE ,1000 ); +monitor_qapi_event_throttle (QAPI_EVENT_WATCHDOG ,1000 );qmp_event_set_func_emit (monitor_qapi_event_queue); }
@@ -741,7 +742,6 @@ static void monitor_protocol_event_init(void) {/* Limit RTC & BALLOON events to 1 per second */ monitor_protocol_event_throttle (QEVENT_BALLOON_CHANGE ,1000 ); -monitor_protocol_event_throttle (QEVENT_WATCHDOG ,1000 );/* limit the rate of quorum events to avoid hammering the management */ monitor_protocol_event_throttle (QEVENT_QUORUM_REPORT_BAD ,1000 );monitor_protocol_event_throttle (QEVENT_QUORUM_FAILURE ,1000 );
qapi-event.json +15 -0
@@ -91,3 +91,18 @@ ## { 'event': 'RTC_CHANGE', 'data': { 'offset': 'int' } } + +## +# @WATCHDOG +# +# Emitted when the watchdog device's timer is expired +# +# @action: action that has been taken +# +# Note: If action is "reset", "shutdown", or "pause" the WATCHDOG event is +# followed respectively by the RESET, SHUTDOWN, or STOP events +# +# Since: 2.1 +## +{ 'event': 'WATCHDOG', + 'data': { 'action': 'WatchdogExpirationAction' } }
qapi-schema.json +24 -0
@@ -4799,4 +4799,28 @@ { 'enum': 'BlockErrorAction', 'data': [ 'ignore', 'report', 'stop' ] } +## +# @WatchdogExpirationAction +# +# An enumeration of the actions taken when the watchdog device's timer is +# expired +# +# @reset: system resets +# +# @shutdown: system shutdown, note that it is similar to @powerdown, which +# tries to set to system status and notify guest +# +# @poweroff: system poweroff, the emulator program exits +# +# @pause: system pauses, similar to @stop +# +# @debug: system enters debug state +# +# @none: nothing is done +# +# Since: 2.1 +## +{ 'enum': 'WatchdogExpirationAction', + 'data': [ 'reset', 'shutdown', 'poweroff', 'pause', 'debug', 'none' ] } + { 'include': 'qapi-event.json' }
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH V6 17/29] qapi event: convert WATCHDOG
hw/watchdog/watchdog.c void watchdog_perform_action(void) · line 109
Quoted 13 lines · Wenchao Xia
Signed-off-by Wenchao Xia <[email protected]>--- docs/qmp/qmp-events.txt | 19 ------------------- hw/watchdog/watchdog.c | 23 +++++++---------------- monitor.c | 2 +- qapi-event.json | 15 +++++++++++++++ qapi-schema.json | 24 ++++++++++++++++++++++++ 5 files changed, 47 insertions(+), 36 deletions(-)hw/watchdog/watchdog.c +0
-0@@ -117,31 +108,31 @@ void watchdog_perform_action(void) {switch (watchdog_action) {
Worth fixing the missing space after switch while touching this area of code?
hw/watchdog/watchdog.c void watchdog_perform_action(void) · line 111
Quoted 3 lines
hw/watchdog/watchdog.c +1
-1case WDT_RESET :/* same as 'system_reset' in monitor */ -watchdog_mon_event ("reset" ); +qapi_event_send_watchdog (WATCHDOG_EXPIRATION_ACTION_RESET ,NULL );
More instances of ignoring the errp argument, where eliminating it might be nicer.
qapi-event.json line 105
Quoted 11 lines
qapi-event.json +11
-0+## +# @WATCHDOG +# +# Emitted when the watchdog device's timer is expired +# +# @action: action that has been taken +# +# Note: If action is "reset", "shutdown", or "pause" the WATCHDOG event is +# followed respectively by the RESET, SHUTDOWN, or STOP events +# +# Since: 2.1
0.14.0
qapi-event.json line 108
Quoted 1 line
qapi-event.json +1
-0+ 'data': { 'action': 'WatchdogExpirationAction' } }
Hmm. You've managed to create error.json in such a manner that it is not self-sufficient. If some other file includes error.json, it must also define WatchdogExpirationAction or it will fail the generators.
qapi-schema.json line 4803
Quoted 4 lines
qapi-schema.json +3
-0+++ b/qapi-schema.json +## +# @WatchdogExpirationAction
I think you will be better off to ensure that error.json is self-sufficient, perhaps by sticking any data type it references directly into common.json rather than qapi-schema.json, and having error.json include common.json. (This is the first instance of referencing an external type, but other events later in the series have the same issue).
qapi-schema.json line 4824
Quoted 4 lines
qapi-schema.json +4
-0+# Since: 2.1 +## +{ 'enum': 'WatchdogExpirationAction', + 'data': [ 'reset', 'shutdown', 'poweroff', 'pause', 'debug', 'none' ] }
Nice conversion of open-coded string to an enum. While I've been asking for the earliest QMP version for Since fields on event objects proper, here, I think you're okay keeping the 'since 2.1' indication. Why? Because we already have other examples in the code base of converting open-coded strings to an enum, where the QMP wire format is the same, but where the version claimed on those enums was the qemu version that did the conversion rather than the age of the command being converted. (Maybe we could audit all of those conversions and retroactively update their Since field, or even come up with a notation for wire-stability release vs. QAPI introspection release - but that sounds like more pain than necessary with no obvious benefit)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH V6 17/29] qapi event: convert WATCHDOG
Quoted 12 lines · Eric Blake
Quoted 9 lines · Wenchao Xia
Signed-off-by Wenchao Xia <[email protected]>--- docs/qmp/qmp-events.txt | 19 ------------------- hw/watchdog/watchdog.c | 23 +++++++---------------- monitor.c | 2 +- qapi-event.json | 15 +++++++++++++++ qapi-schema.json | 24 ++++++++++++++++++++++++ 5 files changed, 47 insertions(+), 36 deletions(-)
Quoted 5 lines
Quoted 1 line
+ 'data': { 'action': 'WatchdogExpirationAction' } }
Hmm. You've managed to create error.json in such a manner that it is not self-sufficient. If some other file includes error.json, it must also define WatchdogExpirationAction or it will fail the generators.
s/error.json/qapi-event.json/
Quoted 7 lines
qapi-schema.json line 4803
Quoted 5 lines
+++
b/qapi-schema.jsonqapi-schema.json +2
-0+## +# @WatchdogExpirationActionI think you will be better off to ensure that error.json is
and again qapi-event.json (not sure why I typed error.json).
Quoted 5 lines
self-sufficient, perhaps by sticking any data type it references directly into common.json rather than qapi-schema.json, and having error.json include common.json. (This is the first instance of referencing an external type, but other events later in the series have the same issue).
Oh weird! I've managed to run all four of scripts/qapi-{visit,types,commands,event}.py directly on qapi-event.json, and didn't get any complaints from the generator. BUT, the generated code is definitely different:
-void qapi_event_send_watchdog(WatchdogExpirationAction action, +void qapi_event_send_watchdog(WatchdogExpirationAction * action,
Error **errp)
That is, when the enum type is known (because the parse was done on qapi-schema.json), the WatchdogExpirationAction argument is treated as an integer enum value; but when the enum type is unknown (because the parse was done directly on an incomplete qapi-event.json), the generator tries to treat it as a pointer to an otherwise unknown structure. (Never mind the odd formatting of the space after the '*' - I believe this pending patch fixes it:
https://lists.gnu.org/archive/html/qemu-devel/2014-06/msg02385.html).
This little exercise raises red flags for me - we probably ought to enhance the code generators to error out instead of blindly act as if unknown types are pointers. But save it for another day - no need to stall this series just to wait for a robustness improvement to the generators.
Meanwhile, my suggestion of making qapi-event.json to be self-sufficient is going to be a bit harder to test, but is still probably worth trying (just moving common types into a common shared include).
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH V6 17/29] qapi event: convert WATCHDOG
Quoted 63 lines · Eric Blake
Quoted 12 lines · Eric Blake
Quoted 9 lines · Wenchao Xia
Signed-off-by Wenchao Xia <[email protected]>--- docs/qmp/qmp-events.txt | 19 ------------------- hw/watchdog/watchdog.c | 23 +++++++---------------- monitor.c | 2 +- qapi-event.json | 15 +++++++++++++++ qapi-schema.json | 24 ++++++++++++++++++++++++ 5 files changed, 47 insertions(+), 36 deletions(-)Quoted 5 lines
Quoted 1 line
+ 'data': { 'action': 'WatchdogExpirationAction' } }
Hmm. You've managed to create error.json in such a manner that it is not self-sufficient. If some other file includes error.json, it must also define WatchdogExpirationAction or it will fail the generators.
s/error.json/qapi-event.json/
Quoted 7 lines
qapi-schema.json line 4803
Quoted 5 lines
+++
b/qapi-schema.jsonqapi-schema.json +2
-0+## +# @WatchdogExpirationActionI think you will be better off to ensure that error.json is
and again qapi-event.json (not sure why I typed error.json).
Quoted 5 lines
self-sufficient, perhaps by sticking any data type it references directly into common.json rather than qapi-schema.json, and having error.json include common.json. (This is the first instance of referencing an external type, but other events later in the series have the same issue).
Oh weird! I've managed to run all four of
scripts/qapi-{visit,types,commands,event}.pydirectly on qapi-event.json, and didn't get any complaints from the generator. BUT, the generated code is definitely different:(quoted diff) +1
-1-void qapi_event_send_watchdog(WatchdogExpirationAction action, +void qapi_event_send_watchdog(WatchdogExpirationAction * action, Error **errp)That is, when the enum type is known (because the parse was done on qapi-schema.json), the WatchdogExpirationAction argument is treated as an integer enum value; but when the enum type is unknown (because the parse was done directly on an incomplete qapi-event.json), the generator tries to treat it as a pointer to an otherwise unknown structure. (Never mind the odd formatting of the space after the '*' - I believe this pending patch fixes it:
https://lists.gnu.org/archive/html/qemu-devel/2014-06/msg02385.html).This little exercise raises red flags for me - we probably ought to enhance the code generators to error out instead of blindly act as if unknown types are pointers. But save it for another day - no need to stall this series just to wait for a robustness improvement to the generators.
Quoted 4 lines
Meanwhile, my suggestion of making qapi-event.json to be self-sufficient is going to be a bit harder to test, but is still probably worth trying (just moving common types into a common shared include).
I think it is a issue about how to orgnize the .json files. There are
some common type defines needed for different .json files, in my series they are needed both in qapi-schema.json and qapi-event.json. So to make qapi-event.json self-sufficient, qapi-schema.json will be insufficient. I considered this before, and thought it is better to reorgnize .json files as:
qapi-types.json
| |
qapi-cmd.json qapi-event.json
It is an adjusting work for existing code, So I didn't do that in my
series.
Re: [Qemu-devel] [PATCH V6 17/29] qapi event: convert WATCHDOG
In reply to Eric BlakeIl 13/06/2014 23:47, Eric Blake ha scritto:
Quoted 9 lines
Quoted 2 lines
+##
Quoted 1 line
+# @WatchdogExpirationAction
I think you will be better off to ensure that error.json is self-sufficient, perhaps by sticking any data type it references directly into common.json rather than qapi-schema.json, and having error.json include common.json. (This is the first instance of referencing an external type, but other events later in the series have the same issue).
Can be done later though, I think?
Paolo
Re: [Qemu-devel] [PATCH V6 17/29] qapi event: convert WATCHDOG
Quoted 11 lines · Paolo Bonzini
Il 13/06/2014 23:47, Eric Blake ha scritto:
Quoted 9 lines
Quoted 2 lines
+##
Quoted 1 line
+# @WatchdogExpirationAction
I think you will be better off to ensure that error.json is self-sufficient, perhaps by sticking any data type it references directly into common.json rather than qapi-schema.json, and having error.json include common.json. (This is the first instance of referencing an external type, but other events later in the series have the same issue).
Quoted 1 line
Can be done later though, I think?
Yes; as I mentioned in my other mail:
https://lists.gnu.org/archive/html/qemu-devel/2014-06/msg03208.html
This little exercise raises red flags for me - we probably ought to enhance the code generators to error out instead of blindly act as if unknown types are pointers. But save it for another day - no need to stall this series just to wait for a robustness improvement to the generators.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v6 18/29 qapi event: convert DEVICE_DELETED
In reply to Wenchao Xia--- docs/qmp/qmp-events.txt | 18 ------------------ hw/core/qdev.c | 12 ++---------- qapi-event.json | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 28 deletions(-)
docs/qmp/qmp-events.txt +0 -18
@@ -158,24 +158,6 @@ Example: 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 -----------------
hw/core/qdev.c +2 -10
@@ -32,8 +32,8 @@#include "qapi/qmp/qerror.h" #include "qapi/visitor.h" #include "qapi/qmp/qjson.h" -#include "monitor/monitor.h" #include "hw/hotplug.h" +#include "qapi-event.h" int qdev_hotplug =0 ;static bool qdev_hot_added = false;
@@ -939,7 +939,6 @@ static void device_unparent(Object *obj) {DeviceState *dev =DEVICE (obj);BusState *bus; -QObject *event_data;bool have_realized = dev->realized;if (dev->realized) {
@@ -959,14 +958,7 @@ static void device_unparent(Object *obj)if (have_realized) {gchar *path =object_get_canonical_path (OBJECT (dev)); -if (dev->id) { - event_data =qobject_from_jsonf ("{ 'device': %s, 'path': %s }" , - dev->id, path); - }else { - event_data =qobject_from_jsonf ("{ 'path': %s }" , path); - } -monitor_protocol_event (QEVENT_DEVICE_DELETED , event_data); -qobject_decref (event_data); +qapi_event_send_device_deleted (!!dev->id, dev->id, path,NULL );g_free (path); } }
qapi-event.json +16 -0
@@ -106,3 +106,19 @@ ## { 'event': 'WATCHDOG', 'data': { 'action': 'WatchdogExpirationAction' } } + +## +# @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. +# +# @device: #optional, device name +# +# @path: device path +# +# Since: 2.1 +## +{ 'event': 'DEVICE_DELETED', + 'data': { '*device': 'str', 'path': 'str' } }
Signature · 1 line
1.7.1
PATCH v6 19/29 qapi event: convert DEVICE_TRAY_MOVED
In reply to Wenchao Xia--- block.c | 21 +++++++-------------- docs/qmp/qmp-events.txt | 18 ------------------ qapi-event.json | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 32 deletions(-)
block.c +7 -14
@@ -35,6 +35,7 @@#include "block/qapi.h" #include "qmp-commands.h" #include "qemu/timer.h" +#include "qapi-event.h" #ifdef CONFIG_BSD #include <sys/types.h>
@@ -2162,17 +2163,6 @@ void bdrv_emit_qmp_error_event(const BlockDriverState *bdrv,qobject_decref (data); } -static void bdrv_emit_qmp_eject_event (BlockDriverState *bs,bool ejected) -{ -QObject *data; - - data =qobject_from_jsonf ("{ 'device': %s, 'tray-open': %i }" , -bdrv_get_device_name (bs), ejected); -monitor_protocol_event (QEVENT_DEVICE_TRAY_MOVED , data); - -qobject_decref (data); -} -static void bdrv_dev_change_media_cb (BlockDriverState *bs,bool load) {if (bs->dev_ops && bs->dev_ops->change_media_cb) {
@@ -2180,11 +2170,13 @@ static void bdrv_dev_change_media_cb(BlockDriverState *bs, bool load) bs->dev_ops->change_media_cb (bs->dev_opaque, load);if (tray_was_closed) {/* tray open */ -bdrv_emit_qmp_eject_event (bs, true); +qapi_event_send_device_tray_moved (bdrv_get_device_name (bs), + true,NULL ); }if (load) {/* tray close */ -bdrv_emit_qmp_eject_event (bs, false); +qapi_event_send_device_tray_moved (bdrv_get_device_name (bs), + false,NULL ); } } }
@@ -5173,7 +5165,8 @@ void bdrv_eject(BlockDriverState *bs, bool eject_flag) }if (bs->device_name[0 ] !='\0' ) { -bdrv_emit_qmp_eject_event (bs, eject_flag); +qapi_event_send_device_tray_moved (bdrv_get_device_name (bs), + eject_flag,NULL ); } }
docs/qmp/qmp-events.txt +0 -18
@@ -158,24 +158,6 @@ Example: Note: The "ready to complete" status is always reset by a BLOCK_JOB_ERROR event. -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 --------------
qapi-event.json +15 -0
@@ -122,3 +122,18 @@ ## { 'event': 'DEVICE_DELETED', 'data': { '*device': 'str', 'path': 'str' } } + +## +# @DEVICE_TRAY_MOVED +# +# Emitted whenever the tray of a removable device is moved by the guest or by +# HMP/QMP commands +# +# @device: device name +# +# @tray-open: true if the tray has been opened or false if it has been closed +# +# Since: 2.1 +## +{ 'event': 'DEVICE_TRAY_MOVED', + 'data': { 'device': 'str', 'tray-open': 'bool' } }
Signature · 1 line
1.7.1
PATCH v6 20/29 qapi event: convert BLOCK_IO_ERROR and BLOCK_JOB_ERROR
In reply to Wenchao Xia--- block.c | 36 +++------------------------------ blockjob.c | 6 ++++- docs/qmp/qmp-events.txt | 47 --------------------------------------------- include/block/block_int.h | 3 -- qapi-event.json | 38 ++++++++++++++++++++++++++++++++++++ qapi-schema.json | 14 +++++++++++++ 6 files changed, 61 insertions(+), 83 deletions(-)
block.c +4 -32
@@ -24,7 +24,6 @@#include "config-host.h" #include "qemu-common.h" #include "trace.h" -#include "monitor/monitor.h" #include "block/block_int.h" #include "block/blockjob.h" #include "qemu/module.h"
@@ -2133,36 +2132,6 @@ void bdrv_set_dev_ops(BlockDriverState *bs, const BlockDevOps *ops, bs->dev_opaque = opaque; } -void bdrv_emit_qmp_error_event (const BlockDriverState *bdrv, -enum MonitorEvent ev, -BlockErrorAction action,bool is_read) -{ -QObject *data; -const char *action_str; - -switch (action) { -case BLOCK_ERROR_ACTION_REPORT : - action_str ="report" ; -break ; -case BLOCK_ERROR_ACTION_IGNORE : - action_str ="ignore" ; -break ; -case BLOCK_ERROR_ACTION_STOP : - action_str ="stop" ; -break ; -default : -abort (); - } - - data =qobject_from_jsonf ("{ 'device': %s, 'action': %s, 'operation': %s }" , - bdrv->device_name, - action_str, - is_read ?"read" :"write" ); -monitor_protocol_event (ev, data); - -qobject_decref (data); -} -static void bdrv_dev_change_media_cb (BlockDriverState *bs,bool load) {if (bs->dev_ops && bs->dev_ops->change_media_cb) {
@@ -3612,7 +3581,10 @@ void bdrv_error_action(BlockDriverState *bs, BlockErrorAction action, bool is_read, int error) {assert (error >=0 ); -bdrv_emit_qmp_error_event (bs,QEVENT_BLOCK_IO_ERROR , action, is_read); +qapi_event_send_block_io_error (bdrv_get_device_name (bs), + is_read ?IO_OPERATION_TYPE_READ : +IO_OPERATION_TYPE_WRITE , + action,NULL );if (action ==BLOCK_ERROR_ACTION_STOP ) {vm_stop (RUN_STATE_IO_ERROR );bdrv_iostatus_set_err (bs, error);
blockjob.c +5 -1
@@ -34,6 +34,7 @@#include "block/coroutine.h" #include "qmp-commands.h" #include "qemu/timer.h" +#include "qapi-event.h" void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs, int64_t speed, BlockDriverCompletionFunc *cb,
@@ -277,7 +278,10 @@ BlockErrorAction block_job_error_action(BlockJob *job, BlockDriverState *bs,default :abort (); } -bdrv_emit_qmp_error_event (job->bs,QEVENT_BLOCK_JOB_ERROR , action, is_read); +qapi_event_send_block_job_error (bdrv_get_device_name (bs), + is_read ?IO_OPERATION_TYPE_READ : +IO_OPERATION_TYPE_WRITE , + action,NULL );if (action ==BLOCK_ERROR_ACTION_STOP ) {block_job_pause (job);block_job_iostatus_set_err (job, error);
docs/qmp/qmp-events.txt +0 -47
59 lines not on this page · raw message
include/block/block_int.h +0 -3
@@ -399,9 +399,6 @@ AioContext *bdrv_get_aio_context(BlockDriverState *bs);#ifdef _WIN32int is_windows_drive (const char *filename);#endif -void bdrv_emit_qmp_error_event (const BlockDriverState *bdrv, -enum MonitorEvent ev, -BlockErrorAction action,bool is_read);/** * stream_start:
qapi-event.json +38 -0
@@ -137,3 +137,41 @@ ## { 'event': 'DEVICE_TRAY_MOVED', 'data': { 'device': 'str', 'tray-open': 'bool' } } + +## +# @BLOCK_IO_ERROR +# +# Emitted when a disk I/O error occurs +# +# @device: device name +# +# @operation: I/O operation +# +# @action: action that has been taken +# +# Note: If action is "stop", a STOP event will eventually follow the +# BLOCK_IO_ERROR event +# +# Since: 2.1 +## +{ 'event': 'BLOCK_IO_ERROR', + 'data': { 'device': 'str', 'operation': 'IoOperationType', + 'action': 'BlockErrorAction' } } + +## +# @BLOCK_JOB_ERROR +# +# Emitted when a block job encounters an error +# +# @device: device name +# +# @operation: I/O operation +# +# @action: action that has been taken +# +# Since: 2.1 +## +{ 'event': 'BLOCK_JOB_ERROR', + 'data': { 'device' : 'str', + 'operation': 'IoOperationType', + 'action' : 'BlockdevOnError' } }
qapi-schema.json +14 -0
@@ -4823,4 +4823,18 @@ { 'enum': 'WatchdogExpirationAction', 'data': [ 'reset', 'shutdown', 'poweroff', 'pause', 'debug', 'none' ] } +## +# @IoOperationType +# +# An enumeration of the I/O operation types +# +# @read: read operation +# +# @write: write operation +# +# Since: 2.1 +## +{ 'enum': 'IoOperationType', + 'data': [ 'read', 'write' ] } + { 'include': 'qapi-event.json' }
Signature · 1 line
1.7.1
PATCH v6 21/29 qapi event: convert BLOCK_IMAGE_CORRUPTED
In reply to Wenchao Xia--- block/qcow2-refcount.c | 14 ++++++++------ docs/qmp/qmp-events.txt | 22 ---------------------- qapi-event.json | 22 ++++++++++++++++++++++ 3 files changed, 30 insertions(+), 28 deletions(-)
block/qcow2-refcount.c +8 -6
@@ -27,6 +27,7 @@#include "block/qcow2.h" #include "qemu/range.h" #include "qapi/qmp/types.h" +#include "qapi-event.h" static int64_t alloc_clusters_noref (BlockDriverState *bs,uint64_t size); static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs,
@@ -1807,7 +1808,6 @@ int qcow2_pre_write_overlap_check(BlockDriverState *bs, int ign, int64_t offset, }else if (ret >0 ) {int metadata_ol_bitnr =ffs (ret) -1 ;char *message; -QObject *data;assert (metadata_ol_bitnr <QCOW2_OL_MAX_BITNR );
@@ -1816,12 +1816,14 @@ int qcow2_pre_write_overlap_check(BlockDriverState *bs, int ign, int64_t offset, metadata_ol_names[metadata_ol_bitnr]); message =g_strdup_printf ("Prevented %s overwrite" , metadata_ol_names[metadata_ol_bitnr]); - data =qobject_from_jsonf ("{ 'device': %s, 'msg': %s, 'offset': %" - PRId64", 'size': %" PRId64" }" , bs->device_name, message, - offset, size); -monitor_protocol_event (QEVENT_BLOCK_IMAGE_CORRUPTED , data); +qapi_event_send_block_image_corrupted (bdrv_get_device_name (bs), + message, + true, + offset, + true, + size, +NULL );g_free (message); -qobject_decref (data);qcow2_mark_corrupt (bs); bs->drv =NULL ;/* make BDS unusable */
docs/qmp/qmp-events.txt +0 -22
@@ -18,28 +18,6 @@ Example: "data": { "actual": 944766976 }, "timestamp": { "seconds": 1267020223, "microseconds": 435656 } } -BLOCK_IMAGE_CORRUPTED ---------------------- - -Emitted when a disk image is being marked corrupt. - -Data: - -- "device": Device name (json-string) -- "msg": Informative message (e.g., reason for the corruption) (json-string) -- "offset": If the corruption resulted from an image access, this is the access - offset into the image (json-int) -- "size": If the corruption resulted from an image access, this is the access - size (json-int) - -Example: - -{ "event": "BLOCK_IMAGE_CORRUPTED", - "data": { "device": "ide0-hd0", - "msg": "Prevented active L1 table overwrite", "offset": 196608, - "size": 65536 }, - "timestamp": { "seconds": 1378126126, "microseconds": 966463 } } - BLOCK_JOB_CANCELLED -------------------
qapi-event.json +22 -0
@@ -159,6 +159,28 @@ 'action': 'BlockErrorAction' } } ## +# @BLOCK_IMAGE_CORRUPTED +# +# Emitted when a disk image is being marked corrupt +# +# @device: device name +# +# @msg: informative message, for example, reason for the corruption +# +# @offset: #optional, if the corruption resulted from an image access, this is +# the access offset into the image +# @size: #optional, if the corruption resulted from an image access, this is +# the access size +# +# Since: 2.1 +## +{ 'event': 'BLOCK_IMAGE_CORRUPTED', + 'data': { 'device' : 'str', + 'msg' : 'str', + '*offset': 'int', + '*size' : 'int' } } + +## # @BLOCK_JOB_ERROR # # Emitted when a block job encounters an error
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH V6 21/29] qapi event: convert BLOCK_IMAGE_CORRUPTED
Quoted 11 lines · Wenchao Xia
Signed-off-by Wenchao Xia <[email protected]>--- block/qcow2-refcount.c | 14 ++++++++------ docs/qmp/qmp-events.txt | 22 ---------------------- qapi-event.json | 22 ++++++++++++++++++++++ 3 files changed, 30 insertions(+), 28 deletions(-)-- "device": Device name (json-string)
-- "msg": Informative message (e.g., reason for the corruption) (json-string)
-- "offset": If the corruption resulted from an image access, this is the access
docs/qmp/qmp-events.txt Example: · line 39
Quoted 9 lines
docs/qmp/qmp-events.txt +0
-9- offset into the image (json-int) -- "size": If the corruption resulted from an image access, this is the access - size (json-int) - -Example: - -{ "event": "BLOCK_IMAGE_CORRUPTED", - "data": { "device": "ide0-hd0", - "msg": "Prevented active L1 table overwrite", "offset": 196608,
The old docs didn't make it clear...
Review
Quoted 2 lines
(quoted diff) +2
-0+# +# @msg: informative message, for example, reason for the corruption
...but the new docs should mention that msg is for human consumption and should not be parsed by machine as it is not guaranteed to be stable
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v6 22/29 qapi event: convert other BLOCK_JOB events
In reply to Wenchao XiaSince BLOCK_JOB_COMPLETED, BLOCK_JOB_CANCELLED, BLOCK_JOB_READY are related, converts them in one patch. The block_job_event_* functions are used to keep encapsulation of BlockJob structure.
--- block/mirror.c | 2 +- blockdev.c | 12 +++---- blockjob.c | 36 +++++++++++++---------- docs/qmp/qmp-events.txt | 71 ---------------------------------------------- include/block/blockjob.h | 17 ++++++++-- qapi-event.json | 71 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 110 insertions(+), 99 deletions(-)
block/mirror.c +1 -1
@@ -427,7 +427,7 @@ static void coroutine_fn mirror_run(void *opaque)*/ s->common.offset = end *BDRV_SECTOR_SIZE ;if (!s->synced) { -block_job_ready (&s->common); +block_job_event_ready (&s->common); s->synced = true; }
blockdev.c +5 -7
@@ -1851,23 +1851,21 @@ void qmp_block_resize(bool has_device, const char *device,static void block_job_cb (void *opaque,int ret) {BlockDriverState *bs = opaque; -QObject *obj; +const char *msg =NULL ;trace_block_job_cb (bs, bs->job, ret);assert (bs->job); - obj =qobject_from_block_job (bs->job); +if (ret <0 ) { -QDict *dict =qobject_to_qdict (obj); -qdict_put (dict,"error" ,qstring_from_str (strerror (-ret))); + msg =strerror (-ret); }if (block_job_is_cancelled (bs->job)) { -monitor_protocol_event (QEVENT_BLOCK_JOB_CANCELLED , obj); +block_job_event_cancelled (bs->job); }else { -monitor_protocol_event (QEVENT_BLOCK_JOB_COMPLETED , obj); +block_job_event_completed (bs->job, msg); } -qobject_decref (obj);bdrv_put_ref_bh_schedule (bs); }
blockjob.c +20 -16
@@ -26,7 +26,6 @@#include "config-host.h" #include "qemu-common.h" #include "trace.h" -#include "monitor/monitor.h" #include "block/block.h" #include "block/blockjob.h" #include "block/block_int.h"
@@ -233,26 +232,31 @@ static void block_job_iostatus_set_err(BlockJob *job, int error) } } +void block_job_event_cancelled (BlockJob *job) +{ +qapi_event_send_block_job_cancelled (job->driver->job_type, +bdrv_get_device_name (job->bs), + job->len, + job->offset, + job->speed, +NULL ); +} -QObject *qobject_from_block_job (BlockJob *job) +void block_job_event_completed (BlockJob *job,const char *msg) { -return qobject_from_jsonf ("{ 'type': %s," -"'device': %s," -"'len': %" PRId64"," -"'offset': %" PRId64"," -"'speed': %" PRId64" }" , - BlockJobType_lookup[job->driver->job_type], -bdrv_get_device_name (job->bs), - job->len, - job->offset, - job->speed); +qapi_event_send_block_job_completed (job->driver->job_type, +bdrv_get_device_name (job->bs), + job->len, + job->offset, + job->speed, + !!msg, + msg, +NULL ); } -void block_job_ready (BlockJob *job) +void block_job_event_ready (BlockJob *job) { -QObject *data =qobject_from_block_job (job); -monitor_protocol_event (QEVENT_BLOCK_JOB_READY , data); -qobject_decref (data); +qapi_event_send_block_job_ready (bdrv_get_device_name (job->bs),NULL ); } BlockErrorAction block_job_error_action(BlockJob *job, BlockDriverState *bs,
docs/qmp/qmp-events.txt +0 -71
77 lines not on this page · raw message
include/block/blockjob.h +13 -4
@@ -217,12 +217,21 @@ void block_job_pause(BlockJob *job);void block_job_resume (BlockJob *job);/** -* qobject_from_block_job: +* block_job_event_cancle: * @job: The job whose information is requested. * -* Return a QDict corresponding to @job's query-block-jobs entry. +* Send a BLOCK_JOB_CANCELLED event for the specified job. */ -QObject *qobject_from_block_job (BlockJob *job); +void block_job_event_cancelled (BlockJob *job); + +/** +* block_job_ready: +* @job: The job which is now ready to complete. +* @msg: Error message. Only present on failure. +* +* Send a BLOCK_JOB_COMPLETED event for the specified job. +*/ +void block_job_event_completed (BlockJob *job,const char *msg);/** * block_job_ready:
@@ -230,7 +239,7 @@ QObject *qobject_from_block_job(BlockJob *job);* * Send a BLOCK_JOB_READY event for the specified job. */ -void block_job_ready (BlockJob *job); +void block_job_event_ready (BlockJob *job);/** * block_job_is_paused:
qapi-event.json +71 -0
80 lines not on this page · raw message
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH V6 22/29] qapi event: convert other BLOCK_JOB events
Quoted 2 lines · Wenchao Xia
Since
BLOCK_JOB_COMPLETED,BLOCK_JOB_CANCELLED,BLOCK_JOB_READYare related, converts them in one patch. The block_job_event_* functions
s/converts/convert/
Quoted 16 lines
are used to keep encapsulation of BlockJob structure.
Signed-off-by Wenchao Xia <[email protected]>--- block/mirror.c | 2 +- blockdev.c | 12 +++---- blockjob.c | 36 +++++++++++++---------- docs/qmp/qmp-events.txt | 71 ---------------------------------------------- include/block/blockjob.h | 17 ++++++++-- qapi-event.json | 71 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 110 insertions(+), 99 deletions(-)-- "device": Device name (json-string) -- "len": Maximum progress value (json-int) -- "offset": Current progress value (json-int)
docs/qmp/qmp-events.txt Example: · line 63
Quoted 7 lines
docs/qmp/qmp-events.txt +0
-7- 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
This sort of disclaimer is what I'm looking for in 21/29.
Quoted 3 lines
/**
- *qobject_from_block_job:
+ *block_job_event_cancle:
s/cancle/cancelled/
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v6 23/29 qapi event: convert NIC_RX_FILTER_CHANGED
In reply to Wenchao XiaParam name is declared as optional, since in code it is an optional one.
--- docs/qmp/qmp-events.txt | 17 ----------------- hw/net/virtio-net.c | 13 +++---------- qapi-event.json | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 27 deletions(-)
docs/qmp/qmp-events.txt +0 -17
@@ -32,23 +32,6 @@ Example: { "event": "GUEST_PANICKED", "data": { "action": "pause" } } -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 } } -} - QUORUM_FAILURE --------------
hw/net/virtio-net.c +3 -10
@@ -22,7 +22,7 @@#include "net/vhost_net.h" #include "hw/virtio/virtio-bus.h" #include "qapi/qmp/qjson.h" -#include "monitor/monitor.h" +#include "qapi-event.h" #define VIRTIO_NET_VM_VERSION 11
@@ -196,19 +196,12 @@ static void virtio_net_set_link_status(NetClientState *nc)static void rxfilter_notify (NetClientState *nc) { -QObject *event_data;VirtIONet *n =qemu_get_nic_opaque (nc);if (nc->rxfilter_notify_enabled) {gchar *path =object_get_canonical_path (OBJECT (n->qdev)); -if (n->netclient_name) { - event_data =qobject_from_jsonf ("{ 'name': %s, 'path': %s }" , - n->netclient_name, path); - }else { - event_data =qobject_from_jsonf ("{ 'path': %s }" , path); - } -monitor_protocol_event (QEVENT_NIC_RX_FILTER_CHANGED , event_data); -qobject_decref (event_data); +qapi_event_send_nic_rx_filter_changed (!!n->netclient_name, + n->netclient_name, path,NULL );g_free (path);/* disable event notification to avoid events flooding */
qapi-event.json +15 -0
@@ -268,3 +268,18 @@ ## { 'event': 'BLOCK_JOB_READY', 'data': { 'device': 'str' } } + +## +# @NIC_RX_FILTER_CHANGED +# +# Emitted once until the 'query-rx-filter' command is executed, the first event +# will always be emitted +# +# @name: #optional, net client name +# +# @path: device path +# +# Since: 2.1 +## +{ 'event': 'NIC_RX_FILTER_CHANGED', + 'data': { '*name': 'str', 'path': 'str' } }
Signature · 1 line
1.7.1
PATCH v6 24/29 qapi event: convert VNC events
In reply to Wenchao XiaSince VNC_CONNECTED, VNC_DISCONNECTED, VNC_INITIALIZED share some common functions, converts them in one patch.
--- docs/qmp/qmp-events.txt | 90 -------------------------------------- qapi-event.json | 49 +++++++++++++++++++++ ui/vnc.c | 111 ++++++++++++++++++++++++----------------------- ui/vnc.h | 4 +- 4 files changed, 108 insertions(+), 146 deletions(-)
docs/qmp/qmp-events.txt +0 -90
@@ -132,93 +132,3 @@ Example: "connection-id": 1804289383, "host": "127.0.0.1", "channel-id": 0, "tls": true} }} - -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 } }
qapi-event.json +49 -0
52 lines not on this page · raw message
ui/vnc.c +57 -54
221 lines not on this page · raw message
ui/vnc.h +2 -2
@@ -31,7 +31,6 @@#include "qemu/queue.h" #include "qemu/thread.h" #include "ui/console.h" -#include "monitor/monitor.h" #include "audio/audio.h" #include "qemu/bitmap.h" #include <zlib.h>
@@ -40,6 +39,7 @@#include "keymaps.h" #include "vnc-palette.h" #include "vnc-enc-zrle.h" +#include "qapi-types.h" // #define _VNC_DEBUG 1
@@ -292,7 +292,7 @@ struct VncStatebool websocket;#endif /* CONFIG_VNC_WS */ -QObject *info; +VncClientInfo *info;Buffer output;Buffer input;
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH V6 24/29] qapi event: convert VNC events
Quoted 2 lines · Wenchao Xia
Since
VNC_CONNECTED,VNC_DISCONNECTED,VNC_INITIALIZEDshare some common functions, converts them in one patch.
s/converts/convert/
Quoted 10 lines
Signed-off-by Wenchao Xia <[email protected]>--- docs/qmp/qmp-events.txt | 90 -------------------------------------- qapi-event.json | 49 +++++++++++++++++++++ ui/vnc.c | 111 ++++++++++++++++++++++++----------------------- ui/vnc.h | 4 +- 4 files changed, 108 insertions(+), 146 deletions(-)
qapi-event.json line 319
Quoted 4 lines
qapi-event.json +4
-0+## +{ 'event': 'VNC_INITIALIZED', + 'data': { 'server': 'VncServerInfo', + 'client': 'VncClientInfo' } }
Those types from the earlier commit make this nice :)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v6 25/29 qapi event: convert SPICE events
In reply to Wenchao XiaSPICE_INITIALIZED, SPICE_CONNECTED, SPICE_DISCONNECTED and SPICE_MIGRATE_COMPLETED are converted in one patch, since they use some common functions. inet_strfamily() is removed since no more caller exist now.
Note that there is no existing doc for SPICE_MIGRATE_COMPLETED in docs/qmp/qmp-events.txt before this patch.
--- docs/qmp/qmp-events.txt | 62 ----------------------------------------- include/qemu/sockets.h | 1 - qapi-event.json | 55 +++++++++++++++++++++++++++++++++++++ ui/spice-core.c | 70 ++++++++++++++++++++++++----------------------- util/qemu-sockets.c | 10 ------- 5 files changed, 91 insertions(+), 107 deletions(-)
docs/qmp/qmp-events.txt +0 -62
@@ -70,65 +70,3 @@ Example: { "event": "QUORUM_REPORT_BAD", "data": { "node-name": "1.raw", "sector-num": 345435, "sector-count": 5 }, "timestamp": { "seconds": 1344522075, "microseconds": 745528 } } - -SPICE_CONNECTED, SPICE_DISCONNECTED ------------------------------------ - -Emitted when a SPICE client connects or 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_CONNECTED", - "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'n'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} -}}
include/qemu/sockets.h +0 -1
@@ -61,7 +61,6 @@ int inet_nonblocking_connect(const char *str, void *opaque, Error **errp);int inet_dgram_opts (QemuOpts *opts,Error **errp); -const char *inet_strfamily (int family);NetworkAddressFamily inet_netfamily (int family);int unix_listen_opts (QemuOpts *opts,Error **errp);
qapi-event.json +55 -0
58 lines not on this page · raw message
ui/spice-core.c +36 -34
127 lines not on this page · raw message
util/qemu-sockets.c +0 -10
@@ -94,16 +94,6 @@ static void inet_setport(struct addrinfo *e, int port) } } -const char *inet_strfamily (int family) -{ -switch (family) { -case PF_INET6 :return "ipv6" ; -case PF_INET :return "ipv4" ; -case PF_UNIX :return "unix" ; - } -return "unknown" ; -} -NetworkAddressFamily inet_netfamily (int family) {switch (family) {
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH V6 25/29] qapi event: convert SPICE events
Quoted 4 lines · Wenchao Xia
SPICE_INITIALIZED,SPICE_CONNECTED,SPICE_DISCONNECTEDandSPICE_MIGRATE_COMPLETEDare converted in one patch, since they use some common functions.inet_strfamily()is removed since no more caller exist now.
s/caller/callers/
Quoted 13 lines
Note that there is no existing doc for
SPICE_MIGRATE_COMPLETEDindocs/qmp/qmp-events.txtbefore this patch.Signed-off-by Wenchao Xia <[email protected]>--- docs/qmp/qmp-events.txt | 62 ----------------------------------------- include/qemu/sockets.h | 1 - qapi-event.json | 55 +++++++++++++++++++++++++++++++++++++ ui/spice-core.c | 70 ++++++++++++++++++++++++----------------------- util/qemu-sockets.c | 10 ------- 5 files changed, 91 insertions(+), 107 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v6 26/29 qapi event: convert BALLOON_CHANGE
In reply to Wenchao Xia--- balloon.c | 13 ------------- docs/qmp/qmp-events.txt | 17 ----------------- hw/virtio/virtio-balloon.c | 6 ++++-- include/sysemu/balloon.h | 2 -- monitor.c | 3 +-- qapi-event.json | 13 +++++++++++++ 6 files changed, 18 insertions(+), 36 deletions(-)
balloon.c +0 -13
@@ -81,19 +81,6 @@ static int qemu_balloon_status(BalloonInfo *info)return 1 ; } -void qemu_balloon_changed (int64_t actual) -{ -QObject *data; - - data =qobject_from_jsonf ("{ 'actual': %" PRId64" }" , - actual); - -monitor_protocol_event (QEVENT_BALLOON_CHANGE , data); - -qobject_decref (data); -} - -BalloonInfo *qmp_query_balloon (Error **errp) {BalloonInfo *info;
docs/qmp/qmp-events.txt +0 -17
@@ -1,23 +1,6 @@ QEMU Machine Protocol Events ============================ -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 } } - GUEST_PANICKED --------------
hw/virtio/virtio-balloon.c +4 -2
@@ -24,6 +24,7 @@#include "sysemu/kvm.h" #include "exec/address-spaces.h" #include "qapi/visitor.h" +#include "qapi-event.h" #if defined(__linux__)#include <sys/mman.h>
@@ -294,8 +295,9 @@ static void virtio_balloon_set_config(VirtIODevice *vdev,memcpy (&config, config_data,sizeof (struct virtio_balloon_config )); dev->actual =le32_to_cpu (config.actual);if (dev->actual != oldactual) { -qemu_balloon_changed (ram_size - - ((ram_addr_t ) dev->actual <<VIRTIO_BALLOON_PFN_SHIFT )); +qapi_event_send_balloon_change (ram_size - + ((ram_addr_t ) dev->actual <<VIRTIO_BALLOON_PFN_SHIFT ), +NULL ); } }
include/sysemu/balloon.h +0 -2
@@ -24,6 +24,4 @@ int qemu_add_balloon_handler(QEMUBalloonEvent *event_func, QEMUBalloonStatus *stat_func, void *opaque);void qemu_remove_balloon_handler (void *opaque); -void qemu_balloon_changed (int64_t actual); -#endif
monitor.c +1 -2
@@ -615,6 +615,7 @@ static void monitor_qapi_event_init(void)/* Limit RTC & BALLOON events to 1 per second */ monitor_qapi_event_throttle (QAPI_EVENT_RTC_CHANGE ,1000 );monitor_qapi_event_throttle (QAPI_EVENT_WATCHDOG ,1000 ); +monitor_qapi_event_throttle (QAPI_EVENT_BALLOON_CHANGE ,1000 );qmp_event_set_func_emit (monitor_qapi_event_queue); }
@@ -740,8 +741,6 @@ monitor_protocol_event_throttle(MonitorEvent event,* and initialize state */ static void monitor_protocol_event_init (void ) { -/* Limit RTC & BALLOON events to 1 per second */ -monitor_protocol_event_throttle (QEVENT_BALLOON_CHANGE ,1000 );/* limit the rate of quorum events to avoid hammering the management */ monitor_protocol_event_throttle (QEVENT_QUORUM_REPORT_BAD ,1000 );monitor_protocol_event_throttle (QEVENT_QUORUM_FAILURE ,1000 );
qapi-event.json +13 -0
@@ -387,3 +387,16 @@ # Since: 2.1 ## { 'event': 'SPICE_MIGRATE_COMPLETED' } + +## +# @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 +# +# @actual: actual level of the guest memory balloon in bytes +# +# Since: 2.1 +## +{ 'event': 'BALLOON_CHANGE', + 'data': { 'actual': 'int' } }
Signature · 1 line
1.7.1
PATCH v6 27/29 qapi event: convert GUEST_PANICKED
In reply to Wenchao Xia'monitor.h' is still included in target-s390x/kvm.c, since I have no good way to verify whether other code need it on my x86 host.
--- docs/qmp/qmp-events.txt | 14 -------------- hw/misc/pvpanic.c | 13 ++----------- qapi-event.json | 12 ++++++++++++ qapi-schema.json | 12 ++++++++++++ target-s390x/kvm.c | 8 +++----- 5 files changed, 29 insertions(+), 30 deletions(-)
docs/qmp/qmp-events.txt +0 -14
@@ -1,20 +1,6 @@ QEMU Machine Protocol Events ============================ -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" } } - QUORUM_FAILURE --------------
hw/misc/pvpanic.c +2 -11
@@ -14,12 +14,12 @@#include "qapi/qmp/qobject.h" #include "qapi/qmp/qjson.h" -#include "monitor/monitor.h" #include "sysemu/sysemu.h" #include "qemu/log.h" #include "hw/nvram/fw_cfg.h" #include "hw/i386/pc.h" +#include "qapi-event.h" /* The bit of supported pv event */ #define PVPANIC_F_PANICKED 0
@@ -31,15 +31,6 @@#define ISA_PVPANIC_DEVICE (obj) \ OBJECT_CHECK(PVPanicState, (obj), TYPE_ISA_PVPANIC_DEVICE) -static void panicked_mon_event (const char *action) -{ -QObject *data; - - data =qobject_from_jsonf ("{ 'action': %s }" , action); -monitor_protocol_event (QEVENT_GUEST_PANICKED , data); -qobject_decref (data); -} -static void handle_event (int event) {static bool logged;
@@ -50,7 +41,7 @@ static void handle_event(int event) }if (event &PVPANIC_PANICKED ) { -panicked_mon_event ("pause" ); +qapi_event_send_guest_panicked (GUEST_PANICK_ACTION_PAUSE ,NULL );vm_stop (RUN_STATE_GUEST_PANICKED );return ; }
qapi-event.json +12 -0
@@ -400,3 +400,15 @@ ## { 'event': 'BALLOON_CHANGE', 'data': { 'actual': 'int' } } + +## +# @GUEST_PANICKED +# +# Emitted when guest OS panic is detected +# +# @action: action that has been taken, currently always "pause" +# +# Since: 2.1 +## +{ 'event': 'GUEST_PANICKED', + 'data': { 'action': 'GuestPanickAction' } }
qapi-schema.json +12 -0
@@ -4837,4 +4837,16 @@ { 'enum': 'IoOperationType', 'data': [ 'read', 'write' ] } +## +# @GuestPanickAction +# +# An enumeration of the actions taken when guest OS panic is detected +# +# @pause: system pauses +# +# Since: 2.1 +## +{ 'enum': 'GuestPanickAction', + 'data': [ 'pause' ] } + { 'include': 'qapi-event.json' }
target-s390x/kvm.c +3 -5
@@ -38,6 +38,7 @@#include "monitor/monitor.h" #include "exec/gdbstub.h" #include "trace.h" +#include "qapi-event.h" /* #define DEBUG_KVM */
@@ -891,11 +892,8 @@ static int handle_intercept(S390CPU *cpu)if (is_special_wait_psw (cs)) {qemu_system_shutdown_request (); }else { -QObject *data; - - data =qobject_from_jsonf ("{ 'action': %s }" ,"pause" ); -monitor_protocol_event (QEVENT_GUEST_PANICKED , data); -qobject_decref (data); +qapi_event_send_guest_panicked (GUEST_PANICK_ACTION_PAUSE , +NULL );vm_stop (RUN_STATE_GUEST_PANICKED ); } }
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH V6 27/29] qapi event: convert GUEST_PANICKED
Quoted 14 lines · Wenchao Xia
'
monitor.h' is still included intarget-s390x/kvm.c, since I have no good way to verify whether other code need it on my x86 host.Signed-off-by Wenchao Xia <[email protected]>--- docs/qmp/qmp-events.txt | 14 -------------- hw/misc/pvpanic.c | 13 ++----------- qapi-event.json | 12 ++++++++++++ qapi-schema.json | 12 ++++++++++++ target-s390x/kvm.c | 8 +++----- 5 files changed, 29 insertions(+), 30 deletions(-)
hw/misc/pvpanic.c static void handle_event(int event) · line 44
Quoted 5 lines
hw/misc/pvpanic.c +1
-1@@ -50,7 +41,7 @@ static void handle_event(int event) }if (event &PVPANIC_PANICKED ) { -panicked_mon_event ("pause" ); +qapi_event_send_guest_panicked (GUEST_PANICK_ACTION_PAUSE ,NULL );
s/PANICK/PANIC/
Quoted 13 lines
hw/misc/pvpanic.c +0
-0vm_stop (RUN_STATE_GUEST_PANICKED );return ; }qapi-event.json +2
-0@@ -400,3 +400,15 @@ ## { 'event': 'BALLOON_CHANGE', 'data': { 'actual': 'int' } } + +##
qapi-event.json line 414
Quoted 10 lines
qapi-event.json +10
-0+# @GUEST_PANICKED +# +# Emitted when guest OS panic is detected +# +# @action: action that has been taken, currently always "pause" +# +# Since: 2.1 +## +{ 'event': 'GUEST_PANICKED', + 'data': { 'action': 'GuestPanickAction' } }
s/GuestPanickAction/GuestPanicAction/
qapi-schema.json line 4841
Quoted 10 lines
qapi-schema.json +2
-0@@ -4837,4 +4837,16 @@ { 'enum': 'IoOperationType', 'data': [ 'read', 'write' ] } +## +# @GuestPanickAction
And again. The English word is 'panic'; the only time you add a 'k' is in situations where you are trying to avoid the hard ending 'c' looking like a soft sound because it is followed by an 'e' or 'i'.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v6 28/29 qapi event: convert QUORUM events
In reply to Wenchao Xia--- block/quorum.c | 25 ++++++++----------------- docs/qmp/qmp-events.txt | 41 ----------------------------------------- monitor.c | 6 +++--- qapi-event.json | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 61 deletions(-) delete mode 100644 docs/qmp/qmp-events.txt
block/quorum.c +8 -17
@@ -17,6 +17,7 @@#include <gnutls/crypto.h> #include "block/block_int.h" #include "qapi/qmp/qjson.h" +#include "qapi-event.h" #define HASH_LENGTH 32
@@ -198,32 +199,22 @@ static QuorumAIOCB *quorum_aio_get(BDRVQuorumState *s,static void quorum_report_bad (QuorumAIOCB *acb,char *node_name,int ret) { -QObject *data; -assert (node_name); - data =qobject_from_jsonf ("{ 'node-name': %s" -", 'sector-num': %" PRId64 -", 'sectors-count': %d }" , - node_name, acb->sector_num, acb->nb_sectors); +const char *msg =NULL ;if (ret <0 ) { -QDict *dict =qobject_to_qdict (data); -qdict_put (dict,"error" ,qstring_from_str (strerror (-ret))); + msg =strerror (-ret); } -monitor_protocol_event (QEVENT_QUORUM_REPORT_BAD , data); -qobject_decref (data); +qapi_event_send_quorum_report_bad (!!msg, msg, node_name, + acb->sector_num, acb->nb_sectors,NULL ); }static void quorum_report_failure (QuorumAIOCB *acb) { -QObject *data;const char *reference = acb->common.bs->device_name[0 ] ? acb->common.bs->device_name : acb->common.bs->node_name; - data =qobject_from_jsonf ("{ 'reference': %s" -", 'sector-num': %" PRId64 -", 'sectors-count': %d }" , - reference, acb->sector_num, acb->nb_sectors); -monitor_protocol_event (QEVENT_QUORUM_FAILURE , data); -qobject_decref (data); + +qapi_event_send_quorum_failure (reference, acb->sector_num, + acb->nb_sectors,NULL ); }static int quorum_vote_error (QuorumAIOCB *acb);
docs/qmp/qmp-events.txt deleted +0 -41
41 lines not on this page · raw message
monitor.c +3 -3
@@ -616,6 +616,9 @@ static void monitor_qapi_event_init(void)monitor_qapi_event_throttle (QAPI_EVENT_RTC_CHANGE ,1000 );monitor_qapi_event_throttle (QAPI_EVENT_WATCHDOG ,1000 );monitor_qapi_event_throttle (QAPI_EVENT_BALLOON_CHANGE ,1000 ); +/* limit the rate of quorum events to avoid hammering the management */ +monitor_qapi_event_throttle (QAPI_EVENT_QUORUM_REPORT_BAD ,1000 ); +monitor_qapi_event_throttle (QAPI_EVENT_QUORUM_FAILURE ,1000 );qmp_event_set_func_emit (monitor_qapi_event_queue); }
@@ -741,9 +744,6 @@ monitor_protocol_event_throttle(MonitorEvent event,* and initialize state */ static void monitor_protocol_event_init (void ) { -/* limit the rate of quorum events to avoid hammering the management */ -monitor_protocol_event_throttle (QEVENT_QUORUM_REPORT_BAD ,1000 ); -monitor_protocol_event_throttle (QEVENT_QUORUM_FAILURE ,1000 ); }/**
qapi-event.json +38 -0
@@ -412,3 +412,41 @@ ## { 'event': 'GUEST_PANICKED', 'data': { 'action': 'GuestPanickAction' } } + +## +# @QUORUM_FAILURE +# +# Emitted by the Quorum block driver if it fails to establish a quorum +# +# @reference: device name if defined else node name +# +# @sector-num: number of the first sector of the failed read operation +# +# @sector-count: failed read operation sector count +# +# Since: 2.1 +## +{ 'event': 'QUORUM_FAILURE', + 'data': { 'reference': 'str', 'sector-num': 'int', 'sector-count': 'int' } } + +## +# @QUORUM_REPORT_BAD +# +# Emitted to report a corruption of a Quorum file +# +# @error: #optional, error message. 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 +# +# @sector-count: failed read operation sector count +# +# Since: 2.1 +## +{ 'event': 'QUORUM_REPORT_BAD', + 'data': { '*error': 'str', 'node-name': 'str', + 'sector-num': 'int', 'sector-count': 'int' } }
Signature · 1 line
1.7.1
PATCH v6 29/29 qapi event: clean up
In reply to Wenchao Xia--- include/monitor/monitor.h | 40 -------- monitor.c | 216 +------------------------------------------- stubs/Makefile.objs | 1 - stubs/mon-protocol-event.c | 6 -- 4 files changed, 3 insertions(+), 260 deletions(-) delete mode 100644 stubs/mon-protocol-event.c
include/monitor/monitor.h +0 -40
@@ -19,48 +19,8 @@ extern Monitor *default_mon;/* flags for monitor commands */ #define MONITOR_CMD_ASYNC 0x0001 -/* QMP events */ -typedef enum MonitorEvent { -QEVENT_SHUTDOWN , -QEVENT_RESET , -QEVENT_POWERDOWN , -QEVENT_STOP , -QEVENT_RESUME , -QEVENT_VNC_CONNECTED , -QEVENT_VNC_INITIALIZED , -QEVENT_VNC_DISCONNECTED , -QEVENT_BLOCK_IO_ERROR , -QEVENT_RTC_CHANGE , -QEVENT_WATCHDOG , -QEVENT_SPICE_CONNECTED , -QEVENT_SPICE_INITIALIZED , -QEVENT_SPICE_DISCONNECTED , -QEVENT_BLOCK_JOB_COMPLETED , -QEVENT_BLOCK_JOB_CANCELLED , -QEVENT_BLOCK_JOB_ERROR , -QEVENT_BLOCK_JOB_READY , -QEVENT_DEVICE_DELETED , -QEVENT_DEVICE_TRAY_MOVED , -QEVENT_NIC_RX_FILTER_CHANGED , -QEVENT_SUSPEND , -QEVENT_SUSPEND_DISK , -QEVENT_WAKEUP , -QEVENT_BALLOON_CHANGE , -QEVENT_SPICE_MIGRATE_COMPLETED , -QEVENT_GUEST_PANICKED , -QEVENT_BLOCK_IMAGE_CORRUPTED , -QEVENT_QUORUM_FAILURE , -QEVENT_QUORUM_REPORT_BAD , - -/* Add to 'monitor_event_names' array in monitor.c when -* defining new events here */ - -QEVENT_MAX , -}MonitorEvent ; -int monitor_cur_is_qmp (void ); -void monitor_protocol_event (MonitorEvent event,QObject *data);void monitor_init (CharDriverState *chr,int flags);int monitor_suspend (Monitor *mon);
monitor.c +3 -213
248 lines not on this page · raw message
stubs/Makefile.objs +0 -1
@@ -14,7 +14,6 @@ stub-obj-y += iothread-lock.o stub-obj-y += migr-blocker.o stub-obj-y += mon-is-qmp.o stub-obj-y += mon-printf.o -stub-obj-y += mon-protocol-event.o stub-obj-y += mon-set-error.o stub-obj-y += pci-drive-hot-add.o stub-obj-y += qtest.o
stubs/mon-protocol-event.c deleted +0 -6
@@ -1,6 +0,0 @@ -#include "qemu-common.h" -#include "monitor/monitor.h" - -void monitor_protocol_event (MonitorEvent event,QObject *data) -{ -}
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH V6 29/29] qapi event: clean up
Quoted 8 lines · Wenchao Xia
Signed-off-by Wenchao Xia <[email protected]>--- include/monitor/monitor.h | 40 -------- monitor.c | 216 +------------------------------------------- stubs/Makefile.objs | 1 - stubs/mon-protocol-event.c | 6 -- 4 files changed, 3 insertions(+), 260 deletions(-) delete mode 100644 stubs/mon-protocol-event.c
Looking forward to v7.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Il 05/06/2014 14:21, Wenchao Xia ha scritto:
Quoted 170 lines
This series add support for tag/keyword 'event' in qapi-schema. A new file was created to store some helper functions in patch 2, patch 4 is the test case, patch 5 is a convert example.
The implemention is done by generate API and a batch of parameters for each event define, it doesn't generate a struture and visit function in the background for every event, so it doesn't support nested structure in the define to avoid trouble. A callback layer is added to control the behavior. More detail can be found in patch 3's message and incode comments.
v2:
Address Luiz's comments:
patch 3: rename *err to*local_err, do not initialize *qmp = NULL, create
a new functionqmp_build_evet_dict().
Other change:
reorgnized script in patch 3, it have a clear three steps, see patch 3's
incode comments.v3:
Address Luiz's comments:
2/5: use -1 when fail to get host timestamp.
3/5: typo fix and better incode comments. all unchanged functions are moved
intoqmp-event.c, from generated file. To do so without include issue, 'int' was used intead of 'enum' in function prototype declaration, since the 'enum' define is a generated type.
Address Eric's comments:
2/5: use -1 when fail to get host timestamp.
3/5: typo fix, adddocs/qapi-code-gen.txt.
4/5: typo fix, verify no other fields in member 'timestamp'. 5/5: add doc in qapi-schema.json.
fix license, all script using GPL2, all C code use LGPL, just as other
similar files in upstream.v4:
Address Eric's comments:
2/5: typo fix, add copyright declaration, use a static function pointer
instead of a struct in C file, assign -1 in two line of codes to avoid issue whentv_secandtv_usecare not in same data width, fix indention.
3/5: typo fix, add copyright declaration.
4/5: add copyright declaration, simplify string compare with
"d->result=g_strcmp0(...)== 0;", add check for tv_usec's range and value.
Other:
3/5: all error check code was moved fromqapi-event.pytoqapi.py, and it
reports better message with line number info. Added related test case.
Note:
Benoit's series which track input file better seems not the final version,
so I didn't rebase this series ontop for now, will do it once Benoit's ones get ACKed.v5:
Address Eric and Markus's comments:
2/28: useuint64_tfor both sec and usec, to avoid type cast issue in printf. Other:
Remove RFC, add full coversion by patch 5-28.
3/28: add prefix for event enum type name, to avoid double define of
QAPIEvent in test code.v6:
Address Eric's comments:
3/29: employ modularization mechnism of schema file of LluÃs series, removeerror_is_set()usage.
4/29:Makefilechange for LluÃs series.
5/29: separate patch for refactoring the existing schema defines, improve doc
for @service in VncBasicInfo.
7/29-28/29: define and convert event caller one by one.
Other change:
6/29: new way to add event emit implemention. In v5 it breaks old event
mechnism, in v6 it touch nothing of old event mechnism but add a new set of functions for new event mechnism.
7/29: Add new file qapi-event.json to store event defines, and all type
defines goes into qapi-schema.json.
29/29: related clean up change.
Note:
I have no way to verifytarget-s390x/kvm.ctouched by patch 27/29, andblock/quorum.ctouched by patch 28/29, need a confirm from whom has the test env.Wenchao Xia (29):
1 os-posix: includesys/time.h
2 qapi: add event helper functions
3 qapi script: add event support
4 test: add test cases for qapi event
5 qapi: adjust existing defines
6 monitor: add an implemention as qapi event emit method 7 qapi: add new schema file qapi-event.json
8 qapi event: convert SHUTDOWN
9 qapi event: convert POWERDOWN
10 qapi event: convert RESET
11 qapi event: convert STOP
12 qapi event: convert RESUME
13 qapi event: convert SUSPEND
14 qapi event: convertSUSPEND_DISK
15 qapi event: convert WAKEUP
16 qapi event: convertRTC_CHANGE
17 qapi event: convert WATCHDOG
18 qapi event: convertDEVICE_DELETED
19 qapi event: convertDEVICE_TRAY_MOVED
20 qapi event: convertBLOCK_IO_ERRORandBLOCK_JOB_ERROR21 qapi event: convertBLOCK_IMAGE_CORRUPTED
22 qapi event: convert otherBLOCK_JOBevents
23 qapi event: convertNIC_RX_FILTER_CHANGED
24 qapi event: convert VNC events
25 qapi event: convert SPICE events
26 qapi event: convertBALLOON_CHANGE
27 qapi event: convertGUEST_PANICKED
28 qapi event: convert QUORUM events
29 qapi event: clean upMakefile | 21 +- Makefile.objs | 2 +- balloon.c | 13 - block.c | 68 +--- block/backup.c | 2 +- block/mirror.c | 9 +- block/qcow2-refcount.c | 14 +- block/quorum.c | 25 +- block/stream.c | 4 +- blockdev.c | 12 +- blockjob.c | 53 ++-- cpus.c | 5 +- docs/qapi-code-gen.txt | 18 + docs/qmp/qmp-events.txt | 541 ------------------------------ hmp.c | 5 +- hw/acpi/core.c | 4 +- hw/block/virtio-blk.c | 6 +- hw/core/qdev.c | 12 +- hw/ide/core.c | 6 +- hw/misc/pvpanic.c | 13 +- hw/net/virtio-net.c | 13 +- hw/ppc/spapr_rtas.c | 3 +- hw/scsi/scsi-disk.c | 6 +- hw/timer/mc146818rtc.c | 3 +- hw/virtio/virtio-balloon.c | 6 +- hw/watchdog/watchdog.c | 23 +- include/block/block.h | 4 - include/block/block_int.h | 3 - include/block/blockjob.h | 17 +- include/monitor/monitor.h | 40 --- include/qapi/qmp-event.h | 27 ++ include/qemu/sockets.h | 3 +- include/sysemu/balloon.h | 2 - include/sysemu/os-posix.h | 2 + include/sysemu/sysemu.h | 2 - monitor.c | 185 +++-------- qapi-event.json | 452 +++++++++++++++++++++++++ qapi-schema.json | 178 +++++++++-- qapi/Makefile.objs | 1 + qapi/qmp-event.c | 74 ++++ scripts/qapi-event.py | 369 ++++++++++++++++++++ scripts/qapi.py | 12 + stubs/Makefile.objs | 1 - stubs/mon-protocol-event.c | 6 - target-s390x/kvm.c | 8 +- tests/Makefile | 18 +- tests/qapi-schema/event-nest-struct.err | 1 + tests/qapi-schema/event-nest-struct.exit | 1 + tests/qapi-schema/event-nest-struct.json | 2 + tests/qapi-schema/qapi-schema-test.json | 12 + tests/qapi-schema/qapi-schema-test.out | 10 +- tests/test-qmp-event.c | 265 +++++++++++++++ trace-events | 4 + ui/spice-core.c | 77 +++-- ui/vnc.c | 120 ++++---- ui/vnc.h | 4 +- util/qemu-sockets.c | 10 +- vl.c | 22 +- 58 files changed, 1732 insertions(+), 1087 deletions(-) delete mode 100644 docs/qmp/qmp-events.txt create mode 100644 include/qapi/qmp-event.h create mode 100644 qapi-event.json
Quoted 11 lines
create mode 100644 qapi/qmp-event.c create mode 100644 scripts/qapi-event.py delete mode 100644 stubs/mon-protocol-event.c create mode 100644 tests/qapi-schema/event-nest-struct.err create mode 100644 tests/qapi-schema/event-nest-struct.exit create mode 100644 tests/qapi-schema/event-nest-struct.json create mode 100644 tests/qapi-schema/event-nest-struct.out create mode 100644 tests/test-qmp-event.c
Unfortunately, this already does not apply anymore.
I've placed the rebase on branch qapi-event of my github repository. The resolutions are trivial, so perhaps Luiz or Michael can pull from there?
Paolo
Quoted 203 lines · Paolo Bonzini
Il 05/06/2014 14:21, Wenchao Xia ha scritto:
Quoted 190 lines
This series add support for tag/keyword 'event' in qapi-schema. A new file was created to store some helper functions in patch 2, patch 4 is
the test case, patch 5 is a convert example.The implemention is done by generate API and a batch of parameters for each
event define, it doesn't generate a struture and visit function in the background for every event, so it doesn't support nested structure in the define to avoid trouble. A callback layer is added to control the behavior.
More detail can be found in patch 3's message and incode comments.v2:
Address Luiz's comments:
patch 3: rename *err to*local_err, do not initialize *qmp = NULL,
create
a new functionqmp_build_evet_dict().
Other change:
reorgnized script in patch 3, it have a clear three steps, see patch
3's
incode comments.v3:
Address Luiz's comments:
2/5: use -1 when fail to get host timestamp.
3/5: typo fix and better incode comments. all unchanged functions
are moved
intoqmp-event.c, from generated file. To do so without include issue, 'int'
was used intead of 'enum' in function prototype declaration, since the 'enum'
define is a generated type.
Address Eric's comments:
2/5: use -1 when fail to get host timestamp.
3/5: typo fix, adddocs/qapi-code-gen.txt.
4/5: typo fix, verify no other fields in member 'timestamp'. 5/5: add doc in qapi-schema.json.
fix license, all script using GPL2, all C code use LGPL, just as other
similar files in upstream.v4:
Address Eric's comments:
2/5: typo fix, add copyright declaration, use a static function pointer
instead of a struct in C file, assign -1 in two line of codes to avoid issue
whentv_secandtv_usecare not in same data width, fix indention.
3/5: typo fix, add copyright declaration.
4/5: add copyright declaration, simplify string compare with
"d->result=g_strcmp0(...)== 0;", add check for tv_usec's range and
value.
Other:
3/5: all error check code was moved fromqapi-event.pytoqapi.py,
and it
reports better message with line number info. Added related test case.
Note:
Benoit's series which track input file better seems not the final
version,
so I didn't rebase this series ontop for now, will do it once Benoit's ones
get ACKed.v5:
Address Eric and Markus's comments:
2/28: useuint64_tfor both sec and usec, to avoid type cast issue
in printf.
Other:
Remove RFC, add full coversion by patch 5-28.
3/28: add prefix for event enum type name, to avoid double define of
QAPIEvent in test code.v6:
Address Eric's comments:
3/29: employ modularization mechnism of schema file of LluÃs
series, removeerror_is_set()usage.
4/29:Makefilechange for LluÃs series.
5/29: separate patch for refactoring the existing schema defines,
improve doc
for @service in VncBasicInfo.
7/29-28/29: define and convert event caller one by one. Other change:
6/29: new way to add event emit implemention. In v5 it breaks old event
mechnism, in v6 it touch nothing of old event mechnism but add a new set of
functions for new event mechnism.
7/29: Add new file qapi-event.json to store event defines, and all type
defines goes into qapi-schema.json.
29/29: related clean up change.
Note:
I have no way to verifytarget-s390x/kvm.ctouched by patch 27/29, andblock/quorum.ctouched by patch 28/29, need a confirm from whom has the test
env.Wenchao Xia (29):
1 os-posix: includesys/time.h
2 qapi: add event helper functions
3 qapi script: add event support
4 test: add test cases for qapi event
5 qapi: adjust existing defines
6 monitor: add an implemention as qapi event emit method 7 qapi: add new schema file qapi-event.json
8 qapi event: convert SHUTDOWN
9 qapi event: convert POWERDOWN
10 qapi event: convert RESET
11 qapi event: convert STOP
12 qapi event: convert RESUME
13 qapi event: convert SUSPEND
14 qapi event: convertSUSPEND_DISK
15 qapi event: convert WAKEUP
16 qapi event: convertRTC_CHANGE
17 qapi event: convert WATCHDOG
18 qapi event: convertDEVICE_DELETED
19 qapi event: convertDEVICE_TRAY_MOVED
20 qapi event: convertBLOCK_IO_ERRORandBLOCK_JOB_ERROR21 qapi event: convertBLOCK_IMAGE_CORRUPTED
22 qapi event: convert otherBLOCK_JOBevents
23 qapi event: convertNIC_RX_FILTER_CHANGED
24 qapi event: convert VNC events
25 qapi event: convert SPICE events
26 qapi event: convertBALLOON_CHANGE
27 qapi event: convertGUEST_PANICKED
28 qapi event: convert QUORUM events
29 qapi event: clean upMakefile | 21 +- Makefile.objs | 2 +- balloon.c | 13 - block.c | 68 +--- block/backup.c | 2 +- block/mirror.c | 9 +- block/qcow2-refcount.c | 14 +- block/quorum.c | 25 +- block/stream.c | 4 +- blockdev.c | 12 +- blockjob.c | 53 ++-- cpus.c | 5 +- docs/qapi-code-gen.txt | 18 + docs/qmp/qmp-events.txt | 541 ------------------------------ hmp.c | 5 +- hw/acpi/core.c | 4 +- hw/block/virtio-blk.c | 6 +- hw/core/qdev.c | 12 +- hw/ide/core.c | 6 +- hw/misc/pvpanic.c | 13 +- hw/net/virtio-net.c | 13 +- hw/ppc/spapr_rtas.c | 3 +- hw/scsi/scsi-disk.c | 6 +- hw/timer/mc146818rtc.c | 3 +- hw/virtio/virtio-balloon.c | 6 +- hw/watchdog/watchdog.c | 23 +- include/block/block.h | 4 - include/block/block_int.h | 3 - include/block/blockjob.h | 17 +- include/monitor/monitor.h | 40 --- include/qapi/qmp-event.h | 27 ++ include/qemu/sockets.h | 3 +- include/sysemu/balloon.h | 2 - include/sysemu/os-posix.h | 2 + include/sysemu/sysemu.h | 2 - monitor.c | 185 +++-------- qapi-event.json | 452 +++++++++++++++++++++++++ qapi-schema.json | 178 +++++++++-- qapi/Makefile.objs | 1 + qapi/qmp-event.c | 74 ++++ scripts/qapi-event.py | 369 ++++++++++++++++++++ scripts/qapi.py | 12 + stubs/Makefile.objs | 1 - stubs/mon-protocol-event.c | 6 - target-s390x/kvm.c | 8 +- tests/Makefile | 18 +- tests/qapi-schema/event-nest-struct.err | 1 + tests/qapi-schema/event-nest-struct.exit | 1 + tests/qapi-schema/event-nest-struct.json | 2 + tests/qapi-schema/qapi-schema-test.json | 12 + tests/qapi-schema/qapi-schema-test.out | 10 +- tests/test-qmp-event.c | 265 +++++++++++++++ trace-events | 4 + ui/spice-core.c | 77 +++-- ui/vnc.c | 120 ++++---- ui/vnc.h | 4 +- util/qemu-sockets.c | 10 +- vl.c | 22 +- 58 files changed, 1732 insertions(+), 1087 deletions(-) delete mode 100644 docs/qmp/qmp-events.txt create mode 100644 include/qapi/qmp-event.h create mode 100644 qapi-event.jsonQuoted 11 lines
create mode 100644 qapi/qmp-event.c create mode 100644 scripts/qapi-event.py delete mode 100644 stubs/mon-protocol-event.c create mode 100644 tests/qapi-schema/event-nest-struct.err create mode 100644 tests/qapi-schema/event-nest-struct.exit create mode 100644 tests/qapi-schema/event-nest-struct.json create mode 100644 tests/qapi-schema/event-nest-struct.out create mode 100644 tests/test-qmp-event.c
Quoted 8 lines
Tested-by Paolo Bonzini <[email protected]>Unfortunately, this already does not apply anymore.
I've placed the rebase on branch qapi-event of my github repository. The resolutions are trivial, so perhaps Luiz or Michael can pull from there?
Paolo
Thanks for testing my work:)
Eric:
I have looked the comments, most fix will arrive in my V7 next week,
but still I have two issues without decision:
1. Whether to use QAPIEvent in callback function type declartion,
See my feedback in 6/29.
2. Whether to make qapi-event.json self sufficent, see my comments
in 17/29.
Il 15/06/2014 02:52, Wenchao Xia ha scritto:
Quoted 8 lines
Quoted 6 lines
Unfortunately, this already does not apply anymore.
I've placed the rebase on branch qapi-event of my github repository. The resolutions are trivial, so perhaps Luiz or Michael can pull from there?
Paolo
Quoted 8 lines
Thanks for testing my work:)
Eric:
I have looked the comments, most fix will arrive in my V7 next week,
but still I have two issues without decision:
1. Whether to use QAPIEvent in callback function type declartion,
See my feedback in 6/29.
2. Whether to make qapi-event.json self sufficent, see my comments
in 17/29.
I am afraid that this will miss 2.1 (and so will dataplane rerror/werror that depends on it), so I went ahead and done all fixes in my qapi-event branch.
I have not yet applied Reviewed-by tags from Eric since some patches are different and I want him to look at the interdiff first.
Regarding error handling, I have left the code in but switched all callers to &error_abort.
The interdiff is here. I ensured that the result is bisectable, and the intermediate changes are responsible for the "spurious" hunks of the interdiff:
Makefile +1 -2
@@ -246,8 +246,7 @@ $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) $(gen-out-type) -o "." -b -i $<, \ " GEN $@") qapi-event.c qapi-event.h :\ -$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi-event.json \ -$(SRC_PATH)/scripts/qapi-event.py $(qapi-py) +$(qapi-modules) $(SRC_PATH)/scripts/qapi-event.py $(qapi-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-event.py \ $(gen-out-type) -o "." -b -i $<, \ " GEN $@")
block.c +4 -4
@@ -2140,12 +2140,12 @@ static void bdrv_dev_change_media_cb(BlockDriverState *bs, bool load)if (tray_was_closed) {/* tray open */ qapi_event_send_device_tray_moved (bdrv_get_device_name (bs), - true,NULL ); + true, &error_abort); }if (load) {/* tray close */ qapi_event_send_device_tray_moved (bdrv_get_device_name (bs), - false,NULL ); + false, &error_abort); } } }
@@ -3591,7 +3591,7 @@ void bdrv_error_action(BlockDriverState *bs, BlockErrorAction action,qapi_event_send_block_io_error (bdrv_get_device_name (bs), is_read ?IO_OPERATION_TYPE_READ :IO_OPERATION_TYPE_WRITE , - action,NULL ); + action, &error_abort);if (action ==BLOCK_ERROR_ACTION_STOP ) {vm_stop (RUN_STATE_IO_ERROR );bdrv_iostatus_set_err (bs, error);
@@ -5165,7 +5165,7 @@ void bdrv_eject(BlockDriverState *bs, bool eject_flag)if (bs->device_name[0 ] !='\0' ) {qapi_event_send_device_tray_moved (bdrv_get_device_name (bs), - eject_flag,NULL ); + eject_flag, &error_abort); } }
block/qcow2-refcount.c +1 -1
@@ -1822,7 +1822,7 @@ int qcow2_pre_write_overlap_check(BlockDriverState *bs, int ign, int64_t offset, offset, true, size, - NULL); + &error_abort);g_free (message);qcow2_mark_corrupt (bs);
block/quorum.c +2 -2
@@ -204,7 +204,7 @@ static void quorum_report_bad(QuorumAIOCB *acb, char *node_name, int ret) msg =strerror (-ret); }qapi_event_send_quorum_report_bad (!!msg, msg, node_name, - acb->sector_num, acb->nb_sectors,NULL ); + acb->sector_num, acb->nb_sectors, &error_abort); }static void quorum_report_failure (QuorumAIOCB *acb)
@@ -214,7 +214,7 @@ static void quorum_report_failure(QuorumAIOCB *acb) acb->common.bs->node_name;qapi_event_send_quorum_failure (reference, acb->sector_num, - acb->nb_sectors,NULL ); + acb->nb_sectors, &error_abort); }static int quorum_vote_error (QuorumAIOCB *acb);
blockjob.c +4 -4
@@ -239,7 +239,7 @@ void block_job_event_cancelled(BlockJob *job) job->len, job->offset, job->speed, - NULL); + &error_abort); }void block_job_event_completed (BlockJob *job,const char *msg)
@@ -251,12 +251,12 @@ void block_job_event_completed(BlockJob *job, const char *msg) job->speed, !!msg, msg, - NULL); + &error_abort); }void block_job_event_ready (BlockJob *job) { -qapi_event_send_block_job_ready (bdrv_get_device_name (job->bs),NULL ); +qapi_event_send_block_job_ready (bdrv_get_device_name (job->bs), &error_abort); } BlockErrorAction block_job_error_action(BlockJob *job, BlockDriverState *bs,
@@ -285,7 +285,7 @@ BlockErrorAction block_job_error_action(BlockJob *job, BlockDriverState *bs,qapi_event_send_block_job_error (bdrv_get_device_name (bs), is_read ?IO_OPERATION_TYPE_READ :IO_OPERATION_TYPE_WRITE , - action,NULL ); + action, &error_abort);if (action ==BLOCK_ERROR_ACTION_STOP ) {block_job_pause (job);block_job_iostatus_set_err (job, error);
cpus.c +1 -1
@@ -531,7 +531,7 @@ static int do_vm_stop(RunState state)pause_all_vcpus ();runstate_set (state);vm_state_notify (0 , state); -qapi_event_send_stop (NULL ); +qapi_event_send_stop (&error_abort); }bdrv_drain_all ();
hw/acpi/core.c +1 -1
@@ -550,7 +550,7 @@ static void acpi_pm1_cnt_write(ACPIREGS *ar, uint16_t val)break ;default :if (sus_typ == ar->pm1.cnt.s4_val) {/* S4 request */ -qapi_event_send_suspend_disk (NULL ); +qapi_event_send_suspend_disk (&error_abort);qemu_system_shutdown_request (); }break ;
hw/core/qdev.c +1 -1
@@ -958,7 +958,7 @@ static void device_unparent(Object *obj)if (have_realized) {gchar *path =object_get_canonical_path (OBJECT (dev)); -qapi_event_send_device_deleted (!!dev->id, dev->id, path,NULL ); +qapi_event_send_device_deleted (!!dev->id, dev->id, path, &error_abort);g_free (path); } }
hw/misc/pvpanic.c +1 -1
@@ -41,7 +41,7 @@ static void handle_event(int event) }if (event &PVPANIC_PANICKED ) { -qapi_event_send_guest_panicked (GUEST_PANICK_ACTION_PAUSE ,NULL ); +qapi_event_send_guest_panicked (GUEST_PANIC_ACTION_PAUSE , &error_abort);vm_stop (RUN_STATE_GUEST_PANICKED );return ; }
hw/net/virtio-net.c +1 -1
@@ -201,7 +201,7 @@ static void rxfilter_notify(NetClientState *nc)if (nc->rxfilter_notify_enabled) {gchar *path =object_get_canonical_path (OBJECT (n->qdev));qapi_event_send_nic_rx_filter_changed (!!n->netclient_name, - n->netclient_name, path,NULL ); + n->netclient_name, path, &error_abort);g_free (path);/* disable event notification to avoid events flooding */
hw/ppc/spapr_rtas.c +1 -1
@@ -94,7 +94,7 @@ static void rtas_set_time_of_day(PowerPCCPU *cpu, sPAPREnvironment *spapr, tm.tm_sec =rtas_ld (args,5 );/* Just generate a monitor event for the change */ -qapi_event_send_rtc_change (qemu_timedate_diff (&tm),NULL ); +qapi_event_send_rtc_change (qemu_timedate_diff (&tm), &error_abort); spapr->rtc_offset =qemu_timedate_diff (&tm);rtas_st (rets,0 ,RTAS_OUT_SUCCESS );
hw/timer/mc146818rtc.c +1 -1
@@ -531,7 +531,7 @@ static void rtc_set_time(RTCState *s) s->base_rtc =mktimegm (&tm); s->last_update =qemu_clock_get_ns (rtc_clock); -qapi_event_send_rtc_change (qemu_timedate_diff (&tm),NULL ); +qapi_event_send_rtc_change (qemu_timedate_diff (&tm), &error_abort); }static void rtc_set_cmos (RTCState *s,const struct tm *tm)
hw/virtio/virtio-balloon.c +1 -1
@@ -292,7 +292,7 @@ static void virtio_balloon_set_config(VirtIODevice *vdev,if (dev->actual != oldactual) {qapi_event_send_balloon_change (ram_size - ((ram_addr_t ) dev->actual <<VIRTIO_BALLOON_PFN_SHIFT ), -NULL ); + &error_abort); } }
hw/watchdog/watchdog.c +6 -6
@@ -108,31 +108,31 @@ void watchdog_perform_action(void) {switch (watchdog_action) {case WDT_RESET :/* same as 'system_reset' in monitor */ -qapi_event_send_watchdog (WATCHDOG_EXPIRATION_ACTION_RESET ,NULL ); +qapi_event_send_watchdog (WATCHDOG_EXPIRATION_ACTION_RESET , &error_abort);qemu_system_reset_request ();break ;case WDT_SHUTDOWN :/* same as 'system_powerdown' in monitor */ -qapi_event_send_watchdog (WATCHDOG_EXPIRATION_ACTION_SHUTDOWN ,NULL ); +qapi_event_send_watchdog (WATCHDOG_EXPIRATION_ACTION_SHUTDOWN , &error_abort);qemu_system_powerdown_request ();break ;case WDT_POWEROFF :/* same as 'quit' command in monitor */ -qapi_event_send_watchdog (WATCHDOG_EXPIRATION_ACTION_POWEROFF ,NULL ); +qapi_event_send_watchdog (WATCHDOG_EXPIRATION_ACTION_POWEROFF , &error_abort);exit (0 );case WDT_PAUSE :/* same as 'stop' command in monitor */ -qapi_event_send_watchdog (WATCHDOG_EXPIRATION_ACTION_PAUSE ,NULL ); +qapi_event_send_watchdog (WATCHDOG_EXPIRATION_ACTION_PAUSE , &error_abort);vm_stop (RUN_STATE_WATCHDOG );break ;case WDT_DEBUG : -qapi_event_send_watchdog (WATCHDOG_EXPIRATION_ACTION_DEBUG ,NULL ); +qapi_event_send_watchdog (WATCHDOG_EXPIRATION_ACTION_DEBUG , &error_abort);fprintf (stderr,"watchdog: timer fired\n" );break ;case WDT_NONE : -qapi_event_send_watchdog (WATCHDOG_EXPIRATION_ACTION_NONE ,NULL ); +qapi_event_send_watchdog (WATCHDOG_EXPIRATION_ACTION_NONE , &error_abort);break ; } }
include/qapi/qmp-event.h +1 -1
@@ -17,7 +17,7 @@#include "qapi/error.h" #include "qapi/qmp/qdict.h" -typedef void (*QMPEventFuncEmit )(int event_kind,QDict *dict,Error **errp); +typedef void (*QMPEventFuncEmit )(unsigned event,QDict *dict,Error **errp);void qmp_event_set_func_emit (QMPEventFuncEmit emit);
include/sysemu/os-posix.h +0 -2
@@ -26,8 +26,6 @@#ifndef QEMU_OS_POSIX_H #define QEMU_OS_POSIX_H -#include <sys/time.h> -void os_set_line_buffering (void );void os_set_proc_name (const char *s);void os_setup_signal_handling (void );
monitor.c +19 -21
@@ -183,10 +183,10 @@ typedef struct MonitorControl {*/ typedef struct MonitorQAPIEventState {QAPIEvent event;/* Event being tracked */ -int64_t rate;/* Period over which to throttle. 0 to disable */ -int64_t last;/* Time at which event was last emitted */ +int64_t rate;/* Minimum time (in ns) between two events */ +int64_t last;/* QEMU_CLOCK_REALTIME value at last emission */ QEMUTimer *timer;/* Timer for handling delayed events */ -QObject *data;/* Event pending delayed dispatch */ +QObject *data;/* Event pending delayed dispatch */ }MonitorQAPIEventState ;struct Monitor {
@@ -451,7 +451,7 @@ static void monitor_qapi_event_emit(QAPIEvent event, QObject *data) {Monitor *mon; -trace_monitor_qapi_event_emit (event, data); +trace_monitor_protocol_event_emit (event, data); QLIST_FOREACH(mon, &mon_list, entry) {if (monitor_ctrl_mode (mon) &&qmp_cmd_mode (mon)) {monitor_json_emitter (mon, data);
@@ -464,19 +464,18 @@ static void monitor_qapi_event_emit(QAPIEvent event, QObject *data)* applying any rate limiting if required. */ static void -monitor_qapi_event_queue (int event_kind,QDict *data,Error **errp) +monitor_qapi_event_queue (QAPIEvent event,QDict *data,Error **errp) {MonitorQAPIEventState *evstate; -assert (event_kind <QAPI_EVENT_MAX ); -QAPIEvent event = (QAPIEvent )event_kind; +assert (event <QAPI_EVENT_MAX );int64_t now =qemu_clock_get_ns (QEMU_CLOCK_REALTIME ); evstate = &(monitor_qapi_event_state[event]); -trace_monitor_qapi_event_queue (event, - data, - evstate->rate, - evstate->last, - now); +trace_monitor_protocol_event_queue (event, + data, + evstate->rate, + evstate->last, + now);/* Rate limit of 0 indicates no throttling */ if (!evstate->rate) {
@@ -514,11 +513,10 @@ static void monitor_qapi_event_handler(void *opaque)MonitorQAPIEventState *evstate = opaque;int64_t now =qemu_clock_get_ns (QEMU_CLOCK_REALTIME ); - -trace_monitor_qapi_event_handler (evstate->event, - evstate->data, - evstate->last, - now); +trace_monitor_protocol_event_handler (evstate->event, + evstate->data, + evstate->last, + now);if (evstate->data) {monitor_qapi_event_emit (evstate->event, evstate->data);qobject_decref (evstate->data);
@@ -535,14 +533,15 @@ static void monitor_qapi_event_handler(void *opaque)* more than 1 event will be emitted within @rate * milliseconds */ -static void monitor_qapi_event_throttle (QAPIEvent event,int64_t rate) +static void +monitor_qapi_event_throttle (QAPIEvent event,int64_t rate) {MonitorQAPIEventState *evstate;assert (event <QAPI_EVENT_MAX ); evstate = &(monitor_qapi_event_state[event]); -trace_monitor_qapi_event_throttle (event, rate); +trace_monitor_protocol_event_throttle (event, rate); evstate->event = event; evstate->rate = rate *SCALE_MS ; evstate->last =0 ;
@@ -555,7 +554,7 @@ static void monitor_qapi_event_throttle(QAPIEvent event, int64_t rate)static void monitor_qapi_event_init (void ) { -/* Limit RTC & BALLOON events to 1 per second */ +/* Limit guest-triggerable events to 1 per second */ monitor_qapi_event_throttle (QAPI_EVENT_RTC_CHANGE ,1000 );monitor_qapi_event_throttle (QAPI_EVENT_WATCHDOG ,1000 );monitor_qapi_event_throttle (QAPI_EVENT_BALLOON_CHANGE ,1000 );
@@ -566,7 +565,6 @@ static void monitor_qapi_event_init(void)qmp_event_set_func_emit (monitor_qapi_event_queue); } -static int do_qmp_capabilities (Monitor *mon,const QDict *params,QObject **ret_data) {
qapi-event.json +26 -26
196 lines not on this page · raw message
qapi-schema.json +2 -2
@@ -3180,7 +3180,7 @@ 'data': [ 'read', 'write' ] } ## -# @GuestPanickAction +# @GuestPanicAction # # An enumeration of the actions taken when guest OS panic is detected #
@@ -3188,7 +3188,7 @@ # # Since: 2.1 ## -{ 'enum': 'GuestPanickAction', +{ 'enum': 'GuestPanicAction', 'data': [ 'pause' ] } { 'include': 'qapi-event.json' }
qapi/block-core.json +9 -7
@@ -1435,14 +1435,16 @@ # # @device: device name # -# @msg: informative message, for example, reason for the corruption +# @msg: informative message for human consumption, such as the kind of +# corruption being detected # # @offset: #optional, if the corruption resulted from an image access, this is # the access offset into the image +# # @size: #optional, if the corruption resulted from an image access, this is # the access size # -# Since: 2.1 +# Since: 1.7 ## { 'event': 'BLOCK_IMAGE_CORRUPTED', 'data': { 'device' : 'str',
@@ -1464,7 +1466,7 @@ # Note: If action is "stop", a STOP event will eventually follow the # BLOCK_IO_ERROR event # -# Since: 2.1 +# Since: 0.13.0 ## { 'event': 'BLOCK_IO_ERROR', 'data': { 'device': 'str', 'operation': 'IoOperationType',
@@ -1491,7 +1493,7 @@ # other than that streaming has failed and clients should not try to # interpret the error string # -# Since: 2.1 +# Since: 1.1 ## { 'event': 'BLOCK_JOB_COMPLETED', 'data': { 'type' : 'BlockJobType',
@@ -1517,7 +1519,7 @@ # # @speed: rate limit, bytes per second # -# Since: 2.1 +# Since: 1.1 ## { 'event': 'BLOCK_JOB_CANCELLED', 'data': { 'type' : 'BlockJobType',
@@ -1537,7 +1539,7 @@ # # @action: action that has been taken # -# Since: 2.1 +# Since: 1.3 ## { 'event': 'BLOCK_JOB_ERROR', 'data': { 'device' : 'str',
@@ -1554,7 +1556,7 @@ # Note: The "ready to complete" status is always reset by a @BLOCK_JOB_ERROR # event # -# Since: 2.1 +# Since: 1.3 ## { 'event': 'BLOCK_JOB_READY', 'data': { 'device': 'str' } }
qapi/block.json +1 -1
@@ -174,7 +174,7 @@ # # @tray-open: true if the tray has been opened or false if it has been closed # -# Since: 2.1 +# Since: 1.1 ## { 'event': 'DEVICE_TRAY_MOVED', 'data': { 'device': 'str', 'tray-open': 'bool' } }
scripts/qapi-event.py +2 -2
@@ -45,7 +45,7 @@ def generate_event_declaration(api_name): api_name = api_name) def generate_event_implement(api_name, event_name, params): - # step 1: declare and variables + # step 1: declare any variables ret = mcgen(""" %(api_name)s
@@ -85,7 +85,7 @@ def generate_event_implement(api_name, event_name, params): v = qmp_output_get_visitor(qov); g_assert(v); - /* Fake visit, as if all member are under a structure */ + /* Fake visit, as if all members are under a structure */ visit_start_struct(v, NULL, "", "%(event_name)s", 0, &local_err); if (local_err) { goto clean;
target-s390x/kvm.c +2 -2
@@ -1030,8 +1030,8 @@ static bool is_special_wait_psw(CPUState *cs)static void guest_panicked (void ) { -qapi_event_send_guest_panicked (GUEST_PANICK_ACTION_PAUSE , -NULL ); +qapi_event_send_guest_panicked (GUEST_PANIC_ACTION_PAUSE , + &error_abort);vm_stop (RUN_STATE_GUEST_PANICKED ); }
tests/test-qmp-event.c +9 -9
@@ -33,7 +33,7 @@ typedef struct QDictCmpData { } QDictCmpData;TestEventData *test_event_data; -static GStaticMutex test_event_lock =G_STATIC_MUTEX_INIT ; +static CompatGMutex test_event_lock;/* Only compares bool, int, string */ static
@@ -94,13 +94,13 @@ static bool qdict_cmp_simple(QDict *a, QDict *b)/* This function is hooked as final emit function, which can verify the correctness. */ -static void event_test_emit (int event_kind,QDict *d,Error **errp) +static void event_test_emit (TEST_QAPIEvent event,QDict *d,Error **errp) {QObject *obj;QDict *t;int64_t s, ms; -/* Verify that we have timestamp, then remove it to compare other field */ +/* Verify that we have timestamp, then remove it to compare other fields */ obj =qdict_get (d,"timestamp" );g_assert (obj); t =qobject_to_qdict (obj);
@@ -129,7 +129,7 @@ static void event_prepare(TestEventData *data, {/* Global variable test_event_data was used to pass the expectation, so test cases can't be executed at same time. */ -g_static_mutex_lock (&test_event_lock); +g_mutex_lock (&test_event_lock); data->expect =qdict_new (); test_event_data = data;
@@ -141,7 +141,7 @@ static void event_teardown(TestEventData *data,QDECREF (data->expect); test_event_data =NULL ; -g_static_mutex_unlock (&test_event_lock); +g_mutex_unlock (&test_event_lock); } static void event_test_add(const char *testpath,
@@ -161,7 +161,7 @@ static void test_event_a(TestEventData *data,QDict *d; d = data->expect;qdict_put (d,"event" ,qstring_from_str ("EVENT_A" )); -qapi_event_send_event_a (NULL ); +qapi_event_send_event_a (&error_abort); } static void test_event_b(TestEventData *data,
@@ -170,7 +170,7 @@ static void test_event_b(TestEventData *data,QDict *d; d = data->expect;qdict_put (d,"event" ,qstring_from_str ("EVENT_B" )); -qapi_event_send_event_b (NULL ); +qapi_event_send_event_b (&error_abort); } static void test_event_c(TestEventData *data,
@@ -198,7 +198,7 @@ static void test_event_c(TestEventData *data,qdict_put (d,"event" ,qstring_from_str ("EVENT_C" ));qdict_put (d,"data" , d_data); -qapi_event_send_event_c (true,1 , true, &b,"test2" ,NULL ); +qapi_event_send_event_c (true,1 , true, &b,"test2" , &error_abort);g_free (b.string); }
@@ -243,7 +243,7 @@ static void test_event_d(TestEventData *data,qdict_put (d,"data" , d_data);qapi_event_send_event_d (&a,"test3" , false,NULL , true,ENUM_ONE_VALUE3 , -NULL ); + &error_abort);g_free (struct1.string);g_free (a.string);
trace-events +0 -4
@@ -932,10 +932,6 @@ monitor_protocol_event_handler(uint32_t event, void *data, uint64_t last, uint64 monitor_protocol_event_emit(uint32_t event, void *data) "event=%d data=%p" monitor_protocol_event_queue(uint32_t event, void *data, uint64_t rate, uint64_t last, uint64_t now) "event=%d data=%p rate=%" PRId64 " last=%" PRId64 " now=%" PRId64 monitor_protocol_event_throttle(uint32_t event, uint64_t rate) "event=%d rate=%" PRId64 -monitor_qapi_event_emit(uint32_t event, void *data) "event=%d data=%p" -monitor_qapi_event_queue(uint32_t event, void *data, uint64_t rate, uint64_t last, uint64_t now) "event=%d data=%p rate=%" PRId64 " last=%" PRId64 " now=%" PRId64 -monitor_qapi_event_handler(uint32_t event, void *data, uint64_t last, uint64_t now) "event=%d data=%p last=%" PRId64 " now=%" PRId64 -monitor_qapi_event_throttle(uint32_t event, uint64_t rate) "event=%d rate=%" PRId64 # hw/net/opencores_eth.c open_eth_mii_write(unsigned idx, uint16_t v) "MII[%02x] <- %04x"
ui/spice-core.c +4 -4
@@ -229,7 +229,7 @@ static void channel_event(int event, SpiceChannelEventInfo *info)switch (event) {case SPICE_CHANNEL_EVENT_CONNECTED : -qapi_event_send_spice_connected (server->base, client->base,NULL ); +qapi_event_send_spice_connected (server->base, client->base, &error_abort);break ;case SPICE_CHANNEL_EVENT_INITIALIZED :if (auth) {
@@ -238,11 +238,11 @@ static void channel_event(int event, SpiceChannelEventInfo *info) }add_channel_info (client, info);channel_list_add (info); -qapi_event_send_spice_initialized (server, client,NULL ); +qapi_event_send_spice_initialized (server, client, &error_abort);break ;case SPICE_CHANNEL_EVENT_DISCONNECTED :channel_list_del (info); -qapi_event_send_spice_disconnected (server->base, client->base,NULL ); +qapi_event_send_spice_disconnected (server->base, client->base, &error_abort);break ;default :break ;
@@ -307,7 +307,7 @@ static void migrate_connect_complete_cb(SpiceMigrateInstance *sin)static void migrate_end_complete_cb (SpiceMigrateInstance *sin) { -qapi_event_send_spice_migrate_completed (NULL ); +qapi_event_send_spice_migrate_completed (&error_abort); spice_migration_completed = true; }
ui/vnc.c +3 -3
@@ -289,13 +289,13 @@ static void vnc_qmp_event(VncState *vs, QAPIEvent event)switch (event) {case QAPI_EVENT_VNC_CONNECTED : -qapi_event_send_vnc_connected (si, vs->info->base,NULL ); +qapi_event_send_vnc_connected (si, vs->info->base, &error_abort);break ;case QAPI_EVENT_VNC_INITIALIZED : -qapi_event_send_vnc_initialized (si, vs->info,NULL ); +qapi_event_send_vnc_initialized (si, vs->info, &error_abort);break ;case QAPI_EVENT_VNC_DISCONNECTED : -qapi_event_send_vnc_disconnected (si, vs->info,NULL ); +qapi_event_send_vnc_disconnected (si, vs->info, &error_abort);break ;default :break ;
vl.c +6 -6
@@ -1746,7 +1746,7 @@ void vm_start(void)runstate_set (RUN_STATE_RUNNING );vm_state_notify (1 ,RUN_STATE_RUNNING );resume_all_vcpus (); -qapi_event_send_resume (NULL ); +qapi_event_send_resume (&error_abort); } }
@@ -1898,7 +1898,7 @@ void qemu_system_reset(bool report)qemu_devices_reset (); }if (report) { -qapi_event_send_reset (NULL ); +qapi_event_send_reset (&error_abort); }cpu_synchronize_all_post_reset (); }
@@ -1919,7 +1919,7 @@ static void qemu_system_suspend(void)pause_all_vcpus ();notifier_list_notify (&suspend_notifiers,NULL );runstate_set (RUN_STATE_SUSPENDED ); -qapi_event_send_suspend (NULL ); +qapi_event_send_suspend (&error_abort); }void qemu_system_suspend_request (void )
@@ -1982,7 +1982,7 @@ void qemu_system_shutdown_request(void)static void qemu_system_powerdown (void ) { -qapi_event_send_powerdown (NULL ); +qapi_event_send_powerdown (&error_abort);notifier_list_notify (&powerdown_notifiers,NULL ); }
@@ -2020,7 +2020,7 @@ static bool main_loop_should_exit(void) }if (qemu_shutdown_requested ()) {qemu_kill_report (); -qapi_event_send_shutdown (NULL ); +qapi_event_send_shutdown (&error_abort);if (no_shutdown) {vm_stop (RUN_STATE_SHUTDOWN ); }else {
@@ -2043,7 +2043,7 @@ static bool main_loop_should_exit(void)notifier_list_notify (&wakeup_notifiers, &wakeup_reason); wakeup_reason =QEMU_WAKEUP_REASON_NONE ;resume_all_vcpus (); -qapi_event_send_wakeup (NULL ); +qapi_event_send_wakeup (&error_abort); }if (qemu_powerdown_requested ()) {qemu_system_powerdown ();
Quoted 18 lines · Paolo Bonzini
Il 15/06/2014 02:52, Wenchao Xia ha scritto:
Quoted 8 lines
Quoted 6 lines
Unfortunately, this already does not apply anymore.
I've placed the rebase on branch qapi-event of my github repository. The resolutions are trivial, so perhaps Luiz or Michael can pull from there?
Paolo
Quoted 8 lines
Thanks for testing my work:)
Eric:
I have looked the comments, most fix will arrive in my V7 next week,
but still I have two issues without decision:
1. Whether to use QAPIEvent in callback function type declartion,
See my feedback in 6/29.
2. Whether to make qapi-event.json self sufficent, see my comments
in 17/29.
Quoted 6 lines
I am afraid that this will miss 2.1 (and so will dataplane rerror/werror that depends on it), so I went ahead and done all fixes in my qapi-event branch.
I have not yet applied Reviewed-by tags from Eric since some patches are different and I want him to look at the interdiff first.
Here's my first glance through your interdiff; I will also respond once I've looked at the commits leading to 8910d4c0f568d1eb46934ef16e9a275d97749973 (your current qapi-event branch head at git://github.com/bonzini/qemu.git).
Quoted 3 lines
Regarding error handling, I have left the code in but switched all callers to
&error_abort.
Works for me to use &error_abort.
Quoted 10 lines
The interdiff is here. I ensured that the result is bisectable, and the intermediate changes are responsible for the "spurious" hunks of the interdiff:
Makefile +0
-0
Makefile $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) · line 249
Quoted 6 lines
Makefile +1
-2@@ -246,8 +246,7 @@ $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) $(gen-out-type) -o "." -b -i $<, \ " GEN $@") qapi-event.c qapi-event.h :\ -$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi-event.json \ -$(SRC_PATH)/scripts/qapi-event.py $(qapi-py) +$(qapi-modules) $(SRC_PATH)/scripts/qapi-event.py $(qapi-py)
Where's the change that adds qapi/event.json to $(qapi-modules)? (Maybe the interdiff doesn't show it?)
Makefile line 29
Quoted 8 lines
Makefile +1
-2+++ b/include/sysemu/os-posix.h@@ -26,8 +26,6 @@ #ifndef QEMU_OS_POSIX_H #define QEMU_OS_POSIX_H -#include <sys/time.h> - void os_set_line_buffering(void);
Why this hunk? Did you accidentally forget to include Wenchao's 1/29 in your series?
Quoted 7 lines
Makefile +0
-0void os_set_proc_name(const char *s); void os_setup_signal_handling(void);monitor.c +0
-0
monitor.c typedef struct MonitorControl { · line 187
Quoted 7 lines
monitor.c +2
-2@@ -183,10 +183,10 @@ typedef struct MonitorControl {*/ typedef struct MonitorQAPIEventState { QAPIEvent event; /* Event being tracked */ - int64_t rate; /* Period over which to throttle. 0 to disable */ - int64_t last; /* Time at which event was last emitted */ + int64_t rate; /* Minimum time (in ns) between two events */ + int64_t last; /* QEMU_CLOCK_REALTIME value at last emission */
I still like the "0 to disable" comment; but I see that you dropped it to keep line length manageable. So I guess I can live with this change.
monitor.c static void monitor_qapi_event_handler(void *opaque) · line 538
Quoted 8 lines
monitor.c +2
-1@@ -535,14 +533,15 @@ static void monitor_qapi_event_handler(void *opaque)* more than 1 event will be emitted within @rate * milliseconds */ -static void monitor_qapi_event_throttle (QAPIEvent event,int64_t rate) +static void +monitor_qapi_event_throttle (QAPIEvent event,int64_t rate) {
Not the usual qemu formatting style.
Overall the interdiff looks like it resolves most of my concerns on v6.
Now for me to read the actual commits in your git repo...
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Il 17/06/2014 18:05, Eric Blake ha scritto:
Quoted 6 lines
Quoted 6 lines
Makefile +0
-0@@ -246,8 +246,7 @@ $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) $(gen-out-type) -o "." -b -i $<, \
Quoted 8 lines
Makefile $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) · line 249
Quoted 5 lines
Makefile +1
-2" GEN $@") qapi-event.c qapi-event.h :\ -$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi-event.json \ -$(SRC_PATH)/scripts/qapi-event.py $(qapi-py) +$(qapi-modules) $(SRC_PATH)/scripts/qapi-event.py $(qapi-py)Where's the change that adds
qapi/event.jsonto $(qapi-modules)? (Maybe the interdiff doesn't show it?)
Oops, it's not there.
Quoted 11 lines
Makefile line 29
Quoted 8 lines
Makefile +1
-2+++ b/include/sysemu/os-posix.h@@ -26,8 +26,6 @@ #ifndef QEMU_OS_POSIX_H #define QEMU_OS_POSIX_H -#include <sys/time.h> - void os_set_line_buffering(void);Why this hunk? Did you accidentally forget to include Wenchao's 1/29 in your series?
Yes, fixing now.
Quoted 10 lines
Makefile static void monitor_qapi_event_handler(void *opaque) · line 538
Quoted 8 lines
Makefile +2
-1@@ -535,14 +533,15 @@ static void monitor_qapi_event_handler(void *opaque) * more than 1 event will be emitted within @rate * milliseconds */ -static void monitor_qapi_event_throttle(QAPIEvent event, int64_t rate) +static void +monitor_qapi_event_throttle(QAPIEvent event, int64_t rate) {Not the usual qemu formatting style.
Yeah, this happened because of __attribute__((__unused__)) and matches other monitor_qapi_ functions. I kind of like the return-type-then-newline too. :)
Quoted 2 lines
Overall the interdiff looks like it resolves most of my concerns on v6.
Now for me to read the actual commits in your git repo...
Will fix in a moment.
Paolo
Quoted 49 lines · Paolo Bonzini
Il 17/06/2014 18:05, Eric Blake ha scritto:
Quoted 7 lines
Quoted 7 lines
Makefile +0
-0@@ -246,8 +246,7 @@ $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) $(gen-out-type) -o "." -b -i $<, \Quoted 8 lines
Makefile $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) · line 249
Quoted 5 lines
Makefile +1
-2" GEN $@") qapi-event.c qapi-event.h :\ -$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi-event.json \ -$(SRC_PATH)/scripts/qapi-event.py $(qapi-py) +$(qapi-modules) $(SRC_PATH)/scripts/qapi-event.py $(qapi-py)Where's the change that adds
qapi/event.jsonto $(qapi-modules)? (Maybe the interdiff doesn't show it?)Oops, it's not there.
Quoted 11 lines
Makefile line 29
Quoted 8 lines
Makefile +1
-2+++ b/include/sysemu/os-posix.h@@ -26,8 +26,6 @@ #ifndef QEMU_OS_POSIX_H #define QEMU_OS_POSIX_H -#include <sys/time.h> - void os_set_line_buffering(void);Why this hunk? Did you accidentally forget to include Wenchao's 1/29 in your series?
Yes, fixing now.
Quoted 11 lines
Makefile static void monitor_qapi_event_handler(void · line 539
Quoted 9 lines
Makefile +2
-1@@ -535,14 +533,15 @@ static void monitor_qapi_event_handler(void *opaque) * more than 1 event will be emitted within @rate * milliseconds */ -static void monitor_qapi_event_throttle(QAPIEvent event, int64_t rate) +static void +monitor_qapi_event_throttle(QAPIEvent event, int64_t rate) {Not the usual qemu formatting style.
Yeah, this happened because of __attribute__((__unused__)) and matches other
monitor_qapi_functions. I kind of like the return-type-then-newline too. :)
Quoted 6 lines
Quoted 2 lines
Overall the interdiff looks like it resolves most of my concerns on v6.
Now for me to read the actual commits in your git repo...Will fix in a moment.
Paolo
If you and Eric think v6 is OK to catch up 2.1, I can send a clean up
patch fixing the typo/doc issues after merge.
Quoted 8 lines · Paolo Bonzini
Il 15/06/2014 02:52, Wenchao Xia ha scritto:
Quoted 7 lines
Quoted 6 lines
Unfortunately, this already does not apply anymore.
I've placed the rebase on branch qapi-event of my github repository. The resolutions are trivial, so perhaps Luiz or Michael can pull from there?
Paolo
I'm still reviewing your git tree; I raised a couple comments on 3/29 (see my replies there). Also:
include/qapi/qmp-event.h line 20
Quoted 7 lines
+++
b/include/qapi/qmp-event.hinclude/qapi/qmp-event.h +1
-1@@ -17,7 +17,7 @@#include "qapi/error.h" #include "qapi/qmp/qdict.h" -typedef void (*QMPEventFuncEmit )(int event_kind,QDict *dict,Error **errp); +typedef void (*QMPEventFuncEmit )(unsigned event,QDict *dict,Error **errp);
It looks like you have some churn on this definition; patch 4/29 in your qapi-event branch did:
-enum QAPIEvent;
-typedef void (*QMPEventFuncEmit)(enum QAPIEvent event, QDict *dict, Error **errp);
+typedef void (*QMPEventFuncEmit)(unsigned event, QDict *dict, Error **errp);
Can you hoist the use of 'unsigned' directly into 2/29 to minimize the churn?
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Il 18/06/2014 06:00, Eric Blake ha scritto:
Quoted 11 lines
Quoted 2 lines
include/qapi/qmp-event.h line 20
Quoted 2 lines
include/qapi/qmp-event.h +1
-1-typedef void (*QMPEventFuncEmit )(int event_kind,QDict *dict,Error **errp); +typedef void (*QMPEventFuncEmit )(unsigned event,QDict *dict,Error **errp);It looks like you have some churn on this definition; patch 4/29 in your qapi-event branch did:
(quoted diff) +0
-2-enum QAPIEvent; -typedef void (*QMPEventFuncEmit)(enum QAPIEvent event, QDict *dict,Error **errp);
+typedef void (*QMPEventFuncEmit)(unsigned event, QDict *dict, Error **errp);
Quoted 2 lines
Can you hoist the use of 'unsigned' directly into 2/29 to minimize the churn?
Yes, will fix in a couple of hours.
Paolo