From nobody Fri May 3 05:56:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501171218545543.9808371720914; Thu, 27 Jul 2017 09:00:18 -0700 (PDT) Received: from localhost ([::1]:43724 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dalCu-0000cf-So for importer@patchew.org; Thu, 27 Jul 2017 12:00:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60158) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal4d-0000Mc-Pg for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dal4a-0006zY-IV for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54942) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dal4a-0006xY-5K for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:36 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E794EFEF0B; Thu, 27 Jul 2017 15:41:33 +0000 (UTC) Received: from localhost (ovpn-112-42.ams2.redhat.com [10.36.112.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 908266EC99; Thu, 27 Jul 2017 15:41:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E794EFEF0B Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 17:41:01 +0200 Message-Id: <20170727154126.11339-2-marcandre.lureau@redhat.com> In-Reply-To: <20170727154126.11339-1-marcandre.lureau@redhat.com> References: <20170727154126.11339-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 27 Jul 2017 15:41:35 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 01/26] qapi: fix type_seen key error X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Michael Roth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The type_seen member can be of a different type than the 'qtype' being checked, since a string create several conflicts. Lookup the real conflicting type in the conflict set, that one must be present in type_seen. This fixes the following error, reproducible with the modified test: Traceback (most recent call last): File "/home/elmarco/src/qq/tests/qapi-schema/test-qapi.py", line 56, in <= module> schema =3D QAPISchema(sys.argv[1]) File "/home/elmarco/src/qq/scripts/qapi.py", line 1470, in __init__ self.exprs =3D check_exprs(parser.exprs) File "/home/elmarco/src/qq/scripts/qapi.py", line 959, in check_exprs check_alternate(expr, info) File "/home/elmarco/src/qq/scripts/qapi.py", line 831, in check_alternate % (name, key, types_seen[qtype])) KeyError: 'QTYPE_QSTRING' Signed-off-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi.py | 4 +++- tests/qapi-schema/alternate-conflict-string.json | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/qapi.py b/scripts/qapi.py index 8aa2775f12..4ecc19e944 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -825,7 +825,9 @@ def check_alternate(expr, info): else: conflicting.add('QTYPE_QNUM') conflicting.add('QTYPE_QBOOL') - if conflicting & set(types_seen): + conflict =3D conflicting & set(types_seen) + if conflict: + qtype =3D list(conflict)[0] raise QAPISemError(info, "Alternate '%s' member '%s' can't " "be distinguished from member '%s'" % (name, key, types_seen[qtype])) diff --git a/tests/qapi-schema/alternate-conflict-string.json b/tests/qapi-= schema/alternate-conflict-string.json index 85adbd4adc..bb2702978e 100644 --- a/tests/qapi-schema/alternate-conflict-string.json +++ b/tests/qapi-schema/alternate-conflict-string.json @@ -1,4 +1,4 @@ # alternate branches of 'str' type conflict with all scalar types { 'alternate': 'Alt', - 'data': { 'one': 'str', - 'two': 'int' } } + 'data': { 'one': 'int', + 'two': 'str' } } --=20 2.14.0.rc0.1.g40ca67566 From nobody Fri May 3 05:56:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501170537166499.482333063096; Thu, 27 Jul 2017 08:48:57 -0700 (PDT) Received: from localhost ([::1]:43676 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal1v-0005BE-Ky for importer@patchew.org; Thu, 27 Jul 2017 11:48:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54606) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal0C-0004Ab-V8 for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:47:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dal0B-0003Lp-Em for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:47:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:65342) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dal06-0003D5-At; Thu, 27 Jul 2017 11:46:58 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7C814A1433; Thu, 27 Jul 2017 15:41:37 +0000 (UTC) Received: from localhost (ovpn-112-42.ams2.redhat.com [10.36.112.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 18B5E62666; Thu, 27 Jul 2017 15:41:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7C814A1433 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 17:41:02 +0200 Message-Id: <20170727154126.11339-3-marcandre.lureau@redhat.com> In-Reply-To: <20170727154126.11339-1-marcandre.lureau@redhat.com> References: <20170727154126.11339-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 27 Jul 2017 15:41:37 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 02/26] qobject: replace dump_qobject() by qobject_to_string() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , "open list:Block layer core" , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The dump functions is generally useful for any qobject user, for testing, debugging etc. The callback-based output is replaced by string allocation. Trading efficiency for ease-of-use is okay here. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/qapi/qmp/qdict.h | 2 ++ include/qapi/qmp/qlist.h | 2 ++ include/qapi/qmp/qobject.h | 7 ++++ block/qapi.c | 90 +++---------------------------------------= ---- qobject/qdict.c | 30 ++++++++++++++++ qobject/qlist.c | 23 ++++++++++++ qobject/qobject.c | 21 +++++++++++ tests/check-qjson.c | 19 ++++++++++ 8 files changed, 108 insertions(+), 86 deletions(-) diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h index 363e431106..c9c4038435 100644 --- a/include/qapi/qmp/qdict.h +++ b/include/qapi/qmp/qdict.h @@ -86,4 +86,6 @@ QObject *qdict_crumple(const QDict *src, Error **errp); =20 void qdict_join(QDict *dest, QDict *src, bool overwrite); =20 +char *qdict_to_string(QDict *dict, int indent); + #endif /* QDICT_H */ diff --git a/include/qapi/qmp/qlist.h b/include/qapi/qmp/qlist.h index c4b5fdad9b..c93ac3e15b 100644 --- a/include/qapi/qmp/qlist.h +++ b/include/qapi/qmp/qlist.h @@ -60,6 +60,8 @@ size_t qlist_size(const QList *qlist); QList *qobject_to_qlist(const QObject *obj); void qlist_destroy_obj(QObject *obj); =20 +char *qlist_to_string(QList *list, int indent); + static inline const QListEntry *qlist_first(const QList *qlist) { return QTAILQ_FIRST(&qlist->head); diff --git a/include/qapi/qmp/qobject.h b/include/qapi/qmp/qobject.h index eab29edd12..3365eb73c9 100644 --- a/include/qapi/qmp/qobject.h +++ b/include/qapi/qmp/qobject.h @@ -105,4 +105,11 @@ static inline QNull *qnull(void) return &qnull_; } =20 +char *qobject_to_string_indent(QObject *obj, int indent); + +static inline char *qobject_to_string(QObject *obj) +{ + return qobject_to_string_indent(obj, 0); +} + #endif /* QOBJECT_H */ diff --git a/block/qapi.c b/block/qapi.c index d2b18ee9df..08b5a666d1 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -623,101 +623,19 @@ void bdrv_snapshot_dump(fprintf_function func_fprint= f, void *f, } } =20 -static void dump_qdict(fprintf_function func_fprintf, void *f, int indenta= tion, - QDict *dict); -static void dump_qlist(fprintf_function func_fprintf, void *f, int indenta= tion, - QList *list); - -static void dump_qobject(fprintf_function func_fprintf, void *f, - int comp_indent, QObject *obj) -{ - switch (qobject_type(obj)) { - case QTYPE_QNUM: { - QNum *value =3D qobject_to_qnum(obj); - char *tmp =3D qnum_to_string(value); - func_fprintf(f, "%s", tmp); - g_free(tmp); - break; - } - case QTYPE_QSTRING: { - QString *value =3D qobject_to_qstring(obj); - func_fprintf(f, "%s", qstring_get_str(value)); - break; - } - case QTYPE_QDICT: { - QDict *value =3D qobject_to_qdict(obj); - dump_qdict(func_fprintf, f, comp_indent, value); - break; - } - case QTYPE_QLIST: { - QList *value =3D qobject_to_qlist(obj); - dump_qlist(func_fprintf, f, comp_indent, value); - break; - } - case QTYPE_QBOOL: { - QBool *value =3D qobject_to_qbool(obj); - func_fprintf(f, "%s", qbool_get_bool(value) ? "true" : "false"= ); - break; - } - default: - abort(); - } -} - -static void dump_qlist(fprintf_function func_fprintf, void *f, int indenta= tion, - QList *list) -{ - const QListEntry *entry; - int i =3D 0; - - for (entry =3D qlist_first(list); entry; entry =3D qlist_next(entry), = i++) { - QType type =3D qobject_type(entry->value); - bool composite =3D (type =3D=3D QTYPE_QDICT || type =3D=3D QTYPE_Q= LIST); - func_fprintf(f, "%*s[%i]:%c", indentation * 4, "", i, - composite ? '\n' : ' '); - dump_qobject(func_fprintf, f, indentation + 1, entry->value); - if (!composite) { - func_fprintf(f, "\n"); - } - } -} - -static void dump_qdict(fprintf_function func_fprintf, void *f, int indenta= tion, - QDict *dict) -{ - const QDictEntry *entry; - - for (entry =3D qdict_first(dict); entry; entry =3D qdict_next(dict, en= try)) { - QType type =3D qobject_type(entry->value); - bool composite =3D (type =3D=3D QTYPE_QDICT || type =3D=3D QTYPE_Q= LIST); - char *key =3D g_malloc(strlen(entry->key) + 1); - int i; - - /* replace dashes with spaces in key (variable) names */ - for (i =3D 0; entry->key[i]; i++) { - key[i] =3D entry->key[i] =3D=3D '-' ? ' ' : entry->key[i]; - } - key[i] =3D 0; - func_fprintf(f, "%*s%s:%c", indentation * 4, "", key, - composite ? '\n' : ' '); - dump_qobject(func_fprintf, f, indentation + 1, entry->value); - if (!composite) { - func_fprintf(f, "\n"); - } - g_free(key); - } -} - void bdrv_image_info_specific_dump(fprintf_function func_fprintf, void *f, ImageInfoSpecific *info_spec) { QObject *obj, *data; Visitor *v =3D qobject_output_visitor_new(&obj); + char *tmp; =20 visit_type_ImageInfoSpecific(v, NULL, &info_spec, &error_abort); visit_complete(v, &obj); data =3D qdict_get(qobject_to_qdict(obj), "data"); - dump_qobject(func_fprintf, f, 1, data); + tmp =3D qobject_to_string_indent(data, 1); + func_fprintf(f, "%s", tmp); + g_free(tmp); qobject_decref(obj); visit_free(v); } diff --git a/qobject/qdict.c b/qobject/qdict.c index 576018e531..1cb5cab5e0 100644 --- a/qobject/qdict.c +++ b/qobject/qdict.c @@ -1022,3 +1022,33 @@ void qdict_join(QDict *dest, QDict *src, bool overwr= ite) entry =3D next; } } + +char *qdict_to_string(QDict *dict, int indent) +{ + const QDictEntry *entry; + GString *str =3D g_string_new(NULL); + + for (entry =3D qdict_first(dict); entry; entry =3D qdict_next(dict, en= try)) { + QType type =3D qobject_type(entry->value); + bool composite =3D (type =3D=3D QTYPE_QDICT || type =3D=3D QTYPE_Q= LIST); + char *key =3D g_malloc(strlen(entry->key) + 1); + char *val =3D qobject_to_string_indent(entry->value, indent + 1); + int i; + + /* replace dashes with spaces in key (variable) names */ + for (i =3D 0; entry->key[i]; i++) { + key[i] =3D entry->key[i] =3D=3D '-' ? ' ' : entry->key[i]; + } + key[i] =3D 0; + g_string_append_printf(str, "%*s%s:", indent * 4, "", key); + g_string_append_c(str, composite ? '\n' : ' '); + g_string_append(str, val); + if (!composite) { + g_string_append_c(str, '\n'); + } + g_free(val); + g_free(key); + } + + return g_string_free(str, false); +} diff --git a/qobject/qlist.c b/qobject/qlist.c index 86b60cb88c..b769248290 100644 --- a/qobject/qlist.c +++ b/qobject/qlist.c @@ -158,3 +158,26 @@ void qlist_destroy_obj(QObject *obj) =20 g_free(qlist); } + +char *qlist_to_string(QList *list, int indent) +{ + GString *str =3D g_string_new(NULL); + const QListEntry *entry; + int i =3D 0; + + for (entry =3D qlist_first(list); entry; entry =3D qlist_next(entry), = i++) { + QType type =3D qobject_type(entry->value); + bool composite =3D (type =3D=3D QTYPE_QDICT || type =3D=3D QTYPE_Q= LIST); + char *val =3D qobject_to_string_indent(entry->value, indent + 1); + + g_string_append_printf(str, "%*s[%i]:", indent * 4, "", i); + g_string_append_c(str, composite ? '\n' : ' '); + g_string_append(str, val); + if (!composite) { + g_string_append_c(str, '\n'); + } + g_free(val); + } + + return g_string_free(str, false); +} diff --git a/qobject/qobject.c b/qobject/qobject.c index b0cafb66f1..b70bef9ccb 100644 --- a/qobject/qobject.c +++ b/qobject/qobject.c @@ -27,3 +27,24 @@ void qobject_destroy(QObject *obj) assert(QTYPE_QNULL < obj->type && obj->type < QTYPE__MAX); qdestroy[obj->type](obj); } + +char *qobject_to_string_indent(QObject *obj, int indent) +{ + switch (qobject_type(obj)) { + case QTYPE_QNULL: + return g_strdup("null"); + case QTYPE_QNUM: + return qnum_to_string(qobject_to_qnum(obj)); + case QTYPE_QSTRING: + return g_strdup(qstring_get_str(qobject_to_qstring(obj))); + case QTYPE_QDICT: + return qdict_to_string(qobject_to_qdict(obj), indent); + case QTYPE_QLIST: + return qlist_to_string(qobject_to_qlist(obj), indent); + case QTYPE_QBOOL: + return g_strdup(qbool_get_bool(qobject_to_qbool(obj)) ? + "true" : "false"); + default: + abort(); + } +} diff --git a/tests/check-qjson.c b/tests/check-qjson.c index a3a97b0d99..9c42a46b7d 100644 --- a/tests/check-qjson.c +++ b/tests/check-qjson.c @@ -1372,6 +1372,23 @@ static void simple_whitespace(void) } } =20 +static void qobject_to_string_test(void) +{ + QObject *obj; + char *tmp; + + obj =3D qobject_from_json("[ 43, { 'c': { 'd' : 12 } }, [ 1, 2 ], 42 ]= ", + &error_abort); + tmp =3D qobject_to_string(obj); + g_assert_cmpstr(tmp, =3D=3D, + "[0]: 43\n" + "[1]:\n c:\n d: 12\n" + "[2]:\n [0]: 1\n [1]: 2\n" + "[3]: 42\n"); + g_free(tmp); + qobject_decref(obj); +} + static void simple_varargs(void) { QObject *embedded_obj; @@ -1545,5 +1562,7 @@ int main(int argc, char **argv) g_test_add_func("/errors/unterminated/literal", unterminated_literal); g_test_add_func("/errors/limits/nesting", limits_nesting); =20 + g_test_add_func("/qobject/to_string", qobject_to_string_test); + return g_test_run(); } --=20 2.14.0.rc0.1.g40ca67566 From nobody Fri May 3 05:56:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501170520839625.6302341614805; Thu, 27 Jul 2017 08:48:40 -0700 (PDT) Received: from localhost ([::1]:43675 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal1i-00051M-90 for importer@patchew.org; Thu, 27 Jul 2017 11:48:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54528) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal09-000480-DC for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:47:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dal06-0003FM-2E for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:47:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56562) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dal05-0003C9-OR for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:46:57 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 94A8DA0C05 for ; Thu, 27 Jul 2017 15:41:39 +0000 (UTC) Received: from localhost (ovpn-112-42.ams2.redhat.com [10.36.112.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 038445D960; Thu, 27 Jul 2017 15:41:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 94A8DA0C05 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 17:41:03 +0200 Message-Id: <20170727154126.11339-4-marcandre.lureau@redhat.com> In-Reply-To: <20170727154126.11339-1-marcandre.lureau@redhat.com> References: <20170727154126.11339-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 27 Jul 2017 15:41:39 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 03/26] qboject: add literal qobject type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Promote LiteralQObject from tests/check-qjson.c to qobject/qlit.c, allowing to statically declare complex qobjects. Add a helper qobject_from_qlit() to instantiate a literal qobject to a real QObject. Add some simple test. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/qapi/qmp/qlit.h | 53 ++++++++++++++++++++++++++++++++++++ qobject/qlit.c | 53 ++++++++++++++++++++++++++++++++++++ tests/check-qjson.c | 72 +++++++++++++++++----------------------------= ---- tests/check-qlit.c | 52 +++++++++++++++++++++++++++++++++++ qobject/Makefile.objs | 2 +- tests/Makefile.include | 5 +++- 6 files changed, 187 insertions(+), 50 deletions(-) create mode 100644 include/qapi/qmp/qlit.h create mode 100644 qobject/qlit.c create mode 100644 tests/check-qlit.c diff --git a/include/qapi/qmp/qlit.h b/include/qapi/qmp/qlit.h new file mode 100644 index 0000000000..fd6bfc3e69 --- /dev/null +++ b/include/qapi/qmp/qlit.h @@ -0,0 +1,53 @@ +/* + * Copyright IBM, Corp. 2009 + * Copyright (c) 2013, 2015 Red Hat Inc. + * + * Authors: + * Anthony Liguori + * Markus Armbruster + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or l= ater. + * See the COPYING.LIB file in the top-level directory. + * + */ +#ifndef QLIT_H_ +#define QLIT_H_ + +#include "qapi-types.h" +#include "qobject.h" + +typedef struct QLitDictEntry QLitDictEntry; +typedef struct QLitObject QLitObject; + +struct QLitObject { + int type; + union { + bool qbool; + int64_t qnum; + const char *qstr; + QLitDictEntry *qdict; + QLitObject *qlist; + } value; +}; + +struct QLitDictEntry { + const char *key; + QLitObject value; +}; + +#define QLIT_QNULL \ + { .type =3D QTYPE_QNULL } +#define QLIT_QBOOL(val) \ + { .type =3D QTYPE_QBOOL, .value.qbool =3D (val) } +#define QLIT_QNUM(val) \ + { .type =3D QTYPE_QNUM, .value.qnum =3D (val) } +#define QLIT_QSTR(val) \ + { .type =3D QTYPE_QSTRING, .value.qstr =3D (val) } +#define QLIT_QDICT(val) \ + { .type =3D QTYPE_QDICT, .value.qdict =3D (val) } +#define QLIT_QLIST(val) \ + { .type =3D QTYPE_QLIST, .value.qlist =3D (val) } + +QObject *qobject_from_qlit(const QLitObject *qlit); + +#endif /* QLIT_H_ */ diff --git a/qobject/qlit.c b/qobject/qlit.c new file mode 100644 index 0000000000..d7407b4b34 --- /dev/null +++ b/qobject/qlit.c @@ -0,0 +1,53 @@ +/* + * QLit literal qobject + * + * Copyright (C) 2017 Red Hat Inc. + * + * Authors: + * Marc-Andr=C3=A9 Lureau + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or l= ater. + * See the COPYING.LIB file in the top-level directory. + */ + +#include "qemu/osdep.h" + +#include "qapi/qmp/qlit.h" +#include "qapi/qmp/types.h" + +QObject *qobject_from_qlit(const QLitObject *qlit) +{ + int i; + + switch (qlit->type) { + case QTYPE_QNULL: + return QOBJECT(qnull()); + case QTYPE_QNUM: + return QOBJECT(qnum_from_int(qlit->value.qnum)); + case QTYPE_QSTRING: + return QOBJECT(qstring_from_str(qlit->value.qstr)); + case QTYPE_QDICT: { + QDict *qdict =3D qdict_new(); + for (i =3D 0; qlit->value.qdict[i].value.type !=3D QTYPE_NONE; i++= ) { + QLitDictEntry *e =3D &qlit->value.qdict[i]; + + qdict_put_obj(qdict, e->key, qobject_from_qlit(&e->value)); + } + return QOBJECT(qdict); + } + case QTYPE_QLIST: { + QList *qlist =3D qlist_new(); + + for (i =3D 0; qlit->value.qlist[i].type !=3D QTYPE_NONE; i++) { + qlist_append_obj(qlist, qobject_from_qlit(&qlit->value.qlist[i= ])); + } + return QOBJECT(qlist); + } + case QTYPE_QBOOL: + return QOBJECT(qbool_from_bool(qlit->value.qbool)); + case QTYPE_NONE: + assert(0); + } + + return NULL; +} diff --git a/tests/check-qjson.c b/tests/check-qjson.c index 9c42a46b7d..1a95aff2ba 100644 --- a/tests/check-qjson.c +++ b/tests/check-qjson.c @@ -16,6 +16,7 @@ #include "qapi/error.h" #include "qapi/qmp/types.h" #include "qapi/qmp/qjson.h" +#include "qapi/qmp/qlit.h" #include "qemu-common.h" =20 static void escaped_string(void) @@ -1059,39 +1060,14 @@ static void keyword_literal(void) QDECREF(null); } =20 -typedef struct LiteralQDictEntry LiteralQDictEntry; -typedef struct LiteralQObject LiteralQObject; - -struct LiteralQObject -{ - int type; - union { - int64_t qnum; - const char *qstr; - LiteralQDictEntry *qdict; - LiteralQObject *qlist; - } value; -}; - -struct LiteralQDictEntry -{ - const char *key; - LiteralQObject value; -}; - -#define QLIT_QNUM(val) (LiteralQObject){.type =3D QTYPE_QNUM, .value.qnum = =3D (val)} -#define QLIT_QSTR(val) (LiteralQObject){.type =3D QTYPE_QSTRING, .value.qs= tr =3D (val)} -#define QLIT_QDICT(val) (LiteralQObject){.type =3D QTYPE_QDICT, .value.qdi= ct =3D (val)} -#define QLIT_QLIST(val) (LiteralQObject){.type =3D QTYPE_QLIST, .value.qli= st =3D (val)} - typedef struct QListCompareHelper { int index; - LiteralQObject *objs; + QLitObject *objs; int result; } QListCompareHelper; =20 -static int compare_litqobj_to_qobj(LiteralQObject *lhs, QObject *rhs); +static int compare_litqobj_to_qobj(QLitObject *lhs, QObject *rhs); =20 static void compare_helper(QObject *obj, void *opaque) { @@ -1109,7 +1085,7 @@ static void compare_helper(QObject *obj, void *opaque) helper->result =3D compare_litqobj_to_qobj(&helper->objs[helper->index= ++], obj); } =20 -static int compare_litqobj_to_qobj(LiteralQObject *lhs, QObject *rhs) +static int compare_litqobj_to_qobj(QLitObject *lhs, QObject *rhs) { int64_t val; =20 @@ -1159,23 +1135,23 @@ static void simple_dict(void) int i; struct { const char *encoded; - LiteralQObject decoded; + QLitObject decoded; } test_cases[] =3D { { .encoded =3D "{\"foo\": 42, \"bar\": \"hello world\"}", - .decoded =3D QLIT_QDICT(((LiteralQDictEntry[]){ + .decoded =3D QLIT_QDICT(((QLitDictEntry[]){ { "foo", QLIT_QNUM(42) }, { "bar", QLIT_QSTR("hello world") }, { } })), }, { .encoded =3D "{}", - .decoded =3D QLIT_QDICT(((LiteralQDictEntry[]){ + .decoded =3D QLIT_QDICT(((QLitDictEntry[]){ { } })), }, { .encoded =3D "{\"foo\": 43}", - .decoded =3D QLIT_QDICT(((LiteralQDictEntry[]){ + .decoded =3D QLIT_QDICT(((QLitDictEntry[]){ { "foo", QLIT_QNUM(43) }, { } })), @@ -1257,11 +1233,11 @@ static void simple_list(void) int i; struct { const char *encoded; - LiteralQObject decoded; + QLitObject decoded; } test_cases[] =3D { { .encoded =3D "[43,42]", - .decoded =3D QLIT_QLIST(((LiteralQObject[]){ + .decoded =3D QLIT_QLIST(((QLitObject[]){ QLIT_QNUM(43), QLIT_QNUM(42), { } @@ -1269,21 +1245,21 @@ static void simple_list(void) }, { .encoded =3D "[43]", - .decoded =3D QLIT_QLIST(((LiteralQObject[]){ + .decoded =3D QLIT_QLIST(((QLitObject[]){ QLIT_QNUM(43), { } })), }, { .encoded =3D "[]", - .decoded =3D QLIT_QLIST(((LiteralQObject[]){ + .decoded =3D QLIT_QLIST(((QLitObject[]){ { } })), }, { .encoded =3D "[{}]", - .decoded =3D QLIT_QLIST(((LiteralQObject[]){ - QLIT_QDICT(((LiteralQDictEntry[]){ + .decoded =3D QLIT_QLIST(((QLitObject[]){ + QLIT_QDICT(((QLitDictEntry[]){ {}, })), {}, @@ -1314,11 +1290,11 @@ static void simple_whitespace(void) int i; struct { const char *encoded; - LiteralQObject decoded; + QLitObject decoded; } test_cases[] =3D { { .encoded =3D " [ 43 , 42 ]", - .decoded =3D QLIT_QLIST(((LiteralQObject[]){ + .decoded =3D QLIT_QLIST(((QLitObject[]){ QLIT_QNUM(43), QLIT_QNUM(42), { } @@ -1326,12 +1302,12 @@ static void simple_whitespace(void) }, { .encoded =3D " [ 43 , { 'h' : 'b' }, [ ], 42 ]", - .decoded =3D QLIT_QLIST(((LiteralQObject[]){ + .decoded =3D QLIT_QLIST(((QLitObject[]){ QLIT_QNUM(43), - QLIT_QDICT(((LiteralQDictEntry[]){ + QLIT_QDICT(((QLitDictEntry[]){ { "h", QLIT_QSTR("b") }, { }})), - QLIT_QLIST(((LiteralQObject[]){ + QLIT_QLIST(((QLitObject[]){ { }})), QLIT_QNUM(42), { } @@ -1339,13 +1315,13 @@ static void simple_whitespace(void) }, { .encoded =3D " [ 43 , { 'h' : 'b' , 'a' : 32 }, [ ], 42 ]", - .decoded =3D QLIT_QLIST(((LiteralQObject[]){ + .decoded =3D QLIT_QLIST(((QLitObject[]){ QLIT_QNUM(43), - QLIT_QDICT(((LiteralQDictEntry[]){ + QLIT_QDICT(((QLitDictEntry[]){ { "h", QLIT_QSTR("b") }, { "a", QLIT_QNUM(32) }, { }})), - QLIT_QLIST(((LiteralQObject[]){ + QLIT_QLIST(((QLitObject[]){ { }})), QLIT_QNUM(42), { } @@ -1393,10 +1369,10 @@ static void simple_varargs(void) { QObject *embedded_obj; QObject *obj; - LiteralQObject decoded =3D QLIT_QLIST(((LiteralQObject[]){ + QLitObject decoded =3D QLIT_QLIST(((QLitObject[]){ QLIT_QNUM(1), QLIT_QNUM(2), - QLIT_QLIST(((LiteralQObject[]){ + QLIT_QLIST(((QLitObject[]){ QLIT_QNUM(32), QLIT_QNUM(42), {}})), diff --git a/tests/check-qlit.c b/tests/check-qlit.c new file mode 100644 index 0000000000..cda4620f92 --- /dev/null +++ b/tests/check-qlit.c @@ -0,0 +1,52 @@ +/* + * QLit unit-tests. + * + * Copyright (C) 2017 Red Hat Inc. + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or l= ater. + * See the COPYING.LIB file in the top-level directory. + */ + +#include "qemu/osdep.h" + +#include "qapi/qmp/qlit.h" + +static void qobject_from_qlit_test(void) +{ + char *str; + QObject *qobj =3D NULL; + QLitObject qlit =3D QLIT_QDICT(( + (QLitDictEntry[]) { + { "foo", QLIT_QNUM(42) }, + { "bar", QLIT_QSTR("hello world") }, + { "baz", QLIT_QNULL }, + { "bee", QLIT_QLIST(( + (QLitObject[]) { + QLIT_QNUM(43), + QLIT_QNUM(44), + QLIT_QBOOL(true), + { }, + })) + }, + { }, + })); + + qobj =3D qobject_from_qlit(&qlit); + + str =3D qobject_to_string(qobj); + g_assert_cmpstr(str, =3D=3D, + "bee:\n [0]: 43\n [1]: 44\n [2]: true\n" \ + "baz: null\nbar: hello world\nfoo: 42\n"); + + g_free(str); + qobject_decref(qobj); +} + +int main(int argc, char **argv) +{ + g_test_init(&argc, &argv, NULL); + + g_test_add_func("/qlit/qobject_from_qlit", qobject_from_qlit_test); + + return g_test_run(); +} diff --git a/qobject/Makefile.objs b/qobject/Makefile.objs index fc8885c9a4..002d25873a 100644 --- a/qobject/Makefile.objs +++ b/qobject/Makefile.objs @@ -1,2 +1,2 @@ -util-obj-y =3D qnull.o qnum.o qstring.o qdict.o qlist.o qbool.o +util-obj-y =3D qnull.o qnum.o qstring.o qdict.o qlist.o qbool.o qlit.o util-obj-y +=3D qjson.o qobject.o json-lexer.o json-streamer.o json-parser= .o diff --git a/tests/Makefile.include b/tests/Makefile.include index 7af278db55..960ab8c6dd 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -12,6 +12,8 @@ check-unit-y +=3D tests/test-char$(EXESUF) gcov-files-check-qdict-y =3D chardev/char.c check-unit-y +=3D tests/check-qnum$(EXESUF) gcov-files-check-qnum-y =3D qobject/qnum.c +check-unit-y +=3D tests/check-qlit$(EXESUF) +gcov-files-check-qlit-y =3D qobject/qlit.c check-unit-y +=3D tests/check-qstring$(EXESUF) gcov-files-check-qstring-y =3D qobject/qstring.c check-unit-y +=3D tests/check-qlist$(EXESUF) @@ -523,7 +525,7 @@ test-obj-y =3D tests/check-qnum.o tests/check-qstring.o= tests/check-qdict.o \ tests/rcutorture.o tests/test-rcu-list.o \ tests/test-qdist.o tests/test-shift128.o \ tests/test-qht.o tests/qht-bench.o tests/test-qht-par.o \ - tests/atomic_add-bench.o + tests/atomic_add-bench.o tests/check-qlit.o =20 $(test-obj-y): QEMU_INCLUDES +=3D -Itests QEMU_CFLAGS +=3D -I$(SRC_PATH)/tests @@ -541,6 +543,7 @@ test-io-obj-y =3D $(io-obj-y) $(test-crypto-obj-y) test-block-obj-y =3D $(block-obj-y) $(test-io-obj-y) tests/iothread.o =20 tests/check-qnum$(EXESUF): tests/check-qnum.o $(test-util-obj-y) +tests/check-qlit$(EXESUF): tests/check-qlit.o $(test-util-obj-y) tests/check-qstring$(EXESUF): tests/check-qstring.o $(test-util-obj-y) tests/check-qdict$(EXESUF): tests/check-qdict.o $(test-util-obj-y) tests/check-qlist$(EXESUF): tests/check-qlist.o $(test-util-obj-y) --=20 2.14.0.rc0.1.g40ca67566 From nobody Fri May 3 05:56:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501170594779231.80318718442902; Thu, 27 Jul 2017 08:49:54 -0700 (PDT) Received: from localhost ([::1]:43678 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal2u-0006YI-2L for importer@patchew.org; Thu, 27 Jul 2017 11:49:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54524) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal09-00047w-Br for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:47:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dal06-0003GW-Np for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:47:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37283) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dal06-0003D6-DI for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:46:58 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 569A2ABBA7; Thu, 27 Jul 2017 15:41:45 +0000 (UTC) Received: from localhost (ovpn-112-42.ams2.redhat.com [10.36.112.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id B269917CC9; Thu, 27 Jul 2017 15:41:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 569A2ABBA7 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 17:41:04 +0200 Message-Id: <20170727154126.11339-5-marcandre.lureau@redhat.com> In-Reply-To: <20170727154126.11339-1-marcandre.lureau@redhat.com> References: <20170727154126.11339-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 27 Jul 2017 15:41:45 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 04/26] qapi: generate a literal qobject for introspection X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Roth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Replace the generated json string with a literal qobject. The later is easier to deal with, at run time, as well as compile time: #if blocks can be more easily added than in a json string. Signed-off-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi-introspect.py | 83 +++++++++++++++++++++-------------= ---- monitor.c | 2 +- tests/test-qobject-input-visitor.c | 10 +++-- docs/devel/qapi-code-gen.txt | 29 ++++++++----- 4 files changed, 72 insertions(+), 52 deletions(-) diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py index 032bcea491..fc72cdb66d 100644 --- a/scripts/qapi-introspect.py +++ b/scripts/qapi-introspect.py @@ -12,72 +12,74 @@ from qapi import * =20 =20 -# Caveman's json.dumps() replacement (we're stuck at Python 2.4) -# TODO try to use json.dumps() once we get unstuck -def to_json(obj, level=3D0): +def to_qlit(obj, level=3D0, first_indent=3DTrue): + def indent(level): + return level * 4 * ' ' + ret =3D '' + if first_indent: + ret +=3D indent(level) if obj is None: - ret =3D 'null' + ret +=3D 'QLIT_QNULL' elif isinstance(obj, str): - ret =3D '"' + obj.replace('"', r'\"') + '"' + ret +=3D 'QLIT_QSTR(' + '"' + obj.replace('"', r'\"') + '"' + ')' elif isinstance(obj, list): - elts =3D [to_json(elt, level + 1) + elts =3D [to_qlit(elt, level + 1) for elt in obj] - ret =3D '[' + ', '.join(elts) + ']' + elts.append(indent(level + 1) + "{ }") + ret +=3D 'QLIT_QLIST(((QLitObject[]) {\n' + ret +=3D ',\n'.join(elts) + '\n' + ret +=3D indent(level) + '}))' elif isinstance(obj, dict): - elts =3D ['"%s": %s' % (key.replace('"', r'\"'), - to_json(obj[key], level + 1)) - for key in sorted(obj.keys())] - ret =3D '{' + ', '.join(elts) + '}' + elts =3D [ indent(level + 1) + '{ "%s", %s }' % + (key.replace('"', r'\"'), to_qlit(obj[key], level + 1, Fa= lse)) + for key in sorted(obj.keys())] + elts.append(indent(level + 1) + '{ }') + ret +=3D 'QLIT_QDICT(((QLitDictEntry[]) {\n' + ret +=3D ',\n'.join(elts) + '\n' + ret +=3D indent(level) + '}))' else: assert False # not implemented - if level =3D=3D 1: - ret =3D '\n' + ret return ret =20 =20 -def to_c_string(string): - return '"' + string.replace('\\', r'\\').replace('"', r'\"') + '"' - - class QAPISchemaGenIntrospectVisitor(QAPISchemaVisitor): def __init__(self, unmask): self._unmask =3D unmask self.defn =3D None self.decl =3D None self._schema =3D None - self._jsons =3D None + self._qlits =3D None self._used_types =3D None self._name_map =3D None =20 def visit_begin(self, schema): self._schema =3D schema - self._jsons =3D [] + self._qlits =3D [] self._used_types =3D [] self._name_map =3D {} =20 def visit_end(self): # visit the types that are actually used - jsons =3D self._jsons - self._jsons =3D [] + qlits =3D self._qlits + self._qlits =3D [] for typ in self._used_types: typ.visit(self) # generate C # TODO can generate awfully long lines - jsons.extend(self._jsons) - name =3D c_name(prefix, protect=3DFalse) + 'qmp_schema_json' + qlits.extend(self._qlits) + name =3D c_name(prefix, protect=3DFalse) + 'qmp_schema_qlit' self.decl =3D mcgen(''' -extern const char %(c_name)s[]; +extern const QLitObject %(c_name)s; ''', c_name=3Dc_name(name)) - lines =3D to_json(jsons).split('\n') - c_string =3D '\n '.join([to_c_string(line) for line in lines]) + c_string =3D to_qlit(qlits) self.defn =3D mcgen(''' -const char %(c_name)s[] =3D %(c_string)s; +const QLitObject %(c_name)s =3D %(c_string)s; ''', c_name=3Dc_name(name), c_string=3Dc_string) self._schema =3D None - self._jsons =3D None + self._qlits =3D None self._used_types =3D None self._name_map =3D None =20 @@ -111,12 +113,12 @@ const char %(c_name)s[] =3D %(c_string)s; return '[' + self._use_type(typ.element_type) + ']' return self._name(typ.name) =20 - def _gen_json(self, name, mtype, obj): + def _gen_qlit(self, name, mtype, obj): if mtype not in ('command', 'event', 'builtin', 'array'): name =3D self._name(name) obj['name'] =3D name obj['meta-type'] =3D mtype - self._jsons.append(obj) + self._qlits.append(obj) =20 def _gen_member(self, member): ret =3D {'name': member.name, 'type': self._use_type(member.type)} @@ -132,24 +134,24 @@ const char %(c_name)s[] =3D %(c_string)s; return {'case': variant.name, 'type': self._use_type(variant.type)} =20 def visit_builtin_type(self, name, info, json_type): - self._gen_json(name, 'builtin', {'json-type': json_type}) + self._gen_qlit(name, 'builtin', {'json-type': json_type}) =20 def visit_enum_type(self, name, info, values, prefix): - self._gen_json(name, 'enum', {'values': values}) + self._gen_qlit(name, 'enum', {'values': values}) =20 def visit_array_type(self, name, info, element_type): element =3D self._use_type(element_type) - self._gen_json('[' + element + ']', 'array', {'element-type': elem= ent}) + self._gen_qlit('[' + element + ']', 'array', {'element-type': elem= ent}) =20 def visit_object_type_flat(self, name, info, members, variants): obj =3D {'members': [self._gen_member(m) for m in members]} if variants: obj.update(self._gen_variants(variants.tag_member.name, variants.variants)) - self._gen_json(name, 'object', obj) + self._gen_qlit(name, 'object', obj) =20 def visit_alternate_type(self, name, info, variants): - self._gen_json(name, 'alternate', + self._gen_qlit(name, 'alternate', {'members': [{'type': self._use_type(m.type)} for m in variants.variants]}) =20 @@ -157,13 +159,13 @@ const char %(c_name)s[] =3D %(c_string)s; gen, success_response, boxed): arg_type =3D arg_type or self._schema.the_empty_object_type ret_type =3D ret_type or self._schema.the_empty_object_type - self._gen_json(name, 'command', + self._gen_qlit(name, 'command', {'arg-type': self._use_type(arg_type), 'ret-type': self._use_type(ret_type)}) =20 def visit_event(self, name, info, arg_type, boxed): arg_type =3D arg_type or self._schema.the_empty_object_type - self._gen_json(name, 'event', {'arg-type': self._use_type(arg_type= )}) + self._gen_qlit(name, 'event', {'arg-type': self._use_type(arg_type= )}) =20 # Debugging aid: unmask QAPI schema's type names # We normally mask them, because they're not QMP wire ABI @@ -205,11 +207,18 @@ h_comment =3D ''' =20 fdef.write(mcgen(''' #include "qemu/osdep.h" +#include "qapi/qmp/qlit.h" #include "%(prefix)sqmp-introspect.h" =20 ''', prefix=3Dprefix)) =20 +fdecl.write(mcgen(''' +#include "qemu/osdep.h" +#include "qapi/qmp/qlit.h" + +''')) + schema =3D QAPISchema(input_file) gen =3D QAPISchemaGenIntrospectVisitor(opt_unmask) schema.visit(gen) diff --git a/monitor.c b/monitor.c index 6d040e620f..a1773d5bc7 100644 --- a/monitor.c +++ b/monitor.c @@ -953,7 +953,7 @@ EventInfoList *qmp_query_events(Error **errp) static void qmp_query_qmp_schema(QDict *qdict, QObject **ret_data, Error **errp) { - *ret_data =3D qobject_from_json(qmp_schema_json, &error_abort); + *ret_data =3D qobject_from_qlit(&qmp_schema_qlit); } =20 /* diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-= visitor.c index bcf02617dc..1969733971 100644 --- a/tests/test-qobject-input-visitor.c +++ b/tests/test-qobject-input-visitor.c @@ -1247,24 +1247,26 @@ static void test_visitor_in_fail_alternate(TestInpu= tVisitorData *data, } =20 static void do_test_visitor_in_qmp_introspect(TestInputVisitorData *data, - const char *schema_json) + const QLitObject *qlit) { SchemaInfoList *schema =3D NULL; + QObject *obj =3D qobject_from_qlit(qlit); Visitor *v; =20 - v =3D visitor_input_test_init_raw(data, schema_json); + v =3D qobject_input_visitor_new(obj); =20 visit_type_SchemaInfoList(v, NULL, &schema, &error_abort); g_assert(schema); =20 qapi_free_SchemaInfoList(schema); + qobject_decref(obj); } =20 static void test_visitor_in_qmp_introspect(TestInputVisitorData *data, const void *unused) { - do_test_visitor_in_qmp_introspect(data, test_qmp_schema_json); - do_test_visitor_in_qmp_introspect(data, qmp_schema_json); + do_test_visitor_in_qmp_introspect(data, &test_qmp_schema_qlit); + do_test_visitor_in_qmp_introspect(data, &qmp_schema_qlit); } =20 int main(int argc, char **argv) diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt index 9903ac4c19..885c61b52f 100644 --- a/docs/devel/qapi-code-gen.txt +++ b/docs/devel/qapi-code-gen.txt @@ -1295,18 +1295,27 @@ Example: #ifndef EXAMPLE_QMP_INTROSPECT_H #define EXAMPLE_QMP_INTROSPECT_H =20 - extern const char example_qmp_schema_json[]; + extern const QLitObject qmp_schema_qlit; =20 #endif $ cat qapi-generated/example-qmp-introspect.c [Uninteresting stuff omitted...] =20 - const char example_qmp_schema_json[] =3D "[" - "{\"arg-type\": \"0\", \"meta-type\": \"event\", \"name\": \"MY_EV= ENT\"}, " - "{\"arg-type\": \"1\", \"meta-type\": \"command\", \"name\": \"my-= command\", \"ret-type\": \"2\"}, " - "{\"members\": [], \"meta-type\": \"object\", \"name\": \"0\"}, " - "{\"members\": [{\"name\": \"arg1\", \"type\": \"[2]\"}], \"meta-t= ype\": \"object\", \"name\": \"1\"}, " - "{\"members\": [{\"name\": \"integer\", \"type\": \"int\"}, {\"def= ault\": null, \"name\": \"string\", \"type\": \"str\"}], \"meta-type\": \"o= bject\", \"name\": \"2\"}, " - "{\"element-type\": \"2\", \"meta-type\": \"array\", \"name\": \"[= 2]\"}, " - "{\"json-type\": \"int\", \"meta-type\": \"builtin\", \"name\": \"= int\"}, " - "{\"json-type\": \"string\", \"meta-type\": \"builtin\", \"name\":= \"str\"}]"; + const QLitObject example_qmp_schema_qlit =3D QLIT_QLIST(((QLitObject[]= ) { + QLIT_QDICT(((QLitDictEntry[]) { + { "arg-type", QLIT_QSTR("0") }, + { "meta-type", QLIT_QSTR("event") }, + { "name", QLIT_QSTR("Event") }, + { } + })), + QLIT_QDICT(((QLitDictEntry[]) { + { "members", QLIT_QLIST(((QLitObject[]) { + { } + })) }, + { "meta-type", QLIT_QSTR("object") }, + { "name", QLIT_QSTR("0") }, + { } + })), + .... + { } + })); --=20 2.14.0.rc0.1.g40ca67566 From nobody Fri May 3 05:56:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150117068545427.267912404672643; Thu, 27 Jul 2017 08:51:25 -0700 (PDT) Received: from localhost ([::1]:43689 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal4N-0008Bk-MQ for importer@patchew.org; Thu, 27 Jul 2017 11:51:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54680) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal0G-0004EA-L1 for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:47:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dal09-0003K6-IO for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:47:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37574) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dal09-0003In-5u for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:47:01 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5975C40256; Thu, 27 Jul 2017 15:41:47 +0000 (UTC) Received: from localhost (ovpn-112-42.ams2.redhat.com [10.36.112.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8148660BE3; Thu, 27 Jul 2017 15:41:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5975C40256 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 17:41:05 +0200 Message-Id: <20170727154126.11339-6-marcandre.lureau@redhat.com> In-Reply-To: <20170727154126.11339-1-marcandre.lureau@redhat.com> References: <20170727154126.11339-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 27 Jul 2017 15:41:47 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 05/26] visitor: pass size of strings array to enum visitor X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Jason Wang , Michael Roth , Markus Armbruster , Igor Mammedov , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Andreas=20F=C3=A4rber?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The size is known at compile time, this avoids having to compute to check array boundaries. Additionally, the following conditional enum entry change will create "hole" in the generated _lookup tables, that should be skipped. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/qapi/visitor.h | 3 ++- scripts/qapi-visit.py | 10 +++++----- include/hw/qdev-core.h | 1 + include/qom/object.h | 4 ++++ qapi/qapi-visit-core.c | 23 ++++++++++++----------- backends/hostmem.c | 1 + crypto/secret.c | 1 + crypto/tlscreds.c | 1 + hw/core/qdev-properties.c | 11 +++++++++-- net/filter.c | 1 + qom/object.c | 11 ++++++++--- tests/check-qom-proplist.c | 1 + tests/test-qobject-input-visitor.c | 2 +- 13 files changed, 47 insertions(+), 23 deletions(-) diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index fe9faf469f..a2d9786c52 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -469,7 +469,8 @@ bool visit_optional(Visitor *v, const char *name, bool = *present); * that visit_type_str() must have no unwelcome side effects. */ void visit_type_enum(Visitor *v, const char *name, int *obj, - const char *const strings[], Error **errp); + const char *const strings[], int nstrings, + Error **errp); =20 /* * Check if visitor is an input visitor. diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index bd0b742236..60850a6cdd 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -147,17 +147,17 @@ out: c_name=3Dc_name(name), c_elt_type=3Delement_type.c_name()) =20 =20 -def gen_visit_enum(name): +def gen_visit_enum(name, prefix): return mcgen(''' =20 void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s *obj, = Error **errp) { int value =3D *obj; - visit_type_enum(v, name, &value, %(c_name)s_lookup, errp); + visit_type_enum(v, name, &value, %(c_name)s_lookup, %(c_max)s, errp); *obj =3D value; } ''', - c_name=3Dc_name(name)) + c_name=3Dc_name(name), c_max=3Dc_enum_const(name, '_MAX',= prefix)) =20 =20 def gen_visit_alternate(name, variants): @@ -288,10 +288,10 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor): if not info: self._btin +=3D gen_visit_decl(name, scalar=3DTrue) if do_builtins: - self.defn +=3D gen_visit_enum(name) + self.defn +=3D gen_visit_enum(name, prefix) else: self.decl +=3D gen_visit_decl(name, scalar=3DTrue) - self.defn +=3D gen_visit_enum(name) + self.defn +=3D gen_visit_enum(name, prefix) =20 def visit_array_type(self, name, info, element_type): decl =3D gen_visit_decl(name) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index ae317286a4..f86a0e1a75 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -250,6 +250,7 @@ struct PropertyInfo { const char *name; const char *description; const char * const *enum_table; + int enum_table_size; int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len); void (*set_default_value)(Object *obj, const Property *prop); void (*create)(Object *obj, Property *prop, Error **errp); diff --git a/include/qom/object.h b/include/qom/object.h index 1b828994fa..53d807e1e6 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -1406,6 +1406,8 @@ void object_class_property_add_bool(ObjectClass *klas= s, const char *name, * @obj: the object to add a property to * @name: the name of the property * @typename: the name of the enum data type + * @strings: an array of strings for the enum + * @nstrings: the size of @strings * @get: the getter or %NULL if the property is write-only. * @set: the setter or %NULL if the property is read-only * @errp: if an error occurs, a pointer to an area to store the error @@ -1416,6 +1418,7 @@ void object_class_property_add_bool(ObjectClass *klas= s, const char *name, void object_property_add_enum(Object *obj, const char *name, const char *typename, const char * const *strings, + int nstrings, int (*get)(Object *, Error **), void (*set)(Object *, int, Error **), Error **errp); @@ -1423,6 +1426,7 @@ void object_property_add_enum(Object *obj, const char= *name, void object_class_property_add_enum(ObjectClass *klass, const char *name, const char *typename, const char * const *strings, + int nstrings, int (*get)(Object *, Error **), void (*set)(Object *, int, Error **), Error **errp); diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c index ed6d2af462..dc0b9f2cee 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qapi-visit-core.c @@ -333,14 +333,13 @@ void visit_type_null(Visitor *v, const char *name, QN= ull **obj, } =20 static void output_type_enum(Visitor *v, const char *name, int *obj, - const char *const strings[], Error **errp) + const char *const strings[], + int nstrings, Error **errp) { - int i =3D 0; int value =3D *obj; char *enum_str; =20 - while (strings[i++] !=3D NULL); - if (value < 0 || value >=3D i - 1) { + if (value < 0 || value >=3D nstrings) { error_setg(errp, QERR_INVALID_PARAMETER, name ? name : "null"); return; } @@ -350,7 +349,8 @@ static void output_type_enum(Visitor *v, const char *na= me, int *obj, } =20 static void input_type_enum(Visitor *v, const char *name, int *obj, - const char *const strings[], Error **errp) + const char *const strings[], + int nstrings, Error **errp) { Error *local_err =3D NULL; int64_t value =3D 0; @@ -362,14 +362,14 @@ static void input_type_enum(Visitor *v, const char *n= ame, int *obj, return; } =20 - while (strings[value] !=3D NULL) { - if (strcmp(strings[value], enum_str) =3D=3D 0) { + while (value < nstrings) { + if (strings[value] && strcmp(strings[value], enum_str) =3D=3D 0) { break; } value++; } =20 - if (strings[value] =3D=3D NULL) { + if (value >=3D nstrings || strings[value] =3D=3D NULL) { error_setg(errp, QERR_INVALID_PARAMETER, enum_str); g_free(enum_str); return; @@ -380,16 +380,17 @@ static void input_type_enum(Visitor *v, const char *n= ame, int *obj, } =20 void visit_type_enum(Visitor *v, const char *name, int *obj, - const char *const strings[], Error **errp) + const char *const strings[], int nstrings, + Error **errp) { assert(obj && strings); trace_visit_type_enum(v, name, obj); switch (v->type) { case VISITOR_INPUT: - input_type_enum(v, name, obj, strings, errp); + input_type_enum(v, name, obj, strings, nstrings, errp); break; case VISITOR_OUTPUT: - output_type_enum(v, name, obj, strings, errp); + output_type_enum(v, name, obj, strings, nstrings, errp); break; case VISITOR_CLONE: /* nothing further to do, scalar value was already copied by diff --git a/backends/hostmem.c b/backends/hostmem.c index 4606b73849..fc475a5387 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -396,6 +396,7 @@ host_memory_backend_class_init(ObjectClass *oc, void *d= ata) NULL, NULL, &error_abort); object_class_property_add_enum(oc, "policy", "HostMemPolicy", HostMemPolicy_lookup, + HOST_MEM_POLICY__MAX, host_memory_backend_get_policy, host_memory_backend_set_policy, &error_abort); object_class_property_add_str(oc, "id", get_id, set_id, &error_abort); diff --git a/crypto/secret.c b/crypto/secret.c index 285ab7a63c..b5382cb7e3 100644 --- a/crypto/secret.c +++ b/crypto/secret.c @@ -379,6 +379,7 @@ qcrypto_secret_class_init(ObjectClass *oc, void *data) object_class_property_add_enum(oc, "format", "QCryptoSecretFormat", QCryptoSecretFormat_lookup, + QCRYPTO_SECRET_FORMAT__MAX, qcrypto_secret_prop_get_format, qcrypto_secret_prop_set_format, NULL); diff --git a/crypto/tlscreds.c b/crypto/tlscreds.c index a8965531b6..8c060127ea 100644 --- a/crypto/tlscreds.c +++ b/crypto/tlscreds.c @@ -234,6 +234,7 @@ qcrypto_tls_creds_class_init(ObjectClass *oc, void *dat= a) object_class_property_add_enum(oc, "endpoint", "QCryptoTLSCredsEndpoint", QCryptoTLSCredsEndpoint_lookup, + QCRYPTO_TLS_CREDS_ENDPOINT__MAX, qcrypto_tls_creds_prop_get_endpoint, qcrypto_tls_creds_prop_set_endpoint, NULL); diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 078fc5d239..696fed5b5b 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -52,7 +52,8 @@ static void get_enum(Object *obj, Visitor *v, const char = *name, void *opaque, Property *prop =3D opaque; int *ptr =3D qdev_get_prop_ptr(dev, prop); =20 - visit_type_enum(v, prop->name, ptr, prop->info->enum_table, errp); + visit_type_enum(v, prop->name, ptr, prop->info->enum_table, + prop->info->enum_table_size, errp); } =20 static void set_enum(Object *obj, Visitor *v, const char *name, void *opaq= ue, @@ -67,7 +68,8 @@ static void set_enum(Object *obj, Visitor *v, const char = *name, void *opaque, return; } =20 - visit_type_enum(v, prop->name, ptr, prop->info->enum_table, errp); + visit_type_enum(v, prop->name, ptr, prop->info->enum_table, + prop->info->enum_table_size, errp); } =20 static void set_default_value_enum(Object *obj, const Property *prop) @@ -586,6 +588,7 @@ const PropertyInfo qdev_prop_on_off_auto =3D { .name =3D "OnOffAuto", .description =3D "on/off/auto", .enum_table =3D OnOffAuto_lookup, + .enum_table_size =3D ON_OFF_AUTO__MAX, .get =3D get_enum, .set =3D set_enum, .set_default_value =3D set_default_value_enum, @@ -598,6 +601,7 @@ QEMU_BUILD_BUG_ON(sizeof(LostTickPolicy) !=3D sizeof(in= t)); const PropertyInfo qdev_prop_losttickpolicy =3D { .name =3D "LostTickPolicy", .enum_table =3D LostTickPolicy_lookup, + .enum_table_size =3D LOST_TICK_POLICY__MAX, .get =3D get_enum, .set =3D set_enum, .set_default_value =3D set_default_value_enum, @@ -612,6 +616,7 @@ const PropertyInfo qdev_prop_blockdev_on_error =3D { .description =3D "Error handling policy, " "report/ignore/enospc/stop/auto", .enum_table =3D BlockdevOnError_lookup, + .enum_table_size =3D BLOCKDEV_ON_ERROR__MAX, .get =3D get_enum, .set =3D set_enum, .set_default_value =3D set_default_value_enum, @@ -626,6 +631,7 @@ const PropertyInfo qdev_prop_bios_chs_trans =3D { .description =3D "Logical CHS translation algorithm, " "auto/none/lba/large/rechs", .enum_table =3D BiosAtaTranslation_lookup, + .enum_table_size =3D BIOS_ATA_TRANSLATION__MAX, .get =3D get_enum, .set =3D set_enum, .set_default_value =3D set_default_value_enum, @@ -638,6 +644,7 @@ const PropertyInfo qdev_prop_fdc_drive_type =3D { .description =3D "FDC drive type, " "144/288/120/none/auto", .enum_table =3D FloppyDriveType_lookup, + .enum_table_size =3D FLOPPY_DRIVE_TYPE__MAX, .get =3D get_enum, .set =3D set_enum, .set_default_value =3D set_default_value_enum, diff --git a/net/filter.c b/net/filter.c index 1dfd2caa23..cf62851344 100644 --- a/net/filter.c +++ b/net/filter.c @@ -180,6 +180,7 @@ static void netfilter_init(Object *obj) NULL); object_property_add_enum(obj, "queue", "NetFilterDirection", NetFilterDirection_lookup, + NET_FILTER_DIRECTION__MAX, netfilter_get_direction, netfilter_set_direct= ion, NULL); object_property_add_str(obj, "status", diff --git a/qom/object.c b/qom/object.c index fe6e744b4d..425bae3a2a 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1247,6 +1247,7 @@ uint64_t object_property_get_uint(Object *obj, const = char *name, =20 typedef struct EnumProperty { const char * const *strings; + int nstrings; int (*get)(Object *, Error **); void (*set)(Object *, int, Error **); } EnumProperty; @@ -1284,7 +1285,7 @@ int object_property_get_enum(Object *obj, const char = *name, visit_complete(v, &str); visit_free(v); v =3D string_input_visitor_new(str); - visit_type_enum(v, name, &ret, enumprop->strings, errp); + visit_type_enum(v, name, &ret, enumprop->strings, enumprop->nstrings, = errp); =20 g_free(str); visit_free(v); @@ -1950,7 +1951,7 @@ static void property_get_enum(Object *obj, Visitor *v= , const char *name, return; } =20 - visit_type_enum(v, name, &value, prop->strings, errp); + visit_type_enum(v, name, &value, prop->strings, prop->nstrings, errp); } =20 static void property_set_enum(Object *obj, Visitor *v, const char *name, @@ -1960,7 +1961,7 @@ static void property_set_enum(Object *obj, Visitor *v= , const char *name, int value; Error *err =3D NULL; =20 - visit_type_enum(v, name, &value, prop->strings, &err); + visit_type_enum(v, name, &value, prop->strings, prop->nstrings, &err); if (err) { error_propagate(errp, err); return; @@ -1978,6 +1979,7 @@ static void property_release_enum(Object *obj, const = char *name, void object_property_add_enum(Object *obj, const char *name, const char *typename, const char * const *strings, + int nstrings, int (*get)(Object *, Error **), void (*set)(Object *, int, Error **), Error **errp) @@ -1986,6 +1988,7 @@ void object_property_add_enum(Object *obj, const char= *name, EnumProperty *prop =3D g_malloc(sizeof(*prop)); =20 prop->strings =3D strings; + prop->nstrings =3D nstrings; prop->get =3D get; prop->set =3D set; =20 @@ -2003,6 +2006,7 @@ void object_property_add_enum(Object *obj, const char= *name, void object_class_property_add_enum(ObjectClass *klass, const char *name, const char *typename, const char * const *strings, + int nstrings, int (*get)(Object *, Error **), void (*set)(Object *, int, Error **), Error **errp) @@ -2011,6 +2015,7 @@ void object_class_property_add_enum(ObjectClass *klas= s, const char *name, EnumProperty *prop =3D g_malloc(sizeof(*prop)); =20 prop->strings =3D strings; + prop->nstrings =3D nstrings; prop->get =3D get; prop->set =3D set; =20 diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c index 432b66585f..1179030248 100644 --- a/tests/check-qom-proplist.c +++ b/tests/check-qom-proplist.c @@ -143,6 +143,7 @@ static void dummy_class_init(ObjectClass *cls, void *da= ta) object_class_property_add_enum(cls, "av", "DummyAnimal", dummy_animal_map, + DUMMY_LAST, dummy_get_av, dummy_set_av, NULL); diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-= visitor.c index 1969733971..4da5d02c35 100644 --- a/tests/test-qobject-input-visitor.c +++ b/tests/test-qobject-input-visitor.c @@ -1110,7 +1110,7 @@ static void test_visitor_in_fail_struct_missing(TestI= nputVisitorData *data, error_free_or_abort(&err); visit_optional(v, "optional", &present); g_assert(!present); - visit_type_enum(v, "enum", &en, EnumOne_lookup, &err); + visit_type_enum(v, "enum", &en, EnumOne_lookup, ENUM_ONE__MAX, &err); error_free_or_abort(&err); visit_type_int(v, "i64", &i64, &err); error_free_or_abort(&err); --=20 2.14.0.rc0.1.g40ca67566 From nobody Fri May 3 05:56:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501171485660125.36938718524368; Thu, 27 Jul 2017 09:04:45 -0700 (PDT) Received: from localhost ([::1]:43746 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dalHE-0003zB-Ao for importer@patchew.org; Thu, 27 Jul 2017 12:04:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59155) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal4D-0008PZ-Ch for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dal4A-0006cI-66 for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33362) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dal4A-0006bw-0C for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:10 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 289207C854; Thu, 27 Jul 2017 15:41:51 +0000 (UTC) Received: from localhost (ovpn-112-42.ams2.redhat.com [10.36.112.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7ACEA18214; Thu, 27 Jul 2017 15:41:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 289207C854 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 17:41:06 +0200 Message-Id: <20170727154126.11339-7-marcandre.lureau@redhat.com> In-Reply-To: <20170727154126.11339-1-marcandre.lureau@redhat.com> References: <20170727154126.11339-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 27 Jul 2017 15:41:51 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 06/26] qapi2texi: minor python code simplification X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Michael Roth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi2texi.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py index 9e015002ef..639eb1d042 100755 --- a/scripts/qapi2texi.py +++ b/scripts/qapi2texi.py @@ -136,10 +136,9 @@ def texi_enum_value(value): def texi_member(member, suffix=3D''): """Format a table of members item for an object type member""" typ =3D member.type.doc_type() - return '@item @code{%s%s%s}%s%s\n' % ( + return '@item @code{%s%s}%s%s\n' % ( member.name, - ': ' if typ else '', - typ if typ else '', + ': %s' % typ if typ else '', ' (optional)' if member.optional else '', suffix) =20 --=20 2.14.0.rc0.1.g40ca67566 From nobody Fri May 3 05:56:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501171796685475.88531755193094; Thu, 27 Jul 2017 09:09:56 -0700 (PDT) Received: from localhost ([::1]:43776 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dalMH-0008BV-0v for importer@patchew.org; Thu, 27 Jul 2017 12:09:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33014) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal51-0000fY-07 for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:52:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dal4v-0007N5-Im for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:52:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43940) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dal4v-0007La-2h for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:57 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DBEFEABB3F; Thu, 27 Jul 2017 15:41:55 +0000 (UTC) Received: from localhost (ovpn-112-42.ams2.redhat.com [10.36.112.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id B342A7E229; Thu, 27 Jul 2017 15:41:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DBEFEABB3F Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 17:41:07 +0200 Message-Id: <20170727154126.11339-8-marcandre.lureau@redhat.com> In-Reply-To: <20170727154126.11339-1-marcandre.lureau@redhat.com> References: <20170727154126.11339-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 27 Jul 2017 15:41:56 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 07/26] qapi: add 'if' condition on top-level schema elements X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Michael Roth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add 'if' c-preprocessor condition on top-level schema elements: struct, enum, union, alternate, command, event. Variants objects types are created outside of #if blocks, since they may be shared by various types. Even if unused, this shouldn't be an issue, since those are internal types. Note that there is no checks in qapi scripts to verify that elements have compatible conditions (ex: if-struct used by a if-foo command). This may thus fail at C build time if they don't share the same subset of conditions. Signed-off-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi.py | 153 +++++++++++++++++++++++++---= ---- scripts/qapi-commands.py | 4 +- scripts/qapi-event.py | 4 +- scripts/qapi-introspect.py | 46 ++++++---- scripts/qapi-types.py | 51 +++++++---- scripts/qapi-visit.py | 13 ++- scripts/qapi2texi.py | 10 +-- tests/Makefile.include | 1 + tests/qapi-schema/bad-if.err | 1 + tests/qapi-schema/bad-if.exit | 1 + tests/qapi-schema/bad-if.json | 3 + tests/qapi-schema/bad-if.out | 0 tests/qapi-schema/qapi-schema-test.json | 20 +++++ tests/qapi-schema/qapi-schema-test.out | 31 +++++++ tests/qapi-schema/test-qapi.py | 21 +++-- 15 files changed, 272 insertions(+), 87 deletions(-) create mode 100644 tests/qapi-schema/bad-if.err create mode 100644 tests/qapi-schema/bad-if.exit create mode 100644 tests/qapi-schema/bad-if.json create mode 100644 tests/qapi-schema/bad-if.out diff --git a/scripts/qapi.py b/scripts/qapi.py index 4ecc19e944..79ba1e93da 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -639,6 +639,16 @@ def add_name(name, info, meta, implicit=3DFalse): all_names[name] =3D meta =20 =20 +def check_if(expr, info): + ifcond =3D expr.get('if') + if not ifcond or isinstance(ifcond, str): + return + if (not isinstance(ifcond, list) or + any([not isinstance(elt, str) for elt in ifcond])): + raise QAPISemError(info, "'if' condition requires a string or " + "a list of string") + + def check_type(info, source, value, allow_array=3DFalse, allow_dict=3DFalse, allow_optional=3DFalse, allow_metas=3D[]): @@ -865,6 +875,7 @@ def check_keys(expr_elem, meta, required, optional=3D[]= ): expr =3D expr_elem['expr'] info =3D expr_elem['info'] name =3D expr[meta] + optional.append('if') if not isinstance(name, str): raise QAPISemError(info, "'%s' key must have a string value" % met= a) required =3D required + [meta] @@ -880,6 +891,8 @@ def check_keys(expr_elem, meta, required, optional=3D[]= ): raise QAPISemError(info, "'%s' of %s '%s' should only use true value" % (key, meta, name)) + if key =3D=3D 'if': + check_if(expr, info) for key in required: if key not in expr: raise QAPISemError(info, "Key '%s' is missing from %s '%s'" @@ -989,6 +1002,10 @@ class QAPISchemaEntity(object): # such place). self.info =3D info self.doc =3D doc + self.ifcond =3D None + + def set_ifcond(self, ifcond): + self.ifcond =3D ifcond =20 def c_name(self): return c_name(self.name) @@ -1017,26 +1034,26 @@ class QAPISchemaVisitor(object): def visit_builtin_type(self, name, info, json_type): pass =20 - def visit_enum_type(self, name, info, values, prefix): + def visit_enum_type(self, name, info, values, prefix, ifcond): pass =20 - def visit_array_type(self, name, info, element_type): + def visit_array_type(self, name, info, element_type, ifcond): pass =20 - def visit_object_type(self, name, info, base, members, variants): + def visit_object_type(self, name, info, base, members, variants, ifcon= d): pass =20 - def visit_object_type_flat(self, name, info, members, variants): + def visit_object_type_flat(self, name, info, members, variants, ifcond= ): pass =20 - def visit_alternate_type(self, name, info, variants): + def visit_alternate_type(self, name, info, variants, ifcond): pass =20 def visit_command(self, name, info, arg_type, ret_type, - gen, success_response, boxed): + gen, success_response, boxed, ifcond): pass =20 - def visit_event(self, name, info, arg_type, boxed): + def visit_event(self, name, info, arg_type, boxed, ifcond): pass =20 =20 @@ -1136,7 +1153,7 @@ class QAPISchemaEnumType(QAPISchemaType): =20 def visit(self, visitor): visitor.visit_enum_type(self.name, self.info, - self.member_names(), self.prefix) + self.member_names(), self.prefix, self.ifc= ond) =20 =20 class QAPISchemaArrayType(QAPISchemaType): @@ -1149,6 +1166,7 @@ class QAPISchemaArrayType(QAPISchemaType): def check(self, schema): self.element_type =3D schema.lookup_type(self._element_type_name) assert self.element_type + self.ifcond =3D self.element_type.ifcond =20 def is_implicit(self): return True @@ -1166,7 +1184,8 @@ class QAPISchemaArrayType(QAPISchemaType): return 'array of ' + elt_doc_type =20 def visit(self, visitor): - visitor.visit_array_type(self.name, self.info, self.element_type) + visitor.visit_array_type(self.name, self.info, self.element_type, + self.ifcond) =20 =20 class QAPISchemaObjectType(QAPISchemaType): @@ -1247,9 +1266,10 @@ class QAPISchemaObjectType(QAPISchemaType): =20 def visit(self, visitor): visitor.visit_object_type(self.name, self.info, - self.base, self.local_members, self.vari= ants) + self.base, self.local_members, self.vari= ants, + self.ifcond) visitor.visit_object_type_flat(self.name, self.info, - self.members, self.variants) + self.members, self.variants, self.i= fcond) =20 =20 class QAPISchemaMember(object): @@ -1392,7 +1412,8 @@ class QAPISchemaAlternateType(QAPISchemaType): return 'value' =20 def visit(self, visitor): - visitor.visit_alternate_type(self.name, self.info, self.variants) + visitor.visit_alternate_type(self.name, self.info, + self.variants, self.ifcond) =20 def is_empty(self): return False @@ -1434,7 +1455,8 @@ class QAPISchemaCommand(QAPISchemaEntity): def visit(self, visitor): visitor.visit_command(self.name, self.info, self.arg_type, self.ret_type, - self.gen, self.success_response, self.boxed) + self.gen, self.success_response, self.boxed, + self.ifcond) =20 =20 class QAPISchemaEvent(QAPISchemaEntity): @@ -1462,7 +1484,8 @@ class QAPISchemaEvent(QAPISchemaEntity): raise QAPISemError(self.info, "Use of 'boxed' requires 'data'") =20 def visit(self, visitor): - visitor.visit_event(self.name, self.info, self.arg_type, self.boxe= d) + visitor.visit_event(self.name, self.info, self.arg_type, self.boxe= d, + self.ifcond) =20 =20 class QAPISchema(object): @@ -1481,11 +1504,12 @@ class QAPISchema(object): print >>sys.stderr, err exit(1) =20 - def _def_entity(self, ent): + def _def_entity(self, ent, ifcond=3DNone): # Only the predefined types are allowed to not have info assert ent.info or self._predefining assert ent.name not in self._entity_dict self._entity_dict[ent.name] =3D ent + ent.set_ifcond(ifcond) =20 def lookup_entity(self, name, typ=3DNone): ent =3D self._entity_dict.get(name) @@ -1534,11 +1558,11 @@ class QAPISchema(object): def _make_enum_members(self, values): return [QAPISchemaMember(v) for v in values] =20 - def _make_implicit_enum_type(self, name, info, values): + def _make_implicit_enum_type(self, name, info, values, ifcond): # See also QAPISchemaObjectTypeMember._pretty_owner() name =3D name + 'Kind' # Use namespace reserved by add_name() self._def_entity(QAPISchemaEnumType( - name, info, None, self._make_enum_members(values), None)) + name, info, None, self._make_enum_members(values), None), ifco= nd) return name =20 def _make_array_type(self, element_type, info): @@ -1547,22 +1571,26 @@ class QAPISchema(object): self._def_entity(QAPISchemaArrayType(name, info, element_type)) return name =20 - def _make_implicit_object_type(self, name, info, doc, role, members): + def _make_implicit_object_type(self, name, info, doc, role, members, + ifcond=3DNone): if not members: return None # See also QAPISchemaObjectTypeMember._pretty_owner() name =3D 'q_obj_%s-%s' % (name, role) - if not self.lookup_entity(name, QAPISchemaObjectType): + if self.lookup_entity(name, QAPISchemaObjectType): + assert ifcond is None + else: self._def_entity(QAPISchemaObjectType(name, info, doc, None, - members, None)) + members, None), ifcond) return name =20 def _def_enum_type(self, expr, info, doc): name =3D expr['enum'] data =3D expr['data'] prefix =3D expr.get('prefix') - self._def_entity(QAPISchemaEnumType( - name, info, doc, self._make_enum_members(data), prefix)) + return self._def_entity(QAPISchemaEnumType( + name, info, doc, self._make_enum_members(data), prefix), + expr.get('if')) =20 def _make_member(self, name, typ, info): optional =3D False @@ -1584,7 +1612,8 @@ class QAPISchema(object): data =3D expr['data'] self._def_entity(QAPISchemaObjectType(name, info, doc, base, self._make_members(data, inf= o), - None)) + None), + expr.get('if')) =20 def _make_variant(self, case, typ): return QAPISchemaObjectTypeVariant(case, typ) @@ -1593,8 +1622,10 @@ class QAPISchema(object): if isinstance(typ, list): assert len(typ) =3D=3D 1 typ =3D self._make_array_type(typ[0], info) + type_entity =3D self.lookup_type(typ) typ =3D self._make_implicit_object_type( - typ, info, None, 'wrapper', [self._make_member('data', typ, in= fo)]) + typ, info, None, 'wrapper', + [self._make_member('data', typ, info)], type_entity.ifcond) return QAPISchemaObjectTypeVariant(case, typ) =20 def _def_union_type(self, expr, info, doc): @@ -1604,8 +1635,9 @@ class QAPISchema(object): tag_name =3D expr.get('discriminator') tag_member =3D None if isinstance(base, dict): - base =3D (self._make_implicit_object_type( - name, info, doc, 'base', self._make_members(base, info))) + base =3D self._make_implicit_object_type( + name, info, doc, 'base', self._make_members(base, info), + expr.get('if')) if tag_name: variants =3D [self._make_variant(key, value) for (key, value) in data.iteritems()] @@ -1614,14 +1646,16 @@ class QAPISchema(object): variants =3D [self._make_simple_variant(key, value, info) for (key, value) in data.iteritems()] typ =3D self._make_implicit_enum_type(name, info, - [v.name for v in variants]) + [v.name for v in variants], + expr.get('if')) tag_member =3D QAPISchemaObjectTypeMember('type', typ, False) members =3D [tag_member] self._def_entity( QAPISchemaObjectType(name, info, doc, base, members, QAPISchemaObjectTypeVariants(tag_name, tag_member, - variants))) + variants)), + expr.get('if')) =20 def _def_alternate_type(self, expr, info, doc): name =3D expr['alternate'] @@ -1633,7 +1667,8 @@ class QAPISchema(object): QAPISchemaAlternateType(name, info, doc, QAPISchemaObjectTypeVariants(None, tag_membe= r, - variants)= )) + variants)= ), + expr.get('if')) =20 def _def_command(self, expr, info, doc): name =3D expr['command'] @@ -1644,12 +1679,14 @@ class QAPISchema(object): boxed =3D expr.get('boxed', False) if isinstance(data, OrderedDict): data =3D self._make_implicit_object_type( - name, info, doc, 'arg', self._make_members(data, info)) + name, info, doc, 'arg', self._make_members(data, info), + expr.get('if')) if isinstance(rets, list): assert len(rets) =3D=3D 1 rets =3D self._make_array_type(rets[0], info) self._def_entity(QAPISchemaCommand(name, info, doc, data, rets, - gen, success_response, boxed)) + gen, success_response, boxed), + expr.get('if')) =20 def _def_event(self, expr, info, doc): name =3D expr['event'] @@ -1657,8 +1694,10 @@ class QAPISchema(object): boxed =3D expr.get('boxed', False) if isinstance(data, OrderedDict): data =3D self._make_implicit_object_type( - name, info, doc, 'arg', self._make_members(data, info)) - self._def_entity(QAPISchemaEvent(name, info, doc, data, boxed)) + name, info, doc, 'arg', self._make_members(data, info), + expr.get('if')) + self._def_entity(QAPISchemaEvent(name, info, doc, data, boxed), + expr.get('if')) =20 def _def_exprs(self): for expr_elem in self.exprs: @@ -1848,6 +1887,54 @@ def guardend(name): name=3Dguardname(name)) =20 =20 +def gen_if(ifcond, func=3D''): + if not ifcond: + return '' + if isinstance(ifcond, str): + ifcond =3D [ifcond] + ret =3D '\n' + for ifc in ifcond: + ret +=3D mcgen('#if %(ifcond)s /* %(func)s */\n', ifcond=3Difc, fu= nc=3Dfunc) + ret +=3D '\n' + return ret + + +def gen_endif(ifcond, func=3D''): + if not ifcond: + return '' + if isinstance(ifcond, str): + ifcond =3D [ifcond] + ret =3D '\n' + for ifc in reversed(ifcond): + ret +=3D mcgen('#endif /* %(ifcond)s %(func)s */\n', + ifcond=3Difc, func=3Dfunc) + ret +=3D '\n' + return ret + + +# wrap a method to add #if / #endif to generated code +# self must have 'if_members' listing the attributes to wrap +# the last argument of the wrapped function must be the 'ifcond' +def if_wrap(func): + def func_wrapper(self, *args, **kwargs): + funcname =3D self.__class__.__name__ + '.' + func.__name__ + ifcond =3D args[-1] + save =3D {} + for mem in self.if_members: + save[mem] =3D getattr(self, mem) + func(self, *args, **kwargs) + for mem, val in save.items(): + newval =3D getattr(self, mem) + if newval !=3D val: + assert newval.startswith(val) + newval =3D newval[len(val):] + val +=3D gen_if(ifcond, funcname) + val +=3D newval + val +=3D gen_endif(ifcond, funcname) + setattr(self, mem, val) + + return func_wrapper + def gen_enum_lookup(name, values, prefix=3DNone): ret =3D mcgen(''' =20 diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py index 974d0a4a80..19b1bb9b88 100644 --- a/scripts/qapi-commands.py +++ b/scripts/qapi-commands.py @@ -228,6 +228,7 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor): self.defn =3D None self._regy =3D None self._visited_ret_types =3D None + self.if_members =3D ['decl', 'defn', '_regy'] =20 def visit_begin(self, schema): self.decl =3D '' @@ -240,8 +241,9 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor): self._regy =3D None self._visited_ret_types =3D None =20 + @if_wrap def visit_command(self, name, info, arg_type, ret_type, - gen, success_response, boxed): + gen, success_response, boxed, ifcond): if not gen: return self.decl +=3D gen_command_decl(name, arg_type, boxed, ret_type) diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py index bcbef1035f..cad9ece790 100644 --- a/scripts/qapi-event.py +++ b/scripts/qapi-event.py @@ -152,6 +152,7 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor): self.decl =3D None self.defn =3D None self._event_names =3D None + self.if_members =3D ['decl', 'defn'] =20 def visit_begin(self, schema): self.decl =3D '' @@ -163,7 +164,8 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor): self.defn +=3D gen_enum_lookup(event_enum_name, self._event_names) self._event_names =3D None =20 - def visit_event(self, name, info, arg_type, boxed): + @if_wrap + def visit_event(self, name, info, arg_type, boxed, ifcond): self.decl +=3D gen_event_send_decl(name, arg_type, boxed) self.defn +=3D gen_event_send(name, arg_type, boxed) self._event_names.append(name) diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py index fc72cdb66d..ecfb0f2752 100644 --- a/scripts/qapi-introspect.py +++ b/scripts/qapi-introspect.py @@ -12,7 +12,7 @@ from qapi import * =20 =20 -def to_qlit(obj, level=3D0, first_indent=3DTrue): +def to_qlit(obj, level=3D0, first_indent=3DTrue, suffix=3D''): def indent(level): return level * 4 * ' ' ret =3D '' @@ -20,14 +20,20 @@ def to_qlit(obj, level=3D0, first_indent=3DTrue): ret +=3D indent(level) if obj is None: ret +=3D 'QLIT_QNULL' + elif isinstance(obj, tuple): + obj, ifcond =3D obj + ret +=3D gen_if(ifcond) + ret +=3D to_qlit(obj, level, False) + suffix + ret +=3D gen_endif(ifcond) + suffix =3D '' elif isinstance(obj, str): ret +=3D 'QLIT_QSTR(' + '"' + obj.replace('"', r'\"') + '"' + ')' elif isinstance(obj, list): - elts =3D [to_qlit(elt, level + 1) + elts =3D [to_qlit(elt, level + 1, True, ",") for elt in obj] elts.append(indent(level + 1) + "{ }") ret +=3D 'QLIT_QLIST(((QLitObject[]) {\n' - ret +=3D ',\n'.join(elts) + '\n' + ret +=3D '\n'.join(elts) + '\n' ret +=3D indent(level) + '}))' elif isinstance(obj, dict): elts =3D [ indent(level + 1) + '{ "%s", %s }' % @@ -39,7 +45,7 @@ def to_qlit(obj, level=3D0, first_indent=3DTrue): ret +=3D indent(level) + '}))' else: assert False # not implemented - return ret + return ret + suffix =20 =20 class QAPISchemaGenIntrospectVisitor(QAPISchemaVisitor): @@ -113,12 +119,12 @@ const QLitObject %(c_name)s =3D %(c_string)s; return '[' + self._use_type(typ.element_type) + ']' return self._name(typ.name) =20 - def _gen_qlit(self, name, mtype, obj): + def _gen_qlit(self, name, mtype, obj, ifcond): if mtype not in ('command', 'event', 'builtin', 'array'): name =3D self._name(name) obj['name'] =3D name obj['meta-type'] =3D mtype - self._qlits.append(obj) + self._qlits.append((obj, ifcond)) =20 def _gen_member(self, member): ret =3D {'name': member.name, 'type': self._use_type(member.type)} @@ -134,38 +140,40 @@ const QLitObject %(c_name)s =3D %(c_string)s; return {'case': variant.name, 'type': self._use_type(variant.type)} =20 def visit_builtin_type(self, name, info, json_type): - self._gen_qlit(name, 'builtin', {'json-type': json_type}) + self._gen_qlit(name, 'builtin', {'json-type': json_type}, None) =20 - def visit_enum_type(self, name, info, values, prefix): - self._gen_qlit(name, 'enum', {'values': values}) + def visit_enum_type(self, name, info, values, prefix, ifcond): + self._gen_qlit(name, 'enum', {'values': values}, ifcond) =20 - def visit_array_type(self, name, info, element_type): + def visit_array_type(self, name, info, element_type, ifcond): element =3D self._use_type(element_type) - self._gen_qlit('[' + element + ']', 'array', {'element-type': elem= ent}) + self._gen_qlit('[' + element + ']', 'array', {'element-type': elem= ent}, + ifcond) =20 - def visit_object_type_flat(self, name, info, members, variants): + def visit_object_type_flat(self, name, info, members, variants, ifcond= ): obj =3D {'members': [self._gen_member(m) for m in members]} if variants: obj.update(self._gen_variants(variants.tag_member.name, variants.variants)) - self._gen_qlit(name, 'object', obj) + self._gen_qlit(name, 'object', obj, ifcond) =20 - def visit_alternate_type(self, name, info, variants): + def visit_alternate_type(self, name, info, variants, ifcond): self._gen_qlit(name, 'alternate', {'members': [{'type': self._use_type(m.type)} - for m in variants.variants]}) + for m in variants.variants]}, ifcond) =20 def visit_command(self, name, info, arg_type, ret_type, - gen, success_response, boxed): + gen, success_response, boxed, ifcond): arg_type =3D arg_type or self._schema.the_empty_object_type ret_type =3D ret_type or self._schema.the_empty_object_type self._gen_qlit(name, 'command', {'arg-type': self._use_type(arg_type), - 'ret-type': self._use_type(ret_type)}) + 'ret-type': self._use_type(ret_type)}, ifcond) =20 - def visit_event(self, name, info, arg_type, boxed): + def visit_event(self, name, info, arg_type, boxed, ifcond): arg_type =3D arg_type or self._schema.the_empty_object_type - self._gen_qlit(name, 'event', {'arg-type': self._use_type(arg_type= )}) + self._gen_qlit(name, 'event', {'arg-type': self._use_type(arg_type= )}, + ifcond) =20 # Debugging aid: unmask QAPI schema's type names # We normally mask them, because they're not QMP wire ABI diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index b45e7b5634..d0d2eb917c 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -53,19 +53,22 @@ def gen_struct_members(members): return ret =20 =20 -def gen_object(name, base, members, variants): - if name in objects_seen: - return '' - objects_seen.add(name) - +def gen_variants_objects(variants): ret =3D '' if variants: for v in variants.variants: if isinstance(v.type, QAPISchemaObjectType): + ret +=3D gen_variants_objects(v.type.variants) ret +=3D gen_object(v.type.name, v.type.base, v.type.local_members, v.type.variants) + return ret =20 - ret +=3D mcgen(''' +def gen_object(name, base, members, variants): + if name in objects_seen: + return '' + objects_seen.add(name) + + ret =3D mcgen(''' =20 struct %(c_name)s { ''', @@ -171,6 +174,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): self.defn =3D None self._fwdecl =3D None self._btin =3D None + self.if_members =3D ['decl', 'defn', '_fwdecl', '_btin'] =20 def visit_begin(self, schema): # gen_object() is recursive, ensure it doesn't visit the empty type @@ -191,11 +195,13 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): self.decl =3D self._btin + self.decl self._btin =3D None =20 - def _gen_type_cleanup(self, name): + @if_wrap + def _gen_type_cleanup(self, name, ifcond): self.decl +=3D gen_type_cleanup_decl(name) self.defn +=3D gen_type_cleanup(name) =20 - def visit_enum_type(self, name, info, values, prefix): + @if_wrap + def visit_enum_type(self, name, info, values, prefix, ifcond): # Special case for our lone builtin enum type # TODO use something cleaner than existence of info if not info: @@ -206,7 +212,8 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): self._fwdecl +=3D gen_enum(name, values, prefix) self.defn +=3D gen_enum_lookup(name, values, prefix) =20 - def visit_array_type(self, name, info, element_type): + @if_wrap + def visit_array_type(self, name, info, element_type, ifcond): if isinstance(element_type, QAPISchemaBuiltinType): self._btin +=3D gen_fwd_object_or_array(name) self._btin +=3D gen_array(name, element_type) @@ -216,13 +223,10 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): else: self._fwdecl +=3D gen_fwd_object_or_array(name) self.decl +=3D gen_array(name, element_type) - self._gen_type_cleanup(name) + self._gen_type_cleanup(name, ifcond) =20 - def visit_object_type(self, name, info, base, members, variants): - # Nothing to do for the special empty builtin - if name =3D=3D 'q_empty': - return - self._fwdecl +=3D gen_fwd_object_or_array(name) + @if_wrap + def _gen_object(self, name, info, base, members, variants, ifcond): self.decl +=3D gen_object(name, base, members, variants) if base and not base.is_implicit(): self.decl +=3D gen_upcast(name, base) @@ -230,12 +234,21 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): # directly use rather than repeat type.is_implicit()? if not name.startswith('q_'): # implicit types won't be directly allocated/freed - self._gen_type_cleanup(name) + self._gen_type_cleanup(name, ifcond) + + def visit_object_type(self, name, info, base, members, variants, ifcon= d): + # Nothing to do for the special empty builtin + if name =3D=3D 'q_empty': + return + self._fwdecl +=3D gen_fwd_object_or_array(name) + self.decl +=3D gen_variants_objects(variants) + self._gen_object(name, info, base, members, variants, ifcond) =20 - def visit_alternate_type(self, name, info, variants): + def visit_alternate_type(self, name, info, variants, ifcond): self._fwdecl +=3D gen_fwd_object_or_array(name) - self.decl +=3D gen_object(name, None, [variants.tag_member], varia= nts) - self._gen_type_cleanup(name) + self.decl +=3D gen_variants_objects(variants) + self._gen_object(name, info, None, [variants.tag_member], + variants, ifcond) =20 # If you link code generated from multiple schemata, you want only one # instance of the code for built-in types. Generate it only when diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index 60850a6cdd..335407d078 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -267,6 +267,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor): self.decl =3D None self.defn =3D None self._btin =3D None + self.if_members =3D ['decl', 'defn', '_btin'] =20 def visit_begin(self, schema): self.decl =3D '' @@ -282,7 +283,8 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor): self.decl =3D self._btin + self.decl self._btin =3D None =20 - def visit_enum_type(self, name, info, values, prefix): + @if_wrap + def visit_enum_type(self, name, info, values, prefix, ifcond): # Special case for our lone builtin enum type # TODO use something cleaner than existence of info if not info: @@ -293,7 +295,8 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor): self.decl +=3D gen_visit_decl(name, scalar=3DTrue) self.defn +=3D gen_visit_enum(name, prefix) =20 - def visit_array_type(self, name, info, element_type): + @if_wrap + def visit_array_type(self, name, info, element_type, ifcond): decl =3D gen_visit_decl(name) defn =3D gen_visit_list(name, element_type) if isinstance(element_type, QAPISchemaBuiltinType): @@ -304,7 +307,8 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor): self.decl +=3D decl self.defn +=3D defn =20 - def visit_object_type(self, name, info, base, members, variants): + @if_wrap + def visit_object_type(self, name, info, base, members, variants, ifcon= d): # Nothing to do for the special empty builtin if name =3D=3D 'q_empty': return @@ -317,7 +321,8 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor): self.decl +=3D gen_visit_decl(name) self.defn +=3D gen_visit_object(name, base, members, variants) =20 - def visit_alternate_type(self, name, info, variants): + @if_wrap + def visit_alternate_type(self, name, info, variants, ifcond): self.decl +=3D gen_visit_decl(name) self.defn +=3D gen_visit_alternate(name, variants) =20 diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py index 639eb1d042..5aa2f48bfd 100755 --- a/scripts/qapi2texi.py +++ b/scripts/qapi2texi.py @@ -207,7 +207,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor): def visit_begin(self, schema): self.out =3D '' =20 - def visit_enum_type(self, name, info, values, prefix): + def visit_enum_type(self, name, info, values, prefix, ifcond): doc =3D self.cur_doc if self.out: self.out +=3D '\n' @@ -216,7 +216,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor): body=3Dtexi_entity(doc, 'Values', member_func=3Dtexi_enum_valu= e)) =20 - def visit_object_type(self, name, info, base, members, variants): + def visit_object_type(self, name, info, base, members, variants, ifcon= d): doc =3D self.cur_doc if base and base.is_implicit(): base =3D None @@ -226,7 +226,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor): name=3Ddoc.symbol, body=3Dtexi_entity(doc, 'Members', base, vari= ants)) =20 - def visit_alternate_type(self, name, info, variants): + def visit_alternate_type(self, name, info, variants, ifcond): doc =3D self.cur_doc if self.out: self.out +=3D '\n' @@ -235,7 +235,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor): body=3Dtexi_entity(doc, 'Members')) =20 def visit_command(self, name, info, arg_type, ret_type, - gen, success_response, boxed): + gen, success_response, boxed, ifcond): doc =3D self.cur_doc if self.out: self.out +=3D '\n' @@ -249,7 +249,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor): name=3Ddoc.symbol, body=3Dbody) =20 - def visit_event(self, name, info, arg_type, boxed): + def visit_event(self, name, info, arg_type, boxed, ifcond): doc =3D self.cur_doc if self.out: self.out +=3D '\n' diff --git a/tests/Makefile.include b/tests/Makefile.include index 960ab8c6dd..0fc7088b2c 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -373,6 +373,7 @@ qapi-schema +=3D args-unknown.json qapi-schema +=3D bad-base.json qapi-schema +=3D bad-data.json qapi-schema +=3D bad-ident.json +qapi-schema +=3D bad-if.json qapi-schema +=3D bad-type-bool.json qapi-schema +=3D bad-type-dict.json qapi-schema +=3D bad-type-int.json diff --git a/tests/qapi-schema/bad-if.err b/tests/qapi-schema/bad-if.err new file mode 100644 index 0000000000..8054fbb143 --- /dev/null +++ b/tests/qapi-schema/bad-if.err @@ -0,0 +1 @@ +tests/qapi-schema/bad-if.json:2: 'if' condition requires a string or a lis= t of string diff --git a/tests/qapi-schema/bad-if.exit b/tests/qapi-schema/bad-if.exit new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/tests/qapi-schema/bad-if.exit @@ -0,0 +1 @@ +1 diff --git a/tests/qapi-schema/bad-if.json b/tests/qapi-schema/bad-if.json new file mode 100644 index 0000000000..3edd1a0bf2 --- /dev/null +++ b/tests/qapi-schema/bad-if.json @@ -0,0 +1,3 @@ +# check invalid 'if' type +{ 'struct': 'TestIfStruct', 'data': { 'foo': 'int' }, + 'if': { 'value': 'defined(TEST_IF_STRUCT)' } } diff --git a/tests/qapi-schema/bad-if.out b/tests/qapi-schema/bad-if.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index c72dbd8050..dc2c444fc1 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -188,3 +188,23 @@ 'data': { 'a': ['__org.qemu_x-Enum'], 'b': ['__org.qemu_x-Struct'], 'c': '__org.qemu_x-Union2', 'd': '__org.qemu_x-Alt' }, 'returns': '__org.qemu_x-Union1' } + +# test 'if' condition handling + +{ 'struct': 'TestIfStruct', 'data': { 'foo': 'int' }, + 'if': 'defined(TEST_IF_STRUCT)' } + +{ 'enum': 'TestIfEnum', 'data': [ 'foo', 'bar' ], + 'if': 'defined(TEST_IF_ENUM)' } + +{ 'union': 'TestIfUnion', 'data': { 'foo': 'TestStruct' }, + 'if': 'defined(TEST_IF_UNION) && defined(TEST_IF_STRUCT)' } + +{ 'alternate': 'TestIfAlternate', 'data': { 'foo': 'int', 'bar': 'TestStru= ct' }, + 'if': 'defined(TEST_IF_ALT) && defined(TEST_IF_STRUCT)' } + +{ 'command': 'TestIfCmd', 'data': { 'foo': 'TestIfStruct' }, + 'if': 'defined(TEST_IF_CMD) && defined(TEST_IF_STRUCT)' } + +{ 'event': 'TestIfEvent', 'data': { 'foo': 'TestIfStruct' }, + 'if': 'defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)' } diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 3b1e9082d3..fc5fd25f1b 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -52,6 +52,29 @@ enum QEnumTwo ['value1', 'value2'] prefix QENUM_TWO enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE +alternate TestIfAlternate + tag type + case foo: int + case bar: TestStruct + if defined(TEST_IF_ALT) && defined(TEST_IF_STRUCT) +command TestIfCmd q_obj_TestIfCmd-arg -> None + gen=3DTrue success_response=3DTrue boxed=3DFalse + if defined(TEST_IF_CMD) && defined(TEST_IF_STRUCT) +enum TestIfEnum ['foo', 'bar'] + if defined(TEST_IF_ENUM) +event TestIfEvent q_obj_TestIfEvent-arg + boxed=3DFalse + if defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT) +object TestIfStruct + member foo: int optional=3DFalse + if defined(TEST_IF_STRUCT) +object TestIfUnion + member type: TestIfUnionKind optional=3DFalse + tag type + case foo: q_obj_TestStruct-wrapper + if defined(TEST_IF_UNION) && defined(TEST_IF_STRUCT) +enum TestIfUnionKind ['foo'] + if defined(TEST_IF_UNION) && defined(TEST_IF_STRUCT) object TestStruct member integer: int optional=3DFalse member boolean: bool optional=3DFalse @@ -172,6 +195,14 @@ object q_obj_EVENT_D-arg member b: str optional=3DFalse member c: str optional=3DTrue member enum3: EnumOne optional=3DTrue +object q_obj_TestIfCmd-arg + member foo: TestIfStruct optional=3DFalse + if defined(TEST_IF_CMD) && defined(TEST_IF_STRUCT) +object q_obj_TestIfEvent-arg + member foo: TestIfStruct optional=3DFalse + if defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT) +object q_obj_TestStruct-wrapper + member data: TestStruct optional=3DFalse object q_obj_UserDefFlatUnion2-base member integer: int optional=3DTrue member string: str optional=3DFalse diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py index c7724d3437..17fd975812 100644 --- a/tests/qapi-schema/test-qapi.py +++ b/tests/qapi-schema/test-qapi.py @@ -17,12 +17,13 @@ import sys =20 =20 class QAPISchemaTestVisitor(QAPISchemaVisitor): - def visit_enum_type(self, name, info, values, prefix): + def visit_enum_type(self, name, info, values, prefix, ifcond): print 'enum %s %s' % (name, values) if prefix: print ' prefix %s' % prefix + self._print_if(ifcond) =20 - def visit_object_type(self, name, info, base, members, variants): + def visit_object_type(self, name, info, base, members, variants, ifcon= d): print 'object %s' % name if base: print ' base %s' % base.name @@ -30,21 +31,25 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor): print ' member %s: %s optional=3D%s' % \ (m.name, m.type.name, m.optional) self._print_variants(variants) + self._print_if(ifcond) =20 - def visit_alternate_type(self, name, info, variants): + def visit_alternate_type(self, name, info, variants, ifcond): print 'alternate %s' % name self._print_variants(variants) + self._print_if(ifcond) =20 def visit_command(self, name, info, arg_type, ret_type, - gen, success_response, boxed): + gen, success_response, boxed, ifcond): print 'command %s %s -> %s' % \ (name, arg_type and arg_type.name, ret_type and ret_type.name) print ' gen=3D%s success_response=3D%s boxed=3D%s' % \ (gen, success_response, boxed) + self._print_if(ifcond) =20 - def visit_event(self, name, info, arg_type, boxed): + def visit_event(self, name, info, arg_type, boxed, ifcond): print 'event %s %s' % (name, arg_type and arg_type.name) print ' boxed=3D%s' % boxed + self._print_if(ifcond) =20 @staticmethod def _print_variants(variants): @@ -53,6 +58,12 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor): for v in variants.variants: print ' case %s: %s' % (v.name, v.type.name) =20 + @staticmethod + def _print_if(ifcond): + if ifcond: + print ' if %s' % ifcond + + schema =3D QAPISchema(sys.argv[1]) schema.visit(QAPISchemaTestVisitor()) =20 --=20 2.14.0.rc0.1.g40ca67566 From nobody Fri May 3 05:56:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501171003829535.888265819005; Thu, 27 Jul 2017 08:56:43 -0700 (PDT) Received: from localhost ([::1]:43713 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal9W-0005DS-8E for importer@patchew.org; Thu, 27 Jul 2017 11:56:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56121) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal23-0005nT-Cy for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:49:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dal20-0004cw-8D for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:48:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52436) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dal1z-0004cP-VP for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:48:56 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A7C03C00DBA4; Thu, 27 Jul 2017 15:41:57 +0000 (UTC) Received: from localhost (ovpn-112-42.ams2.redhat.com [10.36.112.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B71F7DE45; Thu, 27 Jul 2017 15:41:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A7C03C00DBA4 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 17:41:08 +0200 Message-Id: <20170727154126.11339-9-marcandre.lureau@redhat.com> In-Reply-To: <20170727154126.11339-1-marcandre.lureau@redhat.com> References: <20170727154126.11339-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 27 Jul 2017 15:41:57 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 08/26] qapi: add 'if' condition on enum member values X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Michael Roth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi.py | 39 +++++++++++++++++++++= ---- tests/Makefile.include | 2 ++ tests/qapi-schema/enum-dict-member-invalid.err | 1 + tests/qapi-schema/enum-dict-member-invalid.exit | 1 + tests/qapi-schema/enum-dict-member-invalid.json | 2 ++ tests/qapi-schema/enum-dict-member-invalid.out | 0 tests/qapi-schema/enum-dict-member.err | 1 - tests/qapi-schema/enum-dict-member.exit | 2 +- tests/qapi-schema/enum-dict-member.json | 3 +- tests/qapi-schema/enum-dict-member.out | 4 +++ tests/qapi-schema/enum-if-invalid.err | 1 + tests/qapi-schema/enum-if-invalid.exit | 1 + tests/qapi-schema/enum-if-invalid.json | 3 ++ tests/qapi-schema/enum-if-invalid.out | 0 tests/qapi-schema/qapi-schema-test.json | 5 ++-- tests/qapi-schema/qapi-schema-test.out | 3 +- tests/qapi-schema/test-qapi.py | 4 ++- 17 files changed, 58 insertions(+), 14 deletions(-) create mode 100644 tests/qapi-schema/enum-dict-member-invalid.err create mode 100644 tests/qapi-schema/enum-dict-member-invalid.exit create mode 100644 tests/qapi-schema/enum-dict-member-invalid.json create mode 100644 tests/qapi-schema/enum-dict-member-invalid.out create mode 100644 tests/qapi-schema/enum-if-invalid.err create mode 100644 tests/qapi-schema/enum-if-invalid.exit create mode 100644 tests/qapi-schema/enum-if-invalid.json create mode 100644 tests/qapi-schema/enum-if-invalid.out diff --git a/scripts/qapi.py b/scripts/qapi.py index 79ba1e93da..93d07283e6 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -729,6 +729,10 @@ def check_event(expr, info): allow_metas=3Dmeta) =20 =20 +def enum_get_values(expr): + return [e if isinstance(e, str) else e['name'] for e in expr['data']] + + def check_union(expr, info): name =3D expr['union'] base =3D expr.get('base') @@ -788,7 +792,7 @@ def check_union(expr, info): # If the discriminator names an enum type, then all members # of 'data' must also be members of the enum type. if enum_define: - if key not in enum_define['data']: + if key not in enum_get_values(enum_define): raise QAPISemError(info, "Discriminator value '%s' is not found = in " "enum '%s'" @@ -796,7 +800,7 @@ def check_union(expr, info): =20 # If discriminator is user-defined, ensure all values are covered if enum_define: - for value in enum_define['data']: + for value in enum_get_values(enum_define): if value not in members.keys(): raise QAPISemError(info, "Union '%s' data missing '%s' bra= nch" % (name, value)) @@ -827,7 +831,7 @@ def check_alternate(expr, info): if qtype =3D=3D 'QTYPE_QSTRING': enum_expr =3D enum_types.get(value) if enum_expr: - for v in enum_expr['data']: + for v in enum_get_values(enum_expr): if v in ['on', 'off']: conflicting.add('QTYPE_QBOOL') if re.match(r'[-+0-9.]', v): # lazy, could be tightened @@ -857,6 +861,12 @@ def check_enum(expr, info): raise QAPISemError(info, "Enum '%s' requires a string for 'prefix'" % na= me) for member in members: + if isinstance(member, dict): + if not 'name' in member: + raise QAPISemError(info, "Dictionary member of enum '%s' m= ust " + "have a 'name' key" % name) + check_if(member, info) + member =3D member['name'] check_name(info, "Member of enum '%s'" % name, member, enum_member=3DTrue) =20 @@ -1148,12 +1158,15 @@ class QAPISchemaEnumType(QAPISchemaType): def member_names(self): return [v.name for v in self.values] =20 + def members(self): + return [(v.name, v.ifcond) for v in self.values] + def json_type(self): return 'string' =20 def visit(self, visitor): visitor.visit_enum_type(self.name, self.info, - self.member_names(), self.prefix, self.ifc= ond) + self.members(), self.prefix, self.ifcond) =20 =20 class QAPISchemaArrayType(QAPISchemaType): @@ -1275,9 +1288,11 @@ class QAPISchemaObjectType(QAPISchemaType): class QAPISchemaMember(object): role =3D 'member' =20 - def __init__(self, name): + def __init__(self, name, ifcond=3DNone): assert isinstance(name, str) + assert ifcond is None or isinstance(ifcond, str) self.name =3D name + self.ifcond =3D ifcond self.owner =3D None =20 def set_owner(self, name): @@ -1556,7 +1571,9 @@ class QAPISchema(object): qtype_values, 'QTYPE')) =20 def _make_enum_members(self, values): - return [QAPISchemaMember(v) for v in values] + return [QAPISchemaMember(v['name'], v.get('if')) if isinstance(v, = dict) + else QAPISchemaMember(v) + for v in values] =20 def _make_implicit_enum_type(self, name, info, values, ifcond): # See also QAPISchemaObjectTypeMember._pretty_owner() @@ -1942,11 +1959,16 @@ const char *const %(c_name)s_lookup[] =3D { ''', c_name=3Dc_name(name)) for value in values: + ifcond =3D None + if isinstance(value, tuple): + value, ifcond =3D value + ret +=3D gen_if(ifcond) index =3D c_enum_const(name, value, prefix) ret +=3D mcgen(''' [%(index)s] =3D "%(value)s", ''', index=3Dindex, value=3Dvalue) + ret +=3D gen_endif(ifcond) =20 max_index =3D c_enum_const(name, '_MAX', prefix) ret +=3D mcgen(''' @@ -1969,12 +1991,17 @@ typedef enum %(c_name)s { =20 i =3D 0 for value in enum_values: + ifcond =3D None + if isinstance(value, tuple): + value, ifcond =3D value + ret +=3D gen_if(ifcond) ret +=3D mcgen(''' %(c_enum)s =3D %(i)d, ''', c_enum=3Dc_enum_const(name, value, prefix), i=3Di) i +=3D 1 + ret +=3D gen_endif(ifcond) =20 ret +=3D mcgen(''' } %(c_name)s; diff --git a/tests/Makefile.include b/tests/Makefile.include index 0fc7088b2c..cb5daf0009 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -413,6 +413,8 @@ qapi-schema +=3D enum-bad-name.json qapi-schema +=3D enum-bad-prefix.json qapi-schema +=3D enum-clash-member.json qapi-schema +=3D enum-dict-member.json +qapi-schema +=3D enum-dict-member-invalid.json +qapi-schema +=3D enum-if-invalid.json qapi-schema +=3D enum-int-member.json qapi-schema +=3D enum-member-case.json qapi-schema +=3D enum-missing-data.json diff --git a/tests/qapi-schema/enum-dict-member-invalid.err b/tests/qapi-sc= hema/enum-dict-member-invalid.err new file mode 100644 index 0000000000..d12cca0df3 --- /dev/null +++ b/tests/qapi-schema/enum-dict-member-invalid.err @@ -0,0 +1 @@ +tests/qapi-schema/enum-dict-member-invalid.json:2: Dictionary member of en= um 'MyEnum' must have a 'name' key diff --git a/tests/qapi-schema/enum-dict-member-invalid.exit b/tests/qapi-s= chema/enum-dict-member-invalid.exit new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/tests/qapi-schema/enum-dict-member-invalid.exit @@ -0,0 +1 @@ +1 diff --git a/tests/qapi-schema/enum-dict-member-invalid.json b/tests/qapi-s= chema/enum-dict-member-invalid.json new file mode 100644 index 0000000000..9cf8406867 --- /dev/null +++ b/tests/qapi-schema/enum-dict-member-invalid.json @@ -0,0 +1,2 @@ +# we reject any enum member that is not a string or a dict with 'name' +{ 'enum': 'MyEnum', 'data': [ { 'value': 'str' } ] } diff --git a/tests/qapi-schema/enum-dict-member-invalid.out b/tests/qapi-sc= hema/enum-dict-member-invalid.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qapi-schema/enum-dict-member.err b/tests/qapi-schema/enu= m-dict-member.err index 8ca146ea59..e69de29bb2 100644 --- a/tests/qapi-schema/enum-dict-member.err +++ b/tests/qapi-schema/enum-dict-member.err @@ -1 +0,0 @@ -tests/qapi-schema/enum-dict-member.json:2: Member of enum 'MyEnum' require= s a string name diff --git a/tests/qapi-schema/enum-dict-member.exit b/tests/qapi-schema/en= um-dict-member.exit index d00491fd7e..573541ac97 100644 --- a/tests/qapi-schema/enum-dict-member.exit +++ b/tests/qapi-schema/enum-dict-member.exit @@ -1 +1 @@ -1 +0 diff --git a/tests/qapi-schema/enum-dict-member.json b/tests/qapi-schema/en= um-dict-member.json index 79672e0f09..b09a83061c 100644 --- a/tests/qapi-schema/enum-dict-member.json +++ b/tests/qapi-schema/enum-dict-member.json @@ -1,2 +1 @@ -# we reject any enum member that is not a string -{ 'enum': 'MyEnum', 'data': [ { 'value': 'str' } ] } +{ 'enum': 'TestEnum', 'data': [ { 'name': 'foo' }, { 'name': 'bar' } ]} diff --git a/tests/qapi-schema/enum-dict-member.out b/tests/qapi-schema/enu= m-dict-member.out index e69de29bb2..cf8e3cce2b 100644 --- a/tests/qapi-schema/enum-dict-member.out +++ b/tests/qapi-schema/enum-dict-member.out @@ -0,0 +1,4 @@ +enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] + prefix QTYPE +enum TestEnum ['foo', 'bar'] +object q_empty diff --git a/tests/qapi-schema/enum-if-invalid.err b/tests/qapi-schema/enum= -if-invalid.err new file mode 100644 index 0000000000..236b703e88 --- /dev/null +++ b/tests/qapi-schema/enum-if-invalid.err @@ -0,0 +1 @@ +tests/qapi-schema/enum-if-invalid.json:2: 'if' condition requires a string= or a list of string diff --git a/tests/qapi-schema/enum-if-invalid.exit b/tests/qapi-schema/enu= m-if-invalid.exit new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/tests/qapi-schema/enum-if-invalid.exit @@ -0,0 +1 @@ +1 diff --git a/tests/qapi-schema/enum-if-invalid.json b/tests/qapi-schema/enu= m-if-invalid.json new file mode 100644 index 0000000000..60bd0ef1d7 --- /dev/null +++ b/tests/qapi-schema/enum-if-invalid.json @@ -0,0 +1,3 @@ +# check invalid 'if' type +{ 'enum': 'TestIfEnum', 'data': + [ 'foo', { 'name' : 'bar', 'if': { 'val': 'foo' } } ] } diff --git a/tests/qapi-schema/enum-if-invalid.out b/tests/qapi-schema/enum= -if-invalid.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index dc2c444fc1..ad2b405d83 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -194,7 +194,8 @@ { 'struct': 'TestIfStruct', 'data': { 'foo': 'int' }, 'if': 'defined(TEST_IF_STRUCT)' } =20 -{ 'enum': 'TestIfEnum', 'data': [ 'foo', 'bar' ], +{ 'enum': 'TestIfEnum', 'data': + [ 'foo', { 'name' : 'bar', 'if': 'defined(TEST_IF_ENUM_BAR)' } ], 'if': 'defined(TEST_IF_ENUM)' } =20 { 'union': 'TestIfUnion', 'data': { 'foo': 'TestStruct' }, @@ -203,7 +204,7 @@ { 'alternate': 'TestIfAlternate', 'data': { 'foo': 'int', 'bar': 'TestStru= ct' }, 'if': 'defined(TEST_IF_ALT) && defined(TEST_IF_STRUCT)' } =20 -{ 'command': 'TestIfCmd', 'data': { 'foo': 'TestIfStruct' }, +{ 'command': 'TestIfCmd', 'data': { 'foo': 'TestIfStruct', 'bar': 'TestIfE= num' }, 'if': 'defined(TEST_IF_CMD) && defined(TEST_IF_STRUCT)' } =20 { 'event': 'TestIfEvent', 'data': { 'foo': 'TestIfStruct' }, diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index fc5fd25f1b..211c367632 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -60,7 +60,7 @@ alternate TestIfAlternate command TestIfCmd q_obj_TestIfCmd-arg -> None gen=3DTrue success_response=3DTrue boxed=3DFalse if defined(TEST_IF_CMD) && defined(TEST_IF_STRUCT) -enum TestIfEnum ['foo', 'bar'] +enum TestIfEnum ['foo', ('bar', 'defined(TEST_IF_ENUM_BAR)')] if defined(TEST_IF_ENUM) event TestIfEvent q_obj_TestIfEvent-arg boxed=3DFalse @@ -197,6 +197,7 @@ object q_obj_EVENT_D-arg member enum3: EnumOne optional=3DTrue object q_obj_TestIfCmd-arg member foo: TestIfStruct optional=3DFalse + member bar: TestIfEnum optional=3DFalse if defined(TEST_IF_CMD) && defined(TEST_IF_STRUCT) object q_obj_TestIfEvent-arg member foo: TestIfStruct optional=3DFalse diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py index 17fd975812..70054848f0 100644 --- a/tests/qapi-schema/test-qapi.py +++ b/tests/qapi-schema/test-qapi.py @@ -18,7 +18,9 @@ import sys =20 class QAPISchemaTestVisitor(QAPISchemaVisitor): def visit_enum_type(self, name, info, values, prefix, ifcond): - print 'enum %s %s' % (name, values) + values =3D ', '.join(["'%s'" % v[0] if not v[1] else str(v) + for v in values]) + print 'enum %s [%s]' % (name, values) if prefix: print ' prefix %s' % prefix self._print_if(ifcond) --=20 2.14.0.rc0.1.g40ca67566 From nobody Fri May 3 05:56:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150117130456926.62562616831201; Thu, 27 Jul 2017 09:01:44 -0700 (PDT) Received: from localhost ([::1]:43737 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dalEL-0001rF-Ke for importer@patchew.org; Thu, 27 Jul 2017 12:01:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal44-0008GX-Cx for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dal41-0006Xv-9E for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50358) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dal40-0006Wz-V9 for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:01 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 84F65C0094FA; Thu, 27 Jul 2017 15:42:01 +0000 (UTC) Received: from localhost (ovpn-112-42.ams2.redhat.com [10.36.112.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id D33F9784C2; Thu, 27 Jul 2017 15:41:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 84F65C0094FA Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 17:41:09 +0200 Message-Id: <20170727154126.11339-10-marcandre.lureau@redhat.com> In-Reply-To: <20170727154126.11339-1-marcandre.lureau@redhat.com> References: <20170727154126.11339-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 27 Jul 2017 15:42:01 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 09/26] qapi: add 'if' condition on struct member X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Michael Roth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi.py | 18 ++++++++++++++---- scripts/qapi-introspect.py | 2 ++ scripts/qapi-types.py | 2 ++ scripts/qapi-visit.py | 2 ++ tests/Makefile.include | 2 ++ tests/qapi-schema/qapi-schema-test.json | 9 ++++++--- tests/qapi-schema/qapi-schema-test.out | 4 +++- tests/qapi-schema/struct-if-invalid.err | 1 + tests/qapi-schema/struct-if-invalid.exit | 1 + tests/qapi-schema/struct-if-invalid.json | 3 +++ tests/qapi-schema/struct-if-invalid.out | 0 tests/qapi-schema/struct-member-type.err | 0 tests/qapi-schema/struct-member-type.exit | 1 + tests/qapi-schema/struct-member-type.json | 1 + tests/qapi-schema/struct-member-type.out | 5 +++++ tests/qapi-schema/test-qapi.py | 3 ++- 16 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 tests/qapi-schema/struct-if-invalid.err create mode 100644 tests/qapi-schema/struct-if-invalid.exit create mode 100644 tests/qapi-schema/struct-if-invalid.json create mode 100644 tests/qapi-schema/struct-if-invalid.out create mode 100644 tests/qapi-schema/struct-member-type.err create mode 100644 tests/qapi-schema/struct-member-type.exit create mode 100644 tests/qapi-schema/struct-member-type.json create mode 100644 tests/qapi-schema/struct-member-type.out diff --git a/scripts/qapi.py b/scripts/qapi.py index 93d07283e6..1eb40590fb 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -678,7 +678,13 @@ def check_type(info, source, value, allow_array=3DFals= e, return =20 if not allow_dict: - raise QAPISemError(info, "%s should be a type name" % source) + if isinstance(value, dict) and 'type' in value: + check_type(info, source, value['type'], allow_array, + allow_dict, allow_optional, allow_metas) + check_if(value, info) + return + else: + raise QAPISemError(info, "%s should be a type name" % source) =20 if not isinstance(value, OrderedDict): raise QAPISemError(info, @@ -1333,8 +1339,8 @@ class QAPISchemaMember(object): =20 =20 class QAPISchemaObjectTypeMember(QAPISchemaMember): - def __init__(self, name, typ, optional): - QAPISchemaMember.__init__(self, name) + def __init__(self, name, typ, optional, ifcond=3DNone): + QAPISchemaMember.__init__(self, name, ifcond) assert isinstance(typ, str) assert isinstance(optional, bool) self._type_name =3D typ @@ -1611,13 +1617,17 @@ class QAPISchema(object): =20 def _make_member(self, name, typ, info): optional =3D False + ifcond =3D None if name.startswith('*'): name =3D name[1:] optional =3D True + if isinstance(typ, dict): + ifcond =3D typ.get('if') + typ =3D typ['type'] if isinstance(typ, list): assert len(typ) =3D=3D 1 typ =3D self._make_array_type(typ[0], info) - return QAPISchemaObjectTypeMember(name, typ, optional) + return QAPISchemaObjectTypeMember(name, typ, optional, ifcond) =20 def _make_members(self, data, info): return [self._make_member(key, value, info) diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py index ecfb0f2752..98b320a79e 100644 --- a/scripts/qapi-introspect.py +++ b/scripts/qapi-introspect.py @@ -130,6 +130,8 @@ const QLitObject %(c_name)s =3D %(c_string)s; ret =3D {'name': member.name, 'type': self._use_type(member.type)} if member.optional: ret['default'] =3D None + if member.ifcond: + ret =3D (ret, member.ifcond) return ret =20 def _gen_variants(self, tag_name, variants): diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index d0d2eb917c..659fb1da86 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -41,6 +41,7 @@ struct %(c_name)s { def gen_struct_members(members): ret =3D '' for memb in members: + ret +=3D gen_if(memb.ifcond) if memb.optional: ret +=3D mcgen(''' bool has_%(c_name)s; @@ -50,6 +51,7 @@ def gen_struct_members(members): %(c_type)s %(c_name)s; ''', c_type=3Dmemb.type.c_type(), c_name=3Dc_name(memb.nam= e)) + ret +=3D gen_endif(memb.ifcond) return ret =20 =20 diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index 335407d078..f400cef13c 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -53,6 +53,7 @@ void visit_type_%(c_name)s_members(Visitor *v, %(c_name)s= *obj, Error **errp) c_type=3Dbase.c_name()) =20 for memb in members: + ret +=3D gen_if(memb.ifcond) if memb.optional: ret +=3D mcgen(''' if (visit_optional(v, "%(name)s", &obj->has_%(c_name)s)) { @@ -72,6 +73,7 @@ void visit_type_%(c_name)s_members(Visitor *v, %(c_name)s= *obj, Error **errp) ret +=3D mcgen(''' } ''') + ret +=3D gen_endif(memb.ifcond) =20 if variants: ret +=3D mcgen(''' diff --git a/tests/Makefile.include b/tests/Makefile.include index cb5daf0009..816cc5c5e3 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -489,7 +489,9 @@ qapi-schema +=3D returns-whitelist.json qapi-schema +=3D struct-base-clash-deep.json qapi-schema +=3D struct-base-clash.json qapi-schema +=3D struct-data-invalid.json +qapi-schema +=3D struct-if-invalid.json qapi-schema +=3D struct-member-invalid.json +qapi-schema +=3D struct-member-type.json qapi-schema +=3D trailing-comma-list.json qapi-schema +=3D trailing-comma-object.json qapi-schema +=3D type-bypass-bad-gen.json diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index ad2b405d83..bb515280d2 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -191,7 +191,8 @@ =20 # test 'if' condition handling =20 -{ 'struct': 'TestIfStruct', 'data': { 'foo': 'int' }, +{ 'struct': 'TestIfStruct', 'data': + { 'foo': 'int', 'bar': { 'type': 'int', 'if': 'defined(TEST_IF_STRUCT_BA= R)'} }, 'if': 'defined(TEST_IF_STRUCT)' } =20 { 'enum': 'TestIfEnum', 'data': @@ -204,8 +205,10 @@ { 'alternate': 'TestIfAlternate', 'data': { 'foo': 'int', 'bar': 'TestStru= ct' }, 'if': 'defined(TEST_IF_ALT) && defined(TEST_IF_STRUCT)' } =20 -{ 'command': 'TestIfCmd', 'data': { 'foo': 'TestIfStruct', 'bar': 'TestIfE= num' }, +{ 'command': 'TestIfCmd', 'data': + { 'foo': 'TestIfStruct', 'bar': { 'type': 'TestIfEnum', 'if': 'TEST_IF_C= MD_BAR' } }, 'if': 'defined(TEST_IF_CMD) && defined(TEST_IF_STRUCT)' } =20 -{ 'event': 'TestIfEvent', 'data': { 'foo': 'TestIfStruct' }, +{ 'event': 'TestIfEvent', 'data': + { 'foo': 'TestIfStruct', 'bar': { 'type': 'TestIfEnum', 'if': 'TEST_IF_E= VT_BAR' } }, 'if': 'defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)' } diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 211c367632..b17c32a45f 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -67,6 +67,7 @@ event TestIfEvent q_obj_TestIfEvent-arg if defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT) object TestIfStruct member foo: int optional=3DFalse + member bar: int optional=3DFalse if=3Ddefined(TEST_IF_STRUCT_BAR) if defined(TEST_IF_STRUCT) object TestIfUnion member type: TestIfUnionKind optional=3DFalse @@ -197,10 +198,11 @@ object q_obj_EVENT_D-arg member enum3: EnumOne optional=3DTrue object q_obj_TestIfCmd-arg member foo: TestIfStruct optional=3DFalse - member bar: TestIfEnum optional=3DFalse + member bar: TestIfEnum optional=3DFalse if=3DTEST_IF_CMD_BAR if defined(TEST_IF_CMD) && defined(TEST_IF_STRUCT) object q_obj_TestIfEvent-arg member foo: TestIfStruct optional=3DFalse + member bar: TestIfEnum optional=3DFalse if=3DTEST_IF_EVT_BAR if defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT) object q_obj_TestStruct-wrapper member data: TestStruct optional=3DFalse diff --git a/tests/qapi-schema/struct-if-invalid.err b/tests/qapi-schema/st= ruct-if-invalid.err new file mode 100644 index 0000000000..42245262a9 --- /dev/null +++ b/tests/qapi-schema/struct-if-invalid.err @@ -0,0 +1 @@ +tests/qapi-schema/struct-if-invalid.json:2: Member 'bar' of 'data' for str= uct 'TestIfStruct' should be a type name diff --git a/tests/qapi-schema/struct-if-invalid.exit b/tests/qapi-schema/s= truct-if-invalid.exit new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/tests/qapi-schema/struct-if-invalid.exit @@ -0,0 +1 @@ +1 diff --git a/tests/qapi-schema/struct-if-invalid.json b/tests/qapi-schema/s= truct-if-invalid.json new file mode 100644 index 0000000000..466cdb61e1 --- /dev/null +++ b/tests/qapi-schema/struct-if-invalid.json @@ -0,0 +1,3 @@ +# check missing 'type' +{ 'struct': 'TestIfStruct', 'data': + { 'foo': 'int', 'bar': { 'if': 'defined(TEST_IF_STRUCT_BAR)' } } } diff --git a/tests/qapi-schema/struct-if-invalid.out b/tests/qapi-schema/st= ruct-if-invalid.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qapi-schema/struct-member-type.err b/tests/qapi-schema/s= truct-member-type.err new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qapi-schema/struct-member-type.exit b/tests/qapi-schema/= struct-member-type.exit new file mode 100644 index 0000000000..573541ac97 --- /dev/null +++ b/tests/qapi-schema/struct-member-type.exit @@ -0,0 +1 @@ +0 diff --git a/tests/qapi-schema/struct-member-type.json b/tests/qapi-schema/= struct-member-type.json new file mode 100644 index 0000000000..07de38fa4a --- /dev/null +++ b/tests/qapi-schema/struct-member-type.json @@ -0,0 +1 @@ +{ 'struct': 'foo', 'data': { 'a': { 'type': 'str' } } } diff --git a/tests/qapi-schema/struct-member-type.out b/tests/qapi-schema/s= truct-member-type.out new file mode 100644 index 0000000000..2ea68909a9 --- /dev/null +++ b/tests/qapi-schema/struct-member-type.out @@ -0,0 +1,5 @@ +enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] + prefix QTYPE +object foo + member a: str optional=3DFalse +object q_empty diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py index 70054848f0..5d2f67a1d3 100644 --- a/tests/qapi-schema/test-qapi.py +++ b/tests/qapi-schema/test-qapi.py @@ -31,7 +31,8 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor): print ' base %s' % base.name for m in members: print ' member %s: %s optional=3D%s' % \ - (m.name, m.type.name, m.optional) + (m.name, m.type.name, m.optional) + \ + (' if=3D%s' % m.ifcond if m.ifcond else '') self._print_variants(variants) self._print_if(ifcond) =20 --=20 2.14.0.rc0.1.g40ca67566 From nobody Fri May 3 05:56:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501171656308289.4907258837235; Thu, 27 Jul 2017 09:07:36 -0700 (PDT) Received: from localhost ([::1]:43768 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dalK2-0006J2-RL for importer@patchew.org; Thu, 27 Jul 2017 12:07:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32873) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal4y-0000dQ-7L for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:52:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dal4v-0007Md-Co for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:52:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43942) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dal4v-0007Lb-1V for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:57 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5908EABBB5; Thu, 27 Jul 2017 15:42:03 +0000 (UTC) Received: from localhost (ovpn-112-42.ams2.redhat.com [10.36.112.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id C2D377DE45; Thu, 27 Jul 2017 15:42:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5908EABBB5 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 17:41:10 +0200 Message-Id: <20170727154126.11339-11-marcandre.lureau@redhat.com> In-Reply-To: <20170727154126.11339-1-marcandre.lureau@redhat.com> References: <20170727154126.11339-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 27 Jul 2017 15:42:03 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 10/26] qapi: add 'if' condition on union variant X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Michael Roth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi.py | 14 +++++++++----- scripts/qapi-introspect.py | 3 ++- scripts/qapi-types.py | 2 ++ scripts/qapi-visit.py | 4 ++++ tests/qapi-schema/qapi-schema-test.json | 6 +++++- tests/qapi-schema/qapi-schema-test.out | 9 ++++++++- tests/qapi-schema/test-qapi.py | 3 ++- 7 files changed, 32 insertions(+), 9 deletions(-) diff --git a/scripts/qapi.py b/scripts/qapi.py index 1eb40590fb..333a5c0d1e 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -1398,8 +1398,8 @@ class QAPISchemaObjectTypeVariants(object): class QAPISchemaObjectTypeVariant(QAPISchemaObjectTypeMember): role =3D 'branch' =20 - def __init__(self, name, typ): - QAPISchemaObjectTypeMember.__init__(self, name, typ, False) + def __init__(self, name, typ, ifcond=3DNone): + QAPISchemaObjectTypeMember.__init__(self, name, typ, False, ifcond) =20 =20 class QAPISchemaAlternateType(QAPISchemaType): @@ -1646,6 +1646,10 @@ class QAPISchema(object): return QAPISchemaObjectTypeVariant(case, typ) =20 def _make_simple_variant(self, case, typ, info): + ifcond =3D None + if isinstance(typ, dict): + ifcond =3D typ.get('if') + typ =3D typ['type'] if isinstance(typ, list): assert len(typ) =3D=3D 1 typ =3D self._make_array_type(typ[0], info) @@ -1653,7 +1657,7 @@ class QAPISchema(object): typ =3D self._make_implicit_object_type( typ, info, None, 'wrapper', [self._make_member('data', typ, info)], type_entity.ifcond) - return QAPISchemaObjectTypeVariant(case, typ) + return QAPISchemaObjectTypeVariant(case, typ, ifcond) =20 def _def_union_type(self, expr, info, doc): name =3D expr['union'] @@ -1672,8 +1676,8 @@ class QAPISchema(object): else: variants =3D [self._make_simple_variant(key, value, info) for (key, value) in data.iteritems()] - typ =3D self._make_implicit_enum_type(name, info, - [v.name for v in variants], + values =3D [{'name': v.name, 'if': v.ifcond} for v in variants] + typ =3D self._make_implicit_enum_type(name, info, values, expr.get('if')) tag_member =3D QAPISchemaObjectTypeMember('type', typ, False) members =3D [tag_member] diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py index 98b320a79e..a867ea5de1 100644 --- a/scripts/qapi-introspect.py +++ b/scripts/qapi-introspect.py @@ -139,7 +139,8 @@ const QLitObject %(c_name)s =3D %(c_string)s; 'variants': [self._gen_variant(v) for v in variants]} =20 def _gen_variant(self, variant): - return {'case': variant.name, 'type': self._use_type(variant.type)} + return ({'case': variant.name, 'type': self._use_type(variant.type= )}, + variant.ifcond) =20 def visit_builtin_type(self, name, info, json_type): self._gen_qlit(name, 'builtin', {'json-type': json_type}, None) diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index 659fb1da86..d6c8feb55a 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -128,11 +128,13 @@ def gen_variants(variants): c_name=3Dc_name(variants.tag_member.name)) =20 for var in variants.variants: + ret +=3D gen_if(var.ifcond) ret +=3D mcgen(''' %(c_type)s %(c_name)s; ''', c_type=3Dvar.type.c_unboxed_type(), c_name=3Dc_name(var.name)) + ret +=3D gen_endif(var.ifcond) =20 ret +=3D mcgen(''' } u; diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index f400cef13c..0f5cae33e4 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -82,6 +82,7 @@ void visit_type_%(c_name)s_members(Visitor *v, %(c_name)s= *obj, Error **errp) c_name=3Dc_name(variants.tag_member.name)) =20 for var in variants.variants: + ret +=3D gen_if(var.ifcond) ret +=3D mcgen(''' case %(case)s: visit_type_%(c_type)s_members(v, &obj->u.%(c_name)s, &err); @@ -92,6 +93,7 @@ void visit_type_%(c_name)s_members(Visitor *v, %(c_name)s= *obj, Error **errp) variants.tag_member.type.prefix= ), c_type=3Dvar.type.c_name(), c_name=3Dc_name(var.n= ame)) =20 + ret +=3D gen_endif(var.ifcond) ret +=3D mcgen(''' default: abort(); @@ -182,6 +184,7 @@ void visit_type_%(c_name)s(Visitor *v, const char *name= , %(c_name)s **obj, Error c_name=3Dc_name(name)) =20 for var in variants.variants: + ret +=3D gen_if(var.ifcond) ret +=3D mcgen(''' case %(case)s: ''', @@ -209,6 +212,7 @@ void visit_type_%(c_name)s(Visitor *v, const char *name= , %(c_name)s **obj, Error ret +=3D mcgen(''' break; ''') + ret +=3D gen_endif(var.ifcond) =20 ret +=3D mcgen(''' case QTYPE_NONE: diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index bb515280d2..01f7db58dc 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -199,9 +199,13 @@ [ 'foo', { 'name' : 'bar', 'if': 'defined(TEST_IF_ENUM_BAR)' } ], 'if': 'defined(TEST_IF_ENUM)' } =20 -{ 'union': 'TestIfUnion', 'data': { 'foo': 'TestStruct' }, +{ 'union': 'TestIfUnion', 'data': + { 'foo': 'TestStruct', 'union_bar': { 'type': 'str', 'if': 'defined(TEST= _IF_UNION_BAR)'} }, 'if': 'defined(TEST_IF_UNION) && defined(TEST_IF_STRUCT)' } =20 +{ 'command': 'TestIfUnionCmd', 'data': { 'union_cmd_arg': 'TestIfUnion' }, + 'if': 'defined(TEST_IF_UNION)' } + { 'alternate': 'TestIfAlternate', 'data': { 'foo': 'int', 'bar': 'TestStru= ct' }, 'if': 'defined(TEST_IF_ALT) && defined(TEST_IF_STRUCT)' } =20 diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index b17c32a45f..7908eed6fc 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -73,8 +73,12 @@ object TestIfUnion member type: TestIfUnionKind optional=3DFalse tag type case foo: q_obj_TestStruct-wrapper + case union_bar: q_obj_str-wrapper if=3Ddefined(TEST_IF_UNION_BAR) if defined(TEST_IF_UNION) && defined(TEST_IF_STRUCT) -enum TestIfUnionKind ['foo'] +command TestIfUnionCmd q_obj_TestIfUnionCmd-arg -> None + gen=3DTrue success_response=3DTrue boxed=3DFalse + if defined(TEST_IF_UNION) +enum TestIfUnionKind ['foo', ('union_bar', 'defined(TEST_IF_UNION_BAR)')] if defined(TEST_IF_UNION) && defined(TEST_IF_STRUCT) object TestStruct member integer: int optional=3DFalse @@ -204,6 +208,9 @@ object q_obj_TestIfEvent-arg member foo: TestIfStruct optional=3DFalse member bar: TestIfEnum optional=3DFalse if=3DTEST_IF_EVT_BAR if defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT) +object q_obj_TestIfUnionCmd-arg + member union_cmd_arg: TestIfUnion optional=3DFalse + if defined(TEST_IF_UNION) object q_obj_TestStruct-wrapper member data: TestStruct optional=3DFalse object q_obj_UserDefFlatUnion2-base diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py index 5d2f67a1d3..b360d44df1 100644 --- a/tests/qapi-schema/test-qapi.py +++ b/tests/qapi-schema/test-qapi.py @@ -59,7 +59,8 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor): if variants: print ' tag %s' % variants.tag_member.name for v in variants.variants: - print ' case %s: %s' % (v.name, v.type.name) + print ' case %s: %s' % (v.name, v.type.name) + \ + (' if=3D%s' % v.ifcond if v.ifcond else '') =20 @staticmethod def _print_if(ifcond): --=20 2.14.0.rc0.1.g40ca67566 From nobody Fri May 3 05:56:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501171561457531.9846320624654; Thu, 27 Jul 2017 09:06:01 -0700 (PDT) Received: from localhost ([::1]:43754 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dalIU-00053t-1a for importer@patchew.org; Thu, 27 Jul 2017 12:05:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32846) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal4x-0000cu-Ke for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:52:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dal4u-0007Ll-Ek for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41304) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dal4u-0007KM-4y for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:56 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EC48B62657; Thu, 27 Jul 2017 15:42:04 +0000 (UTC) Received: from localhost (ovpn-112-42.ams2.redhat.com [10.36.112.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 836A1785E9; Thu, 27 Jul 2017 15:42:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EC48B62657 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 17:41:11 +0200 Message-Id: <20170727154126.11339-12-marcandre.lureau@redhat.com> In-Reply-To: <20170727154126.11339-1-marcandre.lureau@redhat.com> References: <20170727154126.11339-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 27 Jul 2017 15:42:05 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 11/26] qapi: add 'if' condition on alternate variant X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Michael Roth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi.py | 8 +++++++- scripts/qapi-introspect.py | 2 +- tests/Makefile.include | 1 + tests/qapi-schema/alternate-dict-invalid.err | 1 + tests/qapi-schema/alternate-dict-invalid.exit | 1 + tests/qapi-schema/alternate-dict-invalid.json | 4 ++++ tests/qapi-schema/alternate-dict-invalid.out | 0 tests/qapi-schema/qapi-schema-test.json | 6 +++++- tests/qapi-schema/qapi-schema-test.out | 8 +++++++- 9 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 tests/qapi-schema/alternate-dict-invalid.err create mode 100644 tests/qapi-schema/alternate-dict-invalid.exit create mode 100644 tests/qapi-schema/alternate-dict-invalid.json create mode 100644 tests/qapi-schema/alternate-dict-invalid.out diff --git a/scripts/qapi.py b/scripts/qapi.py index 333a5c0d1e..7f0d56fb01 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -829,6 +829,8 @@ def check_alternate(expr, info): check_type(info, "Member '%s' of alternate '%s'" % (key, name), value, allow_metas=3D['built-in', 'union', 'struct', 'enum']) + if isinstance(value, dict): + value =3D value['type'] qtype =3D find_alternate_member_qtype(value) if not qtype: raise QAPISemError(info, "Alternate '%s' member '%s' cannot us= e " @@ -1643,7 +1645,11 @@ class QAPISchema(object): expr.get('if')) =20 def _make_variant(self, case, typ): - return QAPISchemaObjectTypeVariant(case, typ) + ifcond =3D None + if isinstance(typ, dict): + ifcond =3D typ.get('if') + typ =3D typ['type'] + return QAPISchemaObjectTypeVariant(case, typ, ifcond) =20 def _make_simple_variant(self, case, typ, info): ifcond =3D None diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py index a867ea5de1..cac5a6a392 100644 --- a/scripts/qapi-introspect.py +++ b/scripts/qapi-introspect.py @@ -162,7 +162,7 @@ const QLitObject %(c_name)s =3D %(c_string)s; =20 def visit_alternate_type(self, name, info, variants, ifcond): self._gen_qlit(name, 'alternate', - {'members': [{'type': self._use_type(m.type)} + {'members': [({'type': self._use_type(m.type)}, m.i= fcond) for m in variants.variants]}, ifcond) =20 def visit_command(self, name, info, arg_type, ret_type, diff --git a/tests/Makefile.include b/tests/Makefile.include index 816cc5c5e3..9462deb02b 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -351,6 +351,7 @@ qapi-schema +=3D alternate-conflict-dict.json qapi-schema +=3D alternate-conflict-enum-bool.json qapi-schema +=3D alternate-conflict-enum-int.json qapi-schema +=3D alternate-conflict-string.json +qapi-schema +=3D alternate-dict-invalid.json qapi-schema +=3D alternate-empty.json qapi-schema +=3D alternate-nested.json qapi-schema +=3D alternate-unknown.json diff --git a/tests/qapi-schema/alternate-dict-invalid.err b/tests/qapi-sche= ma/alternate-dict-invalid.err new file mode 100644 index 0000000000..707c40f0f6 --- /dev/null +++ b/tests/qapi-schema/alternate-dict-invalid.err @@ -0,0 +1 @@ +tests/qapi-schema/alternate-dict-invalid.json:2: Member 'two' of alternate= 'Alt' should be a type name diff --git a/tests/qapi-schema/alternate-dict-invalid.exit b/tests/qapi-sch= ema/alternate-dict-invalid.exit new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/tests/qapi-schema/alternate-dict-invalid.exit @@ -0,0 +1 @@ +1 diff --git a/tests/qapi-schema/alternate-dict-invalid.json b/tests/qapi-sch= ema/alternate-dict-invalid.json new file mode 100644 index 0000000000..45f2c8ebef --- /dev/null +++ b/tests/qapi-schema/alternate-dict-invalid.json @@ -0,0 +1,4 @@ +# invalid field dictionnary, missing type +{ 'alternate': 'Alt', + 'data': { 'one': 'str', + 'two': { 'if': 'foo' } } } diff --git a/tests/qapi-schema/alternate-dict-invalid.out b/tests/qapi-sche= ma/alternate-dict-invalid.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index 01f7db58dc..46a4d1c3e5 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -206,9 +206,13 @@ { 'command': 'TestIfUnionCmd', 'data': { 'union_cmd_arg': 'TestIfUnion' }, 'if': 'defined(TEST_IF_UNION)' } =20 -{ 'alternate': 'TestIfAlternate', 'data': { 'foo': 'int', 'bar': 'TestStru= ct' }, +{ 'alternate': 'TestIfAlternate', 'data': + { 'foo': 'int', 'alt_bar': { 'type': 'TestStruct', 'if': 'defined(TEST_I= F_ALT_BAR)'} }, 'if': 'defined(TEST_IF_ALT) && defined(TEST_IF_STRUCT)' } =20 +{ 'command': 'TestIfAlternateCmd', 'data': { 'alt_cmd_arg': 'TestIfAlterna= te' }, + 'if': 'defined(TEST_IF_ALT)' } + { 'command': 'TestIfCmd', 'data': { 'foo': 'TestIfStruct', 'bar': { 'type': 'TestIfEnum', 'if': 'TEST_IF_C= MD_BAR' } }, 'if': 'defined(TEST_IF_CMD) && defined(TEST_IF_STRUCT)' } diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 7908eed6fc..a51c6ac15c 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -55,8 +55,11 @@ enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict',= 'qlist', 'qbool'] alternate TestIfAlternate tag type case foo: int - case bar: TestStruct + case alt_bar: TestStruct if=3Ddefined(TEST_IF_ALT_BAR) if defined(TEST_IF_ALT) && defined(TEST_IF_STRUCT) +command TestIfAlternateCmd q_obj_TestIfAlternateCmd-arg -> None + gen=3DTrue success_response=3DTrue boxed=3DFalse + if defined(TEST_IF_ALT) command TestIfCmd q_obj_TestIfCmd-arg -> None gen=3DTrue success_response=3DTrue boxed=3DFalse if defined(TEST_IF_CMD) && defined(TEST_IF_STRUCT) @@ -200,6 +203,9 @@ object q_obj_EVENT_D-arg member b: str optional=3DFalse member c: str optional=3DTrue member enum3: EnumOne optional=3DTrue +object q_obj_TestIfAlternateCmd-arg + member alt_cmd_arg: TestIfAlternate optional=3DFalse + if defined(TEST_IF_ALT) object q_obj_TestIfCmd-arg member foo: TestIfStruct optional=3DFalse member bar: TestIfEnum optional=3DFalse if=3DTEST_IF_CMD_BAR --=20 2.14.0.rc0.1.g40ca67566 From nobody Fri May 3 05:56:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501171143751933.6772049312845; Thu, 27 Jul 2017 08:59:03 -0700 (PDT) Received: from localhost ([::1]:43720 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dalBj-00078r-7W for importer@patchew.org; Thu, 27 Jul 2017 11:58:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58938) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal44-0008Ge-FU for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dal41-0006Xl-7q for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50360) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dal40-0006Wy-VN for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:01 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9FADEC0587F2; Thu, 27 Jul 2017 15:42:08 +0000 (UTC) Received: from localhost (ovpn-112-42.ams2.redhat.com [10.36.112.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1252862666; Thu, 27 Jul 2017 15:42:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9FADEC0587F2 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 17:41:12 +0200 Message-Id: <20170727154126.11339-13-marcandre.lureau@redhat.com> In-Reply-To: <20170727154126.11339-1-marcandre.lureau@redhat.com> References: <20170727154126.11339-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 27 Jul 2017 15:42:08 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 12/26] qapi2texi: add 'If:' section to generated documentation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Michael Roth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The documentation is generated only once, and doesn't know C pre-conditions. Signed-off-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi2texi.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py index 5aa2f48bfd..bfb8cd7c52 100755 --- a/scripts/qapi2texi.py +++ b/scripts/qapi2texi.py @@ -132,7 +132,6 @@ def texi_enum_value(value): """Format a table of members item for an enumeration value""" return '@item @code{%s}\n' % value.name =20 - def texi_member(member, suffix=3D''): """Format a table of members item for an object type member""" typ =3D member.type.doc_type() @@ -175,7 +174,7 @@ def texi_members(doc, what, base, variants, member_func= ): return '\n@b{%s:}\n@table @asis\n%s@end table\n' % (what, items) =20 =20 -def texi_sections(doc): +def texi_sections(doc, ifcond): """Format additional sections following arguments""" body =3D '' for section in doc.sections: @@ -189,14 +188,16 @@ def texi_sections(doc): body +=3D '\n\n@b{%s:}\n' % name =20 body +=3D func(doc) + if ifcond: + body +=3D '\n\n@b{If:} @code{%s}' % ifcond return body =20 =20 -def texi_entity(doc, what, base=3DNone, variants=3DNone, +def texi_entity(doc, what, ifcond, base=3DNone, variants=3DNone, member_func=3Dtexi_member): return (texi_body(doc) + texi_members(doc, what, base, variants, member_func) - + texi_sections(doc)) + + texi_sections(doc, ifcond)) =20 =20 class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor): @@ -213,7 +214,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor): self.out +=3D '\n' self.out +=3D TYPE_FMT(type=3D'Enum', name=3Ddoc.symbol, - body=3Dtexi_entity(doc, 'Values', + body=3Dtexi_entity(doc, 'Values', ifcond, member_func=3Dtexi_enum_valu= e)) =20 def visit_object_type(self, name, info, base, members, variants, ifcon= d): @@ -224,7 +225,8 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor): self.out +=3D '\n' self.out +=3D TYPE_FMT(type=3D'Object', name=3Ddoc.symbol, - body=3Dtexi_entity(doc, 'Members', base, vari= ants)) + body=3Dtexi_entity(doc, 'Members', ifcond, + base, variants)) =20 def visit_alternate_type(self, name, info, variants, ifcond): doc =3D self.cur_doc @@ -232,7 +234,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor): self.out +=3D '\n' self.out +=3D TYPE_FMT(type=3D'Alternate', name=3Ddoc.symbol, - body=3Dtexi_entity(doc, 'Members')) + body=3Dtexi_entity(doc, 'Members', ifcond)) =20 def visit_command(self, name, info, arg_type, ret_type, gen, success_response, boxed, ifcond): @@ -242,9 +244,9 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor): if boxed: body =3D texi_body(doc) body +=3D '\n@b{Arguments:} the members of @code{%s}' % arg_ty= pe.name - body +=3D texi_sections(doc) + body +=3D texi_sections(doc, ifcond) else: - body =3D texi_entity(doc, 'Arguments') + body =3D texi_entity(doc, 'Arguments', ifcond) self.out +=3D MSG_FMT(type=3D'Command', name=3Ddoc.symbol, body=3Dbody) @@ -255,7 +257,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor): self.out +=3D '\n' self.out +=3D MSG_FMT(type=3D'Event', name=3Ddoc.symbol, - body=3Dtexi_entity(doc, 'Arguments')) + body=3Dtexi_entity(doc, 'Arguments', ifcond)) =20 def symbol(self, doc, entity): self.cur_doc =3D doc @@ -266,7 +268,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor): assert not doc.args if self.out: self.out +=3D '\n' - self.out +=3D texi_body(doc) + texi_sections(doc) + self.out +=3D texi_body(doc) + texi_sections(doc, None) =20 =20 def texi_schema(schema): --=20 2.14.0.rc0.1.g40ca67566 From nobody Fri May 3 05:56:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501170854388385.768150800518; Thu, 27 Jul 2017 08:54:14 -0700 (PDT) Received: from localhost ([::1]:43698 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal75-0002Yq-PD for importer@patchew.org; Thu, 27 Jul 2017 11:54:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56128) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal23-0005nZ-Ea for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:49:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dal20-0004cl-56 for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:48:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52440) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dal1z-0004cR-Vt for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:48:56 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B7C3BC0E7227; Thu, 27 Jul 2017 15:42:10 +0000 (UTC) Received: from localhost (ovpn-112-42.ams2.redhat.com [10.36.112.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E0A5785DD; Thu, 27 Jul 2017 15:42:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B7C3BC0E7227 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 17:41:13 +0200 Message-Id: <20170727154126.11339-14-marcandre.lureau@redhat.com> In-Reply-To: <20170727154126.11339-1-marcandre.lureau@redhat.com> References: <20170727154126.11339-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 27 Jul 2017 15:42:10 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 13/26] qapi2texi: add 'If:' condition to enum values X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Michael Roth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi2texi.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py index bfb8cd7c52..340a55c30d 100755 --- a/scripts/qapi2texi.py +++ b/scripts/qapi2texi.py @@ -130,7 +130,9 @@ def texi_body(doc): =20 def texi_enum_value(value): """Format a table of members item for an enumeration value""" - return '@item @code{%s}\n' % value.name + return '@item @code{%s}%s\n' % ( + value.name, + '\n@b{If:} @code{%s}\n' % value.ifcond if value.ifcond else '') =20 def texi_member(member, suffix=3D''): """Format a table of members item for an object type member""" --=20 2.14.0.rc0.1.g40ca67566 From nobody Fri May 3 05:56:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501171325169699.3872403322536; Thu, 27 Jul 2017 09:02:05 -0700 (PDT) Received: from localhost ([::1]:43739 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dalEg-00026y-N6 for importer@patchew.org; Thu, 27 Jul 2017 12:02:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58926) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal44-0008GU-CN for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dal41-0006Xd-4g for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8658) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dal40-0006X1-Ul for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:01 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 21149C073D66; Thu, 27 Jul 2017 15:42:14 +0000 (UTC) Received: from localhost (ovpn-112-42.ams2.redhat.com [10.36.112.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id D536A5C269; Thu, 27 Jul 2017 15:42:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 21149C073D66 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 17:41:14 +0200 Message-Id: <20170727154126.11339-15-marcandre.lureau@redhat.com> In-Reply-To: <20170727154126.11339-1-marcandre.lureau@redhat.com> References: <20170727154126.11339-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 27 Jul 2017 15:42:14 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 14/26] qapi2texi: add 'If:' condition to struct members X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Michael Roth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi2texi.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py index 340a55c30d..b2c9a9f335 100755 --- a/scripts/qapi2texi.py +++ b/scripts/qapi2texi.py @@ -137,10 +137,11 @@ def texi_enum_value(value): def texi_member(member, suffix=3D''): """Format a table of members item for an object type member""" typ =3D member.type.doc_type() - return '@item @code{%s%s}%s%s\n' % ( + return '@item @code{%s%s}%s%s%s\n' % ( member.name, ': %s' % typ if typ else '', ' (optional)' if member.optional else '', + '\n@b{If:} @code{%s}\n' % member.ifcond if member.ifcond else '', suffix) =20 =20 --=20 2.14.0.rc0.1.g40ca67566 From nobody Fri May 3 05:56:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501171305797537.6814278785473; Thu, 27 Jul 2017 09:01:45 -0700 (PDT) Received: from localhost ([::1]:43738 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dalEM-0001rp-81 for importer@patchew.org; Thu, 27 Jul 2017 12:01:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58925) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal44-0008GT-CN for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dal41-0006XY-49 for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57495) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dal40-0006Wx-VA for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:01 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 99B06C05FFD7; Thu, 27 Jul 2017 15:42:15 +0000 (UTC) Received: from localhost (ovpn-112-42.ams2.redhat.com [10.36.112.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3CBED1801F; Thu, 27 Jul 2017 15:42:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 99B06C05FFD7 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 17:41:15 +0200 Message-Id: <20170727154126.11339-16-marcandre.lureau@redhat.com> In-Reply-To: <20170727154126.11339-1-marcandre.lureau@redhat.com> References: <20170727154126.11339-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 27 Jul 2017 15:42:15 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 15/26] qapi2texi: add condition to variants X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Michael Roth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi2texi.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py index b2c9a9f335..502f1e7c6a 100755 --- a/scripts/qapi2texi.py +++ b/scripts/qapi2texi.py @@ -163,8 +163,9 @@ def texi_members(doc, what, base, variants, member_func= ): items +=3D '@item The members of @code{%s}\n' % base.doc_type() if variants: for v in variants.variants: - when =3D ' when @code{%s} is @t{"%s"}' % ( - variants.tag_member.name, v.name) + when =3D ' when @code{%s} is @t{"%s"}%s' % ( + variants.tag_member.name, v.name, + ' (and @code{%s})' % v.ifcond if v.ifcond else '') if v.type.is_implicit(): assert not v.type.base and not v.type.variants for m in v.type.local_members: --=20 2.14.0.rc0.1.g40ca67566 From nobody Fri May 3 05:56:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501170910817233.80231709084603; Thu, 27 Jul 2017 08:55:10 -0700 (PDT) Received: from localhost ([::1]:43700 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal7y-0003p5-9l for importer@patchew.org; Thu, 27 Jul 2017 11:55:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56123) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal23-0005nV-DH for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:49:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dal20-0004dA-9n for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:48:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52438) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dal1z-0004cQ-W6 for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:48:56 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2598AC0E722D for ; Thu, 27 Jul 2017 15:42:19 +0000 (UTC) Received: from localhost (ovpn-112-42.ams2.redhat.com [10.36.112.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id BDC2653CEE; Thu, 27 Jul 2017 15:42:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2598AC0E722D Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 17:41:16 +0200 Message-Id: <20170727154126.11339-17-marcandre.lureau@redhat.com> In-Reply-To: <20170727154126.11339-1-marcandre.lureau@redhat.com> References: <20170727154126.11339-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 27 Jul 2017 15:42:19 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 16/26] qapi: add conditions to VNC type/commands/events on the schema X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Dr. David Alan Gilbert" , Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add #if defined(CONFIG_VNC) in generated code, and adjust the qmp/hmp code accordingly. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Dr. David Alan Gilbert --- qapi-schema.json | 34 ++++++++++++++++++++++------------ qapi/event.json | 9 ++++++--- hmp.c | 14 +++++++++++++- qmp.c | 30 ++++-------------------------- 4 files changed, 45 insertions(+), 42 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index 9c6c3e1a53..829c66f9eb 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1660,7 +1660,8 @@ 'data': { 'host': 'str', 'service': 'str', 'family': 'NetworkAddressFamily', - 'websocket': 'bool' } } + 'websocket': 'bool' }, + 'if': 'defined(CONFIG_VNC)' } =20 ## # @VncServerInfo: @@ -1674,7 +1675,8 @@ ## { 'struct': 'VncServerInfo', 'base': 'VncBasicInfo', - 'data': { '*auth': 'str' } } + 'data': { '*auth': 'str' }, + 'if': 'defined(CONFIG_VNC)' } =20 ## # @VncClientInfo: @@ -1691,7 +1693,8 @@ ## { 'struct': 'VncClientInfo', 'base': 'VncBasicInfo', - 'data': { '*x509_dname': 'str', '*sasl_username': 'str' } } + 'data': { '*x509_dname': 'str', '*sasl_username': 'str' }, + 'if': 'defined(CONFIG_VNC)' } =20 ## # @VncInfo: @@ -1732,7 +1735,8 @@ { 'struct': 'VncInfo', 'data': {'enabled': 'bool', '*host': 'str', '*family': 'NetworkAddressFamily', - '*service': 'str', '*auth': 'str', '*clients': ['VncClientInfo'= ]} } + '*service': 'str', '*auth': 'str', '*clients': ['VncClientInfo'= ]}, + 'if': 'defined(CONFIG_VNC)' } =20 ## # @VncPrimaryAuth: @@ -1743,7 +1747,8 @@ ## { 'enum': 'VncPrimaryAuth', 'data': [ 'none', 'vnc', 'ra2', 'ra2ne', 'tight', 'ultra', - 'tls', 'vencrypt', 'sasl' ] } + 'tls', 'vencrypt', 'sasl' ], + 'if': 'defined(CONFIG_VNC)' } =20 ## # @VncVencryptSubAuth: @@ -1757,7 +1762,8 @@ 'tls-none', 'x509-none', 'tls-vnc', 'x509-vnc', 'tls-plain', 'x509-plain', - 'tls-sasl', 'x509-sasl' ] } + 'tls-sasl', 'x509-sasl' ], + 'if': 'defined(CONFIG_VNC)' } =20 =20 ## @@ -1775,7 +1781,8 @@ { 'struct': 'VncServerInfo2', 'base': 'VncBasicInfo', 'data': { 'auth' : 'VncPrimaryAuth', - '*vencrypt' : 'VncVencryptSubAuth' } } + '*vencrypt' : 'VncVencryptSubAuth' }, + 'if': 'defined(CONFIG_VNC)' } =20 =20 ## @@ -1808,7 +1815,8 @@ 'clients' : ['VncClientInfo'], 'auth' : 'VncPrimaryAuth', '*vencrypt' : 'VncVencryptSubAuth', - '*display' : 'str' } } + '*display' : 'str' }, + 'if': 'defined(CONFIG_VNC)' } =20 ## # @query-vnc: @@ -1839,7 +1847,8 @@ # } # ## -{ 'command': 'query-vnc', 'returns': 'VncInfo' } +{ 'command': 'query-vnc', 'returns': 'VncInfo', + 'if': 'defined(CONFIG_VNC)' } =20 ## # @query-vnc-servers: @@ -1850,7 +1859,8 @@ # # Since: 2.3 ## -{ 'command': 'query-vnc-servers', 'returns': ['VncInfo2'] } +{ 'command': 'query-vnc-servers', 'returns': ['VncInfo2'], + 'if': 'defined(CONFIG_VNC)' } =20 ## # @SpiceBasicInfo: @@ -3077,8 +3087,8 @@ # Notes: An empty password in this command will set the password to the e= mpty # string. Existing clients are unaffected by executing this comma= nd. ## -{ 'command': 'change-vnc-password', 'data': {'password': 'str'} } - +{ 'command': 'change-vnc-password', 'data': {'password': 'str'}, + 'if': 'defined(CONFIG_VNC)' } ## # @change: # diff --git a/qapi/event.json b/qapi/event.json index 6d22b025cc..c8b8e9f384 100644 --- a/qapi/event.json +++ b/qapi/event.json @@ -263,7 +263,8 @@ ## { 'event': 'VNC_CONNECTED', 'data': { 'server': 'VncServerInfo', - 'client': 'VncBasicInfo' } } + 'client': 'VncBasicInfo' }, + 'if': 'defined(CONFIG_VNC)' } =20 ## # @VNC_INITIALIZED: @@ -290,7 +291,8 @@ ## { 'event': 'VNC_INITIALIZED', 'data': { 'server': 'VncServerInfo', - 'client': 'VncClientInfo' } } + 'client': 'VncClientInfo' }, + 'if': 'defined(CONFIG_VNC)' } =20 ## # @VNC_DISCONNECTED: @@ -316,7 +318,8 @@ ## { 'event': 'VNC_DISCONNECTED', 'data': { 'server': 'VncServerInfo', - 'client': 'VncClientInfo' } } + 'client': 'VncClientInfo' }, + 'if': 'defined(CONFIG_VNC)' } =20 ## # @SPICE_CONNECTED: diff --git a/hmp.c b/hmp.c index fd80dce758..9454c634bd 100644 --- a/hmp.c +++ b/hmp.c @@ -605,6 +605,7 @@ void hmp_info_blockstats(Monitor *mon, const QDict *qdi= ct) qapi_free_BlockStatsList(stats_list); } =20 +#ifdef CONFIG_VNC /* Helper for hmp_info_vnc_clients, _servers */ static void hmp_info_VncBasicInfo(Monitor *mon, VncBasicInfo *info, const char *name) @@ -692,6 +693,12 @@ void hmp_info_vnc(Monitor *mon, const QDict *qdict) qapi_free_VncInfo2List(info2l); =20 } +#else +void hmp_info_vnc(Monitor *mon, const QDict *qdict) +{ + warn_report("VNC support is disabled"); +} +#endif =20 #ifdef CONFIG_SPICE void hmp_info_spice(Monitor *mon, const QDict *qdict) @@ -1708,12 +1715,14 @@ void hmp_eject(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, &err); } =20 +#ifdef CONFIG_VNC static void hmp_change_read_arg(void *opaque, const char *password, void *readline_opaque) { qmp_change_vnc_password(password, NULL); monitor_read_command(opaque, 1); } +#endif =20 void hmp_change(Monitor *mon, const QDict *qdict) { @@ -1724,6 +1733,7 @@ void hmp_change(Monitor *mon, const QDict *qdict) BlockdevChangeReadOnlyMode read_only_mode =3D 0; Error *err =3D NULL; =20 +#ifdef CONFIG_VNC if (strcmp(device, "vnc") =3D=3D 0) { if (read_only) { monitor_printf(mon, @@ -1738,7 +1748,9 @@ void hmp_change(Monitor *mon, const QDict *qdict) } } qmp_change("vnc", target, !!arg, arg, &err); - } else { + } else +#endif + { if (read_only) { read_only_mode =3D qapi_enum_parse(BlockdevChangeReadOnlyMode_lookup, diff --git a/qmp.c b/qmp.c index b86201e349..2c90dacb56 100644 --- a/qmp.c +++ b/qmp.c @@ -130,22 +130,6 @@ void qmp_cpu_add(int64_t id, Error **errp) } } =20 -#ifndef CONFIG_VNC -/* If VNC support is enabled, the "true" query-vnc command is - defined in the VNC subsystem */ -VncInfo *qmp_query_vnc(Error **errp) -{ - error_setg(errp, QERR_FEATURE_DISABLED, "vnc"); - return NULL; -}; - -VncInfo2List *qmp_query_vnc_servers(Error **errp) -{ - error_setg(errp, QERR_FEATURE_DISABLED, "vnc"); - return NULL; -}; -#endif - #ifndef CONFIG_SPICE /* * qmp-commands.hx ensures that QMP command query-spice exists only @@ -403,23 +387,17 @@ static void qmp_change_vnc(const char *target, bool h= as_arg, const char *arg, qmp_change_vnc_listen(target, errp); } } -#else -void qmp_change_vnc_password(const char *password, Error **errp) -{ - error_setg(errp, QERR_FEATURE_DISABLED, "vnc"); -} -static void qmp_change_vnc(const char *target, bool has_arg, const char *a= rg, - Error **errp) -{ - error_setg(errp, QERR_FEATURE_DISABLED, "vnc"); -} #endif /* !CONFIG_VNC */ =20 void qmp_change(const char *device, const char *target, bool has_arg, const char *arg, Error **errp) { if (strcmp(device, "vnc") =3D=3D 0) { +#ifdef CONFIG_VNC qmp_change_vnc(target, has_arg, arg, errp); +#else + error_setg(errp, QERR_FEATURE_DISABLED, "vnc"); +#endif } else { qmp_blockdev_change_medium(true, device, false, NULL, target, has_arg, arg, false, 0, errp); --=20 2.14.0.rc0.1.g40ca67566 From nobody Fri May 3 05:56:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501171653274550.1034754591125; Thu, 27 Jul 2017 09:07:33 -0700 (PDT) Received: from localhost ([::1]:43767 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dalJw-0006ED-LD for importer@patchew.org; Thu, 27 Jul 2017 12:07:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32845) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal4x-0000cs-KY for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:52:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dal4v-0007Mw-EG for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43946) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dal4v-0007Ld-3b for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:57 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B8EFDADAF0 for ; Thu, 27 Jul 2017 15:42:20 +0000 (UTC) Received: from localhost (ovpn-112-42.ams2.redhat.com [10.36.112.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D16B18231; Thu, 27 Jul 2017 15:42:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B8EFDADAF0 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 17:41:17 +0200 Message-Id: <20170727154126.11339-18-marcandre.lureau@redhat.com> In-Reply-To: <20170727154126.11339-1-marcandre.lureau@redhat.com> References: <20170727154126.11339-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 27 Jul 2017 15:42:20 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 17/26] qapi: add conditions to SPICE type/commands/events on the schema X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add #if defined(CONFIG_SPICE) in generated code, and adjust the qmp/hmp code accordingly. Signed-off-by: Marc-Andr=C3=A9 Lureau --- qapi-schema.json | 28 ++++++++++++++++++---------- qapi/event.json | 12 ++++++++---- monitor.c | 3 --- qmp.c | 16 ---------------- 4 files changed, 26 insertions(+), 33 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index 829c66f9eb..bcee3157b0 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1878,7 +1878,8 @@ { 'struct': 'SpiceBasicInfo', 'data': { 'host': 'str', 'port': 'str', - 'family': 'NetworkAddressFamily' } } + 'family': 'NetworkAddressFamily' }, + 'if': 'defined(CONFIG_SPICE)' } =20 ## # @SpiceServerInfo: @@ -1891,7 +1892,8 @@ ## { 'struct': 'SpiceServerInfo', 'base': 'SpiceBasicInfo', - 'data': { '*auth': 'str' } } + 'data': { '*auth': 'str' }, + 'if': 'defined(CONFIG_SPICE)' } =20 ## # @SpiceChannel: @@ -1916,7 +1918,8 @@ { 'struct': 'SpiceChannel', 'base': 'SpiceBasicInfo', 'data': {'connection-id': 'int', 'channel-type': 'int', 'channel-id': 'i= nt', - 'tls': 'bool'} } + 'tls': 'bool'}, + 'if': 'defined(CONFIG_SPICE)' } =20 ## # @SpiceQueryMouseMode: @@ -1935,7 +1938,8 @@ # Since: 1.1 ## { 'enum': 'SpiceQueryMouseMode', - 'data': [ 'client', 'server', 'unknown' ] } + 'data': [ 'client', 'server', 'unknown' ], + 'if': 'defined(CONFIG_SPICE)' } =20 ## # @SpiceInfo: @@ -1972,7 +1976,8 @@ { 'struct': 'SpiceInfo', 'data': {'enabled': 'bool', 'migrated': 'bool', '*host': 'str', '*port':= 'int', '*tls-port': 'int', '*auth': 'str', '*compiled-version': 'str', - 'mouse-mode': 'SpiceQueryMouseMode', '*channels': ['SpiceChanne= l']} } + 'mouse-mode': 'SpiceQueryMouseMode', '*channels': ['SpiceChanne= l']}, + 'if': 'defined(CONFIG_SPICE)' } =20 ## # @query-spice: @@ -2017,7 +2022,8 @@ # } # ## -{ 'command': 'query-spice', 'returns': 'SpiceInfo' } +{ 'command': 'query-spice', 'returns': 'SpiceInfo', + 'if': 'defined(CONFIG_SPICE)' } =20 ## # @BalloonInfo: @@ -5067,7 +5073,8 @@ # Since: 1.5 ## { 'struct': 'ChardevSpiceChannel', 'data': { 'type' : 'str' }, - 'base': 'ChardevCommon' } + 'base': 'ChardevCommon', + 'if': 'defined(CONFIG_SPICE)' } =20 ## # @ChardevSpicePort: @@ -5079,7 +5086,8 @@ # Since: 1.5 ## { 'struct': 'ChardevSpicePort', 'data': { 'fqdn' : 'str' }, - 'base': 'ChardevCommon' } + 'base': 'ChardevCommon', + 'if': 'defined(CONFIG_SPICE)' } =20 ## # @ChardevVC: @@ -5133,8 +5141,8 @@ 'testdev': 'ChardevCommon', 'stdio' : 'ChardevStdio', 'console': 'ChardevCommon', - 'spicevmc' : 'ChardevSpiceChannel', - 'spiceport' : 'ChardevSpicePort', + 'spicevmc' : { 'type': 'ChardevSpic= eChannel', 'if': 'defined(CONFIG_SPICE)' }, + 'spiceport' : { 'type': 'ChardevSpi= cePort', 'if': 'defined(CONFIG_SPICE)' }, 'vc' : 'ChardevVC', 'ringbuf': 'ChardevRingbuf', # next one is just for compatibility diff --git a/qapi/event.json b/qapi/event.json index c8b8e9f384..ff59551914 100644 --- a/qapi/event.json +++ b/qapi/event.json @@ -344,7 +344,8 @@ ## { 'event': 'SPICE_CONNECTED', 'data': { 'server': 'SpiceBasicInfo', - 'client': 'SpiceBasicInfo' } } + 'client': 'SpiceBasicInfo' }, + 'if': 'defined(CONFIG_SPICE)' } =20 ## # @SPICE_INITIALIZED: @@ -372,7 +373,8 @@ ## { 'event': 'SPICE_INITIALIZED', 'data': { 'server': 'SpiceServerInfo', - 'client': 'SpiceChannel' } } + 'client': 'SpiceChannel' }, + 'if': 'defined(CONFIG_SPICE)' } =20 ## # @SPICE_DISCONNECTED: @@ -397,7 +399,8 @@ ## { 'event': 'SPICE_DISCONNECTED', 'data': { 'server': 'SpiceBasicInfo', - 'client': 'SpiceBasicInfo' } } + 'client': 'SpiceBasicInfo' }, + 'if': 'defined(CONFIG_SPICE)' } =20 ## # @SPICE_MIGRATE_COMPLETED: @@ -412,7 +415,8 @@ # "event": "SPICE_MIGRATE_COMPLETED" } # ## -{ 'event': 'SPICE_MIGRATE_COMPLETED' } +{ 'event': 'SPICE_MIGRATE_COMPLETED', + 'if': 'defined(CONFIG_SPICE)' } =20 ## # @MIGRATION: diff --git a/monitor.c b/monitor.c index a1773d5bc7..4bf6a3ea2e 100644 --- a/monitor.c +++ b/monitor.c @@ -970,9 +970,6 @@ static void qmp_query_qmp_schema(QDict *qdict, QObject = **ret_data, */ static void qmp_unregister_commands_hack(void) { -#ifndef CONFIG_SPICE - qmp_unregister_command(&qmp_commands, "query-spice"); -#endif #ifndef CONFIG_REPLICATION qmp_unregister_command(&qmp_commands, "xen-set-replication"); qmp_unregister_command(&qmp_commands, "query-xen-replication-status"); diff --git a/qmp.c b/qmp.c index 2c90dacb56..90816ba283 100644 --- a/qmp.c +++ b/qmp.c @@ -130,22 +130,6 @@ void qmp_cpu_add(int64_t id, Error **errp) } } =20 -#ifndef CONFIG_SPICE -/* - * qmp-commands.hx ensures that QMP command query-spice exists only - * #ifdef CONFIG_SPICE. Necessary for an accurate query-commands - * result. However, the QAPI schema is blissfully unaware of that, - * and the QAPI code generator happily generates a dead - * qmp_marshal_query_spice() that calls qmp_query_spice(). Provide it - * one, or else linking fails. FIXME Educate the QAPI schema on - * CONFIG_SPICE. - */ -SpiceInfo *qmp_query_spice(Error **errp) -{ - abort(); -}; -#endif - void qmp_cont(Error **errp) { BlockBackend *blk; --=20 2.14.0.rc0.1.g40ca67566 From nobody Fri May 3 05:56:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150117106182288.96190755689088; Thu, 27 Jul 2017 08:57:41 -0700 (PDT) Received: from localhost ([::1]:43714 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dalAR-00060Y-CY for importer@patchew.org; Thu, 27 Jul 2017 11:57:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59154) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal4D-0008PY-Ck for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dal4A-0006cT-7t for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33360) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dal49-0006bv-Vx for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:10 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 131E2633E1; Thu, 27 Jul 2017 15:42:24 +0000 (UTC) Received: from localhost (ovpn-112-42.ams2.redhat.com [10.36.112.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA4BE5D9C9; Thu, 27 Jul 2017 15:42:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 131E2633E1 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 17:41:18 +0200 Message-Id: <20170727154126.11339-19-marcandre.lureau@redhat.com> In-Reply-To: <20170727154126.11339-1-marcandre.lureau@redhat.com> References: <20170727154126.11339-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 27 Jul 2017 15:42:24 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 18/26] qapi: add conditions to REPLICATION type/commands on the schema X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: zhanghailiang , Juan Quintela , Markus Armbruster , "Dr. David Alan Gilbert" , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add #if defined(CONFIG_REPLICATION) in generated code, and adjust the code accordingly. Signed-off-by: Marc-Andr=C3=A9 Lureau --- qapi-schema.json | 12 ++++++++---- migration/colo.c | 14 ++------------ monitor.c | 5 ----- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index bcee3157b0..2f4528c769 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -6337,7 +6337,8 @@ # Since: 2.9 ## { 'command': 'xen-set-replication', - 'data': { 'enable': 'bool', 'primary': 'bool', '*failover' : 'bool' } } + 'data': { 'enable': 'bool', 'primary': 'bool', '*failover' : 'bool' }, + 'if': 'defined(CONFIG_REPLICATION)' } =20 ## # @ReplicationStatus: @@ -6352,7 +6353,8 @@ # Since: 2.9 ## { 'struct': 'ReplicationStatus', - 'data': { 'error': 'bool', '*desc': 'str' } } + 'data': { 'error': 'bool', '*desc': 'str' }, + 'if': 'defined(CONFIG_REPLICATION)' } =20 ## # @query-xen-replication-status: @@ -6369,7 +6371,8 @@ # Since: 2.9 ## { 'command': 'query-xen-replication-status', - 'returns': 'ReplicationStatus' } + 'returns': 'ReplicationStatus', + 'if': 'defined(CONFIG_REPLICATION)' } =20 ## # @xen-colo-do-checkpoint: @@ -6385,7 +6388,8 @@ # # Since: 2.9 ## -{ 'command': 'xen-colo-do-checkpoint' } +{ 'command': 'xen-colo-do-checkpoint', + 'if': 'defined(CONFIG_REPLICATION)' } =20 ## # @GICCapability: diff --git a/migration/colo.c b/migration/colo.c index a4255432ac..3bff9fc9a4 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -147,11 +147,11 @@ void colo_do_failover(MigrationState *s) } } =20 +#ifdef CONFIG_REPLICATION void qmp_xen_set_replication(bool enable, bool primary, bool has_failover, bool failover, Error **errp) { -#ifdef CONFIG_REPLICATION ReplicationMode mode =3D primary ? REPLICATION_MODE_PRIMARY : REPLICATION_MODE_SECONDARY; @@ -170,14 +170,10 @@ void qmp_xen_set_replication(bool enable, bool primar= y, } replication_stop_all(failover, failover ? NULL : errp); } -#else - abort(); -#endif } =20 ReplicationStatus *qmp_query_xen_replication_status(Error **errp) { -#ifdef CONFIG_REPLICATION Error *err =3D NULL; ReplicationStatus *s =3D g_new0(ReplicationStatus, 1); =20 @@ -192,19 +188,13 @@ ReplicationStatus *qmp_query_xen_replication_status(E= rror **errp) =20 error_free(err); return s; -#else - abort(); -#endif } =20 void qmp_xen_colo_do_checkpoint(Error **errp) { -#ifdef CONFIG_REPLICATION replication_do_checkpoint_all(errp); -#else - abort(); -#endif } +#endif =20 static void colo_send_message(QEMUFile *f, COLOMessage msg, Error **errp) diff --git a/monitor.c b/monitor.c index 4bf6a3ea2e..383c84d162 100644 --- a/monitor.c +++ b/monitor.c @@ -970,11 +970,6 @@ static void qmp_query_qmp_schema(QDict *qdict, QObject= **ret_data, */ static void qmp_unregister_commands_hack(void) { -#ifndef CONFIG_REPLICATION - qmp_unregister_command(&qmp_commands, "xen-set-replication"); - qmp_unregister_command(&qmp_commands, "query-xen-replication-status"); - qmp_unregister_command(&qmp_commands, "xen-colo-do-checkpoint"); -#endif #ifndef TARGET_I386 qmp_unregister_command(&qmp_commands, "rtc-reset-reinjection"); #endif --=20 2.14.0.rc0.1.g40ca67566 From nobody Fri May 3 05:56:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501170845296569.491811063994; Thu, 27 Jul 2017 08:54:05 -0700 (PDT) Received: from localhost ([::1]:43697 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal6x-0002DD-Sl for importer@patchew.org; Thu, 27 Jul 2017 11:54:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal23-0005nX-EU for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:49:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dal20-0004d5-8S for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:48:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52434) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dal1z-0004cO-WC for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:48:56 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 98D64C0733FC for ; Thu, 27 Jul 2017 15:42:25 +0000 (UTC) Received: from localhost (ovpn-112-42.ams2.redhat.com [10.36.112.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D0BC60BE3; Thu, 27 Jul 2017 15:42:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 98D64C0733FC Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 17:41:19 +0200 Message-Id: <20170727154126.11339-20-marcandre.lureau@redhat.com> In-Reply-To: <20170727154126.11339-1-marcandre.lureau@redhat.com> References: <20170727154126.11339-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 27 Jul 2017 15:42:25 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 19/26] build-sys: move qapi variables in qapi.mak X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau --- Makefile | 43 +++++++++++++++++-------------------------- qapi.mak | 14 ++++++++++++++ 2 files changed, 31 insertions(+), 26 deletions(-) create mode 100644 qapi.mak diff --git a/Makefile b/Makefile index ef721480eb..8cd30fd88e 100644 --- a/Makefile +++ b/Makefile @@ -50,6 +50,7 @@ endif endif =20 include $(SRC_PATH)/rules.mak +include $(SRC_PATH)/qapi.mak =20 GENERATED_FILES =3D qemu-version.h config-host.h qemu-options.def GENERATED_FILES +=3D qmp-commands.h qapi-types.h qapi-visit.h qapi-event.h @@ -390,56 +391,46 @@ qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_P= ATH)/scripts/hxtool qemu-ga$(EXESUF): LIBS =3D $(LIBS_QGA) qemu-ga$(EXESUF): QEMU_CFLAGS +=3D -I qga/qapi-generated =20 -gen-out-type =3D $(subst .,-,$(suffix $@)) - -qapi-py =3D $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py - qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\ -$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-= py) +$(SRC_PATH)/qga/qapi-schema.json $(qapi-types-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \ - $(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \ + $(qapi-gen-type) -o qga/qapi-generated -p "qga-" $<, \ "GEN","$@") qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h :\ -$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-= py) +$(SRC_PATH)/qga/qapi-schema.json $(qapi-visit-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \ - $(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \ + $(qapi-gen-type) -o qga/qapi-generated -p "qga-" $<, \ "GEN","$@") qga/qapi-generated/qga-qmp-commands.h qga/qapi-generated/qga-qmp-marshal.c= :\ -$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qa= pi-py) +$(SRC_PATH)/qga/qapi-schema.json $(qapi-commands-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \ - $(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \ + $(qapi-gen-type) -o qga/qapi-generated -p "qga-" $<, \ "GEN","$@") =20 -qapi-modules =3D $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json= \ - $(SRC_PATH)/qapi/block.json $(SRC_PATH)/qapi/block-core.jso= n \ - $(SRC_PATH)/qapi/event.json $(SRC_PATH)/qapi/introspect.jso= n \ - $(SRC_PATH)/qapi/crypto.json $(SRC_PATH)/qapi/rocker.json \ - $(SRC_PATH)/qapi/trace.json - qapi-types.c qapi-types.h :\ -$(qapi-modules) $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) +$(qapi-modules) $(qapi-types-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \ - $(gen-out-type) -o "." -b $<, \ + $(qapi-gen-type) -o "." -b $<, \ "GEN","$@") qapi-visit.c qapi-visit.h :\ -$(qapi-modules) $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) +$(qapi-modules) $(qapi-visit-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \ - $(gen-out-type) -o "." -b $<, \ + $(qapi-gen-type) -o "." -b $<, \ "GEN","$@") qapi-event.c qapi-event.h :\ -$(qapi-modules) $(SRC_PATH)/scripts/qapi-event.py $(qapi-py) +$(qapi-modules) $(qapi-event-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-event.py \ - $(gen-out-type) -o "." $<, \ + $(qapi-gen-type) -o "." $<, \ "GEN","$@") qmp-commands.h qmp-marshal.c :\ -$(qapi-modules) $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) +$(qapi-modules) $(qapi-commands-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \ - $(gen-out-type) -o "." $<, \ + $(qapi-gen-type) -o "." $<, \ "GEN","$@") qmp-introspect.h qmp-introspect.c :\ -$(qapi-modules) $(SRC_PATH)/scripts/qapi-introspect.py $(qapi-py) +$(qapi-modules) $(qapi-introspect-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-introspect.py \ - $(gen-out-type) -o "." $<, \ + $(qapi-gen-type) -o "." $<, \ "GEN","$@") =20 QGALIB_GEN=3D$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-vi= sit.h qga-qmp-commands.h) diff --git a/qapi.mak b/qapi.mak new file mode 100644 index 0000000000..70196127d9 --- /dev/null +++ b/qapi.mak @@ -0,0 +1,14 @@ +qapi-gen-type =3D $(subst .,-,$(suffix $@)) + +qapi-modules =3D $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json= \ + $(SRC_PATH)/qapi/block.json $(SRC_PATH)/qapi/block-core.json \ + $(SRC_PATH)/qapi/event.json $(SRC_PATH)/qapi/introspect.json \ + $(SRC_PATH)/qapi/crypto.json $(SRC_PATH)/qapi/rocker.json \ + $(SRC_PATH)/qapi/trace.json + +qapi-py =3D $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py +qapi-types-py =3D $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) +qapi-visit-py =3D $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) +qapi-commands-py =3D $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) +qapi-introspect-py =3D $(SRC_PATH)/scripts/qapi-introspect.py $(qapi-py) + --=20 2.14.0.rc0.1.g40ca67566 From nobody Fri May 3 05:56:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15011706246101015.299337405195; Thu, 27 Jul 2017 08:50:24 -0700 (PDT) Received: from localhost ([::1]:43682 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal3J-0007Fi-5g for importer@patchew.org; Thu, 27 Jul 2017 11:50:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55685) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal1W-0005AZ-3c for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:48:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dal1V-0004PO-2z for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:48:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43500) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dal1U-0004Oq-Sj for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:48:25 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1D0711287 for ; Thu, 27 Jul 2017 15:42:27 +0000 (UTC) Received: from localhost (ovpn-112-42.ams2.redhat.com [10.36.112.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB12C5C269; Thu, 27 Jul 2017 15:42:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1D0711287 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 17:41:20 +0200 Message-Id: <20170727154126.11339-21-marcandre.lureau@redhat.com> In-Reply-To: <20170727154126.11339-1-marcandre.lureau@redhat.com> References: <20170727154126.11339-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 27 Jul 2017 15:42:27 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 20/26] tests/qmp-test: add query-qmp-schema test X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The following patch is going to make qmp introspection per-target, and test-qobject-input-visitor.c can no longer link with qmp_schema_qlit. Use a run-time QMP test instead to validate the query-qmp-schema schema. Signed-off-by: Marc-Andr=C3=A9 Lureau --- tests/qmp-test.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/qmp-test.c b/tests/qmp-test.c index 5d0260b2be..1fd37092b5 100644 --- a/tests/qmp-test.c +++ b/tests/qmp-test.c @@ -129,11 +129,32 @@ static void test_qmp_protocol(void) qtest_end(); } =20 +static void test_qmp_query_schema(void) +{ + SchemaInfoList *schema; + QDict *resp; + Visitor *v; + + qtest_start(common_args); + + resp =3D qmp("{'execute': 'query-qmp-schema'}"); + v =3D qobject_input_visitor_new(qdict_get(resp, "return")); + visit_type_SchemaInfoList(v, NULL, &schema, &error_abort); + g_assert(schema); + + qapi_free_SchemaInfoList(schema); + visit_free(v); + QDECREF(resp); + + qtest_end(); +} + int main(int argc, char *argv[]) { g_test_init(&argc, &argv, NULL); =20 qtest_add_func("qmp/protocol", test_qmp_protocol); + qtest_add_func("qmp/query-schema", test_qmp_query_schema); =20 return g_test_run(); } --=20 2.14.0.rc0.1.g40ca67566 From nobody Fri May 3 05:56:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501171507223423.69450438282524; Thu, 27 Jul 2017 09:05:07 -0700 (PDT) Received: from localhost ([::1]:43747 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dalHc-0004Ij-HE for importer@patchew.org; Thu, 27 Jul 2017 12:05:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58927) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal44-0008GW-CV for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dal41-0006Xq-7p for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50356) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dal40-0006Ww-VW for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:01 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 999B0C01CB86; Thu, 27 Jul 2017 15:42:30 +0000 (UTC) Received: from localhost (ovpn-112-42.ams2.redhat.com [10.36.112.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 51DCE5C269; Thu, 27 Jul 2017 15:42:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 999B0C01CB86 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 17:41:21 +0200 Message-Id: <20170727154126.11339-22-marcandre.lureau@redhat.com> In-Reply-To: <20170727154126.11339-1-marcandre.lureau@redhat.com> References: <20170727154126.11339-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 27 Jul 2017 15:42:30 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 21/26] build-sys: make qemu qapi objects per-target X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Roth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Stefan Hajnoczi , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The qapi schema has per-target definitions. Move qapi objects in the per-target build, so they can be configured at compile time. Keep qapi-types.o qapi-visit.o in util-obj as they are necessary for common code, but they will be overwritten during the target link. Add some stubs for block events, in code shared by tools & qemu. The following patch will configure the schema to conditionally remove per-target disabled features. Signed-off-by: Marc-Andr=C3=A9 Lureau --- stubs/qapi-event.c | 74 ++++++++++++++++++++++++++++++++++= ++++ tests/test-qobject-input-visitor.c | 1 - Makefile.objs | 9 +---- Makefile.target | 4 +++ stubs/Makefile.objs | 1 + trace/Makefile.objs | 2 +- 6 files changed, 81 insertions(+), 10 deletions(-) create mode 100644 stubs/qapi-event.c diff --git a/stubs/qapi-event.c b/stubs/qapi-event.c new file mode 100644 index 0000000000..9415299f3a --- /dev/null +++ b/stubs/qapi-event.c @@ -0,0 +1,74 @@ +#include "qemu/osdep.h" +#include "qapi-event.h" + +void qapi_event_send_device_tray_moved(const char *device, const char *id, + bool tray_open, Error **errp) +{ +} + +void qapi_event_send_quorum_report_bad(QuorumOpType type, bool has_error, + const char *error, const char *node= _name, + int64_t sector_num, + int64_t sectors_count, Error **errp) +{ +} + +void qapi_event_send_quorum_failure(const char *reference, int64_t sector_= num, + int64_t sectors_count, Error **errp) +{ +} + +void qapi_event_send_block_job_cancelled(BlockJobType type, const char *de= vice, + int64_t len, int64_t offset, + int64_t speed, Error **errp) +{ +} + +void qapi_event_send_block_job_completed(BlockJobType type, const char *de= vice, + int64_t len, int64_t offset, + int64_t speed, bool has_error, + const char *error, Error **errp) +{ +} + +void qapi_event_send_block_job_error(const char *device, + IoOperationType operation, + BlockErrorAction action, Error **errp) +{ +} + +void qapi_event_send_block_job_ready(BlockJobType type, const char *device, + int64_t len, int64_t offset, int64_t = speed, + Error **errp) +{ +} + +void qapi_event_send_block_io_error(const char *device, const char *node_n= ame, + IoOperationType operation, + BlockErrorAction action, bool has_nosp= ace, + bool nospace, const char *reason, + Error **errp) +{ +} + +void qapi_event_send_block_image_corrupted(const char *device, + bool has_node_name, + const char *node_name, + const char *msg, bool has_offse= t, + int64_t offset, bool has_size, + int64_t size, bool fatal, + Error **errp) +{ +} + +void qapi_event_send_block_write_threshold(const char *node_name, + uint64_t amount_exceeded, + uint64_t write_threshold, + Error **errp) +{ +} + +void qapi_event_send_device_deleted(bool has_device, const char *device, + const char *path, Error **errp) +{ +} diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-= visitor.c index 4da5d02c35..0a9352c5c1 100644 --- a/tests/test-qobject-input-visitor.c +++ b/tests/test-qobject-input-visitor.c @@ -1266,7 +1266,6 @@ static void test_visitor_in_qmp_introspect(TestInputV= isitorData *data, const void *unused) { do_test_visitor_in_qmp_introspect(data, &test_qmp_schema_qlit); - do_test_visitor_in_qmp_introspect(data, &qmp_schema_qlit); } =20 int main(int argc, char **argv) diff --git a/Makefile.objs b/Makefile.objs index 24a4ea08b8..2664720f9b 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -2,7 +2,7 @@ # Common libraries for tools and emulators stub-obj-y =3D stubs/ crypto/ util-obj-y =3D util/ qobject/ qapi/ -util-obj-y +=3D qmp-introspect.o qapi-types.o qapi-visit.o qapi-event.o +util-obj-y +=3D qapi-types.o qapi-visit.o =20 chardev-obj-y =3D chardev/ =20 @@ -72,13 +72,6 @@ common-obj-y +=3D chardev/ common-obj-$(CONFIG_SECCOMP) +=3D qemu-seccomp.o =20 common-obj-$(CONFIG_FDT) +=3D device_tree.o - -###################################################################### -# qapi - -common-obj-y +=3D qmp-marshal.o -common-obj-y +=3D qmp-introspect.o -common-obj-y +=3D qmp.o hmp.o endif =20 ####################################################################### diff --git a/Makefile.target b/Makefile.target index 2baec9252f..a97dd056ad 100644 --- a/Makefile.target +++ b/Makefile.target @@ -154,6 +154,10 @@ endif =20 GENERATED_FILES +=3D hmp-commands.h hmp-commands-info.h =20 +obj-y +=3D qmp-introspect.o qapi-types.o qapi-visit.o qapi-event.o +obj-y +=3D qmp-marshal.o qmp-introspect.o +obj-y +=3D qmp.o hmp.o + endif # CONFIG_SOFTMMU =20 # Workaround for http://gcc.gnu.org/PR55489, see configure. diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs index f5b47bfd74..1b2bef99c9 100644 --- a/stubs/Makefile.objs +++ b/stubs/Makefile.objs @@ -21,6 +21,7 @@ stub-obj-y +=3D machine-init-done.o stub-obj-y +=3D migr-blocker.o stub-obj-y +=3D monitor.o stub-obj-y +=3D notify-event.o +stub-obj-y +=3D qapi-event.o stub-obj-y +=3D qtest.o stub-obj-y +=3D replay.o stub-obj-y +=3D runstate-check.o diff --git a/trace/Makefile.objs b/trace/Makefile.objs index afd571c3ec..6447729d60 100644 --- a/trace/Makefile.objs +++ b/trace/Makefile.objs @@ -56,4 +56,4 @@ util-obj-$(CONFIG_TRACE_SIMPLE) +=3D simple.o util-obj-$(CONFIG_TRACE_FTRACE) +=3D ftrace.o util-obj-y +=3D control.o target-obj-y +=3D control-target.o -util-obj-y +=3D qmp.o +target-obj-y +=3D qmp.o --=20 2.14.0.rc0.1.g40ca67566 From nobody Fri May 3 05:56:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501170758623757.6918719573432; Thu, 27 Jul 2017 08:52:38 -0700 (PDT) Received: from localhost ([::1]:43692 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal5V-0000lt-UY for importer@patchew.org; Thu, 27 Jul 2017 11:52:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55684) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal1W-0005AW-3C for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:48:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dal1V-0004PT-3e for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:48:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43508) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dal1U-0004Or-Tr for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:48:25 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EA64919D4D1 for ; Thu, 27 Jul 2017 15:42:33 +0000 (UTC) Received: from localhost (ovpn-112-42.ams2.redhat.com [10.36.112.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD0451801F; Thu, 27 Jul 2017 15:42:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EA64919D4D1 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 17:41:22 +0200 Message-Id: <20170727154126.11339-23-marcandre.lureau@redhat.com> In-Reply-To: <20170727154126.11339-1-marcandre.lureau@redhat.com> References: <20170727154126.11339-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 27 Jul 2017 15:42:34 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 22/26] qapi: make rtc-reset-reinjection depend on TARGET_I386 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau --- qapi-schema.json | 3 ++- monitor.c | 10 ---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index 2f4528c769..2361c13fc8 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -6270,7 +6270,8 @@ # <- { "return": {} } # ## -{ 'command': 'rtc-reset-reinjection' } +{ 'command': 'rtc-reset-reinjection', + 'if': ['defined(NEED_CPU_H)', 'defined(TARGET_I386)'] } =20 # Rocker ethernet network switch { 'include': 'qapi/rocker.json' } diff --git a/monitor.c b/monitor.c index 383c84d162..f3dafafa22 100644 --- a/monitor.c +++ b/monitor.c @@ -970,9 +970,6 @@ static void qmp_query_qmp_schema(QDict *qdict, QObject = **ret_data, */ static void qmp_unregister_commands_hack(void) { -#ifndef TARGET_I386 - qmp_unregister_command(&qmp_commands, "rtc-reset-reinjection"); -#endif #ifndef TARGET_S390X qmp_unregister_command(&qmp_commands, "dump-skeys"); #endif @@ -4151,13 +4148,6 @@ QemuOptsList qemu_mon_opts =3D { }, }; =20 -#ifndef TARGET_I386 -void qmp_rtc_reset_reinjection(Error **errp) -{ - error_setg(errp, QERR_FEATURE_DISABLED, "rtc-reset-reinjection"); -} -#endif - #ifndef TARGET_S390X void qmp_dump_skeys(const char *filename, Error **errp) { --=20 2.14.0.rc0.1.g40ca67566 From nobody Fri May 3 05:56:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501170999310584.5911939254354; Thu, 27 Jul 2017 08:56:39 -0700 (PDT) Received: from localhost ([::1]:43711 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal9M-00055P-3s for importer@patchew.org; Thu, 27 Jul 2017 11:56:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56122) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal23-0005nU-DW for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:49:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dal21-0004dP-6J for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:48:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52556) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dal20-0004dC-T9 for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:48:57 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F07D3C0B7737; Thu, 27 Jul 2017 15:42:37 +0000 (UTC) Received: from localhost (ovpn-112-42.ams2.redhat.com [10.36.112.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A7596F9FD; Thu, 27 Jul 2017 15:42:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com F07D3C0B7737 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 17:41:23 +0200 Message-Id: <20170727154126.11339-24-marcandre.lureau@redhat.com> In-Reply-To: <20170727154126.11339-1-marcandre.lureau@redhat.com> References: <20170727154126.11339-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 27 Jul 2017 15:42:38 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 23/26] qapi: make s390 commands depend on TARGET_S390X X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexander Graf , Markus Armbruster , "Dr. David Alan Gilbert" , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau --- qapi-schema.json | 10 +++++++--- include/sysemu/arch_init.h | 6 ------ monitor.c | 14 -------------- qmp.c | 14 -------------- stubs/arch-query-cpu-model-baseline.c | 12 ------------ stubs/arch-query-cpu-model-comparison.c | 12 ------------ target/s390x/cpu_models.c | 4 ++-- stubs/Makefile.objs | 2 -- 8 files changed, 9 insertions(+), 65 deletions(-) delete mode 100644 stubs/arch-query-cpu-model-baseline.c delete mode 100644 stubs/arch-query-cpu-model-comparison.c diff --git a/qapi-schema.json b/qapi-schema.json index 2361c13fc8..278d7e2aa3 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3577,7 +3577,8 @@ # ## { 'command': 'dump-skeys', - 'data': { 'filename': 'str' } } + 'data': { 'filename': 'str' }, + 'if': ['defined(NEED_CPU_H)', 'defined(TARGET_S390X)']} =20 ## # @netdev_add: @@ -4621,7 +4622,9 @@ ## { 'command': 'query-cpu-model-comparison', 'data': { 'modela': 'CpuModelInfo', 'modelb': 'CpuModelInfo' }, - 'returns': 'CpuModelCompareInfo' } + 'returns': 'CpuModelCompareInfo', + 'if': ['defined(NEED_CPU_H)', 'defined(TARGET_S390X)']} + =20 ## # @CpuModelBaselineInfo: @@ -4673,7 +4676,8 @@ { 'command': 'query-cpu-model-baseline', 'data': { 'modela': 'CpuModelInfo', 'modelb': 'CpuModelInfo' }, - 'returns': 'CpuModelBaselineInfo' } + 'returns': 'CpuModelBaselineInfo', + 'if': ['defined(NEED_CPU_H)', 'defined(TARGET_S390X)']} =20 ## # @AddfdInfo: diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h index 8751c468ed..e9f1ea0cca 100644 --- a/include/sysemu/arch_init.h +++ b/include/sysemu/arch_init.h @@ -35,11 +35,5 @@ CpuDefinitionInfoList *arch_query_cpu_definitions(Error = **errp); CpuModelExpansionInfo *arch_query_cpu_model_expansion(CpuModelExpansionTyp= e type, CpuModelInfo *mode, Error **errp); -CpuModelCompareInfo *arch_query_cpu_model_comparison(CpuModelInfo *modela, - CpuModelInfo *modelb, - Error **errp); -CpuModelBaselineInfo *arch_query_cpu_model_baseline(CpuModelInfo *modela, - CpuModelInfo *modelb, - Error **errp); =20 #endif diff --git a/monitor.c b/monitor.c index f3dafafa22..505ee5c58d 100644 --- a/monitor.c +++ b/monitor.c @@ -970,19 +970,12 @@ static void qmp_query_qmp_schema(QDict *qdict, QObjec= t **ret_data, */ static void qmp_unregister_commands_hack(void) { -#ifndef TARGET_S390X - qmp_unregister_command(&qmp_commands, "dump-skeys"); -#endif #ifndef TARGET_ARM qmp_unregister_command(&qmp_commands, "query-gic-capabilities"); #endif #if !defined(TARGET_S390X) && !defined(TARGET_I386) qmp_unregister_command(&qmp_commands, "query-cpu-model-expansion"); #endif -#if !defined(TARGET_S390X) - qmp_unregister_command(&qmp_commands, "query-cpu-model-baseline"); - qmp_unregister_command(&qmp_commands, "query-cpu-model-comparison"); -#endif #if !defined(TARGET_PPC) && !defined(TARGET_ARM) && !defined(TARGET_I386) \ && !defined(TARGET_S390X) qmp_unregister_command(&qmp_commands, "query-cpu-definitions"); @@ -4148,13 +4141,6 @@ QemuOptsList qemu_mon_opts =3D { }, }; =20 -#ifndef TARGET_S390X -void qmp_dump_skeys(const char *filename, Error **errp) -{ - error_setg(errp, QERR_FEATURE_DISABLED, "dump-skeys"); -} -#endif - #ifndef TARGET_ARM GICCapabilityList *qmp_query_gic_capabilities(Error **errp) { diff --git a/qmp.c b/qmp.c index 90816ba283..7b6861846f 100644 --- a/qmp.c +++ b/qmp.c @@ -553,20 +553,6 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(C= puModelExpansionType type, return arch_query_cpu_model_expansion(type, model, errp); } =20 -CpuModelCompareInfo *qmp_query_cpu_model_comparison(CpuModelInfo *modela, - CpuModelInfo *modelb, - Error **errp) -{ - return arch_query_cpu_model_comparison(modela, modelb, errp); -} - -CpuModelBaselineInfo *qmp_query_cpu_model_baseline(CpuModelInfo *modela, - CpuModelInfo *modelb, - Error **errp) -{ - return arch_query_cpu_model_baseline(modela, modelb, errp); -} - void qmp_add_client(const char *protocol, const char *fdname, bool has_skipauth, bool skipauth, bool has_tls, bool t= ls, Error **errp) diff --git a/stubs/arch-query-cpu-model-baseline.c b/stubs/arch-query-cpu-m= odel-baseline.c deleted file mode 100644 index 094ec13c2c..0000000000 --- a/stubs/arch-query-cpu-model-baseline.c +++ /dev/null @@ -1,12 +0,0 @@ -#include "qemu/osdep.h" -#include "qemu-common.h" -#include "sysemu/arch_init.h" -#include "qapi/qmp/qerror.h" - -CpuModelBaselineInfo *arch_query_cpu_model_baseline(CpuModelInfo *modela, - CpuModelInfo *modelb, - Error **errp) -{ - error_setg(errp, QERR_UNSUPPORTED); - return NULL; -} diff --git a/stubs/arch-query-cpu-model-comparison.c b/stubs/arch-query-cpu= -model-comparison.c deleted file mode 100644 index d5486ae980..0000000000 --- a/stubs/arch-query-cpu-model-comparison.c +++ /dev/null @@ -1,12 +0,0 @@ -#include "qemu/osdep.h" -#include "qemu-common.h" -#include "sysemu/arch_init.h" -#include "qapi/qmp/qerror.h" - -CpuModelCompareInfo *arch_query_cpu_model_comparison(CpuModelInfo *modela, - CpuModelInfo *modelb, - Error **errp) -{ - error_setg(errp, QERR_UNSUPPORTED); - return NULL; -} diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index fa1338fc72..cdff9cdd3b 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -559,7 +559,7 @@ static void list_add_feat(const char *name, void *opaqu= e) *last =3D entry; } =20 -CpuModelCompareInfo *arch_query_cpu_model_comparison(CpuModelInfo *infoa, +CpuModelCompareInfo *qmp_query_cpu_model_comparison(CpuModelInfo *infoa, CpuModelInfo *infob, Error **errp) { @@ -632,7 +632,7 @@ CpuModelCompareInfo *arch_query_cpu_model_comparison(Cp= uModelInfo *infoa, return compare_info; } =20 -CpuModelBaselineInfo *arch_query_cpu_model_baseline(CpuModelInfo *infoa, +CpuModelBaselineInfo *qmp_query_cpu_model_baseline(CpuModelInfo *infoa, CpuModelInfo *infob, Error **errp) { diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs index 1b2bef99c9..049d389966 100644 --- a/stubs/Makefile.objs +++ b/stubs/Makefile.objs @@ -1,7 +1,5 @@ stub-obj-y +=3D arch-query-cpu-def.o stub-obj-y +=3D arch-query-cpu-model-expansion.o -stub-obj-y +=3D arch-query-cpu-model-comparison.o -stub-obj-y +=3D arch-query-cpu-model-baseline.o stub-obj-y +=3D bdrv-next-monitor-owned.o stub-obj-y +=3D blk-commit-all.o stub-obj-y +=3D blockdev-close-all-bdrv-states.o --=20 2.14.0.rc0.1.g40ca67566 From nobody Fri May 3 05:56:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501171143138173.07170183405867; Thu, 27 Jul 2017 08:59:03 -0700 (PDT) Received: from localhost ([::1]:43721 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dalBl-0007Dx-SZ for importer@patchew.org; Thu, 27 Jul 2017 11:59:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56457) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal2K-0006Ag-V6 for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:49:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dal2K-0005BZ-4E for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:49:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54582) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dal2J-0005BC-UI for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:49:16 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2D5BA883D6 for ; Thu, 27 Jul 2017 15:42:42 +0000 (UTC) Received: from localhost (ovpn-112-42.ams2.redhat.com [10.36.112.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 481DA17CC9; Thu, 27 Jul 2017 15:42:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2D5BA883D6 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 17:41:24 +0200 Message-Id: <20170727154126.11339-25-marcandre.lureau@redhat.com> In-Reply-To: <20170727154126.11339-1-marcandre.lureau@redhat.com> References: <20170727154126.11339-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 27 Jul 2017 15:42:42 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 24/26] qapi: make query-gic-capabilities depend on TARGET_ARM X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Dr. David Alan Gilbert" , Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau --- qapi-schema.json | 3 ++- monitor.c | 11 ----------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index 278d7e2aa3..a5c28bc9ad 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -6437,7 +6437,8 @@ # { "version": 3, "emulated": false, "kernel": true } ] } # ## -{ 'command': 'query-gic-capabilities', 'returns': ['GICCapability'] } +{ 'command': 'query-gic-capabilities', 'returns': ['GICCapability'], + 'if': ['defined(NEED_CPU_H)', 'defined(TARGET_ARM)']} =20 ## # @CpuInstanceProperties: diff --git a/monitor.c b/monitor.c index 505ee5c58d..3bdae8d9d0 100644 --- a/monitor.c +++ b/monitor.c @@ -970,9 +970,6 @@ static void qmp_query_qmp_schema(QDict *qdict, QObject = **ret_data, */ static void qmp_unregister_commands_hack(void) { -#ifndef TARGET_ARM - qmp_unregister_command(&qmp_commands, "query-gic-capabilities"); -#endif #if !defined(TARGET_S390X) && !defined(TARGET_I386) qmp_unregister_command(&qmp_commands, "query-cpu-model-expansion"); #endif @@ -4141,14 +4138,6 @@ QemuOptsList qemu_mon_opts =3D { }, }; =20 -#ifndef TARGET_ARM -GICCapabilityList *qmp_query_gic_capabilities(Error **errp) -{ - error_setg(errp, QERR_FEATURE_DISABLED, "query-gic-capabilities"); - return NULL; -} -#endif - HotpluggableCPUList *qmp_query_hotpluggable_cpus(Error **errp) { MachineState *ms =3D MACHINE(qdev_get_machine()); --=20 2.14.0.rc0.1.g40ca67566 From nobody Fri May 3 05:56:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501171805145832.2201477940756; Thu, 27 Jul 2017 09:10:05 -0700 (PDT) Received: from localhost ([::1]:43779 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dalMP-0008MO-NU for importer@patchew.org; Thu, 27 Jul 2017 12:10:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32840) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal4x-0000cp-Je for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:52:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dal4v-0007Ml-Cr for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43944) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dal4v-0007Lc-3G for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:51:57 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BE337AE44C; Thu, 27 Jul 2017 15:42:45 +0000 (UTC) Received: from localhost (ovpn-112-42.ams2.redhat.com [10.36.112.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4926A6C433; Thu, 27 Jul 2017 15:42:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BE337AE44C Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 17:41:25 +0200 Message-Id: <20170727154126.11339-26-marcandre.lureau@redhat.com> In-Reply-To: <20170727154126.11339-1-marcandre.lureau@redhat.com> References: <20170727154126.11339-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 27 Jul 2017 15:42:45 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 25/26] qapi: make query-cpu-model-expansion depend on s390 or x86 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexander Graf , Eduardo Habkost , "Dr. David Alan Gilbert" , Markus Armbruster , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau --- qapi-schema.json | 4 +++- include/sysemu/arch_init.h | 3 --- monitor.c | 3 --- qmp.c | 7 ------- stubs/arch-query-cpu-model-expansion.c | 12 ------------ target/i386/cpu.c | 2 +- target/s390x/cpu_models.c | 3 ++- stubs/Makefile.objs | 1 - 8 files changed, 6 insertions(+), 29 deletions(-) delete mode 100644 stubs/arch-query-cpu-model-expansion.c diff --git a/qapi-schema.json b/qapi-schema.json index a5c28bc9ad..f5e1acff83 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -4535,7 +4535,9 @@ { 'command': 'query-cpu-model-expansion', 'data': { 'type': 'CpuModelExpansionType', 'model': 'CpuModelInfo' }, - 'returns': 'CpuModelExpansionInfo' } + 'returns': 'CpuModelExpansionInfo', + 'if': ['defined(NEED_CPU_H)', + 'defined(TARGET_S390X) || defined(TARGET_I386)']} =20 ## # @CpuModelCompareResult: diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h index e9f1ea0cca..fb3d20a1b8 100644 --- a/include/sysemu/arch_init.h +++ b/include/sysemu/arch_init.h @@ -32,8 +32,5 @@ int kvm_available(void); int xen_available(void); =20 CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp); -CpuModelExpansionInfo *arch_query_cpu_model_expansion(CpuModelExpansionTyp= e type, - CpuModelInfo *mode, - Error **errp); =20 #endif diff --git a/monitor.c b/monitor.c index 3bdae8d9d0..b134c39144 100644 --- a/monitor.c +++ b/monitor.c @@ -970,9 +970,6 @@ static void qmp_query_qmp_schema(QDict *qdict, QObject = **ret_data, */ static void qmp_unregister_commands_hack(void) { -#if !defined(TARGET_S390X) && !defined(TARGET_I386) - qmp_unregister_command(&qmp_commands, "query-cpu-model-expansion"); -#endif #if !defined(TARGET_PPC) && !defined(TARGET_ARM) && !defined(TARGET_I386) \ && !defined(TARGET_S390X) qmp_unregister_command(&qmp_commands, "query-cpu-definitions"); diff --git a/qmp.c b/qmp.c index 7b6861846f..afa266ec1e 100644 --- a/qmp.c +++ b/qmp.c @@ -546,13 +546,6 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error= **errp) return arch_query_cpu_definitions(errp); } =20 -CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType= type, - CpuModelInfo *model, - Error **errp) -{ - return arch_query_cpu_model_expansion(type, model, errp); -} - void qmp_add_client(const char *protocol, const char *fdname, bool has_skipauth, bool skipauth, bool has_tls, bool t= ls, Error **errp) diff --git a/stubs/arch-query-cpu-model-expansion.c b/stubs/arch-query-cpu-= model-expansion.c deleted file mode 100644 index ae7cf554d1..0000000000 --- a/stubs/arch-query-cpu-model-expansion.c +++ /dev/null @@ -1,12 +0,0 @@ -#include "qemu/osdep.h" -#include "qemu-common.h" -#include "sysemu/arch_init.h" -#include "qapi/qmp/qerror.h" - -CpuModelExpansionInfo *arch_query_cpu_model_expansion(CpuModelExpansionTyp= e type, - CpuModelInfo *mode, - Error **errp) -{ - error_setg(errp, QERR_UNSUPPORTED); - return NULL; -} diff --git a/target/i386/cpu.c b/target/i386/cpu.c index ddc45abd70..d683e70a13 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -2574,7 +2574,7 @@ out: } =20 CpuModelExpansionInfo * -arch_query_cpu_model_expansion(CpuModelExpansionType type, +qmp_query_cpu_model_expansion(CpuModelExpansionType type, CpuModelInfo *model, Error **errp) { diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index cdff9cdd3b..863dce064f 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -22,6 +22,7 @@ #ifndef CONFIG_USER_ONLY #include "sysemu/arch_init.h" #endif +#include "qmp-commands.h" =20 #define CPUDEF_INIT(_type, _gen, _ec_ga, _mha_pow, _hmfai, _name, _desc) \ { \ @@ -520,7 +521,7 @@ static void cpu_info_from_model(CpuModelInfo *info, con= st S390CPUModel *model, } } =20 -CpuModelExpansionInfo *arch_query_cpu_model_expansion(CpuModelExpansionTyp= e type, +CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType= type, CpuModelInfo *model, Error **errp) { diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs index 049d389966..dcfe6f49f9 100644 --- a/stubs/Makefile.objs +++ b/stubs/Makefile.objs @@ -1,5 +1,4 @@ stub-obj-y +=3D arch-query-cpu-def.o -stub-obj-y +=3D arch-query-cpu-model-expansion.o stub-obj-y +=3D bdrv-next-monitor-owned.o stub-obj-y +=3D blk-commit-all.o stub-obj-y +=3D blockdev-close-all-bdrv-states.o --=20 2.14.0.rc0.1.g40ca67566 From nobody Fri May 3 05:56:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501171723941559.6657546454245; Thu, 27 Jul 2017 09:08:43 -0700 (PDT) Received: from localhost ([::1]:43770 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dalL5-00079T-3c for importer@patchew.org; Thu, 27 Jul 2017 12:08:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dal51-0000g7-KH for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:52:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dal50-0007SZ-AP for qemu-devel@nongnu.org; Thu, 27 Jul 2017 11:52:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43948) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dal4v-0007Li-4Q; Thu, 27 Jul 2017 11:51:57 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7717864076; Thu, 27 Jul 2017 15:42:50 +0000 (UTC) Received: from localhost (ovpn-112-42.ams2.redhat.com [10.36.112.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D6B06EC99; Thu, 27 Jul 2017 15:42:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7717864076 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 17:41:26 +0200 Message-Id: <20170727154126.11339-27-marcandre.lureau@redhat.com> In-Reply-To: <20170727154126.11339-1-marcandre.lureau@redhat.com> References: <20170727154126.11339-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 27 Jul 2017 15:42:50 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 26/26] qapi: make query-cpu-definitions depend on specific targets X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Markus Armbruster , "Dr. David Alan Gilbert" , Alexander Graf , "open list:ARM" , "open list:PowerPC" , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Gibson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" It depends on TARGET_PPC || TARGET_ARM || TARGET_I386 || TARGET_S390X. Signed-off-by: Marc-Andr=C3=A9 Lureau --- qapi-schema.json | 4 +++- include/sysemu/arch_init.h | 2 -- monitor.c | 22 ---------------------- qmp.c | 5 ----- stubs/arch-query-cpu-def.c | 10 ---------- target/arm/helper.c | 3 ++- target/i386/cpu.c | 3 ++- target/ppc/translate_init.c | 3 ++- target/s390x/cpu_models.c | 2 +- stubs/Makefile.objs | 1 - 10 files changed, 10 insertions(+), 45 deletions(-) delete mode 100644 stubs/arch-query-cpu-def.c diff --git a/qapi-schema.json b/qapi-schema.json index f5e1acff83..8e3949bca8 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -4433,7 +4433,9 @@ # # Since: 1.2.0 ## -{ 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'] } +{ 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'], + 'if': ['defined(NEED_CPU_H)', + 'defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_I38= 6) || defined(TARGET_S390X)'] } =20 ## # @CpuModelInfo: diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h index fb3d20a1b8..e9721b9ce8 100644 --- a/include/sysemu/arch_init.h +++ b/include/sysemu/arch_init.h @@ -31,6 +31,4 @@ extern const uint32_t arch_type; int kvm_available(void); int xen_available(void); =20 -CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp); - #endif diff --git a/monitor.c b/monitor.c index b134c39144..6600819599 100644 --- a/monitor.c +++ b/monitor.c @@ -956,26 +956,6 @@ static void qmp_query_qmp_schema(QDict *qdict, QObject= **ret_data, *ret_data =3D qobject_from_qlit(&qmp_schema_qlit); } =20 -/* - * We used to define commands in qmp-commands.hx in addition to the - * QAPI schema. This permitted defining some of them only in certain - * configurations. query-commands has always reflected that (good, - * because it lets QMP clients figure out what's actually available), - * while query-qmp-schema never did (not so good). This function is a - * hack to keep the configuration-specific commands defined exactly as - * before, even though qmp-commands.hx is gone. - * - * FIXME Educate the QAPI schema on configuration-specific commands, - * and drop this hack. - */ -static void qmp_unregister_commands_hack(void) -{ -#if !defined(TARGET_PPC) && !defined(TARGET_ARM) && !defined(TARGET_I386) \ - && !defined(TARGET_S390X) - qmp_unregister_command(&qmp_commands, "query-cpu-definitions"); -#endif -} - void monitor_init_qmp_commands(void) { /* @@ -995,8 +975,6 @@ void monitor_init_qmp_commands(void) qmp_register_command(&qmp_commands, "netdev_add", qmp_netdev_add, QCO_NO_OPTIONS); =20 - qmp_unregister_commands_hack(); - QTAILQ_INIT(&qmp_cap_negotiation_commands); qmp_register_command(&qmp_cap_negotiation_commands, "qmp_capabilities", qmp_marshal_qmp_capabilities, QCO_NO_OPTIONS); diff --git a/qmp.c b/qmp.c index afa266ec1e..d57ccf1251 100644 --- a/qmp.c +++ b/qmp.c @@ -541,11 +541,6 @@ DevicePropertyInfoList *qmp_device_list_properties(con= st char *typename, return prop_list; } =20 -CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) -{ - return arch_query_cpu_definitions(errp); -} - void qmp_add_client(const char *protocol, const char *fdname, bool has_skipauth, bool skipauth, bool has_tls, bool t= ls, Error **errp) diff --git a/stubs/arch-query-cpu-def.c b/stubs/arch-query-cpu-def.c deleted file mode 100644 index cefe4beb82..0000000000 --- a/stubs/arch-query-cpu-def.c +++ /dev/null @@ -1,10 +0,0 @@ -#include "qemu/osdep.h" -#include "qemu-common.h" -#include "sysemu/arch_init.h" -#include "qapi/qmp/qerror.h" - -CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp) -{ - error_setg(errp, QERR_UNSUPPORTED); - return NULL; -} diff --git a/target/arm/helper.c b/target/arm/helper.c index 4ed32c56b8..ec644f3930 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -15,6 +15,7 @@ #include /* For crc32 */ #include "exec/semihost.h" #include "sysemu/kvm.h" +#include "qmp-commands.h" =20 #define ARM_CPU_FREQ 1000000000 /* FIXME: 1 GHz, should be configurable */ =20 @@ -5336,7 +5337,7 @@ static void arm_cpu_add_definition(gpointer data, gpo= inter user_data) *cpu_list =3D entry; } =20 -CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp) +CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) { CpuDefinitionInfoList *cpu_list =3D NULL; GSList *list; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index d683e70a13..e5f61f6bff 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -36,6 +36,7 @@ #include "qapi/visitor.h" #include "qom/qom-qobject.h" #include "sysemu/arch_init.h" +#include "qmp-commands.h" =20 #if defined(CONFIG_KVM) #include @@ -2318,7 +2319,7 @@ static void x86_cpu_definition_entry(gpointer data, g= pointer user_data) *cpu_list =3D entry; } =20 -CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp) +CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) { CpuDefinitionInfoList *cpu_list =3D NULL; GSList *list =3D get_sorted_cpu_model_list(); diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c index 01723bdfec..2a2d62e5bb 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -34,6 +34,7 @@ #include "hw/ppc/ppc.h" #include "mmu-book3s-v3.h" #include "sysemu/qtest.h" +#include "qmp-commands.h" =20 //#define PPC_DUMP_CPU //#define PPC_DEBUG_SPR @@ -10391,7 +10392,7 @@ static void ppc_cpu_defs_entry(gpointer data, gpoin= ter user_data) *first =3D entry; } =20 -CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp) +CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) { CpuDefinitionInfoList *cpu_list =3D NULL; GSList *list; diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 863dce064f..8021dda341 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -387,7 +387,7 @@ static void create_cpu_model_list(ObjectClass *klass, v= oid *opaque) *cpu_list =3D entry; } =20 -CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp) +CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) { struct CpuDefinitionInfoListData list_data =3D { .list =3D NULL, diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs index dcfe6f49f9..71af433f6b 100644 --- a/stubs/Makefile.objs +++ b/stubs/Makefile.objs @@ -1,4 +1,3 @@ -stub-obj-y +=3D arch-query-cpu-def.o stub-obj-y +=3D bdrv-next-monitor-owned.o stub-obj-y +=3D blk-commit-all.o stub-obj-y +=3D blockdev-close-all-bdrv-states.o --=20 2.14.0.rc0.1.g40ca67566