* [Qemu-devel] [PATCH v5a 0/3] trivial qapi cleanups @ 2014-09-26 15:20 Eric Blake 2014-09-26 15:20 ` [Qemu-devel] [PATCH v5 1/3] qapi: Consistent whitespace in tests/Makefile Eric Blake ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: Eric Blake @ 2014-09-26 15:20 UTC (permalink / raw) To: qemu-devel Cc: qemu-trivial, Luiz Capitulino, Fam Zheng, Markus Armbruster, wenchaoqemu This is split out from [PATCH v4 00/19]: drop qapi nested structs in order to get the trivial stuff in now, rather than holding it up for what may be another month while I address the larger findings against the rest of that series. v4 was here: https://lists.gnu.org/archive/html/qemu-devel/2014-09/msg04022.html Changelog: v5: no change (just splitting the series into two parts) v4: add docs (patch 3 is new) [Markus] v3: no changes v2: add makefile cleanups (patch 1-2) v1: this portion of the larger series was not present Eric Blake (3): qapi: Consistent whitespace in tests/Makefile qapi: Ignore files created during make check qapi: Update docs given recent event, spacing fixes docs/qapi-code-gen.txt | 100 +++++++++++++++++++++++++++++++++++++++---------- tests/.gitignore | 3 ++ tests/Makefile | 32 ++++++++-------- 3 files changed, 99 insertions(+), 36 deletions(-) -- 1.9.3 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH v5 1/3] qapi: Consistent whitespace in tests/Makefile 2014-09-26 15:20 [Qemu-devel] [PATCH v5a 0/3] trivial qapi cleanups Eric Blake @ 2014-09-26 15:20 ` Eric Blake 2014-09-26 15:20 ` [Qemu-devel] [PATCH v5 2/3] qapi: Ignore files created during make check Eric Blake ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: Eric Blake @ 2014-09-26 15:20 UTC (permalink / raw) To: qemu-devel Cc: qemu-trivial, Luiz Capitulino, Fam Zheng, Markus Armbruster, wenchaoqemu tests/Makefile had a mix of TAB vs. 8-space indentation; given that it is a Makefile, TAB is more idiomatic even though in these particular cases the choice of whitespace didn't matter. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> --- tests/Makefile | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/Makefile b/tests/Makefile index f5de29c..3c5bc0f 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -196,23 +196,23 @@ $(foreach target,$(SYSEMU_TARGET_LIST), \ $(eval check-qtest-$(target)-y += tests/qom-test$(EXESUF))) check-qapi-schema-y := $(addprefix tests/qapi-schema/, \ - comments.json empty.json funny-char.json indented-expr.json \ - missing-colon.json missing-comma-list.json \ - missing-comma-object.json non-objects.json \ - qapi-schema-test.json quoted-structural-chars.json \ - trailing-comma-list.json trailing-comma-object.json \ - unclosed-list.json unclosed-object.json unclosed-string.json \ - duplicate-key.json union-invalid-base.json flat-union-no-base.json \ - flat-union-invalid-discriminator.json \ - flat-union-invalid-branch-key.json flat-union-reverse-define.json \ - flat-union-string-discriminator.json \ - 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 event-nest-struct.json) + comments.json empty.json funny-char.json indented-expr.json \ + missing-colon.json missing-comma-list.json \ + missing-comma-object.json non-objects.json \ + qapi-schema-test.json quoted-structural-chars.json \ + trailing-comma-list.json trailing-comma-object.json \ + unclosed-list.json unclosed-object.json unclosed-string.json \ + duplicate-key.json union-invalid-base.json flat-union-no-base.json \ + flat-union-invalid-discriminator.json \ + flat-union-invalid-branch-key.json flat-union-reverse-define.json \ + flat-union-string-discriminator.json \ + 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 event-nest-struct.json) GENERATED_HEADERS += tests/test-qapi-types.h tests/test-qapi-visit.h \ - tests/test-qmp-commands.h tests/test-qapi-event.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 \ @@ -224,7 +224,7 @@ test-obj-y = tests/check-qint.o tests/check-qstring.o tests/check-qdict.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 \ - tests/test-qapi-event.o + tests/test-qapi-event.o $(test-obj-y): QEMU_INCLUDES += -Itests QEMU_CFLAGS += -I$(SRC_PATH)/tests -- 1.9.3 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH v5 2/3] qapi: Ignore files created during make check 2014-09-26 15:20 [Qemu-devel] [PATCH v5a 0/3] trivial qapi cleanups Eric Blake 2014-09-26 15:20 ` [Qemu-devel] [PATCH v5 1/3] qapi: Consistent whitespace in tests/Makefile Eric Blake @ 2014-09-26 15:20 ` Eric Blake 2014-09-26 15:20 ` [Qemu-devel] [PATCH v5 3/3] qapi: Update docs given recent event, spacing fixes Eric Blake 2014-09-26 17:19 ` [Qemu-devel] [Qemu-trivial] [PATCH v5a 0/3] trivial qapi cleanups Michael Tokarev 3 siblings, 0 replies; 5+ messages in thread From: Eric Blake @ 2014-09-26 15:20 UTC (permalink / raw) To: qemu-devel Cc: qemu-trivial, Luiz Capitulino, Fam Zheng, Markus Armbruster, wenchaoqemu After an in-tree build and run of 'make check-{qapi-schema,unit}', I noticed some leftover files. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Wenchao Xia <wenchaoqemu@gmail.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> --- tests/.gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/.gitignore b/tests/.gitignore index c71c110..e2e4957 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -14,11 +14,14 @@ test-int128 test-iov test-mul64 test-opts-visitor +test-qapi-event.[ch] test-qapi-types.[ch] test-qapi-visit.[ch] test-qdev-global-props +test-qemu-opts test-qmp-commands test-qmp-commands.h +test-qmp-event test-qmp-input-strict test-qmp-input-visitor test-qmp-marshal.c -- 1.9.3 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH v5 3/3] qapi: Update docs given recent event, spacing fixes 2014-09-26 15:20 [Qemu-devel] [PATCH v5a 0/3] trivial qapi cleanups Eric Blake 2014-09-26 15:20 ` [Qemu-devel] [PATCH v5 1/3] qapi: Consistent whitespace in tests/Makefile Eric Blake 2014-09-26 15:20 ` [Qemu-devel] [PATCH v5 2/3] qapi: Ignore files created during make check Eric Blake @ 2014-09-26 15:20 ` Eric Blake 2014-09-26 17:19 ` [Qemu-devel] [Qemu-trivial] [PATCH v5a 0/3] trivial qapi cleanups Michael Tokarev 3 siblings, 0 replies; 5+ messages in thread From: Eric Blake @ 2014-09-26 15:20 UTC (permalink / raw) To: qemu-devel Cc: qemu-trivial, Luiz Capitulino, Fam Zheng, Markus Armbruster, wenchaoqemu Commit 21cd70d added event support but didn't document what the generated code looks like. Commit 05dfb26 removed some unwanted spaces in the generated code, but didn't reflect those changes into the documentation. Finally, the docs start with a big disclaimer about QMP not using QAPI yet, which feels rather stale. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> --- docs/qapi-code-gen.txt | 100 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 80 insertions(+), 20 deletions(-) diff --git a/docs/qapi-code-gen.txt b/docs/qapi-code-gen.txt index a6197a9..8313ba6 100644 --- a/docs/qapi-code-gen.txt +++ b/docs/qapi-code-gen.txt @@ -1,10 +1,5 @@ = How to use the QAPI code generator = -* Note: as of this writing, QMP does not use QAPI. Eventually QMP -commands will be converted to use QAPI internally. The following -information describes QMP/QAPI as it will exist after the -conversion. - QAPI is a native C API within QEMU which provides management-level functionality to internal/external users. For external users/processes, this interface is made available by a JSON-based @@ -19,7 +14,7 @@ marshaling/dispatch code for the guest agent server running in the guest. This document will describe how the schemas, scripts, and resulting -code is used. +code are used. == QMP/Guest agent schema == @@ -234,6 +229,7 @@ Resulting in this JSON object: "data": { "b": "test string" }, "timestamp": { "seconds": 1267020223, "microseconds": 435656 } } + == Code generation == Schemas are fed into 3 scripts to generate all the code/files that, paired @@ -256,6 +252,8 @@ command which takes that type as a parameter and returns the same type: 'data': {'arg1': 'UserDefOne'}, 'returns': 'UserDefOne' } + { 'event': 'MY_EVENT' } + === scripts/qapi-types.py === Used to generate the C types defined by a schema. The following files are @@ -277,7 +275,7 @@ Example: $ cat qapi-generated/example-qapi-types.c [Uninteresting stuff omitted...] - void qapi_free_UserDefOneList(UserDefOneList * obj) + void qapi_free_UserDefOneList(UserDefOneList *obj) { QapiDeallocVisitor *md; Visitor *v; @@ -292,7 +290,7 @@ Example: qapi_dealloc_visitor_cleanup(md); } - void qapi_free_UserDefOne(UserDefOne * obj) + void qapi_free_UserDefOne(UserDefOne *obj) { QapiDeallocVisitor *md; Visitor *v; @@ -331,11 +329,11 @@ Example: struct UserDefOne { int64_t integer; - char * string; + char *string; }; - void qapi_free_UserDefOneList(UserDefOneList * obj); - void qapi_free_UserDefOne(UserDefOne * obj); + void qapi_free_UserDefOneList(UserDefOneList *obj); + void qapi_free_UserDefOne(UserDefOne *obj); #endif @@ -364,7 +362,7 @@ Example: $ cat qapi-generated/example-qapi-visit.c [Uninteresting stuff omitted...] - static void visit_type_UserDefOne_fields(Visitor *m, UserDefOne ** obj, Error **errp) + static void visit_type_UserDefOne_fields(Visitor *m, UserDefOne **obj, Error **errp) { Error *err = NULL; visit_type_int(m, &(*obj)->integer, "integer", &err); @@ -380,7 +378,7 @@ Example: error_propagate(errp, err); } - void visit_type_UserDefOne(Visitor *m, UserDefOne ** obj, const char *name, Error **errp) + void visit_type_UserDefOne(Visitor *m, UserDefOne **obj, const char *name, Error **errp) { Error *err = NULL; @@ -394,7 +392,7 @@ Example: error_propagate(errp, err); } - void visit_type_UserDefOneList(Visitor *m, UserDefOneList ** obj, const char *name, Error **errp) + void visit_type_UserDefOneList(Visitor *m, UserDefOneList **obj, const char *name, Error **errp) { Error *err = NULL; GenericList *i, **prev; @@ -427,8 +425,8 @@ Example: [Visitors for builtin types omitted...] - void visit_type_UserDefOne(Visitor *m, UserDefOne ** obj, const char *name, Error **errp); - void visit_type_UserDefOneList(Visitor *m, UserDefOneList ** obj, const char *name, Error **errp); + void visit_type_UserDefOne(Visitor *m, UserDefOne **obj, const char *name, Error **errp); + void visit_type_UserDefOneList(Visitor *m, UserDefOneList **obj, const char *name, Error **errp); #endif @@ -451,10 +449,12 @@ $(prefix)qmp-commands.h: Function prototypes for the QMP commands Example: + $ python scripts/qapi-commands.py --output-dir="qapi-generated" + --prefix="example-" --input-file=example-schema.json $ cat qapi-generated/example-qmp-marshal.c [Uninteresting stuff omitted...] - static void qmp_marshal_output_my_command(UserDefOne * ret_in, QObject **ret_out, Error **errp) + static void qmp_marshal_output_my_command(UserDefOne *ret_in, QObject **ret_out, Error **errp) { Error *local_err = NULL; QmpOutputVisitor *mo = qmp_output_visitor_new(); @@ -480,11 +480,11 @@ Example: static void qmp_marshal_input_my_command(QDict *args, QObject **ret, Error **errp) { Error *local_err = NULL; - UserDefOne * retval = NULL; + UserDefOne *retval = NULL; QmpInputVisitor *mi = qmp_input_visitor_new_strict(QOBJECT(args)); QapiDeallocVisitor *md; Visitor *v; - UserDefOne * arg1 = NULL; + UserDefOne *arg1 = NULL; v = qmp_input_get_visitor(mi); visit_type_UserDefOne(v, &arg1, "arg1", &local_err); @@ -525,6 +525,66 @@ Example: #include "qapi/qmp/qdict.h" #include "qapi/error.h" - UserDefOne * qmp_my_command(UserDefOne * arg1, Error **errp); + UserDefOne *qmp_my_command(UserDefOne *arg1, Error **errp); + + #endif + +=== scripts/qapi-event.py === + +Used to generate the event-related C code defined by a schema. The +following files are created: + +$(prefix)qapi-event.h - Function prototypes for each event type, plus an + enumeration of all event names +$(prefix)qapi-event.c - Implementation of functions to send an event + +Example: + + $ python scripts/qapi-event.py --output-dir="qapi-generated" + --prefix="example-" --input-file=example-schema.json + $ cat qapi-generated/example-qapi-event.c +[Uninteresting stuff omitted...] + + void qapi_event_send_my_event(Error **errp) + { + QDict *qmp; + Error *local_err = NULL; + QMPEventFuncEmit emit; + emit = qmp_event_get_func_emit(); + if (!emit) { + return; + } + + qmp = qmp_event_build_dict("MY_EVENT"); + + emit(EXAMPLE_QAPI_EVENT_MY_EVENT, qmp, &local_err); + + error_propagate(errp, local_err); + QDECREF(qmp); + } + + const char *EXAMPLE_QAPIEvent_lookup[] = { + "MY_EVENT", + NULL, + }; + $ cat qapi-generated/example-qapi-event.h +[Uninteresting stuff omitted...] + + #ifndef EXAMPLE_QAPI_EVENT_H + #define EXAMPLE_QAPI_EVENT_H + + #include "qapi/error.h" + #include "qapi/qmp/qdict.h" + #include "example-qapi-types.h" + + + void qapi_event_send_my_event(Error **errp); + + extern const char *EXAMPLE_QAPIEvent_lookup[]; + typedef enum EXAMPLE_QAPIEvent + { + EXAMPLE_QAPI_EVENT_MY_EVENT = 0, + EXAMPLE_QAPI_EVENT_MAX = 1, + } EXAMPLE_QAPIEvent; #endif -- 1.9.3 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [Qemu-trivial] [PATCH v5a 0/3] trivial qapi cleanups 2014-09-26 15:20 [Qemu-devel] [PATCH v5a 0/3] trivial qapi cleanups Eric Blake ` (2 preceding siblings ...) 2014-09-26 15:20 ` [Qemu-devel] [PATCH v5 3/3] qapi: Update docs given recent event, spacing fixes Eric Blake @ 2014-09-26 17:19 ` Michael Tokarev 3 siblings, 0 replies; 5+ messages in thread From: Michael Tokarev @ 2014-09-26 17:19 UTC (permalink / raw) To: Eric Blake, qemu-devel Cc: qemu-trivial, Fam Zheng, Markus Armbruster, wenchaoqemu, Luiz Capitulino 26.09.2014 19:20, Eric Blake wrote: > This is split out from [PATCH v4 00/19]: drop qapi nested structs > in order to get the trivial stuff in now, rather than holding it > up for what may be another month while I address the larger findings > against the rest of that series. Applied all 3 to -trivial. > qapi: Consistent whitespace in tests/Makefile For this one I had to edit context a bit since the previous line changed identation meanwhile. Which is quite hilarious in this context... ;) Thanks, /mjt ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-09-26 17:20 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-09-26 15:20 [Qemu-devel] [PATCH v5a 0/3] trivial qapi cleanups Eric Blake 2014-09-26 15:20 ` [Qemu-devel] [PATCH v5 1/3] qapi: Consistent whitespace in tests/Makefile Eric Blake 2014-09-26 15:20 ` [Qemu-devel] [PATCH v5 2/3] qapi: Ignore files created during make check Eric Blake 2014-09-26 15:20 ` [Qemu-devel] [PATCH v5 3/3] qapi: Update docs given recent event, spacing fixes Eric Blake 2014-09-26 17:19 ` [Qemu-devel] [Qemu-trivial] [PATCH v5a 0/3] trivial qapi cleanups Michael Tokarev
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).