From nobody Mon Apr 29 02:38:33 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517589346947738.9020719793634; Fri, 2 Feb 2018 08:35:46 -0800 (PST) Received: from localhost ([::1]:39002 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eheJW-0005f7-4s for importer@patchew.org; Fri, 02 Feb 2018 11:35:46 -0500 Received: from eggs.gnu.org ([208.118.235.92]:55980) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehdMe-0002k9-CO for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:36:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ehdLV-0004dr-KC for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:34:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58932) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ehdLU-0004cB-VR for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:33:45 -0500 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 3FE567F7B9; Fri, 2 Feb 2018 13:04:34 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-148.ams2.redhat.com [10.36.116.148]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6200D6F115; Fri, 2 Feb 2018 13:03:41 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 93DF81138646; Fri, 2 Feb 2018 14:03:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 2 Feb 2018 14:03:16 +0100 Message-Id: <20180202130336.24719-2-armbru@redhat.com> In-Reply-To: <20180202130336.24719-1-armbru@redhat.com> References: <20180202130336.24719-1-armbru@redhat.com> 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.28]); Fri, 02 Feb 2018 13:04:34 +0000 (UTC) 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 RFC 01/21] qapi: Streamline boilerplate comment generation 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: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Every generator has separate boilerplate for .h and .c, and their differences are boring. All of them repeat the license note. Reduce the repetition as follows. Move common text like the license note to common open_output(), next to the existintg common text there. For each generator, replace the two separate descriptions by a single one. While there, emit an "automatically generated" note into generated documentation, too. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi-commands.py | 26 +++----------------------- scripts/qapi-event.py | 26 +++----------------------- scripts/qapi-introspect.py | 21 ++------------------- scripts/qapi-types.py | 26 +++----------------------- scripts/qapi-visit.py | 26 +++----------------------- scripts/qapi.py | 31 ++++++++++++++++++------------- scripts/qapi2texi.py | 3 ++- tests/qapi-schema/doc-good.texi | 3 ++- 8 files changed, 36 insertions(+), 126 deletions(-) diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py index 26c56c5062..25ac52503a 100644 --- a/scripts/qapi-commands.py +++ b/scripts/qapi-commands.py @@ -255,38 +255,18 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor): =20 (input_file, output_dir, do_c, do_h, prefix, opts) =3D parse_command_line() =20 -c_comment =3D ''' -/* - * schema-defined QMP->QAPI command dispatch +blurb =3D ''' + * Schema-defined QAPI/QMP commands * * Copyright IBM, Corp. 2011 * * Authors: * Anthony Liguori - * - * 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. - * - */ -''' -h_comment =3D ''' -/* - * schema-defined QAPI function prototypes - * - * Copyright IBM, Corp. 2011 - * - * Authors: - * Anthony Liguori - * - * 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. - * - */ ''' =20 (fdef, fdecl) =3D open_output(output_dir, do_c, do_h, prefix, 'qmp-marshal.c', 'qmp-commands.h', - c_comment, h_comment) + blurb) =20 fdef.write(mcgen(''' =20 diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py index 9d7134658d..31faedc689 100644 --- a/scripts/qapi-event.py +++ b/scripts/qapi-event.py @@ -171,38 +171,18 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor): =20 (input_file, output_dir, do_c, do_h, prefix, dummy) =3D parse_command_line= () =20 -c_comment =3D ''' -/* - * schema-defined QAPI event functions +blurb =3D ''' + * Schema-defined QAPI/QMP events * * Copyright (c) 2014 Wenchao Xia * * Authors: * Wenchao Xia - * - * 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. - * - */ -''' -h_comment =3D ''' -/* - * schema-defined QAPI event functions - * - * Copyright (c) 2014 Wenchao Xia - * - * Authors: - * Wenchao Xia - * - * 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. - * - */ ''' =20 (fdef, fdecl) =3D open_output(output_dir, do_c, do_h, prefix, 'qapi-event.c', 'qapi-event.h', - c_comment, h_comment) + blurb) =20 fdef.write(mcgen(''' #include "qemu/osdep.h" diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py index 032bcea491..83da2bdb94 100644 --- a/scripts/qapi-introspect.py +++ b/scripts/qapi-introspect.py @@ -176,32 +176,15 @@ for o, a in opts: if o in ('-u', '--unmask-non-abi-names'): opt_unmask =3D True =20 -c_comment =3D ''' -/* +blurb =3D ''' * QAPI/QMP schema introspection * * Copyright (C) 2015 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. - * - */ -''' -h_comment =3D ''' -/* - * QAPI/QMP schema introspection - * - * Copyright (C) 2015 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. - * - */ ''' =20 (fdef, fdecl) =3D open_output(output_dir, do_c, do_h, prefix, 'qmp-introspect.c', 'qmp-introspect.h', - c_comment, h_comment) + blurb) =20 fdef.write(mcgen(''' #include "qemu/osdep.h" diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index 7e3051dbb9..86afc57f92 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -250,39 +250,19 @@ for o, a in opts: if o in ('-b', '--builtins'): do_builtins =3D True =20 -c_comment =3D ''' -/* - * deallocation functions for schema-defined QAPI types +blurb =3D ''' + * Schema-defined QAPI types * * Copyright IBM, Corp. 2011 * * Authors: * Anthony Liguori * Michael Roth - * - * 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. - * - */ -''' -h_comment =3D ''' -/* - * schema-defined QAPI types - * - * Copyright IBM, Corp. 2011 - * - * Authors: - * Anthony Liguori - * - * 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. - * - */ ''' =20 (fdef, fdecl) =3D open_output(output_dir, do_c, do_h, prefix, 'qapi-types.c', 'qapi-types.h', - c_comment, h_comment) + blurb) =20 fdef.write(mcgen(''' #include "qemu/osdep.h" diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index 7e1cfc13f0..9f7127e548 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -334,38 +334,18 @@ for o, a in opts: if o in ('-b', '--builtins'): do_builtins =3D True =20 -c_comment =3D ''' -/* - * schema-defined QAPI visitor functions +blurb =3D ''' + * Schema-defined QAPI visitors * * Copyright IBM, Corp. 2011 * * Authors: * Anthony Liguori - * - * 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. - * - */ -''' -h_comment =3D ''' -/* - * schema-defined QAPI visitor functions - * - * Copyright IBM, Corp. 2011 - * - * Authors: - * Anthony Liguori - * - * 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. - * - */ ''' =20 (fdef, fdecl) =3D open_output(output_dir, do_c, do_h, prefix, 'qapi-visit.c', 'qapi-visit.h', - c_comment, h_comment) + blurb) =20 fdef.write(mcgen(''' #include "qemu/osdep.h" diff --git a/scripts/qapi.py b/scripts/qapi.py index 43a54bf40f..2e4b2bc9eb 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -1975,11 +1975,21 @@ def parse_command_line(extra_options=3D'', extra_lo= ng_options=3D[]): # =20 =20 -def open_output(output_dir, do_c, do_h, prefix, c_file, h_file, - c_comment, h_comment): +def open_output(output_dir, do_c, do_h, prefix, c_file, h_file, blurb): guard =3D guardname(prefix + h_file) c_file =3D output_dir + prefix + c_file h_file =3D output_dir + prefix + h_file + comment =3D mcgen('''/* AUTOMATICALLY GENERATED, DO NOT MODIFY */ + +/* +%(blurb)s + * + * 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. + */ + +''', + blurb=3Dblurb.strip('\n')) =20 if output_dir: try: @@ -1998,27 +2008,22 @@ def open_output(output_dir, do_c, do_h, prefix, c_f= ile, h_file, fdef =3D maybe_open(do_c, c_file, 'w') fdecl =3D maybe_open(do_h, h_file, 'w') =20 - fdef.write(mcgen(''' -/* AUTOMATICALLY GENERATED, DO NOT MODIFY */ -%(comment)s -''', - comment=3Dc_comment)) - + fdef.write(comment) + fdecl.write(comment) fdecl.write(mcgen(''' -/* AUTOMATICALLY GENERATED, DO NOT MODIFY */ -%(comment)s #ifndef %(guard)s #define %(guard)s =20 ''', - comment=3Dh_comment, guard=3Dguard)) + guard=3Dguard)) =20 return (fdef, fdecl) =20 =20 def close_output(fdef, fdecl): - fdecl.write(''' + fdecl.write(mcgen(''' + #endif -''') +''')) fdecl.close() fdef.close() diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py index 92e2af2cd6..924b374cd3 100755 --- a/scripts/qapi2texi.py +++ b/scripts/qapi2texi.py @@ -282,7 +282,8 @@ def main(argv): print >>sys.stderr, ("%s: need pragma 'doc-required' " "to generate documentation" % argv[0]) sys.exit(1) - print texi_schema(schema) + print '@c AUTOMATICALLY GENERATED, DO NOT MODIFY\n' + print texi_schema(schema), =20 =20 if __name__ =3D=3D '__main__': diff --git a/tests/qapi-schema/doc-good.texi b/tests/qapi-schema/doc-good.t= exi index 1778312581..0aed2300a5 100644 --- a/tests/qapi-schema/doc-good.texi +++ b/tests/qapi-schema/doc-good.texi @@ -1,3 +1,5 @@ +@c AUTOMATICALLY GENERATED, DO NOT MODIFY + @section Section =20 @subsection Subsection @@ -231,4 +233,3 @@ If you're bored enough to read this, go see a video of = boxed cats =20 @end deftypefn =20 - --=20 2.13.6 From nobody Mon Apr 29 02:38:33 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517588789456545.4878578595673; Fri, 2 Feb 2018 08:26:29 -0800 (PST) Received: from localhost ([::1]:38845 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eheAR-0005yv-E4 for importer@patchew.org; Fri, 02 Feb 2018 11:26:23 -0500 Received: from eggs.gnu.org ([208.118.235.92]:55980) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehdLZ-0002k9-Tm for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:34:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ehdKV-0003Vb-JM for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:33:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49382) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ehdKU-0003Ta-Uq for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:32:43 -0500 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 AE29C2815F; Fri, 2 Feb 2018 13:04:23 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-148.ams2.redhat.com [10.36.116.148]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 60EAD6F111; Fri, 2 Feb 2018 13:03:41 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 979AD1138648; Fri, 2 Feb 2018 14:03:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 2 Feb 2018 14:03:17 +0100 Message-Id: <20180202130336.24719-3-armbru@redhat.com> In-Reply-To: <20180202130336.24719-1-armbru@redhat.com> References: <20180202130336.24719-1-armbru@redhat.com> 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]); Fri, 02 Feb 2018 13:04:23 +0000 (UTC) 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 RFC 02/21] qapi: Generate up-to-date copyright notice 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: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Each generator carries a copyright notice for the generator itself, and another one for the files it generates. Only the former have been updated along the way, the latter have not, and are all out of date. Fix by copying the generator's copyright notice to the generated files instead. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi-commands.py | 34 +++++++++++++++------------------- scripts/qapi-event.py | 32 ++++++++++++++------------------ scripts/qapi-introspect.py | 25 ++++++++++++------------- scripts/qapi-types.py | 32 ++++++++++++++------------------ scripts/qapi-visit.py | 34 +++++++++++++++------------------- scripts/qapi.py | 7 +++++-- 6 files changed, 75 insertions(+), 89 deletions(-) diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py index 25ac52503a..a861ac52e7 100644 --- a/scripts/qapi-commands.py +++ b/scripts/qapi-commands.py @@ -1,16 +1,17 @@ -# -# QAPI command marshaller generator -# -# Copyright IBM, Corp. 2011 -# Copyright (C) 2014-2016 Red Hat, Inc. -# -# Authors: -# Anthony Liguori -# Michael Roth -# Markus Armbruster -# -# This work is licensed under the terms of the GNU GPL, version 2. -# See the COPYING file in the top-level directory. +""" +QAPI command marshaller generator + +Copyright IBM, Corp. 2011 +Copyright (C) 2014-2018 Red Hat, Inc. + +Authors: + Anthony Liguori + Michael Roth + Markus Armbruster + +This work is licensed under the terms of the GNU GPL, version 2. +See the COPYING file in the top-level directory. +""" =20 from qapi import * =20 @@ -257,16 +258,11 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor): =20 blurb =3D ''' * Schema-defined QAPI/QMP commands - * - * Copyright IBM, Corp. 2011 - * - * Authors: - * Anthony Liguori ''' =20 (fdef, fdecl) =3D open_output(output_dir, do_c, do_h, prefix, 'qmp-marshal.c', 'qmp-commands.h', - blurb) + blurb, __doc__) =20 fdef.write(mcgen(''' =20 diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py index 31faedc689..b1d611c5ea 100644 --- a/scripts/qapi-event.py +++ b/scripts/qapi-event.py @@ -1,15 +1,16 @@ -# -# QAPI event generator -# -# Copyright (c) 2014 Wenchao Xia -# Copyright (c) 2015-2016 Red Hat Inc. -# -# Authors: -# Wenchao Xia -# Markus Armbruster -# -# This work is licensed under the terms of the GNU GPL, version 2. -# See the COPYING file in the top-level directory. +""" +QAPI event generator + +Copyright (c) 2014 Wenchao Xia +Copyright (c) 2015-2018 Red Hat Inc. + +Authors: + Wenchao Xia + Markus Armbruster + +This work is licensed under the terms of the GNU GPL, version 2. +See the COPYING file in the top-level directory. +""" =20 from qapi import * =20 @@ -173,16 +174,11 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor): =20 blurb =3D ''' * Schema-defined QAPI/QMP events - * - * Copyright (c) 2014 Wenchao Xia - * - * Authors: - * Wenchao Xia ''' =20 (fdef, fdecl) =3D open_output(output_dir, do_c, do_h, prefix, 'qapi-event.c', 'qapi-event.h', - blurb) + blurb, __doc__) =20 fdef.write(mcgen(''' #include "qemu/osdep.h" diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py index 83da2bdb94..bd9253a172 100644 --- a/scripts/qapi-introspect.py +++ b/scripts/qapi-introspect.py @@ -1,13 +1,14 @@ -# -# QAPI introspection generator -# -# Copyright (C) 2015-2016 Red Hat, Inc. -# -# Authors: -# Markus Armbruster -# -# This work is licensed under the terms of the GNU GPL, version 2. -# See the COPYING file in the top-level directory. +""" +QAPI introspection generator + +Copyright (C) 2015-2018 Red Hat, Inc. + +Authors: + Markus Armbruster + +This work is licensed under the terms of the GNU GPL, version 2. +See the COPYING file in the top-level directory. +""" =20 from qapi import * =20 @@ -178,13 +179,11 @@ for o, a in opts: =20 blurb =3D ''' * QAPI/QMP schema introspection - * - * Copyright (C) 2015 Red Hat, Inc. ''' =20 (fdef, fdecl) =3D open_output(output_dir, do_c, do_h, prefix, 'qmp-introspect.c', 'qmp-introspect.h', - blurb) + blurb, __doc__) =20 fdef.write(mcgen(''' #include "qemu/osdep.h" diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index 86afc57f92..1103dbda2d 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -1,15 +1,17 @@ -# -# QAPI types generator -# -# Copyright IBM, Corp. 2011 -# Copyright (c) 2013-2016 Red Hat Inc. -# -# Authors: -# Anthony Liguori -# Markus Armbruster -# -# This work is licensed under the terms of the GNU GPL, version 2. +""" +QAPI types generator + +Copyright IBM, Corp. 2011 +Copyright (c) 2013-2018 Red Hat Inc. + +Authors: + Anthony Liguori + Michael Roth + Markus Armbruster + +This work is licensed under the terms of the GNU GPL, version 2. # See the COPYING file in the top-level directory. +""" =20 from qapi import * =20 @@ -252,17 +254,11 @@ for o, a in opts: =20 blurb =3D ''' * Schema-defined QAPI types - * - * Copyright IBM, Corp. 2011 - * - * Authors: - * Anthony Liguori - * Michael Roth ''' =20 (fdef, fdecl) =3D open_output(output_dir, do_c, do_h, prefix, 'qapi-types.c', 'qapi-types.h', - blurb) + blurb, __doc__) =20 fdef.write(mcgen(''' #include "qemu/osdep.h" diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index 9f7127e548..5231f89c36 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -1,16 +1,17 @@ -# -# QAPI visitor generator -# -# Copyright IBM, Corp. 2011 -# Copyright (C) 2014-2016 Red Hat, Inc. -# -# Authors: -# Anthony Liguori -# Michael Roth -# Markus Armbruster -# -# This work is licensed under the terms of the GNU GPL, version 2. -# See the COPYING file in the top-level directory. +""" +QAPI visitor generator + +Copyright IBM, Corp. 2011 +Copyright (C) 2014-2018 Red Hat, Inc. + +Authors: + Anthony Liguori + Michael Roth + Markus Armbruster + +This work is licensed under the terms of the GNU GPL, version 2. +See the COPYING file in the top-level directory. +""" =20 from qapi import * =20 @@ -336,16 +337,11 @@ for o, a in opts: =20 blurb =3D ''' * Schema-defined QAPI visitors - * - * Copyright IBM, Corp. 2011 - * - * Authors: - * Anthony Liguori ''' =20 (fdef, fdecl) =3D open_output(output_dir, do_c, do_h, prefix, 'qapi-visit.c', 'qapi-visit.h', - blurb) + blurb, __doc__) =20 fdef.write(mcgen(''' #include "qemu/osdep.h" diff --git a/scripts/qapi.py b/scripts/qapi.py index 2e4b2bc9eb..d0816f7479 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -1975,21 +1975,24 @@ def parse_command_line(extra_options=3D'', extra_lo= ng_options=3D[]): # =20 =20 -def open_output(output_dir, do_c, do_h, prefix, c_file, h_file, blurb): +def open_output(output_dir, do_c, do_h, prefix, c_file, h_file, blurb, doc= ): guard =3D guardname(prefix + h_file) c_file =3D output_dir + prefix + c_file h_file =3D output_dir + prefix + h_file + copyright =3D '\n * '.join(re.findall(r'^Copyright .*', doc, re.MULTIL= INE)) comment =3D mcgen('''/* AUTOMATICALLY GENERATED, DO NOT MODIFY */ =20 /* %(blurb)s * + * %(copyright)s + * * 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. */ =20 ''', - blurb=3Dblurb.strip('\n')) + blurb=3Dblurb.strip('\n'), copyright=3Dcopyright) =20 if output_dir: try: --=20 2.13.6 From nobody Mon Apr 29 02:38:33 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517588454242556.7361908512668; Fri, 2 Feb 2018 08:20:54 -0800 (PST) Received: from localhost ([::1]:38738 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehe57-00014p-4h for importer@patchew.org; Fri, 02 Feb 2018 11:20:53 -0500 Received: from eggs.gnu.org ([208.118.235.92]:55470) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehdLH-0002Ut-DM for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:34:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ehdKD-00037Z-3Y for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:33:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58346) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ehdKC-00035I-Ct for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:32:24 -0500 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 23BFD2DB707; Fri, 2 Feb 2018 13:04:17 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-148.ams2.redhat.com [10.36.116.148]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 61F586F113; Fri, 2 Feb 2018 13:03:41 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9BEB0113864A; Fri, 2 Feb 2018 14:03:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 2 Feb 2018 14:03:18 +0100 Message-Id: <20180202130336.24719-4-armbru@redhat.com> In-Reply-To: <20180202130336.24719-1-armbru@redhat.com> References: <20180202130336.24719-1-armbru@redhat.com> 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.29]); Fri, 02 Feb 2018 13:04:17 +0000 (UTC) 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 RFC 03/21] qapi: New classes QAPIGenC, QAPIGenH, QAPIGenDoc 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: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" These classes encapsulate accumulating and writing output. Convert C code generation to QAPIGenC and QAPIGenH. The conversion is rather shallow: most of the output accumulation is not converted. Left for later. The indentation machinery uses a single global variable indent_level, even though we generally interleave creation of a .c and its .h. It should become instance variable of QAPIGenC. Also left for later. Documentation generation isn't converted, and QAPIGenDoc isn't used. This will change shortly. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi-commands.py | 27 ++++++------- scripts/qapi-event.py | 26 +++++++------ scripts/qapi-introspect.py | 22 ++++++----- scripts/qapi-types.py | 26 +++++++------ scripts/qapi-visit.py | 26 +++++++------ scripts/qapi.py | 96 ++++++++++++++++++++++++++----------------= ---- 6 files changed, 122 insertions(+), 101 deletions(-) diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py index a861ac52e7..4be7dbc482 100644 --- a/scripts/qapi-commands.py +++ b/scripts/qapi-commands.py @@ -260,12 +260,10 @@ blurb =3D ''' * Schema-defined QAPI/QMP commands ''' =20 -(fdef, fdecl) =3D open_output(output_dir, do_c, do_h, prefix, - 'qmp-marshal.c', 'qmp-commands.h', - blurb, __doc__) - -fdef.write(mcgen(''' +genc =3D QAPIGenC(blurb, __doc__) +genh =3D QAPIGenH(blurb, __doc__) =20 +genc.body(mcgen(''' #include "qemu/osdep.h" #include "qemu-common.h" #include "qemu/module.h" @@ -279,21 +277,24 @@ fdef.write(mcgen(''' #include "%(prefix)sqmp-commands.h" =20 ''', - prefix=3Dprefix)) + prefix=3Dprefix)) =20 -fdecl.write(mcgen(''' +genh.body(mcgen(''' #include "%(prefix)sqapi-types.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/dispatch.h" =20 void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds); ''', - prefix=3Dprefix, c_prefix=3Dc_name(prefix, protect=3DFal= se))) + prefix=3Dprefix, c_prefix=3Dc_name(prefix, protect=3DFalse= ))) =20 schema =3D QAPISchema(input_file) -gen =3D QAPISchemaGenCommandVisitor() -schema.visit(gen) -fdef.write(gen.defn) -fdecl.write(gen.decl) +vis =3D QAPISchemaGenCommandVisitor() +schema.visit(vis) +genc.body(vis.defn) +genh.body(vis.decl) =20 -close_output(fdef, fdecl) +if do_c: + genc.write(output_dir, prefix + 'qmp-marshal.c') +if do_h: + genh.write(output_dir, prefix + 'qmp-commands.h') diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py index b1d611c5ea..da3de17c76 100644 --- a/scripts/qapi-event.py +++ b/scripts/qapi-event.py @@ -176,11 +176,10 @@ blurb =3D ''' * Schema-defined QAPI/QMP events ''' =20 -(fdef, fdecl) =3D open_output(output_dir, do_c, do_h, prefix, - 'qapi-event.c', 'qapi-event.h', - blurb, __doc__) +genc =3D QAPIGenC(blurb, __doc__) +genh =3D QAPIGenH(blurb, __doc__) =20 -fdef.write(mcgen(''' +genc.body(mcgen(''' #include "qemu/osdep.h" #include "qemu-common.h" #include "%(prefix)sqapi-event.h" @@ -190,22 +189,25 @@ fdef.write(mcgen(''' #include "qapi/qmp-event.h" =20 ''', - prefix=3Dprefix)) + prefix=3Dprefix)) =20 -fdecl.write(mcgen(''' +genh.body(mcgen(''' #include "qapi/util.h" #include "qapi/qmp/qdict.h" #include "%(prefix)sqapi-types.h" =20 ''', - prefix=3Dprefix)) + prefix=3Dprefix)) =20 event_enum_name =3D c_name(prefix + 'QAPIEvent', protect=3DFalse) =20 schema =3D QAPISchema(input_file) -gen =3D QAPISchemaGenEventVisitor() -schema.visit(gen) -fdef.write(gen.defn) -fdecl.write(gen.decl) +vis =3D QAPISchemaGenEventVisitor() +schema.visit(vis) +genc.body(vis.defn) +genh.body(vis.decl) =20 -close_output(fdef, fdecl) +if do_c: + genc.write(output_dir, prefix + 'qapi-event.c') +if do_h: + genh.write(output_dir, prefix + 'qapi-event.h') diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py index bd9253a172..c654f8fa94 100644 --- a/scripts/qapi-introspect.py +++ b/scripts/qapi-introspect.py @@ -181,21 +181,23 @@ blurb =3D ''' * QAPI/QMP schema introspection ''' =20 -(fdef, fdecl) =3D open_output(output_dir, do_c, do_h, prefix, - 'qmp-introspect.c', 'qmp-introspect.h', - blurb, __doc__) +genc =3D QAPIGenC(blurb, __doc__) +genh =3D QAPIGenH(blurb, __doc__) =20 -fdef.write(mcgen(''' +genc.body(mcgen(''' #include "qemu/osdep.h" #include "%(prefix)sqmp-introspect.h" =20 ''', - prefix=3Dprefix)) + prefix=3Dprefix)) =20 schema =3D QAPISchema(input_file) -gen =3D QAPISchemaGenIntrospectVisitor(opt_unmask) -schema.visit(gen) -fdef.write(gen.defn) -fdecl.write(gen.decl) +vis =3D QAPISchemaGenIntrospectVisitor(opt_unmask) +schema.visit(vis) +genc.body(vis.defn) +genh.body(vis.decl) =20 -close_output(fdef, fdecl) +if do_c: + genc.write(output_dir, prefix + 'qmp-introspect.c') +if do_h: + genh.write(output_dir, prefix + 'qmp-introspect.h') diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index 1103dbda2d..97406b3368 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -180,7 +180,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): self.decl =3D '' self.defn =3D '' self._fwdecl =3D '' - self._btin =3D guardstart('QAPI_TYPES_BUILTIN') + self._btin =3D '\n' + guardstart('QAPI_TYPES_BUILTIN') =20 def visit_end(self): self.decl =3D self._fwdecl + self.decl @@ -256,26 +256,28 @@ blurb =3D ''' * Schema-defined QAPI types ''' =20 -(fdef, fdecl) =3D open_output(output_dir, do_c, do_h, prefix, - 'qapi-types.c', 'qapi-types.h', - blurb, __doc__) +genc =3D QAPIGenC(blurb, __doc__) +genh =3D QAPIGenH(blurb, __doc__) =20 -fdef.write(mcgen(''' +genc.body(mcgen(''' #include "qemu/osdep.h" #include "qapi/dealloc-visitor.h" #include "%(prefix)sqapi-types.h" #include "%(prefix)sqapi-visit.h" ''', - prefix=3Dprefix)) + prefix=3Dprefix)) =20 -fdecl.write(mcgen(''' +genh.body(mcgen(''' #include "qapi/util.h" ''')) =20 schema =3D QAPISchema(input_file) -gen =3D QAPISchemaGenTypeVisitor() -schema.visit(gen) -fdef.write(gen.defn) -fdecl.write(gen.decl) +vis =3D QAPISchemaGenTypeVisitor() +schema.visit(vis) +genc.body(vis.defn) +genh.body(vis.decl) =20 -close_output(fdef, fdecl) +if do_c: + genc.write(output_dir, prefix + 'qapi-types.c') +if do_h: + genh.write(output_dir, prefix + 'qapi-types.h') diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index 5231f89c36..d1b25daf0d 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -339,30 +339,32 @@ blurb =3D ''' * Schema-defined QAPI visitors ''' =20 -(fdef, fdecl) =3D open_output(output_dir, do_c, do_h, prefix, - 'qapi-visit.c', 'qapi-visit.h', - blurb, __doc__) +genc =3D QAPIGenC(blurb, __doc__) +genh =3D QAPIGenH(blurb, __doc__) =20 -fdef.write(mcgen(''' +genc.body(mcgen(''' #include "qemu/osdep.h" #include "qemu-common.h" #include "qapi/error.h" #include "%(prefix)sqapi-visit.h" ''', - prefix=3Dprefix)) + prefix=3Dprefix)) =20 -fdecl.write(mcgen(''' +genh.body(mcgen(''' #include "qapi/visitor.h" #include "qapi/qmp/qerror.h" #include "%(prefix)sqapi-types.h" =20 ''', - prefix=3Dprefix)) + prefix=3Dprefix)) =20 schema =3D QAPISchema(input_file) -gen =3D QAPISchemaGenVisitVisitor() -schema.visit(gen) -fdef.write(gen.defn) -fdecl.write(gen.decl) +vis =3D QAPISchemaGenVisitVisitor() +schema.visit(vis) +genc.body(vis.defn) +genh.body(vis.decl) =20 -close_output(fdef, fdecl) +if do_c: + genc.write(output_dir, prefix + 'qapi-visit.c') +if do_h: + genh.write(output_dir, prefix + 'qapi-visit.h') diff --git a/scripts/qapi.py b/scripts/qapi.py index d0816f7479..d73ef618e2 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -2,7 +2,7 @@ # QAPI helper library # # Copyright IBM, Corp. 2011 -# Copyright (c) 2013-2016 Red Hat Inc. +# Copyright (c) 2013-2018 Red Hat Inc. # # Authors: # Anthony Liguori @@ -1820,7 +1820,6 @@ def guardname(filename): =20 def guardstart(name): return mcgen(''' - #ifndef %(name)s #define %(name)s =20 @@ -1832,7 +1831,6 @@ def guardend(name): return mcgen(''' =20 #endif /* %(name)s */ - ''', name=3Dguardname(name)) =20 @@ -1970,17 +1968,53 @@ def parse_command_line(extra_options=3D'', extra_lo= ng_options=3D[]): =20 return (fname, output_dir, do_c, do_h, prefix, extra_opts) =20 + # -# Generate output files with boilerplate +# Accumulate and write output # =20 +class QAPIGen(object): + + def __init__(self): + self._preamble =3D '' + self._body =3D '' + + def preamble(self, text): + self._preamble +=3D text + + def body(self, text): + self._body +=3D text + + def top(self, fname): + return '' + + def bottom(self, fname): + return '' + + def write(self, output_dir, fname): + if output_dir: + try: + os.makedirs(output_dir) + except os.error as e: + if e.errno !=3D errno.EEXIST: + raise + f =3D open(os.path.join(output_dir, fname), 'w') + f.write(self.top(fname) + self._preamble + self._body + + self.bottom(fname)) + f.close() + + +class QAPIGenC(QAPIGen): + + def __init__(self, blurb, pydoc): + QAPIGen.__init__(self) + self._blurb =3D blurb.strip('\n') + self._copyright =3D '\n * '.join(re.findall(r'^Copyright .*', pydo= c, + re.MULTILINE)) =20 -def open_output(output_dir, do_c, do_h, prefix, c_file, h_file, blurb, doc= ): - guard =3D guardname(prefix + h_file) - c_file =3D output_dir + prefix + c_file - h_file =3D output_dir + prefix + h_file - copyright =3D '\n * '.join(re.findall(r'^Copyright .*', doc, re.MULTIL= INE)) - comment =3D mcgen('''/* AUTOMATICALLY GENERATED, DO NOT MODIFY */ + def top(self, fname): + return mcgen(''' +/* AUTOMATICALLY GENERATED, DO NOT MODIFY */ =20 /* %(blurb)s @@ -1992,41 +2026,19 @@ def open_output(output_dir, do_c, do_h, prefix, c_f= ile, h_file, blurb, doc): */ =20 ''', - blurb=3Dblurb.strip('\n'), copyright=3Dcopyright) + blurb=3Dself._blurb, copyright=3Dself._copyright) =20 - if output_dir: - try: - os.makedirs(output_dir) - except os.error as e: - if e.errno !=3D errno.EEXIST: - raise =20 - def maybe_open(really, name, opt): - if really: - return open(name, opt) - else: - import StringIO - return StringIO.StringIO() +class QAPIGenH(QAPIGenC): =20 - fdef =3D maybe_open(do_c, c_file, 'w') - fdecl =3D maybe_open(do_h, h_file, 'w') + def top(self, fname): + return QAPIGenC.top(self, fname) + guardstart(fname) =20 - fdef.write(comment) - fdecl.write(comment) - fdecl.write(mcgen(''' -#ifndef %(guard)s -#define %(guard)s + def bottom(self, fname): + return guardend(fname) =20 -''', - guard=3Dguard)) =20 - return (fdef, fdecl) - - -def close_output(fdef, fdecl): - fdecl.write(mcgen(''' - -#endif -''')) - fdecl.close() - fdef.close() +class QAPIGenDoc(QAPIGen): + def top(self, fname): + return (QAPIGen.top(self, fname) + + '@c AUTOMATICALLY GENERATED, DO NOT MODIFY\n\n') --=20 2.13.6 From nobody Mon Apr 29 02:38:33 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517589557150424.7563938678919; Fri, 2 Feb 2018 08:39:17 -0800 (PST) Received: from localhost ([::1]:39246 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eheMu-0008V7-5p for importer@patchew.org; Fri, 02 Feb 2018 11:39:16 -0500 Received: from eggs.gnu.org ([208.118.235.92]:55592) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehdNV-0002Ze-PB for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:36:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ehdMG-0005f0-QO for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:35:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39762) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ehdMG-0005cd-2e for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:34:32 -0500 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 E724E4D220; Fri, 2 Feb 2018 13:04:50 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-148.ams2.redhat.com [10.36.116.148]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B9DD6F119; Fri, 2 Feb 2018 13:03:42 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A1027113864E; Fri, 2 Feb 2018 14:03:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 2 Feb 2018 14:03:19 +0100 Message-Id: <20180202130336.24719-5-armbru@redhat.com> In-Reply-To: <20180202130336.24719-1-armbru@redhat.com> References: <20180202130336.24719-1-armbru@redhat.com> 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]); Fri, 02 Feb 2018 13:04:50 +0000 (UTC) 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 RFC 04/21] qapi: Reduce use of global variables in generators some 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: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In preparation of the next commit, which will turn the generators into modules. These global variables will become local to main() then. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi-commands.py | 9 +++++---- scripts/qapi-event.py | 15 +++++++-------- scripts/qapi-introspect.py | 7 ++++--- scripts/qapi-types.py | 17 +++++++++-------- scripts/qapi-visit.py | 17 +++++++++-------- 5 files changed, 34 insertions(+), 31 deletions(-) diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py index 4be7dbc482..d229537659 100644 --- a/scripts/qapi-commands.py +++ b/scripts/qapi-commands.py @@ -207,7 +207,7 @@ def gen_register_command(name, success_response): return ret =20 =20 -def gen_registry(registry): +def gen_registry(registry, prefix): ret =3D mcgen(''' =20 void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds) @@ -224,7 +224,8 @@ void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds) =20 =20 class QAPISchemaGenCommandVisitor(QAPISchemaVisitor): - def __init__(self): + def __init__(self, prefix): + self._prefix =3D prefix self.decl =3D None self.defn =3D None self._regy =3D None @@ -237,7 +238,7 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor): self._visited_ret_types =3D set() =20 def visit_end(self): - self.defn +=3D gen_registry(self._regy) + self.defn +=3D gen_registry(self._regy, self._prefix) self._regy =3D None self._visited_ret_types =3D None =20 @@ -289,7 +290,7 @@ void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds); prefix=3Dprefix, c_prefix=3Dc_name(prefix, protect=3DFalse= ))) =20 schema =3D QAPISchema(input_file) -vis =3D QAPISchemaGenCommandVisitor() +vis =3D QAPISchemaGenCommandVisitor(prefix) schema.visit(vis) genc.body(vis.defn) genh.body(vis.decl) diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py index da3de17c76..1af21b580a 100644 --- a/scripts/qapi-event.py +++ b/scripts/qapi-event.py @@ -58,7 +58,7 @@ def gen_param_var(typ): return ret =20 =20 -def gen_event_send(name, arg_type, boxed): +def gen_event_send(name, arg_type, boxed, event_enum_name): # FIXME: Our declaration of local variables (and of 'errp' in the # parameter list) can collide with exploded members of the event's # data type passed in as parameters. If this collision ever hits in @@ -149,7 +149,8 @@ out: =20 =20 class QAPISchemaGenEventVisitor(QAPISchemaVisitor): - def __init__(self): + def __init__(self, prefix): + self._enum_name =3D c_name(prefix + 'QAPIEvent', protect=3DFalse) self.decl =3D None self.defn =3D None self._event_names =3D None @@ -160,13 +161,13 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor): self._event_names =3D [] =20 def visit_end(self): - self.decl +=3D gen_enum(event_enum_name, self._event_names) - self.defn +=3D gen_enum_lookup(event_enum_name, self._event_names) + self.decl +=3D gen_enum(self._enum_name, self._event_names) + self.defn +=3D gen_enum_lookup(self._enum_name, self._event_names) self._event_names =3D None =20 def visit_event(self, name, info, arg_type, boxed): self.decl +=3D gen_event_send_decl(name, arg_type, boxed) - self.defn +=3D gen_event_send(name, arg_type, boxed) + self.defn +=3D gen_event_send(name, arg_type, boxed, self._enum_na= me) self._event_names.append(name) =20 =20 @@ -199,10 +200,8 @@ genh.body(mcgen(''' ''', prefix=3Dprefix)) =20 -event_enum_name =3D c_name(prefix + 'QAPIEvent', protect=3DFalse) - schema =3D QAPISchema(input_file) -vis =3D QAPISchemaGenEventVisitor() +vis =3D QAPISchemaGenEventVisitor(prefix) schema.visit(vis) genc.body(vis.defn) genh.body(vis.decl) diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py index c654f8fa94..8d4e3c1c3a 100644 --- a/scripts/qapi-introspect.py +++ b/scripts/qapi-introspect.py @@ -41,7 +41,8 @@ def to_c_string(string): =20 =20 class QAPISchemaGenIntrospectVisitor(QAPISchemaVisitor): - def __init__(self, unmask): + def __init__(self, prefix, unmask): + self._prefix =3D prefix self._unmask =3D unmask self.defn =3D None self.decl =3D None @@ -65,7 +66,7 @@ class QAPISchemaGenIntrospectVisitor(QAPISchemaVisitor): # generate C # TODO can generate awfully long lines jsons.extend(self._jsons) - name =3D c_name(prefix, protect=3DFalse) + 'qmp_schema_json' + name =3D c_name(self._prefix, protect=3DFalse) + 'qmp_schema_json' self.decl =3D mcgen(''' extern const char %(c_name)s[]; ''', @@ -192,7 +193,7 @@ genc.body(mcgen(''' prefix=3Dprefix)) =20 schema =3D QAPISchema(input_file) -vis =3D QAPISchemaGenIntrospectVisitor(opt_unmask) +vis =3D QAPISchemaGenIntrospectVisitor(prefix, opt_unmask) schema.visit(vis) genc.body(vis.defn) genh.body(vis.decl) diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index 97406b3368..2d711b137b 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -168,7 +168,8 @@ void qapi_free_%(c_name)s(%(c_name)s *obj) =20 =20 class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): - def __init__(self): + def __init__(self, opt_builtins): + self._opt_builtins =3D opt_builtins self.decl =3D None self.defn =3D None self._fwdecl =3D None @@ -187,7 +188,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): self._fwdecl =3D None # To avoid header dependency hell, we always generate # declarations for built-in types in our header files and - # simply guard them. See also do_builtins (command line + # simply guard them. See also opt_builtins (command line # option -b). self._btin +=3D guardend('QAPI_TYPES_BUILTIN') self.decl =3D self._btin + self.decl @@ -202,7 +203,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): # TODO use something cleaner than existence of info if not info: self._btin +=3D gen_enum(name, values, prefix) - if do_builtins: + if self._opt_builtins: self.defn +=3D gen_enum_lookup(name, values, prefix) else: self._fwdecl +=3D gen_enum(name, values, prefix) @@ -213,7 +214,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): self._btin +=3D gen_fwd_object_or_array(name) self._btin +=3D gen_array(name, element_type) self._btin +=3D gen_type_cleanup_decl(name) - if do_builtins: + if self._opt_builtins: self.defn +=3D gen_type_cleanup(name) else: self._fwdecl +=3D gen_fwd_object_or_array(name) @@ -241,16 +242,16 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): =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 -# do_builtins, enabled by command line option -b. See also +# opt_builtins, enabled by command line option -b. See also # QAPISchemaGenTypeVisitor.visit_end(). -do_builtins =3D False +opt_builtins =3D False =20 (input_file, output_dir, do_c, do_h, prefix, opts) =3D \ parse_command_line('b', ['builtins']) =20 for o, a in opts: if o in ('-b', '--builtins'): - do_builtins =3D True + opt_builtins =3D True =20 blurb =3D ''' * Schema-defined QAPI types @@ -272,7 +273,7 @@ genh.body(mcgen(''' ''')) =20 schema =3D QAPISchema(input_file) -vis =3D QAPISchemaGenTypeVisitor() +vis =3D QAPISchemaGenTypeVisitor(opt_builtins) schema.visit(vis) genc.body(vis.defn) genh.body(vis.decl) diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index d1b25daf0d..79dc6cae48 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -264,7 +264,8 @@ out: =20 =20 class QAPISchemaGenVisitVisitor(QAPISchemaVisitor): - def __init__(self): + def __init__(self, opt_builtins): + self._opt_builtins =3D opt_builtins self.decl =3D None self.defn =3D None self._btin =3D None @@ -277,7 +278,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor): def visit_end(self): # To avoid header dependency hell, we always generate # declarations for built-in types in our header files and - # simply guard them. See also do_builtins (command line + # simply guard them. See also opt_builtins (command line # option -b). self._btin +=3D guardend('QAPI_VISIT_BUILTIN') self.decl =3D self._btin + self.decl @@ -288,7 +289,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor): # TODO use something cleaner than existence of info if not info: self._btin +=3D gen_visit_decl(name, scalar=3DTrue) - if do_builtins: + if self._opt_builtins: self.defn +=3D gen_visit_enum(name) else: self.decl +=3D gen_visit_decl(name, scalar=3DTrue) @@ -299,7 +300,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor): defn =3D gen_visit_list(name, element_type) if isinstance(element_type, QAPISchemaBuiltinType): self._btin +=3D decl - if do_builtins: + if self._opt_builtins: self.defn +=3D defn else: self.decl +=3D decl @@ -324,16 +325,16 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor): =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 -# do_builtins, enabled by command line option -b. See also +# opt_builtins, enabled by command line option -b. See also # QAPISchemaGenVisitVisitor.visit_end(). -do_builtins =3D False +opt_builtins =3D False =20 (input_file, output_dir, do_c, do_h, prefix, opts) =3D \ parse_command_line('b', ['builtins']) =20 for o, a in opts: if o in ('-b', '--builtins'): - do_builtins =3D True + opt_builtins =3D True =20 blurb =3D ''' * Schema-defined QAPI visitors @@ -359,7 +360,7 @@ genh.body(mcgen(''' prefix=3Dprefix)) =20 schema =3D QAPISchema(input_file) -vis =3D QAPISchemaGenVisitVisitor() +vis =3D QAPISchemaGenVisitVisitor(opt_builtins) schema.visit(vis) genc.body(vis.defn) genh.body(vis.decl) --=20 2.13.6 From nobody Mon Apr 29 02:38:33 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517591850547348.24838409220604; Fri, 2 Feb 2018 09:17:30 -0800 (PST) Received: from localhost ([::1]:40743 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehext-0000H0-Hc for importer@patchew.org; Fri, 02 Feb 2018 12:17:29 -0500 Received: from eggs.gnu.org ([208.118.235.92]:35624) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehdQ1-0006Mx-Ft for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:39:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ehdMC-0005Z0-FG for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:38:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32996) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ehdMB-0005Xi-Ra for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:34:28 -0500 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 3D880C022F; Fri, 2 Feb 2018 13:04:53 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-148.ams2.redhat.com [10.36.116.148]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 03D037A241; Fri, 2 Feb 2018 13:04:20 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A4B68113864F; Fri, 2 Feb 2018 14:03:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 2 Feb 2018 14:03:20 +0100 Message-Id: <20180202130336.24719-6-armbru@redhat.com> In-Reply-To: <20180202130336.24719-1-armbru@redhat.com> References: <20180202130336.24719-1-armbru@redhat.com> 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.39]); Fri, 02 Feb 2018 13:04:53 +0000 (UTC) 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 RFC 05/21] qapi: Turn generators into modules 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: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The next commit will introduce a common driver program for all generators. The generators need to be modules for that. qapi2texi.py already is. Make the other generators follow suit. The changes are actually trivial. Obvious in the diffs once you view them with whitespace changes ignored. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi-commands.py | 43 ++++++++++++++++++-------------- scripts/qapi-event.py | 43 ++++++++++++++++++-------------- scripts/qapi-introspect.py | 54 ++++++++++++++++++++++------------------ scripts/qapi-types.py | 56 ++++++++++++++++++++++------------------- scripts/qapi-visit.py | 62 +++++++++++++++++++++++++-----------------= ---- 5 files changed, 143 insertions(+), 115 deletions(-) diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py index d229537659..331b58670e 100644 --- a/scripts/qapi-commands.py +++ b/scripts/qapi-commands.py @@ -255,16 +255,17 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor): self._regy +=3D gen_register_command(name, success_response) =20 =20 -(input_file, output_dir, do_c, do_h, prefix, opts) =3D parse_command_line() +def main(argv): + (input_file, output_dir, do_c, do_h, prefix, opts) =3D parse_command_l= ine() =20 -blurb =3D ''' + blurb =3D ''' * Schema-defined QAPI/QMP commands ''' =20 -genc =3D QAPIGenC(blurb, __doc__) -genh =3D QAPIGenH(blurb, __doc__) + genc =3D QAPIGenC(blurb, __doc__) + genh =3D QAPIGenH(blurb, __doc__) =20 -genc.body(mcgen(''' + genc.body(mcgen(''' #include "qemu/osdep.h" #include "qemu-common.h" #include "qemu/module.h" @@ -278,24 +279,28 @@ genc.body(mcgen(''' #include "%(prefix)sqmp-commands.h" =20 ''', - prefix=3Dprefix)) + prefix=3Dprefix)) =20 -genh.body(mcgen(''' + genh.body(mcgen(''' #include "%(prefix)sqapi-types.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/dispatch.h" =20 void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds); ''', - prefix=3Dprefix, c_prefix=3Dc_name(prefix, protect=3DFalse= ))) - -schema =3D QAPISchema(input_file) -vis =3D QAPISchemaGenCommandVisitor(prefix) -schema.visit(vis) -genc.body(vis.defn) -genh.body(vis.decl) - -if do_c: - genc.write(output_dir, prefix + 'qmp-marshal.c') -if do_h: - genh.write(output_dir, prefix + 'qmp-commands.h') + prefix=3Dprefix, c_prefix=3Dc_name(prefix, protect=3DF= alse))) + + schema =3D QAPISchema(input_file) + vis =3D QAPISchemaGenCommandVisitor(prefix) + schema.visit(vis) + genc.body(vis.defn) + genh.body(vis.decl) + + if do_c: + genc.write(output_dir, prefix + 'qmp-marshal.c') + if do_h: + genh.write(output_dir, prefix + 'qmp-commands.h') + + +if __name__ =3D=3D '__main__': + main(sys.argv) diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py index 1af21b580a..5b33c694d4 100644 --- a/scripts/qapi-event.py +++ b/scripts/qapi-event.py @@ -171,16 +171,17 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor): self._event_names.append(name) =20 =20 -(input_file, output_dir, do_c, do_h, prefix, dummy) =3D parse_command_line= () +def main(argv): + (input_file, output_dir, do_c, do_h, prefix, dummy) =3D parse_command_= line() =20 -blurb =3D ''' + blurb =3D ''' * Schema-defined QAPI/QMP events ''' =20 -genc =3D QAPIGenC(blurb, __doc__) -genh =3D QAPIGenH(blurb, __doc__) + genc =3D QAPIGenC(blurb, __doc__) + genh =3D QAPIGenH(blurb, __doc__) =20 -genc.body(mcgen(''' + genc.body(mcgen(''' #include "qemu/osdep.h" #include "qemu-common.h" #include "%(prefix)sqapi-event.h" @@ -190,23 +191,27 @@ genc.body(mcgen(''' #include "qapi/qmp-event.h" =20 ''', - prefix=3Dprefix)) + prefix=3Dprefix)) =20 -genh.body(mcgen(''' + genh.body(mcgen(''' #include "qapi/util.h" #include "qapi/qmp/qdict.h" #include "%(prefix)sqapi-types.h" =20 ''', - prefix=3Dprefix)) - -schema =3D QAPISchema(input_file) -vis =3D QAPISchemaGenEventVisitor(prefix) -schema.visit(vis) -genc.body(vis.defn) -genh.body(vis.decl) - -if do_c: - genc.write(output_dir, prefix + 'qapi-event.c') -if do_h: - genh.write(output_dir, prefix + 'qapi-event.h') + prefix=3Dprefix)) + + schema =3D QAPISchema(input_file) + vis =3D QAPISchemaGenEventVisitor(prefix) + schema.visit(vis) + genc.body(vis.defn) + genh.body(vis.decl) + + if do_c: + genc.write(output_dir, prefix + 'qapi-event.c') + if do_h: + genh.write(output_dir, prefix + 'qapi-event.h') + + +if __name__ =3D=3D '__main__': + main(sys.argv) diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py index 8d4e3c1c3a..09e7d1f140 100644 --- a/scripts/qapi-introspect.py +++ b/scripts/qapi-introspect.py @@ -167,38 +167,44 @@ const char %(c_name)s[] =3D %(c_string)s; arg_type =3D arg_type or self._schema.the_empty_object_type self._gen_json(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 -opt_unmask =3D False =20 -(input_file, output_dir, do_c, do_h, prefix, opts) =3D \ - parse_command_line('u', ['unmask-non-abi-names']) +def main(argv): + # Debugging aid: unmask QAPI schema's type names + # We normally mask them, because they're not QMP wire ABI + opt_unmask =3D False =20 -for o, a in opts: - if o in ('-u', '--unmask-non-abi-names'): - opt_unmask =3D True + (input_file, output_dir, do_c, do_h, prefix, opts) =3D \ + parse_command_line('u', ['unmask-non-abi-names']) =20 -blurb =3D ''' + for o, a in opts: + if o in ('-u', '--unmask-non-abi-names'): + opt_unmask =3D True + + blurb =3D ''' * QAPI/QMP schema introspection ''' =20 -genc =3D QAPIGenC(blurb, __doc__) -genh =3D QAPIGenH(blurb, __doc__) + genc =3D QAPIGenC(blurb, __doc__) + genh =3D QAPIGenH(blurb, __doc__) =20 -genc.body(mcgen(''' + genc.body(mcgen(''' #include "qemu/osdep.h" #include "%(prefix)sqmp-introspect.h" =20 ''', - prefix=3Dprefix)) - -schema =3D QAPISchema(input_file) -vis =3D QAPISchemaGenIntrospectVisitor(prefix, opt_unmask) -schema.visit(vis) -genc.body(vis.defn) -genh.body(vis.decl) - -if do_c: - genc.write(output_dir, prefix + 'qmp-introspect.c') -if do_h: - genh.write(output_dir, prefix + 'qmp-introspect.h') + prefix=3Dprefix)) + + schema =3D QAPISchema(input_file) + vis =3D QAPISchemaGenIntrospectVisitor(prefix, opt_unmask) + schema.visit(vis) + genc.body(vis.defn) + genh.body(vis.decl) + + if do_c: + genc.write(output_dir, prefix + 'qmp-introspect.c') + if do_h: + genh.write(output_dir, prefix + 'qmp-introspect.h') + + +if __name__ =3D=3D '__main__': + main(sys.argv) diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index 2d711b137b..f2ddde94b1 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -240,45 +240,51 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): self.decl +=3D gen_object(name, None, [variants.tag_member], varia= nts) self._gen_type_cleanup(name) =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 -# opt_builtins, enabled by command line option -b. See also -# QAPISchemaGenTypeVisitor.visit_end(). -opt_builtins =3D False =20 -(input_file, output_dir, do_c, do_h, prefix, opts) =3D \ - parse_command_line('b', ['builtins']) +def main(argv): + # If you link code generated from multiple schemata, you want only one + # instance of the code for built-in types. Generate it only when + # opt_builtins, enabled by command line option -b. See also + # QAPISchemaGenTypeVisitor.visit_end(). + opt_builtins =3D False =20 -for o, a in opts: - if o in ('-b', '--builtins'): - opt_builtins =3D True + (input_file, output_dir, do_c, do_h, prefix, opts) =3D \ + parse_command_line('b', ['builtins']) =20 -blurb =3D ''' + for o, a in opts: + if o in ('-b', '--builtins'): + opt_builtins =3D True + + blurb =3D ''' * Schema-defined QAPI types ''' =20 -genc =3D QAPIGenC(blurb, __doc__) -genh =3D QAPIGenH(blurb, __doc__) + genc =3D QAPIGenC(blurb, __doc__) + genh =3D QAPIGenH(blurb, __doc__) =20 -genc.body(mcgen(''' + genc.body(mcgen(''' #include "qemu/osdep.h" #include "qapi/dealloc-visitor.h" #include "%(prefix)sqapi-types.h" #include "%(prefix)sqapi-visit.h" ''', - prefix=3Dprefix)) + prefix=3Dprefix)) =20 -genh.body(mcgen(''' + genh.body(mcgen(''' #include "qapi/util.h" ''')) =20 -schema =3D QAPISchema(input_file) -vis =3D QAPISchemaGenTypeVisitor(opt_builtins) -schema.visit(vis) -genc.body(vis.defn) -genh.body(vis.decl) + schema =3D QAPISchema(input_file) + vis =3D QAPISchemaGenTypeVisitor(opt_builtins) + schema.visit(vis) + genc.body(vis.defn) + genh.body(vis.decl) =20 -if do_c: - genc.write(output_dir, prefix + 'qapi-types.c') -if do_h: - genh.write(output_dir, prefix + 'qapi-types.h') + if do_c: + genc.write(output_dir, prefix + 'qapi-types.c') + if do_h: + genh.write(output_dir, prefix + 'qapi-types.h') + + +if __name__ =3D=3D '__main__': + main(sys.argv) diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index 79dc6cae48..473fa72574 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -323,49 +323,55 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor): self.decl +=3D gen_visit_decl(name) self.defn +=3D gen_visit_alternate(name, variants) =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 -# opt_builtins, enabled by command line option -b. See also -# QAPISchemaGenVisitVisitor.visit_end(). -opt_builtins =3D False =20 -(input_file, output_dir, do_c, do_h, prefix, opts) =3D \ - parse_command_line('b', ['builtins']) +def main(argv): + # If you link code generated from multiple schemata, you want only one + # instance of the code for built-in types. Generate it only when + # opt_builtins, enabled by command line option -b. See also + # QAPISchemaGenVisitVisitor.visit_end(). + opt_builtins =3D False =20 -for o, a in opts: - if o in ('-b', '--builtins'): - opt_builtins =3D True + (input_file, output_dir, do_c, do_h, prefix, opts) =3D \ + parse_command_line('b', ['builtins']) =20 -blurb =3D ''' + for o, a in opts: + if o in ('-b', '--builtins'): + opt_builtins =3D True + + blurb =3D ''' * Schema-defined QAPI visitors ''' =20 -genc =3D QAPIGenC(blurb, __doc__) -genh =3D QAPIGenH(blurb, __doc__) + genc =3D QAPIGenC(blurb, __doc__) + genh =3D QAPIGenH(blurb, __doc__) =20 -genc.body(mcgen(''' + genc.body(mcgen(''' #include "qemu/osdep.h" #include "qemu-common.h" #include "qapi/error.h" #include "%(prefix)sqapi-visit.h" ''', - prefix=3Dprefix)) + prefix=3Dprefix)) =20 -genh.body(mcgen(''' + genh.body(mcgen(''' #include "qapi/visitor.h" #include "qapi/qmp/qerror.h" #include "%(prefix)sqapi-types.h" =20 ''', - prefix=3Dprefix)) - -schema =3D QAPISchema(input_file) -vis =3D QAPISchemaGenVisitVisitor(opt_builtins) -schema.visit(vis) -genc.body(vis.defn) -genh.body(vis.decl) - -if do_c: - genc.write(output_dir, prefix + 'qapi-visit.c') -if do_h: - genh.write(output_dir, prefix + 'qapi-visit.h') + prefix=3Dprefix)) + + schema =3D QAPISchema(input_file) + vis =3D QAPISchemaGenVisitVisitor(opt_builtins) + schema.visit(vis) + genc.body(vis.defn) + genh.body(vis.decl) + + if do_c: + genc.write(output_dir, prefix + 'qapi-visit.c') + if do_h: + genh.write(output_dir, prefix + 'qapi-visit.h') + + +if __name__ =3D=3D '__main__': + main(sys.argv) --=20 2.13.6 From nobody Mon Apr 29 02:38:33 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517588100163567.9370299685093; Fri, 2 Feb 2018 08:15:00 -0800 (PST) Received: from localhost ([::1]:38564 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehdzK-0004Dx-6z for importer@patchew.org; Fri, 02 Feb 2018 11:14:54 -0500 Received: from eggs.gnu.org ([208.118.235.92]:51439) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehdIw-0000Q1-NR for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:32:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ehdHs-0000Tq-IG for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:31:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42462) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ehdHr-0000S1-Ua for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:30:00 -0500 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 7DF5699C78; Fri, 2 Feb 2018 13:04:31 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-148.ams2.redhat.com [10.36.116.148]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9915F7D962; Fri, 2 Feb 2018 13:04:17 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id AE27D1138650; Fri, 2 Feb 2018 14:03:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 2 Feb 2018 14:03:21 +0100 Message-Id: <20180202130336.24719-7-armbru@redhat.com> In-Reply-To: <20180202130336.24719-1-armbru@redhat.com> References: <20180202130336.24719-1-armbru@redhat.com> 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.38]); Fri, 02 Feb 2018 13:04:31 +0000 (UTC) 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 RFC 06/21] qapi-gen: New common driver for code and doc generators 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: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Whenever qapi-schema.json changes, we run six programs eleven times to update eleven files. This is silly. Replace the six programs by a single program that spits out all eleven files. Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau --- Makefile | 86 ++++++++++--------= ---- scripts/qapi-gen.py | 41 +++++++++++ scripts/qapi/__init__.py | 0 scripts/{qapi-commands.py =3D> qapi/commands.py} | 23 ++---- scripts/{qapi.py =3D> qapi/common.py} | 0 scripts/{qapi2texi.py =3D> qapi/doc.py} | 29 ++------ scripts/{qapi-event.py =3D> qapi/events.py} | 23 ++---- scripts/{qapi-introspect.py =3D> qapi/introspect.py} | 32 ++------ scripts/{qapi-types.py =3D> qapi/types.py} | 34 ++------- scripts/{qapi-visit.py =3D> qapi/visit.py} | 34 ++------- tests/Makefile.include | 56 +++++++------- tests/qapi-schema/test-qapi.py | 2 +- 12 files changed, 140 insertions(+), 220 deletions(-) create mode 100755 scripts/qapi-gen.py create mode 100644 scripts/qapi/__init__.py rename scripts/{qapi-commands.py =3D> qapi/commands.py} (94%) rename scripts/{qapi.py =3D> qapi/common.py} (100%) rename scripts/{qapi2texi.py =3D> qapi/doc.py} (92%) mode change 100755 =3D> 100644 rename scripts/{qapi-event.py =3D> qapi/events.py} (92%) rename scripts/{qapi-introspect.py =3D> qapi/introspect.py} (90%) rename scripts/{qapi-types.py =3D> qapi/types.py} (90%) rename scripts/{qapi-visit.py =3D> qapi/visit.py} (92%) diff --git a/Makefile b/Makefile index af31e8981f..e02f0c13ef 100644 --- a/Makefile +++ b/Makefile @@ -92,6 +92,7 @@ GENERATED_FILES +=3D qmp-commands.h qapi-types.h qapi-vis= it.h qapi-event.h GENERATED_FILES +=3D qmp-marshal.c qapi-types.c qapi-visit.c qapi-event.c GENERATED_FILES +=3D qmp-introspect.h GENERATED_FILES +=3D qmp-introspect.c +GENERATED_FILES +=3D qapi.texi =20 GENERATED_FILES +=3D trace/generated-tcg-tracers.h =20 @@ -477,25 +478,26 @@ qemu-ga$(EXESUF): QEMU_CFLAGS +=3D -I qga/qapi-genera= ted qemu-keymap$(EXESUF): LIBS +=3D $(XKBCOMMON_LIBS) qemu-keymap$(EXESUF): QEMU_CFLAGS +=3D $(XKBCOMMON_CFLAGS) =20 -gen-out-type =3D $(subst .,-,$(suffix $@)) +qapi-py =3D $(SRC_PATH)/scripts/qapi/commands.py \ +$(SRC_PATH)/scripts/qapi/events.py \ +$(SRC_PATH)/scripts/qapi/introspect.py \ +$(SRC_PATH)/scripts/qapi/types.py \ +$(SRC_PATH)/scripts/qapi/visit.py \ +$(SRC_PATH)/scripts/qapi/common.py \ +$(SRC_PATH)/scripts/qapi/doc.py \ +$(SRC_PATH)/scripts/ordereddict.py \ +$(SRC_PATH)/scripts/qapi-gen.py =20 -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) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \ - $(gen-out-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) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \ - $(gen-out-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) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \ - $(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \ - "GEN","$@") +qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h \ +qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h \ +qga/qapi-generated/qga-qmp-commands.h qga/qapi-generated/qga-qmp-marshal.c= \ +qga/qapi-generated/qga-qapi.texi: \ +qga/qapi-generated/qapi-gen-timestamp ; +qga/qapi-generated/qapi-gen-timestamp: $(SRC_PATH)/qga/qapi-schema.json $(= qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \ + -o qga/qapi-generated -p "qga-" $<, \ + "GEN","$(@:%-timestamp=3D%)") + @>$@ =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 \ @@ -512,31 +514,18 @@ qapi-modules =3D $(SRC_PATH)/qapi-schema.json $(SRC_P= ATH)/qapi/common.json \ $(SRC_PATH)/qapi/transaction.json \ $(SRC_PATH)/qapi/ui.json =20 -qapi-types.c qapi-types.h :\ -$(qapi-modules) $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \ - $(gen-out-type) -o "." -b $<, \ - "GEN","$@") -qapi-visit.c qapi-visit.h :\ -$(qapi-modules) $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \ - $(gen-out-type) -o "." -b $<, \ - "GEN","$@") -qapi-event.c qapi-event.h :\ -$(qapi-modules) $(SRC_PATH)/scripts/qapi-event.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-event.py \ - $(gen-out-type) -o "." $<, \ - "GEN","$@") -qmp-commands.h qmp-marshal.c :\ -$(qapi-modules) $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \ - $(gen-out-type) -o "." $<, \ - "GEN","$@") -qmp-introspect.h qmp-introspect.c :\ -$(qapi-modules) $(SRC_PATH)/scripts/qapi-introspect.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-introspect.py \ - $(gen-out-type) -o "." $<, \ - "GEN","$@") +qapi-types.c qapi-types.h \ +qapi-visit.c qapi-visit.h \ +qmp-commands.h qmp-marshal.c \ +qapi-event.c qapi-event.h \ +qmp-introspect.h qmp-introspect.c \ +qapi.texi: \ +qapi-gen-timestamp ; +qapi-gen-timestamp: $(qapi-modules) $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \ + -o "." -b $<, \ + "GEN","$(@:%-timestamp=3D%)") + @>$@ =20 QGALIB_GEN=3D$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-vi= sit.h qga-qmp-commands.h) $(qga-obj-y): $(QGALIB_GEN) @@ -596,6 +585,7 @@ clean: rm -f trace/generated-tracers-dtrace.dtrace* rm -f trace/generated-tracers-dtrace.h* rm -f $(foreach f,$(GENERATED_FILES),$(f) $(f)-timestamp) + rm -f qapi-gen-timestamp rm -rf qapi-generated rm -rf qga/qapi-generated for d in $(ALL_SUBDIRS); do \ @@ -803,13 +793,11 @@ qemu-monitor-info.texi: $(SRC_PATH)/hmp-commands-info= .hx $(SRC_PATH)/scripts/hxt qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@= ") =20 -docs/interop/qemu-qmp-qapi.texi docs/interop/qemu-ga-qapi.texi: $(SRC_PATH= )/scripts/qapi2texi.py $(qapi-py) +docs/interop/qemu-qmp-qapi.texi: qapi.texi + @cp -p $< $@ =20 -docs/interop/qemu-qmp-qapi.texi: $(qapi-modules) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi2texi.py $< > $@,"= GEN","$@") - -docs/interop/qemu-ga-qapi.texi: $(SRC_PATH)/qga/qapi-schema.json - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi2texi.py $< > $@,"= GEN","$@") +docs/interop/qemu-ga-qapi.texi: qga/qapi-generated/qga-qapi.texi + @cp -p $< $@ =20 qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi qemu-monitor-inf= o.texi qemu.1: qemu-option-trace.texi diff --git a/scripts/qapi-gen.py b/scripts/qapi-gen.py new file mode 100755 index 0000000000..575c938a1b --- /dev/null +++ b/scripts/qapi-gen.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python +# QAPI generator +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING file in the top-level directory. + +import sys +from qapi.common import parse_command_line, QAPISchema +from qapi.types import gen_types +from qapi.visit import gen_visit +from qapi.commands import gen_commands +from qapi.events import gen_events +from qapi.introspect import gen_introspect +from qapi.doc import gen_doc + + +def main(argv): + (input_file, output_dir, do_c, do_h, prefix, opts) =3D \ + parse_command_line('bu', ['builtins', 'unmask-non-abi-names']) + + opt_builtins =3D False + opt_unmask =3D False + + for o, a in opts: + if o in ('-b', '--builtins'): + opt_builtins =3D True + if o in ('-u', '--unmask-non-abi-names'): + opt_unmask =3D True + + schema =3D QAPISchema(input_file) + + gen_types(schema, output_dir, prefix, opt_builtins) + gen_visit(schema, output_dir, prefix, opt_builtins) + gen_commands(schema, output_dir, prefix) + gen_events(schema, output_dir, prefix) + gen_introspect(schema, output_dir, prefix, opt_unmask) + gen_doc(schema, output_dir, prefix) + + +if __name__ =3D=3D '__main__': + main(sys.argv) diff --git a/scripts/qapi/__init__.py b/scripts/qapi/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/scripts/qapi-commands.py b/scripts/qapi/commands.py similarity index 94% rename from scripts/qapi-commands.py rename to scripts/qapi/commands.py index 331b58670e..383a4dd426 100644 --- a/scripts/qapi-commands.py +++ b/scripts/qapi/commands.py @@ -13,7 +13,7 @@ This work is licensed under the terms of the GNU GPL, ver= sion 2. See the COPYING file in the top-level directory. """ =20 -from qapi import * +from qapi.common import * =20 =20 def gen_command_decl(name, arg_type, boxed, ret_type): @@ -255,13 +255,8 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor): self._regy +=3D gen_register_command(name, success_response) =20 =20 -def main(argv): - (input_file, output_dir, do_c, do_h, prefix, opts) =3D parse_command_l= ine() - - blurb =3D ''' - * Schema-defined QAPI/QMP commands -''' - +def gen_commands(schema, output_dir, prefix): + blurb =3D ' * Schema-defined QAPI/QMP commands' genc =3D QAPIGenC(blurb, __doc__) genh =3D QAPIGenH(blurb, __doc__) =20 @@ -290,17 +285,9 @@ void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds= ); ''', prefix=3Dprefix, c_prefix=3Dc_name(prefix, protect=3DF= alse))) =20 - schema =3D QAPISchema(input_file) vis =3D QAPISchemaGenCommandVisitor(prefix) schema.visit(vis) genc.body(vis.defn) genh.body(vis.decl) - - if do_c: - genc.write(output_dir, prefix + 'qmp-marshal.c') - if do_h: - genh.write(output_dir, prefix + 'qmp-commands.h') - - -if __name__ =3D=3D '__main__': - main(sys.argv) + genc.write(output_dir, prefix + 'qmp-marshal.c') + genh.write(output_dir, prefix + 'qmp-commands.h') diff --git a/scripts/qapi.py b/scripts/qapi/common.py similarity index 100% rename from scripts/qapi.py rename to scripts/qapi/common.py diff --git a/scripts/qapi2texi.py b/scripts/qapi/doc.py old mode 100755 new mode 100644 similarity index 92% rename from scripts/qapi2texi.py rename to scripts/qapi/doc.py index 924b374cd3..1f57f6e1c2 --- a/scripts/qapi2texi.py +++ b/scripts/qapi/doc.py @@ -4,10 +4,9 @@ # This work is licensed under the terms of the GNU LGPL, version 2+. # See the COPYING file in the top-level directory. """This script produces the documentation of a qapi schema in texinfo form= at""" + import re -import sys - -import qapi +import qapi.common =20 MSG_FMT =3D """ @deftypefn {type} {{}} {name} @@ -196,7 +195,7 @@ def texi_entity(doc, what, base=3DNone, variants=3DNone, + texi_sections(doc)) =20 =20 -class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor): +class QAPISchemaGenDocVisitor(qapi.common.QAPISchemaVisitor): def __init__(self): self.out =3D None self.cur_doc =3D None @@ -271,20 +270,8 @@ def texi_schema(schema): return gen.out =20 =20 -def main(argv): - """Takes schema argument, prints result to stdout""" - if len(argv) !=3D 2: - print >>sys.stderr, "%s: need exactly 1 argument: SCHEMA" % argv[0] - sys.exit(1) - - schema =3D qapi.QAPISchema(argv[1]) - if not qapi.doc_required: - print >>sys.stderr, ("%s: need pragma 'doc-required' " - "to generate documentation" % argv[0]) - sys.exit(1) - print '@c AUTOMATICALLY GENERATED, DO NOT MODIFY\n' - print texi_schema(schema), - - -if __name__ =3D=3D '__main__': - main(sys.argv) +def gen_doc(schema, output_dir, prefix): + if qapi.common.doc_required: + gen =3D qapi.common.QAPIGenDoc() + gen.body(texi_schema(schema)) + gen.write(output_dir, prefix + 'qapi.texi') diff --git a/scripts/qapi-event.py b/scripts/qapi/events.py similarity index 92% rename from scripts/qapi-event.py rename to scripts/qapi/events.py index 5b33c694d4..1f267686db 100644 --- a/scripts/qapi-event.py +++ b/scripts/qapi/events.py @@ -12,7 +12,7 @@ This work is licensed under the terms of the GNU GPL, ver= sion 2. See the COPYING file in the top-level directory. """ =20 -from qapi import * +from qapi.common import * =20 =20 def build_event_send_proto(name, arg_type, boxed): @@ -171,13 +171,8 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor): self._event_names.append(name) =20 =20 -def main(argv): - (input_file, output_dir, do_c, do_h, prefix, dummy) =3D parse_command_= line() - - blurb =3D ''' - * Schema-defined QAPI/QMP events -''' - +def gen_events(schema, output_dir, prefix): + blurb =3D ' * Schema-defined QAPI/QMP events' genc =3D QAPIGenC(blurb, __doc__) genh =3D QAPIGenH(blurb, __doc__) =20 @@ -201,17 +196,9 @@ def main(argv): ''', prefix=3Dprefix)) =20 - schema =3D QAPISchema(input_file) vis =3D QAPISchemaGenEventVisitor(prefix) schema.visit(vis) genc.body(vis.defn) genh.body(vis.decl) - - if do_c: - genc.write(output_dir, prefix + 'qapi-event.c') - if do_h: - genh.write(output_dir, prefix + 'qapi-event.h') - - -if __name__ =3D=3D '__main__': - main(sys.argv) + genc.write(output_dir, prefix + 'qapi-event.c') + genh.write(output_dir, prefix + 'qapi-event.h') diff --git a/scripts/qapi-introspect.py b/scripts/qapi/introspect.py similarity index 90% rename from scripts/qapi-introspect.py rename to scripts/qapi/introspect.py index 09e7d1f140..2153060f2c 100644 --- a/scripts/qapi-introspect.py +++ b/scripts/qapi/introspect.py @@ -10,7 +10,7 @@ This work is licensed under the terms of the GNU GPL, ver= sion 2. See the COPYING file in the top-level directory. """ =20 -from qapi import * +from qapi.common import * =20 =20 # Caveman's json.dumps() replacement (we're stuck at Python 2.4) @@ -168,22 +168,8 @@ const char %(c_name)s[] =3D %(c_string)s; self._gen_json(name, 'event', {'arg-type': self._use_type(arg_type= )}) =20 =20 -def main(argv): - # Debugging aid: unmask QAPI schema's type names - # We normally mask them, because they're not QMP wire ABI - opt_unmask =3D False - - (input_file, output_dir, do_c, do_h, prefix, opts) =3D \ - parse_command_line('u', ['unmask-non-abi-names']) - - for o, a in opts: - if o in ('-u', '--unmask-non-abi-names'): - opt_unmask =3D True - - blurb =3D ''' - * QAPI/QMP schema introspection -''' - +def gen_introspect(schema, output_dir, prefix, opt_unmask): + blurb =3D ' * QAPI/QMP schema introspection' genc =3D QAPIGenC(blurb, __doc__) genh =3D QAPIGenH(blurb, __doc__) =20 @@ -194,17 +180,9 @@ def main(argv): ''', prefix=3Dprefix)) =20 - schema =3D QAPISchema(input_file) vis =3D QAPISchemaGenIntrospectVisitor(prefix, opt_unmask) schema.visit(vis) genc.body(vis.defn) genh.body(vis.decl) - - if do_c: - genc.write(output_dir, prefix + 'qmp-introspect.c') - if do_h: - genh.write(output_dir, prefix + 'qmp-introspect.h') - - -if __name__ =3D=3D '__main__': - main(sys.argv) + genc.write(output_dir, prefix + 'qmp-introspect.c') + genh.write(output_dir, prefix + 'qmp-introspect.h') diff --git a/scripts/qapi-types.py b/scripts/qapi/types.py similarity index 90% rename from scripts/qapi-types.py rename to scripts/qapi/types.py index f2ddde94b1..b2095120e0 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi/types.py @@ -13,7 +13,7 @@ This work is licensed under the terms of the GNU GPL, ver= sion 2. # See the COPYING file in the top-level directory. """ =20 -from qapi import * +from qapi.common import * =20 =20 # variants must be emitted before their container; track what has already @@ -241,24 +241,8 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): self._gen_type_cleanup(name) =20 =20 -def main(argv): - # If you link code generated from multiple schemata, you want only one - # instance of the code for built-in types. Generate it only when - # opt_builtins, enabled by command line option -b. See also - # QAPISchemaGenTypeVisitor.visit_end(). - opt_builtins =3D False - - (input_file, output_dir, do_c, do_h, prefix, opts) =3D \ - parse_command_line('b', ['builtins']) - - for o, a in opts: - if o in ('-b', '--builtins'): - opt_builtins =3D True - - blurb =3D ''' - * Schema-defined QAPI types -''' - +def gen_types(schema, output_dir, prefix, opt_builtins): + blurb =3D ' * Schema-defined QAPI types' genc =3D QAPIGenC(blurb, __doc__) genh =3D QAPIGenH(blurb, __doc__) =20 @@ -274,17 +258,9 @@ def main(argv): #include "qapi/util.h" ''')) =20 - schema =3D QAPISchema(input_file) vis =3D QAPISchemaGenTypeVisitor(opt_builtins) schema.visit(vis) genc.body(vis.defn) genh.body(vis.decl) - - if do_c: - genc.write(output_dir, prefix + 'qapi-types.c') - if do_h: - genh.write(output_dir, prefix + 'qapi-types.h') - - -if __name__ =3D=3D '__main__': - main(sys.argv) + genc.write(output_dir, prefix + 'qapi-types.c') + genh.write(output_dir, prefix + 'qapi-types.h') diff --git a/scripts/qapi-visit.py b/scripts/qapi/visit.py similarity index 92% rename from scripts/qapi-visit.py rename to scripts/qapi/visit.py index 473fa72574..80c0b85f8c 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi/visit.py @@ -13,7 +13,7 @@ This work is licensed under the terms of the GNU GPL, ver= sion 2. See the COPYING file in the top-level directory. """ =20 -from qapi import * +from qapi.common import * =20 =20 def gen_visit_decl(name, scalar=3DFalse): @@ -324,24 +324,8 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor): self.defn +=3D gen_visit_alternate(name, variants) =20 =20 -def main(argv): - # If you link code generated from multiple schemata, you want only one - # instance of the code for built-in types. Generate it only when - # opt_builtins, enabled by command line option -b. See also - # QAPISchemaGenVisitVisitor.visit_end(). - opt_builtins =3D False - - (input_file, output_dir, do_c, do_h, prefix, opts) =3D \ - parse_command_line('b', ['builtins']) - - for o, a in opts: - if o in ('-b', '--builtins'): - opt_builtins =3D True - - blurb =3D ''' - * Schema-defined QAPI visitors -''' - +def gen_visit(schema, output_dir, prefix, opt_builtins): + blurb =3D ' * Schema-defined QAPI visitors' genc =3D QAPIGenC(blurb, __doc__) genh =3D QAPIGenH(blurb, __doc__) =20 @@ -361,17 +345,9 @@ def main(argv): ''', prefix=3Dprefix)) =20 - schema =3D QAPISchema(input_file) vis =3D QAPISchemaGenVisitVisitor(opt_builtins) schema.visit(vis) genc.body(vis.defn) genh.body(vis.decl) - - if do_c: - genc.write(output_dir, prefix + 'qapi-visit.c') - if do_h: - genh.write(output_dir, prefix + 'qapi-visit.h') - - -if __name__ =3D=3D '__main__': - main(sys.argv) + genc.write(output_dir, prefix + 'qapi-visit.c') + genh.write(output_dir, prefix + 'qapi-visit.h') diff --git a/tests/Makefile.include b/tests/Makefile.include index 851aafe9d1..768655a810 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -23,7 +23,16 @@ check-help: ifneq ($(wildcard config-host.mak),) export SRC_PATH =20 -qapi-py =3D $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py +# TODO don't duplicate $(SRC_PATH)/Makefile's qapi-py here +qapi-py =3D $(SRC_PATH)/scripts/qapi/commands.py \ +$(SRC_PATH)/scripts/qapi/events.py \ +$(SRC_PATH)/scripts/qapi/introspect.py \ +$(SRC_PATH)/scripts/qapi/types.py \ +$(SRC_PATH)/scripts/qapi/visit.py \ +$(SRC_PATH)/scripts/qapi/common.py \ +$(SRC_PATH)/scripts/qapi/doc.py \ +$(SRC_PATH)/scripts/ordereddict.py \ +$(SRC_PATH)/scripts/qapi-gen.py =20 # Get the list of all supported sysemu targets SYSEMU_TARGET_LIST :=3D $(subst -softmmu.mak,,$(notdir \ @@ -642,34 +651,24 @@ tests/test-logging$(EXESUF): tests/test-logging.o $(t= est-util-obj-y) tests/test-replication$(EXESUF): tests/test-replication.o $(test-util-obj-= y) \ $(test-block-obj-y) =20 -tests/test-qapi-types.c tests/test-qapi-types.h :\ -$(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qa= pi-types.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \ - $(gen-out-type) -o tests -p "test-" $<, \ - "GEN","$@") -tests/test-qapi-visit.c tests/test-qapi-visit.h :\ -$(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qa= pi-visit.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \ - $(gen-out-type) -o tests -p "test-" $<, \ - "GEN","$@") -tests/test-qmp-commands.h tests/test-qmp-marshal.c :\ -$(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qa= pi-commands.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \ - $(gen-out-type) -o tests -p "test-" $<, \ - "GEN","$@") -tests/test-qapi-event.c tests/test-qapi-event.h :\ -$(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qa= pi-event.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-event.py \ - $(gen-out-type) -o tests -p "test-" $<, \ - "GEN","$@") -tests/test-qmp-introspect.c tests/test-qmp-introspect.h :\ -$(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qa= pi-introspect.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-introspect.py \ - $(gen-out-type) -o tests -p "test-" $<, \ - "GEN","$@") +tests/test-qapi-types.c tests/test-qapi-types.h \ +tests/test-qapi-visit.c tests/test-qapi-visit.h \ +tests/test-qmp-commands.h tests/test-qmp-marshal.c \ +tests/test-qapi-event.c tests/test-qapi-event.h \ +tests/test-qmp-introspect.c tests/test-qmp-introspect.h: \ +tests/test-qapi-gen-timestamp ; +tests/test-qapi-gen-timestamp: $(SRC_PATH)/tests/qapi-schema/qapi-schema-t= est.json $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \ + -o tests -p "test-" $<, \ + "GEN","$(@:%-timestamp=3D%)") + @>$@ =20 -tests/qapi-schema/doc-good.test.texi: $(SRC_PATH)/tests/qapi-schema/doc-go= od.json $(SRC_PATH)/scripts/qapi2texi.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi2texi.py $< > $@,"= GEN","$@") +tests/qapi-schema/doc-good.test.texi: $(SRC_PATH)/tests/qapi-schema/doc-go= od.json $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \ + -o tests/qapi-schema -p "doc-good-" $<, \ + "GEN","$@") + @mv tests/qapi-schema/doc-good-qapi.texi $@ + @rm -f tests/qapi-schema/doc-good-qapi-*.[ch] tests/qapi-schema/doc-good-= qmp-*.[ch] =20 tests/test-string-output-visitor$(EXESUF): tests/test-string-output-visito= r.o $(test-qapi-obj-y) tests/test-string-input-visitor$(EXESUF): tests/test-string-input-visitor.= o $(test-qapi-obj-y) @@ -937,6 +936,7 @@ check-clean: $(MAKE) -C tests/tcg clean rm -rf $(check-unit-y) tests/*.o $(QEMU_IOTESTS_HELPERS-y) rm -rf $(sort $(foreach target,$(SYSEMU_TARGET_LIST), $(check-qtest-$(tar= get)-y)) $(check-qtest-generic-y)) + rm -f tests/test-qapi-gen-timestamp =20 clean: check-clean =20 diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py index fe0ca08d78..7772d09919 100644 --- a/tests/qapi-schema/test-qapi.py +++ b/tests/qapi-schema/test-qapi.py @@ -10,7 +10,7 @@ # See the COPYING file in the top-level directory. # =20 -from qapi import * +from qapi.common import * from pprint import pprint import os import sys --=20 2.13.6 From nobody Mon Apr 29 02:38:33 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517589155174149.924067638064; Fri, 2 Feb 2018 08:32:35 -0800 (PST) Received: from localhost ([::1]:38964 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eheGL-0002mP-Bm for importer@patchew.org; Fri, 02 Feb 2018 11:32:29 -0500 Received: from eggs.gnu.org ([208.118.235.92]:55862) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehdMa-0002hf-Sm for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:35:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ehdLV-0004e8-OH for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:34:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58930) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ehdLU-0004cE-Uv for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:33:45 -0500 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 2CB6D70D73; Fri, 2 Feb 2018 13:04:57 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-148.ams2.redhat.com [10.36.116.148]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B7B327CD9F; Fri, 2 Feb 2018 13:04:19 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B6C591138651; Fri, 2 Feb 2018 14:03:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 2 Feb 2018 14:03:22 +0100 Message-Id: <20180202130336.24719-8-armbru@redhat.com> In-Reply-To: <20180202130336.24719-1-armbru@redhat.com> References: <20180202130336.24719-1-armbru@redhat.com> 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.28]); Fri, 02 Feb 2018 13:04:57 +0000 (UTC) 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 RFC 07/21] qapi: Move parse_command_line() next to its only use 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: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi-gen.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++= +- scripts/qapi/common.py | 54 ----------------------------------------------= ---- 2 files changed, 51 insertions(+), 55 deletions(-) diff --git a/scripts/qapi-gen.py b/scripts/qapi-gen.py index 575c938a1b..6302fd0d55 100755 --- a/scripts/qapi-gen.py +++ b/scripts/qapi-gen.py @@ -4,8 +4,10 @@ # This work is licensed under the terms of the GNU GPL, version 2 or later. # See the COPYING file in the top-level directory. =20 +import getopt +import re import sys -from qapi.common import parse_command_line, QAPISchema +from qapi.common import QAPISchema from qapi.types import gen_types from qapi.visit import gen_visit from qapi.commands import gen_commands @@ -14,6 +16,54 @@ from qapi.introspect import gen_introspect from qapi.doc import gen_doc =20 =20 +def parse_command_line(extra_options=3D'', extra_long_options=3D[]): + + try: + opts, args =3D getopt.gnu_getopt(sys.argv[1:], + 'chp:o:' + extra_options, + ['source', 'header', 'prefix=3D', + 'output-dir=3D'] + extra_long_opti= ons) + except getopt.GetoptError as err: + print >>sys.stderr, "%s: %s" % (sys.argv[0], str(err)) + sys.exit(1) + + output_dir =3D '' + prefix =3D '' + do_c =3D False + do_h =3D False + extra_opts =3D [] + + for oa in opts: + o, a =3D oa + if o in ('-p', '--prefix'): + match =3D re.match(r'([A-Za-z_.-][A-Za-z0-9_.-]*)?', a) + if match.end() !=3D len(a): + print >>sys.stderr, \ + "%s: 'funny character '%s' in argument of --prefix" \ + % (sys.argv[0], a[match.end()]) + sys.exit(1) + prefix =3D a + elif o in ('-o', '--output-dir'): + output_dir =3D a + '/' + elif o in ('-c', '--source'): + do_c =3D True + elif o in ('-h', '--header'): + do_h =3D True + else: + extra_opts.append(oa) + + if not do_c and not do_h: + do_c =3D True + do_h =3D True + + if len(args) !=3D 1: + print >>sys.stderr, "%s: need exactly one argument" % sys.argv[0] + sys.exit(1) + fname =3D args[0] + + return (fname, output_dir, do_c, do_h, prefix, extra_opts) + + def main(argv): (input_file, output_dir, do_c, do_h, prefix, opts) =3D \ parse_command_line('bu', ['builtins', 'unmask-non-abi-names']) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index d73ef618e2..cfa2671ca3 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -12,7 +12,6 @@ # See the COPYING file in the top-level directory. =20 import errno -import getopt import os import re import string @@ -1917,59 +1916,6 @@ def build_params(arg_type, boxed, extra): =20 =20 # -# Common command line parsing -# - - -def parse_command_line(extra_options=3D'', extra_long_options=3D[]): - - try: - opts, args =3D getopt.gnu_getopt(sys.argv[1:], - 'chp:o:' + extra_options, - ['source', 'header', 'prefix=3D', - 'output-dir=3D'] + extra_long_opti= ons) - except getopt.GetoptError as err: - print >>sys.stderr, "%s: %s" % (sys.argv[0], str(err)) - sys.exit(1) - - output_dir =3D '' - prefix =3D '' - do_c =3D False - do_h =3D False - extra_opts =3D [] - - for oa in opts: - o, a =3D oa - if o in ('-p', '--prefix'): - match =3D re.match(r'([A-Za-z_.-][A-Za-z0-9_.-]*)?', a) - if match.end() !=3D len(a): - print >>sys.stderr, \ - "%s: 'funny character '%s' in argument of --prefix" \ - % (sys.argv[0], a[match.end()]) - sys.exit(1) - prefix =3D a - elif o in ('-o', '--output-dir'): - output_dir =3D a + '/' - elif o in ('-c', '--source'): - do_c =3D True - elif o in ('-h', '--header'): - do_h =3D True - else: - extra_opts.append(oa) - - if not do_c and not do_h: - do_c =3D True - do_h =3D True - - if len(args) !=3D 1: - print >>sys.stderr, "%s: need exactly one argument" % sys.argv[0] - sys.exit(1) - fname =3D args[0] - - return (fname, output_dir, do_c, do_h, prefix, extra_opts) - - -# # Accumulate and write output # =20 --=20 2.13.6 From nobody Mon Apr 29 02:38:33 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151758974069815.281832735545436; Fri, 2 Feb 2018 08:42:20 -0800 (PST) Received: from localhost ([::1]:39366 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehePo-0002sG-JX for importer@patchew.org; Fri, 02 Feb 2018 11:42:16 -0500 Received: from eggs.gnu.org ([208.118.235.92]:60321) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehdO5-0004p8-Lb for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:37:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ehdKD-00037w-Dz for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:36:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58318) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ehdKC-00035B-Bb for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:32:24 -0500 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 080EB2CE927; Fri, 2 Feb 2018 13:04:57 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-148.ams2.redhat.com [10.36.116.148]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BAAF560F85; Fri, 2 Feb 2018 13:04:19 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id BD2F01138656; Fri, 2 Feb 2018 14:03:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 2 Feb 2018 14:03:23 +0100 Message-Id: <20180202130336.24719-9-armbru@redhat.com> In-Reply-To: <20180202130336.24719-1-armbru@redhat.com> References: <20180202130336.24719-1-armbru@redhat.com> 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.29]); Fri, 02 Feb 2018 13:04:57 +0000 (UTC) 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 RFC 08/21] qapi: Touch generated files only when they change 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: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" A massive number of objects depends on QAPI-generated headers. In my "build everything" tree, it's roughly 4500 out of 4800. This is particularly annoying when only some of the generated files change, say for a doc fix. Improve qapi-gen.py to touch its output files only if they actually change. Rebuild time for a QAPI doc fix drops from many minutes to a few seconds. Rebuilds get faster for certain code changes, too. For instance, adding a simple QMP event now recompiles less than 200 instead of 4500 objects. But adding a QAPI type is as bad as ever; we clearly got more work to do. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- scripts/qapi/common.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index cfa2671ca3..be0fcc548a 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -1944,9 +1944,16 @@ class QAPIGen(object): except os.error as e: if e.errno !=3D errno.EEXIST: raise - f =3D open(os.path.join(output_dir, fname), 'w') - f.write(self.top(fname) + self._preamble + self._body + fd =3D os.open(os.path.join(output_dir, fname), + os.O_RDWR | os.O_CREAT, 0666) + f =3D os.fdopen(fd, 'r+') + text =3D (self.top(fname) + self._preamble + self._body + self.bottom(fname)) + oldtext =3D f.read(len(text) + 1) + if text !=3D oldtext: + f.seek(0) + f.truncate(0) + f.write(text) f.close() =20 =20 --=20 2.13.6 From nobody Mon Apr 29 02:38:33 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517588891448867.7719366283363; Fri, 2 Feb 2018 08:28:11 -0800 (PST) Received: from localhost ([::1]:38911 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eheCA-0007g1-If for importer@patchew.org; Fri, 02 Feb 2018 11:28:10 -0500 Received: from eggs.gnu.org ([208.118.235.92]:55457) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehdLH-0002Uf-5v for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:34:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ehdKD-00037L-31 for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:33:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58332) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ehdKC-00035C-57 for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:32:24 -0500 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 53E072D269A; Fri, 2 Feb 2018 13:04:45 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-148.ams2.redhat.com [10.36.116.148]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EA08D6F111; Fri, 2 Feb 2018 13:04:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C0F1C1138657; Fri, 2 Feb 2018 14:03:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 2 Feb 2018 14:03:24 +0100 Message-Id: <20180202130336.24719-10-armbru@redhat.com> In-Reply-To: <20180202130336.24719-1-armbru@redhat.com> References: <20180202130336.24719-1-armbru@redhat.com> 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.29]); Fri, 02 Feb 2018 13:04:45 +0000 (UTC) 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 RFC 09/21] qapi: Don't absolutize include file name in error messages 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: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Error messages print absolute filenames of included files even gave a relative one on the command line: PYTHONPATH=3Dscripts python -B tests/qapi-schema/test-qapi.py tests/qa= pi-schema/include-cycle.json In file included from tests/qapi-schema/include-cycle.json:1: In file included from /work/armbru/qemu/tests/qapi-schema/include-cycle= -b.json:1: /work/armbru/qemu/tests/qapi-schema/include-cycle-c.json:1: Inclusion l= oop for include-cycle.json Improve this to In file included from tests/qapi-schema/include-cycle.json:1: In file included from tests/qapi-schema/include-cycle-b.json:1: tests/qapi-schema/include-cycle-c.json:1: Inclusion loop for include-cy= cle.json Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi/common.py | 12 ++++++------ tests/qapi-schema/include-no-file.err | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index be0fcc548a..6c6962a364 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -255,9 +255,8 @@ class QAPIDoc(object): class QAPISchemaParser(object): =20 def __init__(self, fp, previously_included=3D[], incl_info=3DNone): - abs_fname =3D os.path.abspath(fp.name) self.fname =3D fp.name - previously_included.append(abs_fname) + previously_included.append(os.path.abspath(fp.name)) self.incl_info =3D incl_info self.src =3D fp.read() if self.src =3D=3D '' or self.src[-1] !=3D '\n': @@ -288,7 +287,7 @@ class QAPISchemaParser(object): if not isinstance(include, str): raise QAPISemError(info, "Value of 'include' must be a strin= g") - self._include(include, info, os.path.dirname(abs_fname), + self._include(include, info, os.path.dirname(self.fname), previously_included) elif "pragma" in expr: self.reject_expr_doc(cur_doc) @@ -321,7 +320,8 @@ class QAPISchemaParser(object): % doc.symbol) =20 def _include(self, include, info, base_dir, previously_included): - incl_abs_fname =3D os.path.join(base_dir, include) + incl_fname =3D os.path.join(base_dir, include) + incl_abs_fname =3D os.path.abspath(incl_fname) # catch inclusion cycle inf =3D info while inf: @@ -333,9 +333,9 @@ class QAPISchemaParser(object): if incl_abs_fname in previously_included: return try: - fobj =3D open(incl_abs_fname, 'r') + fobj =3D open(incl_fname, 'r') except IOError as e: - raise QAPISemError(info, '%s: %s' % (e.strerror, include)) + raise QAPISemError(info, '%s: %s' % (e.strerror, incl_fname)) exprs_include =3D QAPISchemaParser(fobj, previously_included, info) self.exprs.extend(exprs_include.exprs) self.docs.extend(exprs_include.docs) diff --git a/tests/qapi-schema/include-no-file.err b/tests/qapi-schema/incl= ude-no-file.err index d5b9b22d85..e42bcf4bc1 100644 --- a/tests/qapi-schema/include-no-file.err +++ b/tests/qapi-schema/include-no-file.err @@ -1 +1 @@ -tests/qapi-schema/include-no-file.json:1: No such file or directory: inclu= de-no-file-sub.json +tests/qapi-schema/include-no-file.json:1: No such file or directory: tests= /qapi-schema/include-no-file-sub.json --=20 2.13.6 From nobody Mon Apr 29 02:38:33 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517592115801780.4791872826688; Fri, 2 Feb 2018 09:21:55 -0800 (PST) Received: from localhost ([::1]:40999 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehf27-0004Cu-Bk for importer@patchew.org; Fri, 02 Feb 2018 12:21:51 -0500 Received: from eggs.gnu.org ([208.118.235.92]:38749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehdRw-000868-O7 for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:41:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ehdQs-0003uG-EI for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:40:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54058) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ehdK2-0002uP-Sw for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:32:15 -0500 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 D4165C05E76F; Fri, 2 Feb 2018 13:04:58 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-148.ams2.redhat.com [10.36.116.148]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ED9237CD62; Fri, 2 Feb 2018 13:04:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C3FC11138659; Fri, 2 Feb 2018 14:03:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 2 Feb 2018 14:03:25 +0100 Message-Id: <20180202130336.24719-11-armbru@redhat.com> In-Reply-To: <20180202130336.24719-1-armbru@redhat.com> References: <20180202130336.24719-1-armbru@redhat.com> 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]); Fri, 02 Feb 2018 13:04:58 +0000 (UTC) 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 RFC 10/21] qapi/common: Eliminate QAPISchema.exprs 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: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi/common.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 6c6962a364..78e960d07c 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -1457,13 +1457,13 @@ class QAPISchema(object): def __init__(self, fname): try: parser =3D QAPISchemaParser(open(fname, 'r')) - self.exprs =3D check_exprs(parser.exprs) + exprs =3D check_exprs(parser.exprs) self.docs =3D parser.docs self._entity_dict =3D {} self._predefining =3D True self._def_predefineds() self._predefining =3D False - self._def_exprs() + self._def_exprs(exprs) self.check() except QAPIError as err: print >>sys.stderr, err @@ -1648,8 +1648,8 @@ class QAPISchema(object): name, info, doc, 'arg', self._make_members(data, info)) self._def_entity(QAPISchemaEvent(name, info, doc, data, boxed)) =20 - def _def_exprs(self): - for expr_elem in self.exprs: + def _def_exprs(self, exprs): + for expr_elem in exprs: expr =3D expr_elem['expr'] info =3D expr_elem['info'] doc =3D expr_elem.get('doc') --=20 2.13.6 From nobody Mon Apr 29 02:38:33 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517590589196279.5900734049019; Fri, 2 Feb 2018 08:56:29 -0800 (PST) Received: from localhost ([::1]:39920 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehedW-0006vN-Sw for importer@patchew.org; Fri, 02 Feb 2018 11:56:27 -0500 Received: from eggs.gnu.org ([208.118.235.92]:57117) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehdNI-0003Ev-FJ for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:36:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ehdMC-0005ZV-La for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:35:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33006) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ehdMB-0005Xj-Rg for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:34:28 -0500 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 15A77A0BFA; Fri, 2 Feb 2018 13:04:53 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-148.ams2.redhat.com [10.36.116.148]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DA3AE6312F; Fri, 2 Feb 2018 13:04:37 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C70C9113865A; Fri, 2 Feb 2018 14:03:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 2 Feb 2018 14:03:26 +0100 Message-Id: <20180202130336.24719-12-armbru@redhat.com> In-Reply-To: <20180202130336.24719-1-armbru@redhat.com> References: <20180202130336.24719-1-armbru@redhat.com> 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.39]); Fri, 02 Feb 2018 13:04:53 +0000 (UTC) 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 RFC 11/21] qapi: Lift error reporting from QAPISchema.__init__() to callers 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: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi-gen.py | 8 ++++++-- scripts/qapi/common.py | 23 +++++++++-------------- tests/qapi-schema/test-qapi.py | 8 +++++++- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/scripts/qapi-gen.py b/scripts/qapi-gen.py index 6302fd0d55..ba82ca92cc 100755 --- a/scripts/qapi-gen.py +++ b/scripts/qapi-gen.py @@ -7,7 +7,7 @@ import getopt import re import sys -from qapi.common import QAPISchema +from qapi.common import QAPIError, QAPISchema from qapi.types import gen_types from qapi.visit import gen_visit from qapi.commands import gen_commands @@ -77,7 +77,11 @@ def main(argv): if o in ('-u', '--unmask-non-abi-names'): opt_unmask =3D True =20 - schema =3D QAPISchema(input_file) + try: + schema =3D QAPISchema(input_file) + except QAPIError as err: + print >>sys.stderr, err + exit(1) =20 gen_types(schema, output_dir, prefix, opt_builtins) gen_visit(schema, output_dir, prefix, opt_builtins) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 78e960d07c..d334e1db5a 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -15,7 +15,6 @@ import errno import os import re import string -import sys from ordereddict import OrderedDict =20 builtin_types =3D { @@ -1455,19 +1454,15 @@ class QAPISchemaEvent(QAPISchemaEntity): =20 class QAPISchema(object): def __init__(self, fname): - try: - parser =3D QAPISchemaParser(open(fname, 'r')) - exprs =3D check_exprs(parser.exprs) - self.docs =3D parser.docs - self._entity_dict =3D {} - self._predefining =3D True - self._def_predefineds() - self._predefining =3D False - self._def_exprs(exprs) - self.check() - except QAPIError as err: - print >>sys.stderr, err - exit(1) + parser =3D QAPISchemaParser(open(fname, 'r')) + exprs =3D check_exprs(parser.exprs) + self.docs =3D parser.docs + self._entity_dict =3D {} + self._predefining =3D True + self._def_predefineds() + self._predefining =3D False + self._def_exprs(exprs) + self.check() =20 def _def_entity(self, ent): # Only the predefined types are allowed to not have info diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py index 7772d09919..d6bb8ec6a4 100644 --- a/tests/qapi-schema/test-qapi.py +++ b/tests/qapi-schema/test-qapi.py @@ -53,7 +53,13 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor): for v in variants.variants: print ' case %s: %s' % (v.name, v.type.name) =20 -schema =3D QAPISchema(sys.argv[1]) + +try: + schema =3D QAPISchema(sys.argv[1]) +except QAPIError as err: + print >>sys.stderr, err + exit(1) + schema.visit(QAPISchemaTestVisitor()) =20 for doc in schema.docs: --=20 2.13.6 From nobody Mon Apr 29 02:38:33 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517589262319944.2570433387006; Fri, 2 Feb 2018 08:34:22 -0800 (PST) Received: from localhost ([::1]:38994 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eheI9-0004Kn-GY for importer@patchew.org; Fri, 02 Feb 2018 11:34:21 -0500 Received: from eggs.gnu.org ([208.118.235.92]:59855) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehdNm-0004cN-PK for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:37:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ehdMi-0006NP-LE for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:36:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49022) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ehdMh-0006LD-TQ for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:35:00 -0500 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 CF33D7B004; Fri, 2 Feb 2018 13:04:58 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-148.ams2.redhat.com [10.36.116.148]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BC7FD7CD9C; Fri, 2 Feb 2018 13:04:32 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id CA01D1138662; Fri, 2 Feb 2018 14:03:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 2 Feb 2018 14:03:27 +0100 Message-Id: <20180202130336.24719-13-armbru@redhat.com> In-Reply-To: <20180202130336.24719-1-armbru@redhat.com> References: <20180202130336.24719-1-armbru@redhat.com> 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]); Fri, 02 Feb 2018 13:04:58 +0000 (UTC) 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 RFC 12/21] qapi: Concentrate QAPISchemaParser.exprs updates in .__init__() 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: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi/common.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index d334e1db5a..7a327bfe9f 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -286,8 +286,12 @@ class QAPISchemaParser(object): if not isinstance(include, str): raise QAPISemError(info, "Value of 'include' must be a strin= g") - self._include(include, info, os.path.dirname(self.fname), - previously_included) + exprs_include =3D self._include(include, info, + os.path.dirname(self.fname), + previously_included) + if exprs_include: + self.exprs.extend(exprs_include.exprs) + self.docs.extend(exprs_include.docs) elif "pragma" in expr: self.reject_expr_doc(cur_doc) if len(expr) !=3D 1: @@ -330,14 +334,13 @@ class QAPISchemaParser(object): =20 # skip multiple include of the same file if incl_abs_fname in previously_included: - return + return None + try: fobj =3D open(incl_fname, 'r') except IOError as e: raise QAPISemError(info, '%s: %s' % (e.strerror, incl_fname)) - exprs_include =3D QAPISchemaParser(fobj, previously_included, info) - self.exprs.extend(exprs_include.exprs) - self.docs.extend(exprs_include.docs) + return QAPISchemaParser(fobj, previously_included, info) =20 def _pragma(self, name, value, info): global doc_required, returns_whitelist, name_case_whitelist --=20 2.13.6 From nobody Mon Apr 29 02:38:33 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517588645259202.78951310570346; Fri, 2 Feb 2018 08:24:05 -0800 (PST) Received: from localhost ([::1]:38798 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehe8C-0003ns-8j for importer@patchew.org; Fri, 02 Feb 2018 11:24:04 -0500 Received: from eggs.gnu.org ([208.118.235.92]:55983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehdLZ-0002kG-Uk for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:34:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ehdKV-0003VU-JV for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:33:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49388) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ehdKU-0003Tg-U1 for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:32:43 -0500 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 80EA82815B; Fri, 2 Feb 2018 13:04:56 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-148.ams2.redhat.com [10.36.116.148]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7C4FF6F110; Fri, 2 Feb 2018 13:04:35 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id CCFBA1138663; Fri, 2 Feb 2018 14:03:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 2 Feb 2018 14:03:28 +0100 Message-Id: <20180202130336.24719-14-armbru@redhat.com> In-Reply-To: <20180202130336.24719-1-armbru@redhat.com> References: <20180202130336.24719-1-armbru@redhat.com> 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]); Fri, 02 Feb 2018 13:04:56 +0000 (UTC) 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 RFC 13/21] qapi: Record 'include' directives in parse tree 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: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The parse tree is a list of expressions. Except include expressions currently get replaced by the included file's parse tree. Instead of throwing away the include expression, keep it with the file name expanded so you don't have to track the including file's directory to make sense of it. A future commit will put this include expression to use. Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi/common.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 7a327bfe9f..d5b93e7381 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -286,8 +286,11 @@ class QAPISchemaParser(object): if not isinstance(include, str): raise QAPISemError(info, "Value of 'include' must be a strin= g") - exprs_include =3D self._include(include, info, - os.path.dirname(self.fname), + incl_fname =3D os.path.join(os.path.dirname(self.fname), + include) + self.exprs.append({'expr': {'include': incl_fname}, + 'info': info}) + exprs_include =3D self._include(include, info, incl_fname, previously_included) if exprs_include: self.exprs.extend(exprs_include.exprs) @@ -322,8 +325,7 @@ class QAPISchemaParser(object): "Documentation for '%s' is not followed by the definition" % doc.symbol) =20 - def _include(self, include, info, base_dir, previously_included): - incl_fname =3D os.path.join(base_dir, include) + def _include(self, include, info, incl_fname, previously_included): incl_abs_fname =3D os.path.abspath(incl_fname) # catch inclusion cycle inf =3D info @@ -889,6 +891,9 @@ def check_exprs(exprs): info =3D expr_elem['info'] doc =3D expr_elem.get('doc') =20 + if 'include' in expr: + continue + if not doc and doc_required: raise QAPISemError(info, "Expression missing documentation comment") @@ -927,6 +932,9 @@ def check_exprs(exprs): =20 # Try again for hidden UnionKind enum for expr_elem in exprs: + if 'include' in expr: + continue + expr =3D expr_elem['expr'] if 'union' in expr and not discriminator_find_enum_define(expr): name =3D '%sKind' % expr['union'] @@ -939,6 +947,9 @@ def check_exprs(exprs): =20 # Validate that exprs make sense for expr_elem in exprs: + if 'include' in expr: + continue + expr =3D expr_elem['expr'] info =3D expr_elem['info'] doc =3D expr_elem.get('doc') @@ -1663,6 +1674,8 @@ class QAPISchema(object): self._def_command(expr, info, doc) elif 'event' in expr: self._def_event(expr, info, doc) + elif 'include' in expr: + pass else: assert False =20 --=20 2.13.6 From nobody Mon Apr 29 02:38:33 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517588706984914.1396720123154; Fri, 2 Feb 2018 08:25:06 -0800 (PST) Received: from localhost ([::1]:38808 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehe9B-0004hS-WE for importer@patchew.org; Fri, 02 Feb 2018 11:25:06 -0500 Received: from eggs.gnu.org ([208.118.235.92]:51504) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehdIz-0000Sp-I0 for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:32:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ehdHv-0000XY-Cs for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:31:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43722) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ehdHu-0000WA-U5 for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:30:03 -0500 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 20196C053FD5; Fri, 2 Feb 2018 13:04:57 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-148.ams2.redhat.com [10.36.116.148]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9202D67DDC; Fri, 2 Feb 2018 13:04:35 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id CFFE21138664; Fri, 2 Feb 2018 14:03:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 2 Feb 2018 14:03:29 +0100 Message-Id: <20180202130336.24719-15-armbru@redhat.com> In-Reply-To: <20180202130336.24719-1-armbru@redhat.com> References: <20180202130336.24719-1-armbru@redhat.com> 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.32]); Fri, 02 Feb 2018 13:04:57 +0000 (UTC) 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 RFC 14/21] qapi: Generate in source order 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: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The generators' conversion to visitors (merge commit 9e72681d16) changed the processing order of entities from source order to alphabetical order. The next commit needs source order, so change it back. Signed-off-by: Markus Armbruster --- scripts/qapi/common.py | 4 +- tests/qapi-schema/comments.out | 2 +- tests/qapi-schema/doc-bad-section.out | 4 +- tests/qapi-schema/doc-good.out | 32 ++-- tests/qapi-schema/empty.out | 2 +- tests/qapi-schema/event-case.out | 2 +- tests/qapi-schema/ident-with-escape.out | 6 +- tests/qapi-schema/include-relpath.out | 2 +- tests/qapi-schema/include-repetition.out | 2 +- tests/qapi-schema/include-simple.out | 2 +- tests/qapi-schema/indented-expr.out | 2 +- tests/qapi-schema/qapi-schema-test.out | 320 +++++++++++++++------------= ---- 12 files changed, 191 insertions(+), 189 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index d5b93e7381..3b97bf8702 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -1471,6 +1471,7 @@ class QAPISchema(object): parser =3D QAPISchemaParser(open(fname, 'r')) exprs =3D check_exprs(parser.exprs) self.docs =3D parser.docs + self._entity_list =3D [] self._entity_dict =3D {} self._predefining =3D True self._def_predefineds() @@ -1482,6 +1483,7 @@ class QAPISchema(object): # 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_list.append(ent) self._entity_dict[ent.name] =3D ent =20 def lookup_entity(self, name, typ=3DNone): @@ -1685,7 +1687,7 @@ class QAPISchema(object): =20 def visit(self, visitor): visitor.visit_begin(self) - for (name, entity) in sorted(self._entity_dict.items()): + for entity in self._entity_list: if visitor.visit_needed(entity): entity.visit(visitor) visitor.visit_end() diff --git a/tests/qapi-schema/comments.out b/tests/qapi-schema/comments.out index 17e652535c..0261ddf202 100644 --- a/tests/qapi-schema/comments.out +++ b/tests/qapi-schema/comments.out @@ -1,4 +1,4 @@ +object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE enum Status ['good', 'bad', 'ugly'] -object q_empty diff --git a/tests/qapi-schema/doc-bad-section.out b/tests/qapi-schema/doc-= bad-section.out index 089bde1381..23bf8c71ab 100644 --- a/tests/qapi-schema/doc-bad-section.out +++ b/tests/qapi-schema/doc-bad-section.out @@ -1,7 +1,7 @@ -enum Enum ['one', 'two'] +object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE -object q_empty +enum Enum ['one', 'two'] doc symbol=3DEnum body=3D =3D=3D Produces *invalid* texinfo diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out index 1d2c250527..0c07301f07 100644 --- a/tests/qapi-schema/doc-good.out +++ b/tests/qapi-schema/doc-good.out @@ -1,35 +1,35 @@ +object q_empty +enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] + prefix QTYPE +enum Enum ['one', 'two'] object Base member base1: Enum optional=3DFalse -enum Enum ['one', 'two'] +object Variant1 + member var1: str optional=3DFalse +object Variant2 object Object base Base tag base1 case one: Variant1 case two: Variant2 -enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] - prefix QTYPE +object q_obj_Variant1-wrapper + member data: Variant1 optional=3DFalse +object q_obj_Variant2-wrapper + member data: Variant2 optional=3DFalse +enum SugaredUnionKind ['one', 'two'] object SugaredUnion member type: SugaredUnionKind optional=3DFalse tag type case one: q_obj_Variant1-wrapper case two: q_obj_Variant2-wrapper -enum SugaredUnionKind ['one', 'two'] -object Variant1 - member var1: str optional=3DFalse -object Variant2 -command cmd q_obj_cmd-arg -> Object - gen=3DTrue success_response=3DTrue boxed=3DFalse -command cmd-boxed Object -> None - gen=3DTrue success_response=3DTrue boxed=3DTrue -object q_empty -object q_obj_Variant1-wrapper - member data: Variant1 optional=3DFalse -object q_obj_Variant2-wrapper - member data: Variant2 optional=3DFalse object q_obj_cmd-arg member arg1: int optional=3DFalse member arg2: str optional=3DTrue member arg3: bool optional=3DFalse +command cmd q_obj_cmd-arg -> Object + gen=3DTrue success_response=3DTrue boxed=3DFalse +command cmd-boxed Object -> None + gen=3DTrue success_response=3DTrue boxed=3DTrue doc freeform body=3D =3D Section diff --git a/tests/qapi-schema/empty.out b/tests/qapi-schema/empty.out index 40b886ddae..0ec234eec4 100644 --- a/tests/qapi-schema/empty.out +++ b/tests/qapi-schema/empty.out @@ -1,3 +1,3 @@ +object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE -object q_empty diff --git a/tests/qapi-schema/event-case.out b/tests/qapi-schema/event-cas= e.out index 313c0fe7be..110571b793 100644 --- a/tests/qapi-schema/event-case.out +++ b/tests/qapi-schema/event-case.out @@ -1,5 +1,5 @@ +object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE event oops None boxed=3DFalse -object q_empty diff --git a/tests/qapi-schema/ident-with-escape.out b/tests/qapi-schema/id= ent-with-escape.out index b5637cb2e0..8336aa7629 100644 --- a/tests/qapi-schema/ident-with-escape.out +++ b/tests/qapi-schema/ident-with-escape.out @@ -1,7 +1,7 @@ +object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE -command fooA q_obj_fooA-arg -> None - gen=3DTrue success_response=3DTrue boxed=3DFalse -object q_empty object q_obj_fooA-arg member bar1: str optional=3DFalse +command fooA q_obj_fooA-arg -> None + gen=3DTrue success_response=3DTrue boxed=3DFalse diff --git a/tests/qapi-schema/include-relpath.out b/tests/qapi-schema/incl= ude-relpath.out index 17e652535c..0261ddf202 100644 --- a/tests/qapi-schema/include-relpath.out +++ b/tests/qapi-schema/include-relpath.out @@ -1,4 +1,4 @@ +object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE enum Status ['good', 'bad', 'ugly'] -object q_empty diff --git a/tests/qapi-schema/include-repetition.out b/tests/qapi-schema/i= nclude-repetition.out index 17e652535c..0261ddf202 100644 --- a/tests/qapi-schema/include-repetition.out +++ b/tests/qapi-schema/include-repetition.out @@ -1,4 +1,4 @@ +object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE enum Status ['good', 'bad', 'ugly'] -object q_empty diff --git a/tests/qapi-schema/include-simple.out b/tests/qapi-schema/inclu= de-simple.out index 17e652535c..0261ddf202 100644 --- a/tests/qapi-schema/include-simple.out +++ b/tests/qapi-schema/include-simple.out @@ -1,4 +1,4 @@ +object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE enum Status ['good', 'bad', 'ugly'] -object q_empty diff --git a/tests/qapi-schema/indented-expr.out b/tests/qapi-schema/indent= ed-expr.out index 586795f44d..34de8be426 100644 --- a/tests/qapi-schema/indented-expr.out +++ b/tests/qapi-schema/indented-expr.out @@ -1,7 +1,7 @@ +object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE command eins None -> None gen=3DTrue success_response=3DTrue boxed=3DFalse -object q_empty command zwei None -> None gen=3DTrue success_response=3DTrue boxed=3DFalse diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 3b1e9082d3..50706b0136 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -1,87 +1,129 @@ -alternate AltEnumBool - tag type - case e: EnumOne - case b: bool -alternate AltEnumInt - tag type - case e: EnumOne - case i: int -alternate AltEnumNum - tag type - case e: EnumOne - case n: number -alternate AltNumEnum - tag type - case n: number - case e: EnumOne -alternate AltStrObj - tag type - case s: str - case o: TestStruct -event EVENT_A None - boxed=3DFalse -event EVENT_B None - boxed=3DFalse -event EVENT_C q_obj_EVENT_C-arg - boxed=3DFalse -event EVENT_D q_obj_EVENT_D-arg - boxed=3DFalse -event EVENT_E UserDefZero - boxed=3DTrue -event EVENT_F UserDefAlternate - boxed=3DTrue +object q_empty +enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] + prefix QTYPE +object TestStruct + member integer: int optional=3DFalse + member boolean: bool optional=3DFalse + member string: str optional=3DFalse +object NestedEnumsOne + member enum1: EnumOne optional=3DFalse + member enum2: EnumOne optional=3DTrue + member enum3: EnumOne optional=3DFalse + member enum4: EnumOne optional=3DTrue +enum MyEnum [] object Empty1 object Empty2 base Empty1 +command user_def_cmd0 Empty2 -> Empty2 + gen=3DTrue success_response=3DTrue boxed=3DFalse +enum QEnumTwo ['value1', 'value2'] + prefix QENUM_TWO +object UserDefOne + base UserDefZero + member string: str optional=3DFalse + member enum1: EnumOne optional=3DTrue enum EnumOne ['value1', 'value2', 'value3'] -object EventStructOne - member struct1: UserDefOne optional=3DFalse +object UserDefZero + member integer: int optional=3DFalse +object UserDefTwoDictDict + member userdef: UserDefOne optional=3DFalse member string: str optional=3DFalse - member enum2: EnumOne optional=3DTrue +object UserDefTwoDict + member string1: str optional=3DFalse + member dict2: UserDefTwoDictDict optional=3DFalse + member dict3: UserDefTwoDictDict optional=3DTrue +object UserDefTwo + member string0: str optional=3DFalse + member dict1: UserDefTwoDict optional=3DFalse object ForceArrays member unused1: UserDefOneList optional=3DFalse member unused2: UserDefTwoList optional=3DFalse member unused3: TestStructList optional=3DFalse -enum MyEnum [] -object NestedEnumsOne - member enum1: EnumOne optional=3DFalse - member enum2: EnumOne optional=3DTrue - member enum3: EnumOne optional=3DFalse - member enum4: EnumOne optional=3DTrue -enum QEnumTwo ['value1', 'value2'] - prefix QENUM_TWO -enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] - prefix QTYPE -object TestStruct - member integer: int optional=3DFalse - member boolean: bool optional=3DFalse - member string: str optional=3DFalse object UserDefA member boolean: bool optional=3DFalse member a_b: int optional=3DTrue -alternate UserDefAlternate - tag type - case udfu: UserDefFlatUnion - case e: EnumOne - case i: int - case n: null object UserDefB member intb: int optional=3DFalse member a-b: bool optional=3DTrue -object UserDefC - member string1: str optional=3DFalse - member string2: str optional=3DFalse object UserDefFlatUnion base UserDefUnionBase tag enum1 case value1: UserDefA case value2: UserDefB case value3: UserDefB +object UserDefUnionBase + base UserDefZero + member string: str optional=3DFalse + member enum1: EnumOne optional=3DFalse +object q_obj_UserDefFlatUnion2-base + member integer: int optional=3DTrue + member string: str optional=3DFalse + member enum1: QEnumTwo optional=3DFalse object UserDefFlatUnion2 base q_obj_UserDefFlatUnion2-base tag enum1 case value1: UserDefC case value2: UserDefB +object WrapAlternate + member alt: UserDefAlternate optional=3DFalse +alternate UserDefAlternate + tag type + case udfu: UserDefFlatUnion + case e: EnumOne + case i: int + case n: null +object UserDefC + member string1: str optional=3DFalse + member string2: str optional=3DFalse +alternate AltEnumBool + tag type + case e: EnumOne + case b: bool +alternate AltEnumNum + tag type + case e: EnumOne + case n: number +alternate AltNumEnum + tag type + case n: number + case e: EnumOne +alternate AltEnumInt + tag type + case e: EnumOne + case i: int +alternate AltStrObj + tag type + case s: str + case o: TestStruct +object q_obj_intList-wrapper + member data: intList optional=3DFalse +object q_obj_int8List-wrapper + member data: int8List optional=3DFalse +object q_obj_int16List-wrapper + member data: int16List optional=3DFalse +object q_obj_int32List-wrapper + member data: int32List optional=3DFalse +object q_obj_int64List-wrapper + member data: int64List optional=3DFalse +object q_obj_uint8List-wrapper + member data: uint8List optional=3DFalse +object q_obj_uint16List-wrapper + member data: uint16List optional=3DFalse +object q_obj_uint32List-wrapper + member data: uint32List optional=3DFalse +object q_obj_uint64List-wrapper + member data: uint64List optional=3DFalse +object q_obj_numberList-wrapper + member data: numberList optional=3DFalse +object q_obj_boolList-wrapper + member data: boolList optional=3DFalse +object q_obj_strList-wrapper + member data: strList optional=3DFalse +object q_obj_sizeList-wrapper + member data: sizeList optional=3DFalse +object q_obj_anyList-wrapper + member data: anyList optional=3DFalse +enum UserDefNativeListUnionKind ['integer', 's8', 's16', 's32', 's64', 'u8= ', 'u16', 'u32', 'u64', 'number', 'boolean', 'string', 'sizes', 'any'] object UserDefNativeListUnion member type: UserDefNativeListUnionKind optional=3DFalse tag type @@ -99,133 +141,91 @@ object UserDefNativeListUnion case string: q_obj_strList-wrapper case sizes: q_obj_sizeList-wrapper case any: q_obj_anyList-wrapper -enum UserDefNativeListUnionKind ['integer', 's8', 's16', 's32', 's64', 'u8= ', 'u16', 'u32', 'u64', 'number', 'boolean', 'string', 'sizes', 'any'] -object UserDefOne - base UserDefZero - member string: str optional=3DFalse - member enum1: EnumOne optional=3DTrue +command user_def_cmd None -> None + gen=3DTrue success_response=3DTrue boxed=3DFalse +object q_obj_user_def_cmd1-arg + member ud1a: UserDefOne optional=3DFalse +command user_def_cmd1 q_obj_user_def_cmd1-arg -> None + gen=3DTrue success_response=3DTrue boxed=3DFalse +object q_obj_user_def_cmd2-arg + member ud1a: UserDefOne optional=3DFalse + member ud1b: UserDefOne optional=3DTrue +command user_def_cmd2 q_obj_user_def_cmd2-arg -> UserDefTwo + gen=3DTrue success_response=3DTrue boxed=3DFalse +object q_obj_guest-get-time-arg + member a: int optional=3DFalse + member b: int optional=3DTrue +command guest-get-time q_obj_guest-get-time-arg -> int + gen=3DTrue success_response=3DTrue boxed=3DFalse +object q_obj_guest-sync-arg + member arg: any optional=3DFalse +command guest-sync q_obj_guest-sync-arg -> any + gen=3DTrue success_response=3DTrue boxed=3DFalse +command boxed-struct UserDefZero -> None + gen=3DTrue success_response=3DTrue boxed=3DTrue +command boxed-union UserDefNativeListUnion -> None + gen=3DTrue success_response=3DTrue boxed=3DTrue object UserDefOptions member i64: intList optional=3DTrue member u64: uint64List optional=3DTrue member u16: uint16List optional=3DTrue member i64x: int optional=3DTrue member u64x: uint64 optional=3DTrue -object UserDefTwo - member string0: str optional=3DFalse - member dict1: UserDefTwoDict optional=3DFalse -object UserDefTwoDict - member string1: str optional=3DFalse - member dict2: UserDefTwoDictDict optional=3DFalse - member dict3: UserDefTwoDictDict optional=3DTrue -object UserDefTwoDictDict - member userdef: UserDefOne optional=3DFalse +object EventStructOne + member struct1: UserDefOne optional=3DFalse member string: str optional=3DFalse -object UserDefUnionBase - base UserDefZero - member string: str optional=3DFalse - member enum1: EnumOne optional=3DFalse -object UserDefZero - member integer: int optional=3DFalse -object WrapAlternate - member alt: UserDefAlternate optional=3DFalse -event __ORG.QEMU_X-EVENT __org.qemu_x-Struct + member enum2: EnumOne optional=3DTrue +event EVENT_A None + boxed=3DFalse +event EVENT_B None + boxed=3DFalse +object q_obj_EVENT_C-arg + member a: int optional=3DTrue + member b: UserDefOne optional=3DTrue + member c: str optional=3DFalse +event EVENT_C q_obj_EVENT_C-arg + boxed=3DFalse +object q_obj_EVENT_D-arg + member a: EventStructOne optional=3DFalse + member b: str optional=3DFalse + member c: str optional=3DTrue + member enum3: EnumOne optional=3DTrue +event EVENT_D q_obj_EVENT_D-arg boxed=3DFalse -alternate __org.qemu_x-Alt - tag type - case __org.qemu_x-branch: str - case b: __org.qemu_x-Base +event EVENT_E UserDefZero + boxed=3DTrue +event EVENT_F UserDefAlternate + boxed=3DTrue +enum __org.qemu_x-Enum ['__org.qemu_x-value'] object __org.qemu_x-Base member __org.qemu_x-member1: __org.qemu_x-Enum optional=3DFalse -enum __org.qemu_x-Enum ['__org.qemu_x-value'] object __org.qemu_x-Struct base __org.qemu_x-Base member __org.qemu_x-member2: str optional=3DFalse member wchar-t: int optional=3DTrue -object __org.qemu_x-Struct2 - member array: __org.qemu_x-Union1List optional=3DFalse +object q_obj_str-wrapper + member data: str optional=3DFalse +enum __org.qemu_x-Union1Kind ['__org.qemu_x-branch'] object __org.qemu_x-Union1 member type: __org.qemu_x-Union1Kind optional=3DFalse tag type case __org.qemu_x-branch: q_obj_str-wrapper -enum __org.qemu_x-Union1Kind ['__org.qemu_x-branch'] +object __org.qemu_x-Struct2 + member array: __org.qemu_x-Union1List optional=3DFalse object __org.qemu_x-Union2 base __org.qemu_x-Base tag __org.qemu_x-member1 case __org.qemu_x-value: __org.qemu_x-Struct2 -command __org.qemu_x-command q_obj___org.qemu_x-command-arg -> __org.qemu_= x-Union1 - gen=3DTrue success_response=3DTrue boxed=3DFalse -command boxed-struct UserDefZero -> None - gen=3DTrue success_response=3DTrue boxed=3DTrue -command boxed-union UserDefNativeListUnion -> None - gen=3DTrue success_response=3DTrue boxed=3DTrue -command guest-get-time q_obj_guest-get-time-arg -> int - gen=3DTrue success_response=3DTrue boxed=3DFalse -command guest-sync q_obj_guest-sync-arg -> any - gen=3DTrue success_response=3DTrue boxed=3DFalse -object q_empty -object q_obj_EVENT_C-arg - member a: int optional=3DTrue - member b: UserDefOne optional=3DTrue - member c: str optional=3DFalse -object q_obj_EVENT_D-arg - member a: EventStructOne optional=3DFalse - member b: str optional=3DFalse - member c: str optional=3DTrue - member enum3: EnumOne optional=3DTrue -object q_obj_UserDefFlatUnion2-base - member integer: int optional=3DTrue - member string: str optional=3DFalse - member enum1: QEnumTwo optional=3DFalse +alternate __org.qemu_x-Alt + tag type + case __org.qemu_x-branch: str + case b: __org.qemu_x-Base +event __ORG.QEMU_X-EVENT __org.qemu_x-Struct + boxed=3DFalse object q_obj___org.qemu_x-command-arg member a: __org.qemu_x-EnumList optional=3DFalse member b: __org.qemu_x-StructList optional=3DFalse member c: __org.qemu_x-Union2 optional=3DFalse member d: __org.qemu_x-Alt optional=3DFalse -object q_obj_anyList-wrapper - member data: anyList optional=3DFalse -object q_obj_boolList-wrapper - member data: boolList optional=3DFalse -object q_obj_guest-get-time-arg - member a: int optional=3DFalse - member b: int optional=3DTrue -object q_obj_guest-sync-arg - member arg: any optional=3DFalse -object q_obj_int16List-wrapper - member data: int16List optional=3DFalse -object q_obj_int32List-wrapper - member data: int32List optional=3DFalse -object q_obj_int64List-wrapper - member data: int64List optional=3DFalse -object q_obj_int8List-wrapper - member data: int8List optional=3DFalse -object q_obj_intList-wrapper - member data: intList optional=3DFalse -object q_obj_numberList-wrapper - member data: numberList optional=3DFalse -object q_obj_sizeList-wrapper - member data: sizeList optional=3DFalse -object q_obj_str-wrapper - member data: str optional=3DFalse -object q_obj_strList-wrapper - member data: strList optional=3DFalse -object q_obj_uint16List-wrapper - member data: uint16List optional=3DFalse -object q_obj_uint32List-wrapper - member data: uint32List optional=3DFalse -object q_obj_uint64List-wrapper - member data: uint64List optional=3DFalse -object q_obj_uint8List-wrapper - member data: uint8List optional=3DFalse -object q_obj_user_def_cmd1-arg - member ud1a: UserDefOne optional=3DFalse -object q_obj_user_def_cmd2-arg - member ud1a: UserDefOne optional=3DFalse - member ud1b: UserDefOne optional=3DTrue -command user_def_cmd None -> None - gen=3DTrue success_response=3DTrue boxed=3DFalse -command user_def_cmd0 Empty2 -> Empty2 - gen=3DTrue success_response=3DTrue boxed=3DFalse -command user_def_cmd1 q_obj_user_def_cmd1-arg -> None - gen=3DTrue success_response=3DTrue boxed=3DFalse -command user_def_cmd2 q_obj_user_def_cmd2-arg -> UserDefTwo +command __org.qemu_x-command q_obj___org.qemu_x-command-arg -> __org.qemu_= x-Union1 gen=3DTrue success_response=3DTrue boxed=3DFalse --=20 2.13.6 From nobody Mon Apr 29 02:38:33 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517590310133570.1562516061091; Fri, 2 Feb 2018 08:51:50 -0800 (PST) Received: from localhost ([::1]:39658 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eheZ3-0002eE-7k for importer@patchew.org; Fri, 02 Feb 2018 11:51:49 -0500 Received: from eggs.gnu.org ([208.118.235.92]:55455) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehdLH-0002Ua-44 for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:34:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ehdKD-00037R-2w for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:33:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58336) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ehdKC-00035H-5m for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:32:24 -0500 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 557842CE964; Fri, 2 Feb 2018 13:04:59 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-148.ams2.redhat.com [10.36.116.148]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2064C855A3; Fri, 2 Feb 2018 13:04:47 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id D323B1138666; Fri, 2 Feb 2018 14:03:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 2 Feb 2018 14:03:30 +0100 Message-Id: <20180202130336.24719-16-armbru@redhat.com> In-Reply-To: <20180202130336.24719-1-armbru@redhat.com> References: <20180202130336.24719-1-armbru@redhat.com> 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.29]); Fri, 02 Feb 2018 13:04:59 +0000 (UTC) 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 RFC 15/21] qapi: Record 'include' directives in intermediate representation 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: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The include directive permits modular QAPI schemata, but the generated code is monolithic all the same. To permit generating modular code, the front end needs to pass more information on inclusions to the back ends. The commit before last added the necessary information to the parse tree. This commit adds it to the intermediate representation and its QAPISchemaVisitor. A later commit will use this to to generate modular code. New entity QAPISchemaInclude represents inclusions. Call new visitor method visit_include() for it, so visitors can see the sub-modules a module includes. New QAPISchemaEntity attribute @module names the entity's source file. Call new visitor method visit_module() when it changes during a visit, so visitors can keep track of the module being visited. Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi/common.py | 44 ++++++++++++++++++++++++++++= ---- tests/qapi-schema/comments.out | 1 + tests/qapi-schema/doc-bad-section.out | 1 + tests/qapi-schema/doc-good.out | 1 + tests/qapi-schema/event-case.out | 1 + tests/qapi-schema/ident-with-escape.out | 1 + tests/qapi-schema/include-relpath.out | 5 ++++ tests/qapi-schema/include-repetition.out | 10 ++++++++ tests/qapi-schema/include-simple.out | 3 +++ tests/qapi-schema/indented-expr.out | 1 + tests/qapi-schema/qapi-schema-test.out | 1 + tests/qapi-schema/test-qapi.py | 7 +++++ 12 files changed, 71 insertions(+), 5 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 3b97bf8702..f4e9ebbb53 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -981,8 +981,9 @@ def check_exprs(exprs): =20 class QAPISchemaEntity(object): def __init__(self, name, info, doc): - assert isinstance(name, str) + assert name is None or isinstance(name, str) self.name =3D name + self.module =3D None # For explicitly defined entities, info points to the (explicit) # definition. For builtins (and their arrays), info is None. # For implicitly defined entities, info points to a place that @@ -1011,10 +1012,16 @@ class QAPISchemaVisitor(object): def visit_end(self): pass =20 + def visit_module(self, fname): + pass + def visit_needed(self, entity): # Default to visiting everything return True =20 + def visit_include(self, fname, info): + pass + def visit_builtin_type(self, name, info, json_type): pass =20 @@ -1041,6 +1048,16 @@ class QAPISchemaVisitor(object): pass =20 =20 +class QAPISchemaInclude(QAPISchemaEntity): + + def __init__(self, fname, info): + QAPISchemaEntity.__init__(self, None, info, None) + self.fname =3D fname + + def visit(self, visitor): + visitor.visit_include(self.fname, self.info) + + class QAPISchemaType(QAPISchemaEntity): # Return the C type for common use. # For the types we commonly box, this is a pointer type. @@ -1468,6 +1485,7 @@ class QAPISchemaEvent(QAPISchemaEntity): =20 class QAPISchema(object): def __init__(self, fname): + self._fname =3D fname parser =3D QAPISchemaParser(open(fname, 'r')) exprs =3D check_exprs(parser.exprs) self.docs =3D parser.docs @@ -1475,16 +1493,19 @@ class QAPISchema(object): self._entity_dict =3D {} self._predefining =3D True self._def_predefineds() - self._predefining =3D False self._def_exprs(exprs) self.check() =20 def _def_entity(self, ent): # Only the predefined types are allowed to not have info assert ent.info or self._predefining - assert ent.name not in self._entity_dict + assert ent.name is None or ent.name not in self._entity_dict self._entity_list.append(ent) - self._entity_dict[ent.name] =3D ent + if ent.name is not None: + self._entity_dict[ent.name] =3D ent + if ent.info: + ent.module =3D os.path.relpath(ent.info['file'], + os.path.dirname(self._fname)) =20 def lookup_entity(self, name, typ=3DNone): ent =3D self._entity_dict.get(name) @@ -1495,6 +1516,15 @@ class QAPISchema(object): def lookup_type(self, name): return self.lookup_entity(name, QAPISchemaType) =20 + def _def_include(self, expr, info, doc): + include =3D expr['include'] + assert doc is None + main_info =3D info + while main_info['parent']: + main_info =3D main_info['parent'] + fname =3D os.path.relpath(include, os.path.dirname(main_info['file= '])) + self._def_entity(QAPISchemaInclude(fname, info)) + def _def_builtin_type(self, name, json_type, c_type): self._def_entity(QAPISchemaBuiltinType(name, json_type, c_type)) # TODO As long as we have QAPI_TYPES_BUILTIN to share multiple @@ -1677,7 +1707,7 @@ class QAPISchema(object): elif 'event' in expr: self._def_event(expr, info, doc) elif 'include' in expr: - pass + self._def_include(expr, info, doc) else: assert False =20 @@ -1687,8 +1717,12 @@ class QAPISchema(object): =20 def visit(self, visitor): visitor.visit_begin(self) + module =3D None for entity in self._entity_list: if visitor.visit_needed(entity): + if entity.module !=3D module: + module =3D entity.module + visitor.visit_module(module) entity.visit(visitor) visitor.visit_end() =20 diff --git a/tests/qapi-schema/comments.out b/tests/qapi-schema/comments.out index 0261ddf202..8d2f1ce8a2 100644 --- a/tests/qapi-schema/comments.out +++ b/tests/qapi-schema/comments.out @@ -1,4 +1,5 @@ object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE +module comments.json enum Status ['good', 'bad', 'ugly'] diff --git a/tests/qapi-schema/doc-bad-section.out b/tests/qapi-schema/doc-= bad-section.out index 23bf8c71ab..cd28721568 100644 --- a/tests/qapi-schema/doc-bad-section.out +++ b/tests/qapi-schema/doc-bad-section.out @@ -1,6 +1,7 @@ object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE +module doc-bad-section.json enum Enum ['one', 'two'] doc symbol=3DEnum body=3D diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out index 0c07301f07..430b5a87db 100644 --- a/tests/qapi-schema/doc-good.out +++ b/tests/qapi-schema/doc-good.out @@ -1,6 +1,7 @@ object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE +module doc-good.json enum Enum ['one', 'two'] object Base member base1: Enum optional=3DFalse diff --git a/tests/qapi-schema/event-case.out b/tests/qapi-schema/event-cas= e.out index 110571b793..88c0964917 100644 --- a/tests/qapi-schema/event-case.out +++ b/tests/qapi-schema/event-case.out @@ -1,5 +1,6 @@ object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE +module event-case.json event oops None boxed=3DFalse diff --git a/tests/qapi-schema/ident-with-escape.out b/tests/qapi-schema/id= ent-with-escape.out index 8336aa7629..ee3b34e623 100644 --- a/tests/qapi-schema/ident-with-escape.out +++ b/tests/qapi-schema/ident-with-escape.out @@ -1,6 +1,7 @@ object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE +module ident-with-escape.json object q_obj_fooA-arg member bar1: str optional=3DFalse command fooA q_obj_fooA-arg -> None diff --git a/tests/qapi-schema/include-relpath.out b/tests/qapi-schema/incl= ude-relpath.out index 0261ddf202..ebbabd7a18 100644 --- a/tests/qapi-schema/include-relpath.out +++ b/tests/qapi-schema/include-relpath.out @@ -1,4 +1,9 @@ object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE +module include-relpath.json +include include/relpath.json +module include/relpath.json +include include-relpath-sub.json +module include-relpath-sub.json enum Status ['good', 'bad', 'ugly'] diff --git a/tests/qapi-schema/include-repetition.out b/tests/qapi-schema/i= nclude-repetition.out index 0261ddf202..7235e055bc 100644 --- a/tests/qapi-schema/include-repetition.out +++ b/tests/qapi-schema/include-repetition.out @@ -1,4 +1,14 @@ object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE +module include-repetition.json +include comments.json +module comments.json enum Status ['good', 'bad', 'ugly'] +module include-repetition.json +include include-repetition-sub.json +module include-repetition-sub.json +include comments.json +include comments.json +module include-repetition.json +include comments.json diff --git a/tests/qapi-schema/include-simple.out b/tests/qapi-schema/inclu= de-simple.out index 0261ddf202..006f723eeb 100644 --- a/tests/qapi-schema/include-simple.out +++ b/tests/qapi-schema/include-simple.out @@ -1,4 +1,7 @@ object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE +module include-simple.json +include include-simple-sub.json +module include-simple-sub.json enum Status ['good', 'bad', 'ugly'] diff --git a/tests/qapi-schema/indented-expr.out b/tests/qapi-schema/indent= ed-expr.out index 34de8be426..a79935e8c3 100644 --- a/tests/qapi-schema/indented-expr.out +++ b/tests/qapi-schema/indented-expr.out @@ -1,6 +1,7 @@ object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE +module indented-expr.json command eins None -> None gen=3DTrue success_response=3DTrue boxed=3DFalse command zwei None -> None diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 50706b0136..012e7fc06a 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -1,6 +1,7 @@ object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE +module qapi-schema-test.json object TestStruct member integer: int optional=3DFalse member boolean: bool optional=3DFalse diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py index d6bb8ec6a4..2027eef3e5 100644 --- a/tests/qapi-schema/test-qapi.py +++ b/tests/qapi-schema/test-qapi.py @@ -17,6 +17,13 @@ import sys =20 =20 class QAPISchemaTestVisitor(QAPISchemaVisitor): + + def visit_module(self, name): + print 'module %s' % name + + def visit_include(self, name, info): + print 'include %s' % name + def visit_enum_type(self, name, info, values, prefix): print 'enum %s %s' % (name, values) if prefix: --=20 2.13.6 From nobody Mon Apr 29 02:38:33 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517591630319524.1045178384873; Fri, 2 Feb 2018 09:13:50 -0800 (PST) Received: from localhost ([::1]:40591 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eheuL-0005IX-A5 for importer@patchew.org; Fri, 02 Feb 2018 12:13:49 -0500 Received: from eggs.gnu.org ([208.118.235.92]:55862) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehdOj-0002hf-P7 for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:38:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ehdKW-0003XA-I9 for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:37:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49422) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ehdKW-0003VR-0Z for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:32:44 -0500 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 522493C47; Fri, 2 Feb 2018 13:04:59 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-148.ams2.redhat.com [10.36.116.148]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 210A77C855; Fri, 2 Feb 2018 13:04:47 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id DBD3F1138667; Fri, 2 Feb 2018 14:03:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 2 Feb 2018 14:03:31 +0100 Message-Id: <20180202130336.24719-17-armbru@redhat.com> In-Reply-To: <20180202130336.24719-1-armbru@redhat.com> References: <20180202130336.24719-1-armbru@redhat.com> 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]); Fri, 02 Feb 2018 13:04:59 +0000 (UTC) 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 RFC 16/21] qapi/types qapi/visit: Make visitors use QAPIGen more 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: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The conversion is rather shallow so far: most of the output accumulation is not converted. Take the next step: convert output accumulation in QAPISchemaGenTypeVisitor and QAPISchemaGenVisitVisitor. Helper functions outside these classes are not converted. Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi/types.py | 83 +++++++++++++++++++++++------------------------= ---- scripts/qapi/visit.py | 83 +++++++++++++++++++++++------------------------= ---- 2 files changed, 74 insertions(+), 92 deletions(-) diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index b2095120e0..eeffcbf32c 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -168,35 +168,44 @@ void qapi_free_%(c_name)s(%(c_name)s *obj) =20 =20 class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): - def __init__(self, opt_builtins): + def __init__(self, opt_builtins, prefix): self._opt_builtins =3D opt_builtins - self.decl =3D None - self.defn =3D None - self._fwdecl =3D None - self._btin =3D None + self._prefix =3D prefix + blurb =3D ' * Schema-defined QAPI types' + self._genc =3D QAPIGenC(blurb, __doc__) + self._genh =3D QAPIGenH(blurb, __doc__) + self._genc.preamble(mcgen(''' +#include "qemu/osdep.h" +#include "qapi/dealloc-visitor.h" +#include "%(prefix)sqapi-types.h" +#include "%(prefix)sqapi-visit.h" +''', + prefix=3Dprefix)) + self._genh.preamble(mcgen(''' +#include "qapi/util.h" +''')) + self._btin =3D '\n' + guardstart('QAPI_TYPES_BUILTIN') + + def write(self, output_dir): + self._genc.write(output_dir, self._prefix + 'qapi-types.c') + self._genh.write(output_dir, self._prefix + 'qapi-types.h') =20 def visit_begin(self, schema): # gen_object() is recursive, ensure it doesn't visit the empty type objects_seen.add(schema.the_empty_object_type.name) - self.decl =3D '' - self.defn =3D '' - self._fwdecl =3D '' - self._btin =3D '\n' + guardstart('QAPI_TYPES_BUILTIN') =20 def visit_end(self): - self.decl =3D self._fwdecl + self.decl - self._fwdecl =3D None # To avoid header dependency hell, we always generate # declarations for built-in types in our header files and # simply guard them. See also opt_builtins (command line # option -b). self._btin +=3D guardend('QAPI_TYPES_BUILTIN') - self.decl =3D self._btin + self.decl + self._genh.preamble(self._btin) self._btin =3D None =20 def _gen_type_cleanup(self, name): - self.decl +=3D gen_type_cleanup_decl(name) - self.defn +=3D gen_type_cleanup(name) + self._genh.body(gen_type_cleanup_decl(name)) + self._genc.body(gen_type_cleanup(name)) =20 def visit_enum_type(self, name, info, values, prefix): # Special case for our lone builtin enum type @@ -204,10 +213,10 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): if not info: self._btin +=3D gen_enum(name, values, prefix) if self._opt_builtins: - self.defn +=3D gen_enum_lookup(name, values, prefix) + self._genc.body(gen_enum_lookup(name, values, prefix)) else: - self._fwdecl +=3D gen_enum(name, values, prefix) - self.defn +=3D gen_enum_lookup(name, values, prefix) + self._genh.preamble(gen_enum(name, values, prefix)) + self._genc.body(gen_enum_lookup(name, values, prefix)) =20 def visit_array_type(self, name, info, element_type): if isinstance(element_type, QAPISchemaBuiltinType): @@ -215,20 +224,20 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): self._btin +=3D gen_array(name, element_type) self._btin +=3D gen_type_cleanup_decl(name) if self._opt_builtins: - self.defn +=3D gen_type_cleanup(name) + self._genc.body(gen_type_cleanup(name)) else: - self._fwdecl +=3D gen_fwd_object_or_array(name) - self.decl +=3D gen_array(name, element_type) + self._genh.preamble(gen_fwd_object_or_array(name)) + self._genh.body(gen_array(name, element_type)) self._gen_type_cleanup(name) =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) - self.decl +=3D gen_object(name, base, members, variants) + self._genh.preamble(gen_fwd_object_or_array(name)) + self._genh.body(gen_object(name, base, members, variants)) if base and not base.is_implicit(): - self.decl +=3D gen_upcast(name, base) + self._genh.body(gen_upcast(name, base)) # TODO Worth changing the visitor signature, so we could # directly use rather than repeat type.is_implicit()? if not name.startswith('q_'): @@ -236,31 +245,13 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): self._gen_type_cleanup(name) =20 def visit_alternate_type(self, name, info, variants): - self._fwdecl +=3D gen_fwd_object_or_array(name) - self.decl +=3D gen_object(name, None, [variants.tag_member], varia= nts) + self._genh.preamble(gen_fwd_object_or_array(name)) + self._genh.body(gen_object(name, None, + [variants.tag_member], variants)) self._gen_type_cleanup(name) =20 =20 def gen_types(schema, output_dir, prefix, opt_builtins): - blurb =3D ' * Schema-defined QAPI types' - genc =3D QAPIGenC(blurb, __doc__) - genh =3D QAPIGenH(blurb, __doc__) - - genc.body(mcgen(''' -#include "qemu/osdep.h" -#include "qapi/dealloc-visitor.h" -#include "%(prefix)sqapi-types.h" -#include "%(prefix)sqapi-visit.h" -''', - prefix=3Dprefix)) - - genh.body(mcgen(''' -#include "qapi/util.h" -''')) - - vis =3D QAPISchemaGenTypeVisitor(opt_builtins) + vis =3D QAPISchemaGenTypeVisitor(opt_builtins, prefix) schema.visit(vis) - genc.body(vis.defn) - genh.body(vis.decl) - genc.write(output_dir, prefix + 'qapi-types.c') - genh.write(output_dir, prefix + 'qapi-types.h') + vis.write(output_dir) diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index 80c0b85f8c..ee1a849574 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -264,24 +264,38 @@ out: =20 =20 class QAPISchemaGenVisitVisitor(QAPISchemaVisitor): - def __init__(self, opt_builtins): + def __init__(self, opt_builtins, prefix): self._opt_builtins =3D opt_builtins - self.decl =3D None - self.defn =3D None - self._btin =3D None - - def visit_begin(self, schema): - self.decl =3D '' - self.defn =3D '' + self._prefix =3D prefix + blurb =3D ' * Schema-defined QAPI visitors' + self._genc =3D QAPIGenC(blurb, __doc__) + self._genh =3D QAPIGenH(blurb, __doc__) + self._genc.preamble(mcgen(''' +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "qapi/error.h" +#include "%(prefix)sqapi-visit.h" +''', + prefix=3Dprefix)) + self._genh.preamble(mcgen(''' +#include "qapi/visitor.h" +#include "qapi/qmp/qerror.h" +#include "%(prefix)sqapi-types.h" +''', + prefix=3Dprefix)) self._btin =3D guardstart('QAPI_VISIT_BUILTIN') =20 + def write(self, output_dir): + self._genc.write(output_dir, self._prefix + 'qapi-visit.c') + self._genh.write(output_dir, self._prefix + 'qapi-visit.h') + def visit_end(self): # To avoid header dependency hell, we always generate # declarations for built-in types in our header files and # simply guard them. See also opt_builtins (command line # option -b). self._btin +=3D guardend('QAPI_VISIT_BUILTIN') - self.decl =3D self._btin + self.decl + self._genh.preamble(self._btin) self._btin =3D None =20 def visit_enum_type(self, name, info, values, prefix): @@ -290,10 +304,10 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor): if not info: self._btin +=3D gen_visit_decl(name, scalar=3DTrue) if self._opt_builtins: - self.defn +=3D gen_visit_enum(name) + self._genc.body(gen_visit_enum(name)) else: - self.decl +=3D gen_visit_decl(name, scalar=3DTrue) - self.defn +=3D gen_visit_enum(name) + self._genh.body(gen_visit_decl(name, scalar=3DTrue)) + self._genc.body(gen_visit_enum(name)) =20 def visit_array_type(self, name, info, element_type): decl =3D gen_visit_decl(name) @@ -301,53 +315,30 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor): if isinstance(element_type, QAPISchemaBuiltinType): self._btin +=3D decl if self._opt_builtins: - self.defn +=3D defn + self._genc.body(defn) else: - self.decl +=3D decl - self.defn +=3D defn + self._genh.body(decl) + self._genc.body(defn) =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.decl +=3D gen_visit_members_decl(name) - self.defn +=3D gen_visit_object_members(name, base, members, varia= nts) + self._genh.body(gen_visit_members_decl(name)) + self._genc.body(gen_visit_object_members(name, base, members, vari= ants)) # TODO Worth changing the visitor signature, so we could # directly use rather than repeat type.is_implicit()? if not name.startswith('q_'): # only explicit types need an allocating visit - self.decl +=3D gen_visit_decl(name) - self.defn +=3D gen_visit_object(name, base, members, variants) + self._genh.body(gen_visit_decl(name)) + self._genc.body(gen_visit_object(name, base, members, variants= )) =20 def visit_alternate_type(self, name, info, variants): - self.decl +=3D gen_visit_decl(name) - self.defn +=3D gen_visit_alternate(name, variants) + self._genh.body(gen_visit_decl(name)) + self._genc.body(gen_visit_alternate(name, variants)) =20 =20 def gen_visit(schema, output_dir, prefix, opt_builtins): - blurb =3D ' * Schema-defined QAPI visitors' - genc =3D QAPIGenC(blurb, __doc__) - genh =3D QAPIGenH(blurb, __doc__) - - genc.body(mcgen(''' -#include "qemu/osdep.h" -#include "qemu-common.h" -#include "qapi/error.h" -#include "%(prefix)sqapi-visit.h" -''', - prefix=3Dprefix)) - - genh.body(mcgen(''' -#include "qapi/visitor.h" -#include "qapi/qmp/qerror.h" -#include "%(prefix)sqapi-types.h" - -''', - prefix=3Dprefix)) - - vis =3D QAPISchemaGenVisitVisitor(opt_builtins) + vis =3D QAPISchemaGenVisitVisitor(opt_builtins, prefix) schema.visit(vis) - genc.body(vis.defn) - genh.body(vis.decl) - genc.write(output_dir, prefix + 'qapi-visit.c') - genh.write(output_dir, prefix + 'qapi-visit.h') + vis.write(output_dir) --=20 2.13.6 From nobody Mon Apr 29 02:38:33 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517591000075596.703470610043; Fri, 2 Feb 2018 09:03:20 -0800 (PST) Received: from localhost ([::1]:40111 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehekA-0004Q3-7D for importer@patchew.org; Fri, 02 Feb 2018 12:03:18 -0500 Received: from eggs.gnu.org ([208.118.235.92]:38385) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehdWJ-0007iS-Vd for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:46:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ehdRv-0004xa-N3 for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:44:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49386) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ehdKV-0003Tc-2Z for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:32:43 -0500 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 E2FE34D2F0; Fri, 2 Feb 2018 13:05:24 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-148.ams2.redhat.com [10.36.116.148]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 31F1D6D021; Fri, 2 Feb 2018 13:04:52 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E2DD21138668; Fri, 2 Feb 2018 14:03:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 2 Feb 2018 14:03:32 +0100 Message-Id: <20180202130336.24719-18-armbru@redhat.com> In-Reply-To: <20180202130336.24719-1-armbru@redhat.com> References: <20180202130336.24719-1-armbru@redhat.com> 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.30]); Fri, 02 Feb 2018 13:05:24 +0000 (UTC) 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 RFC 17/21] qapi/types qapi/visit: Generate built-in stuff into separate files 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: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Linking code from multiple separate QAPI schemata into the same program is possible, but involves some weirdness around built-in types: * We generate code for built-in types into .c only with option --builtins. The user is responsible to generate code for exactly one QAPI schema per program with --builtins. * We generate code for them it into .h regardless of --builtins, guarded by #ifndef QAPI_VISIT_BUILTIN. Because the code for built-in types is exactly the same in all of them, including any combination of these headers works. Replace this contraption by something more conventional: generate code for built-in types into their very own files: qapi-builtin-types.c, qapi-builtin-visit.c, qapi-builtin-types.h, qapi-builtin-visit.h, but only with --builtins. Obey --output-dir, but ignore --prefix for them. Make qapi-types.h include qapi-builtin-types.h. With multiple schemata you now have multiple qapi-types.[ch], but only one qapi-builtin-types.[ch]. Same for qapi-visit.[ch] and qapi-builtin-visit.[ch]. Bonus: if all you need is built-in stuff, you can include a much smaller header. To be exploited shortly. Signed-off-by: Markus Armbruster --- Makefile | 13 +++++--- Makefile.objs | 1 + scripts/qapi/common.py | 18 +++++------ scripts/qapi/types.py | 82 ++++++++++++++++++++++++++--------------------= -- scripts/qapi/visit.py | 84 ++++++++++++++++++++++++++++------------------= ---- 5 files changed, 111 insertions(+), 87 deletions(-) diff --git a/Makefile b/Makefile index e02f0c13ef..f9b7900330 100644 --- a/Makefile +++ b/Makefile @@ -88,10 +88,13 @@ endif include $(SRC_PATH)/rules.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 -GENERATED_FILES +=3D qmp-marshal.c qapi-types.c qapi-visit.c qapi-event.c -GENERATED_FILES +=3D qmp-introspect.h -GENERATED_FILES +=3D qmp-introspect.c +GENERATED_FILES +=3D qmp-commands.h qmp-marshal.c +GENERATED_FILES +=3D qapi-builtin-types.h qapi-builtin-types.c +GENERATED_FILES +=3D qapi-types.h qapi-types.c +GENERATED_FILES +=3D qapi-builtin-visit.h qapi-builtin-visit.c +GENERATED_FILES +=3D qapi-visit.h qapi-visit.c +GENERATED_FILES +=3D qapi-event.h qapi-event.c +GENERATED_FILES +=3D qmp-introspect.c qmp-introspect.h GENERATED_FILES +=3D qapi.texi =20 GENERATED_FILES +=3D trace/generated-tcg-tracers.h @@ -514,7 +517,9 @@ qapi-modules =3D $(SRC_PATH)/qapi-schema.json $(SRC_PAT= H)/qapi/common.json \ $(SRC_PATH)/qapi/transaction.json \ $(SRC_PATH)/qapi/ui.json =20 +qapi-builtin-types.c qapi-builtin-types.h \ qapi-types.c qapi-types.h \ +qapi-builtin-visit.c qapi-builtin-visit.h \ qapi-visit.c qapi-visit.h \ qmp-commands.h qmp-marshal.c \ qapi-event.c qapi-event.h \ diff --git a/Makefile.objs b/Makefile.objs index 323ef12384..f16cca06e7 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -2,6 +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 qapi-builtin-types.o qapi-builtin-visit.o util-obj-y +=3D qmp-introspect.o qapi-types.o qapi-visit.o qapi-event.o =20 chardev-obj-y =3D chardev/ diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index f4e9ebbb53..7ffffc78d9 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -1527,11 +1527,10 @@ class QAPISchema(object): =20 def _def_builtin_type(self, name, json_type, c_type): self._def_entity(QAPISchemaBuiltinType(name, json_type, c_type)) - # TODO As long as we have QAPI_TYPES_BUILTIN to share multiple - # qapi-types.h from a single .c, all arrays of builtins must be - # declared in the first file whether or not they are used. Nicer - # would be to use lazy instantiation, while figuring out how to - # avoid compilation issues with multiple qapi-types.h. + # Instantiating only the arrays that are actually used would + # be nice, but we can't as long as their generated code + # (qapi-builtin-types.[ch]) may be shared by some other + # schema. self._make_array_type(name, None) =20 def _def_predefineds(self): @@ -1985,14 +1984,15 @@ class QAPIGen(object): return '' =20 def write(self, output_dir, fname): - if output_dir: + pathname =3D os.path.join(output_dir, fname) + dir =3D os.path.dirname(pathname) + if dir: try: - os.makedirs(output_dir) + os.makedirs(dir) except os.error as e: if e.errno !=3D errno.EEXIST: raise - fd =3D os.open(os.path.join(output_dir, fname), - os.O_RDWR | os.O_CREAT, 0666) + fd =3D os.open(pathname, os.O_RDWR | os.O_CREAT, 0666) f =3D os.fdopen(fd, 'r+') text =3D (self.top(fname) + self._preamble + self._body + self.bottom(fname)) diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index eeffcbf32c..f84ed17960 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -171,64 +171,72 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): def __init__(self, opt_builtins, prefix): self._opt_builtins =3D opt_builtins self._prefix =3D prefix - blurb =3D ' * Schema-defined QAPI types' - self._genc =3D QAPIGenC(blurb, __doc__) - self._genh =3D QAPIGenH(blurb, __doc__) + self._module =3D {} + self._add_module(None, ' * Built-in QAPI types') self._genc.preamble(mcgen(''' #include "qemu/osdep.h" #include "qapi/dealloc-visitor.h" -#include "%(prefix)sqapi-types.h" -#include "%(prefix)sqapi-visit.h" -''', - prefix=3Dprefix)) +#include "qapi-builtin-types.h" +#include "qapi-builtin-visit.h" +''')) self._genh.preamble(mcgen(''' #include "qapi/util.h" ''')) - self._btin =3D '\n' + guardstart('QAPI_TYPES_BUILTIN') + + def _module_basename(self, name): + if name is None: + return 'qapi-builtin-types' + return self._prefix + 'qapi-types' + + def _add_module(self, name, blurb): + genc =3D QAPIGenC(blurb, __doc__) + genh =3D QAPIGenH(blurb, __doc__) + self._module[name] =3D (genc, genh) + self._set_module(name) + + def _set_module(self, name): + self._genc, self._genh =3D self._module[name] =20 def write(self, output_dir): - self._genc.write(output_dir, self._prefix + 'qapi-types.c') - self._genh.write(output_dir, self._prefix + 'qapi-types.h') + for name in self._module: + if name is None and not self._opt_builtins: + continue + basename =3D self._module_basename(name) + (genc, genh) =3D self._module[name] + genc.write(output_dir, basename + '.c') + genh.write(output_dir, basename + '.h') =20 def visit_begin(self, schema): # gen_object() is recursive, ensure it doesn't visit the empty type objects_seen.add(schema.the_empty_object_type.name) =20 - def visit_end(self): - # To avoid header dependency hell, we always generate - # declarations for built-in types in our header files and - # simply guard them. See also opt_builtins (command line - # option -b). - self._btin +=3D guardend('QAPI_TYPES_BUILTIN') - self._genh.preamble(self._btin) - self._btin =3D None + def visit_module(self, name): + if len(self._module) !=3D 1: + return + self._add_module(name, ' * Schema-defined QAPI types') + self._genc.preamble(mcgen(''' +#include "qemu/osdep.h" +#include "qapi/dealloc-visitor.h" +#include "%(prefix)sqapi-types.h" +#include "%(prefix)sqapi-visit.h" +''', + prefix=3Dself._prefix)) + self._genh.preamble(mcgen(''' +#include "qapi-builtin-types.h" +''')) =20 def _gen_type_cleanup(self, name): self._genh.body(gen_type_cleanup_decl(name)) self._genc.body(gen_type_cleanup(name)) =20 def visit_enum_type(self, name, info, values, prefix): - # Special case for our lone builtin enum type - # TODO use something cleaner than existence of info - if not info: - self._btin +=3D gen_enum(name, values, prefix) - if self._opt_builtins: - self._genc.body(gen_enum_lookup(name, values, prefix)) - else: - self._genh.preamble(gen_enum(name, values, prefix)) - self._genc.body(gen_enum_lookup(name, values, prefix)) + self._genh.preamble(gen_enum(name, values, prefix)) + self._genc.body(gen_enum_lookup(name, values, prefix)) =20 def visit_array_type(self, name, info, element_type): - if isinstance(element_type, QAPISchemaBuiltinType): - self._btin +=3D gen_fwd_object_or_array(name) - self._btin +=3D gen_array(name, element_type) - self._btin +=3D gen_type_cleanup_decl(name) - if self._opt_builtins: - self._genc.body(gen_type_cleanup(name)) - else: - self._genh.preamble(gen_fwd_object_or_array(name)) - self._genh.body(gen_array(name, element_type)) - self._gen_type_cleanup(name) + self._genh.preamble(gen_fwd_object_or_array(name)) + self._genh.body(gen_array(name, element_type)) + self._gen_type_cleanup(name) =20 def visit_object_type(self, name, info, base, members, variants): # Nothing to do for the special empty builtin diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index ee1a849574..f23e71bb9a 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -267,58 +267,68 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor): def __init__(self, opt_builtins, prefix): self._opt_builtins =3D opt_builtins self._prefix =3D prefix - blurb =3D ' * Schema-defined QAPI visitors' - self._genc =3D QAPIGenC(blurb, __doc__) - self._genh =3D QAPIGenH(blurb, __doc__) + self._module =3D {} + self._add_module(None, ' * Built-in QAPI visitors') self._genc.preamble(mcgen(''' #include "qemu/osdep.h" #include "qemu-common.h" #include "qapi/error.h" -#include "%(prefix)sqapi-visit.h" -''', - prefix=3Dprefix)) +#include "qapi-builtin-visit.h" +''')) self._genh.preamble(mcgen(''' #include "qapi/visitor.h" #include "qapi/qmp/qerror.h" -#include "%(prefix)sqapi-types.h" +#include "qapi-builtin-types.h" ''', - prefix=3Dprefix)) - self._btin =3D guardstart('QAPI_VISIT_BUILTIN') + prefix=3Dprefix)) + + def _module_basename(self, name): + if name is None: + return 'qapi-builtin-visit' + return self._prefix + 'qapi-visit' + + def _add_module(self, name, blurb): + genc =3D QAPIGenC(blurb, __doc__) + genh =3D QAPIGenH(blurb, __doc__) + self._module[name] =3D (genc, genh) + self._set_module(name) + + def _set_module(self, name): + self._genc, self._genh =3D self._module[name] =20 def write(self, output_dir): - self._genc.write(output_dir, self._prefix + 'qapi-visit.c') - self._genh.write(output_dir, self._prefix + 'qapi-visit.h') + for name in self._module: + if name is None and not self._opt_builtins: + continue + basename =3D self._module_basename(name) + (genc, genh) =3D self._module[name] + genc.write(output_dir, basename + '.c') + genh.write(output_dir, basename + '.h') =20 - def visit_end(self): - # To avoid header dependency hell, we always generate - # declarations for built-in types in our header files and - # simply guard them. See also opt_builtins (command line - # option -b). - self._btin +=3D guardend('QAPI_VISIT_BUILTIN') - self._genh.preamble(self._btin) - self._btin =3D None + def visit_module(self, name): + if len(self._module) !=3D 1: + return + self._add_module(name, ' * Schema-defined QAPI visitors') + self._genc.preamble(mcgen(''' +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "qapi/error.h" +#include "%(prefix)sqapi-visit.h" +''', + prefix=3Dself._prefix)) + self._genh.preamble(mcgen(''' +#include "qapi-builtin-visit.h" +#include "%(prefix)sqapi-types.h" +''', + prefix=3Dself._prefix)) =20 def visit_enum_type(self, name, info, values, prefix): - # Special case for our lone builtin enum type - # TODO use something cleaner than existence of info - if not info: - self._btin +=3D gen_visit_decl(name, scalar=3DTrue) - if self._opt_builtins: - self._genc.body(gen_visit_enum(name)) - else: - self._genh.body(gen_visit_decl(name, scalar=3DTrue)) - self._genc.body(gen_visit_enum(name)) + self._genh.body(gen_visit_decl(name, scalar=3DTrue)) + self._genc.body(gen_visit_enum(name)) =20 def visit_array_type(self, name, info, element_type): - decl =3D gen_visit_decl(name) - defn =3D gen_visit_list(name, element_type) - if isinstance(element_type, QAPISchemaBuiltinType): - self._btin +=3D decl - if self._opt_builtins: - self._genc.body(defn) - else: - self._genh.body(decl) - self._genc.body(defn) + self._genh.body(gen_visit_decl(name)) + self._genc.body(gen_visit_list(name, element_type)) =20 def visit_object_type(self, name, info, base, members, variants): # Nothing to do for the special empty builtin --=20 2.13.6 From nobody Mon Apr 29 02:38:33 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517591259101506.7738571295822; Fri, 2 Feb 2018 09:07:39 -0800 (PST) Received: from localhost ([::1]:40292 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eheoJ-000876-8U for importer@patchew.org; Fri, 02 Feb 2018 12:07:35 -0500 Received: from eggs.gnu.org ([208.118.235.92]:55980) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehdNk-0002k9-CI for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:37:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ehdMG-0005dz-9T for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:35:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39778) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ehdMF-0005cg-Ut for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:34:32 -0500 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 6C7038E707; Fri, 2 Feb 2018 13:05:12 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-148.ams2.redhat.com [10.36.116.148]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8D3486E52A; Fri, 2 Feb 2018 13:04:52 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E90251138669; Fri, 2 Feb 2018 14:03:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 2 Feb 2018 14:03:33 +0100 Message-Id: <20180202130336.24719-19-armbru@redhat.com> In-Reply-To: <20180202130336.24719-1-armbru@redhat.com> References: <20180202130336.24719-1-armbru@redhat.com> 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]); Fri, 02 Feb 2018 13:05:12 +0000 (UTC) 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 RFC 18/21] qapi/common: Fix guardname() for funny filenames 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: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" guardname() fails to return a valid C identifier for arguments containing anything but [A-Za-z0-9_.-']. Fix that. Signed-off-by: Markus Armbruster --- scripts/qapi/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 7ffffc78d9..7d497b5b17 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -1860,7 +1860,7 @@ def mcgen(code, **kwds): =20 =20 def guardname(filename): - return c_name(filename, protect=3DFalse).upper() + return re.sub(r'[^A-Za-z0-9_]', '_', filename).upper() =20 =20 def guardstart(name): --=20 2.13.6 From nobody Mon Apr 29 02:38:33 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517589560903696.2842974670369; Fri, 2 Feb 2018 08:39:20 -0800 (PST) Received: from localhost ([::1]:39250 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eheMy-0000Ac-3P for importer@patchew.org; Fri, 02 Feb 2018 11:39:20 -0500 Received: from eggs.gnu.org ([208.118.235.92]:55983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehdMe-0002kG-Go for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:36:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ehdLV-0004dv-ML for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:34:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58938) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ehdLV-0004cC-02 for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:33:45 -0500 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 C366C70008; Fri, 2 Feb 2018 13:05:08 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-148.ams2.redhat.com [10.36.116.148]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B193E7A25C; Fri, 2 Feb 2018 13:04:54 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id EE6BE113866C; Fri, 2 Feb 2018 14:03:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 2 Feb 2018 14:03:34 +0100 Message-Id: <20180202130336.24719-20-armbru@redhat.com> In-Reply-To: <20180202130336.24719-1-armbru@redhat.com> References: <20180202130336.24719-1-armbru@redhat.com> 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.28]); Fri, 02 Feb 2018 13:05:08 +0000 (UTC) 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 RFC 19/21] qapi/types: Generate separate .h, .c for each module 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: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Our qapi-schema.json is composed of modules connected by include directives, but the generated code is monolithic all the same: one qapi-types.h with all the types, one qapi-visit.h with all the visitors, and so forth. These monolithic headers get included all over the place. In my "build everything" tree, adding a QAPI type recompiles about 4500 out of 4800 objects. Nobody would write such monolithic headers by hand. It stands to reason that one shouldn't generate them, either. Split up generated qapi-types.h to mirror the schema's modular structure: one header per module. Name the main module's header qapi-types.h, and sub-module D/B.json's header D/qapi-types-B.h. Mirror the schema's includes in the headers, so that qapi-types.h gets you everything exactly as before. If you need less, you can include one or more of the sub-module headers. To be exploited shortly. Split up qapi-types.c similarly. Signed-off-by: Markus Armbruster --- Makefile | 30 ++++++++++++++++++++++++++++++ Makefile.objs | 18 +++++++++++++++++- scripts/qapi/types.py | 18 ++++++++++++++++-- 3 files changed, 63 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index f9b7900330..f1b68dca9b 100644 --- a/Makefile +++ b/Makefile @@ -91,6 +91,21 @@ GENERATED_FILES =3D qemu-version.h config-host.h qemu-op= tions.def GENERATED_FILES +=3D qmp-commands.h qmp-marshal.c GENERATED_FILES +=3D qapi-builtin-types.h qapi-builtin-types.c GENERATED_FILES +=3D qapi-types.h qapi-types.c +GENERATED_FILES +=3D qapi/qapi-types-block-core.h qapi/qapi-types-block-co= re.c +GENERATED_FILES +=3D qapi/qapi-types-block.h qapi/qapi-types-block.c +GENERATED_FILES +=3D qapi/qapi-types-char.h qapi/qapi-types-char.c +GENERATED_FILES +=3D qapi/qapi-types-common.h qapi/qapi-types-common.c +GENERATED_FILES +=3D qapi/qapi-types-crypto.h qapi/qapi-types-crypto.c +GENERATED_FILES +=3D qapi/qapi-types-introspect.h qapi/qapi-types-introspe= ct.c +GENERATED_FILES +=3D qapi/qapi-types-migration.h qapi/qapi-types-migration= .c +GENERATED_FILES +=3D qapi/qapi-types-net.h qapi/qapi-types-net.c +GENERATED_FILES +=3D qapi/qapi-types-rocker.h qapi/qapi-types-rocker.c +GENERATED_FILES +=3D qapi/qapi-types-run-state.h qapi/qapi-types-run-state= .c +GENERATED_FILES +=3D qapi/qapi-types-sockets.h qapi/qapi-types-sockets.c +GENERATED_FILES +=3D qapi/qapi-types-tpm.h qapi/qapi-types-tpm.c +GENERATED_FILES +=3D qapi/qapi-types-trace.h qapi/qapi-types-trace.c +GENERATED_FILES +=3D qapi/qapi-types-transaction.h qapi/qapi-types-transac= tion.c +GENERATED_FILES +=3D qapi/qapi-types-ui.h qapi/qapi-types-ui.c GENERATED_FILES +=3D qapi-builtin-visit.h qapi-builtin-visit.c GENERATED_FILES +=3D qapi-visit.h qapi-visit.c GENERATED_FILES +=3D qapi-event.h qapi-event.c @@ -519,6 +534,21 @@ qapi-modules =3D $(SRC_PATH)/qapi-schema.json $(SRC_PA= TH)/qapi/common.json \ =20 qapi-builtin-types.c qapi-builtin-types.h \ qapi-types.c qapi-types.h \ +qapi/qapi-types-block-core.c qapi/qapi-types-block-core.h \ +qapi/qapi-types-block.c qapi/qapi-types-block.h \ +qapi/qapi-types-char.c qapi/qapi-types-char.h \ +qapi/qapi-types-common.c qapi/qapi-types-common.h \ +qapi/qapi-types-crypto.c qapi/qapi-types-crypto.h \ +qapi/qapi-types-introspect.c qapi/qapi-types-introspect.h \ +qapi/qapi-types-migration.c qapi/qapi-types-migration.h \ +qapi/qapi-types-net.c qapi/qapi-types-net.h \ +qapi/qapi-types-rocker.c qapi/qapi-types-rocker.h \ +qapi/qapi-types-run-state.c qapi/qapi-types-run-state.h \ +qapi/qapi-types-sockets.c qapi/qapi-types-sockets.h \ +qapi/qapi-types-tpm.c qapi/qapi-types-tpm.h \ +qapi/qapi-types-trace.c qapi/qapi-types-trace.h \ +qapi/qapi-types-transaction.c qapi/qapi-types-transaction.h \ +qapi/qapi-types-ui.c qapi/qapi-types-ui.h \ qapi-builtin-visit.c qapi-builtin-visit.h \ qapi-visit.c qapi-visit.h \ qmp-commands.h qmp-marshal.c \ diff --git a/Makefile.objs b/Makefile.objs index f16cca06e7..e7411a2658 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -3,7 +3,23 @@ stub-obj-y =3D stubs/ crypto/ util-obj-y =3D util/ qobject/ qapi/ util-obj-y +=3D qapi-builtin-types.o qapi-builtin-visit.o -util-obj-y +=3D qmp-introspect.o qapi-types.o qapi-visit.o qapi-event.o +util-obj-y +=3D qapi-types.o +util-obj-y +=3D qapi/qapi-types-block-core.o +util-obj-y +=3D qapi/qapi-types-block.o +util-obj-y +=3D qapi/qapi-types-char.o +util-obj-y +=3D qapi/qapi-types-common.o +util-obj-y +=3D qapi/qapi-types-crypto.o +util-obj-y +=3D qapi/qapi-types-introspect.o +util-obj-y +=3D qapi/qapi-types-migration.o +util-obj-y +=3D qapi/qapi-types-net.o +util-obj-y +=3D qapi/qapi-types-rocker.o +util-obj-y +=3D qapi/qapi-types-run-state.o +util-obj-y +=3D qapi/qapi-types-sockets.o +util-obj-y +=3D qapi/qapi-types-tpm.o +util-obj-y +=3D qapi/qapi-types-trace.o +util-obj-y +=3D qapi/qapi-types-transaction.o +util-obj-y +=3D qapi/qapi-types-ui.o +util-obj-y +=3D qmp-introspect.o qapi-visit.o qapi-event.o =20 chardev-obj-y =3D chardev/ =20 diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index f84ed17960..7bd8e1a978 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -172,6 +172,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): self._opt_builtins =3D opt_builtins self._prefix =3D prefix self._module =3D {} + self._main_module =3D None self._add_module(None, ' * Built-in QAPI types') self._genc.preamble(mcgen(''' #include "qemu/osdep.h" @@ -186,7 +187,11 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): def _module_basename(self, name): if name is None: return 'qapi-builtin-types' - return self._prefix + 'qapi-types' + basename =3D os.path.join(os.path.dirname(name), + self._prefix + 'qapi-types') + if name =3D=3D self._main_module: + return basename + return basename + '-' + os.path.splitext(os.path.basename(name))[0] =20 def _add_module(self, name, blurb): genc =3D QAPIGenC(blurb, __doc__) @@ -211,7 +216,10 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): objects_seen.add(schema.the_empty_object_type.name) =20 def visit_module(self, name): - if len(self._module) !=3D 1: + if self._main_module is None: + self._main_module =3D name + if name in self._module: + self._set_module(name) return self._add_module(name, ' * Schema-defined QAPI types') self._genc.preamble(mcgen(''' @@ -225,6 +233,12 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): #include "qapi-builtin-types.h" ''')) =20 + def visit_include(self, name, info): + self._genh.preamble(mcgen(''' +#include "%(basename)s.h" +''', + basename=3Dself._module_basename(name))) + def _gen_type_cleanup(self, name): self._genh.body(gen_type_cleanup_decl(name)) self._genc.body(gen_type_cleanup(name)) --=20 2.13.6 From nobody Mon Apr 29 02:38:33 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517589969732483.39177307580485; Fri, 2 Feb 2018 08:46:09 -0800 (PST) Received: from localhost ([::1]:39504 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eheTW-0006BK-Pt for importer@patchew.org; Fri, 02 Feb 2018 11:46:06 -0500 Received: from eggs.gnu.org ([208.118.235.92]:55993) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehdLa-0002kH-4O for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:38:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ehdKV-0003WE-VJ for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:33:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49378) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ehdKV-0003TX-5j for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:32:43 -0500 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 16EF147068; Fri, 2 Feb 2018 13:05:06 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-148.ams2.redhat.com [10.36.116.148]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 50D605191D; Fri, 2 Feb 2018 13:04:54 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id F3789113866D; Fri, 2 Feb 2018 14:03:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 2 Feb 2018 14:03:35 +0100 Message-Id: <20180202130336.24719-21-armbru@redhat.com> In-Reply-To: <20180202130336.24719-1-armbru@redhat.com> References: <20180202130336.24719-1-armbru@redhat.com> 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.30]); Fri, 02 Feb 2018 13:05:06 +0000 (UTC) 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 RFC 20/21] Include less of qapi-types.h 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: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In my "build everything" tree, a change to the types in qapi-schema.json triggers a recompile of about 4500 out of 4800 objects. The previous commit split up the generated qapi-types.h. Replace includes of qapi-types.h (i.e. all types) by includes of parts where possible. To illustrate the benefits: adding a type to qapi/migration.json now recompiles some 2300 instead of 4500 objects. The next commit will improve it further. Signed-off-by: Markus Armbruster --- crypto/cipherpriv.h | 2 +- hw/block/block.c | 1 + hw/block/hd-geometry.c | 1 + hw/net/rocker/rocker_fp.c | 2 +- include/block/block.h | 2 +- include/block/dirty-bitmap.h | 2 +- include/chardev/char.h | 1 + include/crypto/cipher.h | 2 +- include/crypto/hash.h | 2 +- include/crypto/hmac.h | 2 +- include/crypto/secret.h | 1 + include/crypto/tlscreds.h | 1 + include/hw/block/block.h | 2 +- include/hw/block/fdc.h | 2 +- include/hw/ppc/spapr_drc.h | 1 + include/hw/qdev-properties.h | 1 + include/io/dns-resolver.h | 1 + include/migration/colo.h | 2 +- include/migration/failover.h | 2 +- include/migration/global_state.h | 1 + include/monitor/monitor.h | 1 + include/net/filter.h | 1 + include/net/net.h | 2 +- include/qapi/error.h | 2 +- include/qapi/qmp/qobject.h | 2 +- include/qapi/visitor.h | 2 +- include/qemu/sockets.h | 2 +- include/qemu/throttle.h | 2 +- include/qom/cpu.h | 1 + include/qom/object.h | 2 +- include/sysemu/dump.h | 2 ++ include/sysemu/hostmem.h | 1 + include/sysemu/replay.h | 1 + include/sysemu/sysemu.h | 1 + include/sysemu/tpm.h | 1 + include/sysemu/watchdog.h | 2 +- include/ui/input.h | 2 +- migration/migration.h | 1 + migration/ram.h | 2 +- net/tap_int.h | 2 +- replication.h | 1 + ui/vnc.h | 1 + 42 files changed, 43 insertions(+), 22 deletions(-) diff --git a/crypto/cipherpriv.h b/crypto/cipherpriv.h index 77da4c2f32..0823239f41 100644 --- a/crypto/cipherpriv.h +++ b/crypto/cipherpriv.h @@ -15,7 +15,7 @@ #ifndef QCRYPTO_CIPHERPRIV_H #define QCRYPTO_CIPHERPRIV_H =20 -#include "qapi-types.h" +#include "qapi/qapi-types-crypto.h" =20 typedef struct QCryptoCipherDriver QCryptoCipherDriver; =20 diff --git a/hw/block/block.c b/hw/block/block.c index b0269c857f..b91e2b6d7e 100644 --- a/hw/block/block.c +++ b/hw/block/block.c @@ -12,6 +12,7 @@ #include "sysemu/block-backend.h" #include "hw/block/block.h" #include "qapi/error.h" +#include "qapi/qapi-types-block.h" #include "qemu/error-report.h" =20 void blkconf_serial(BlockConf *conf, char **serial) diff --git a/hw/block/hd-geometry.c b/hw/block/hd-geometry.c index 57ad5012a7..79384a2b0a 100644 --- a/hw/block/hd-geometry.c +++ b/hw/block/hd-geometry.c @@ -32,6 +32,7 @@ =20 #include "qemu/osdep.h" #include "sysemu/block-backend.h" +#include "qapi/qapi-types-block.h" #include "qemu/bswap.h" #include "hw/block/block.h" #include "trace.h" diff --git a/hw/net/rocker/rocker_fp.c b/hw/net/rocker/rocker_fp.c index 4b3c9847db..27b17c890f 100644 --- a/hw/net/rocker/rocker_fp.c +++ b/hw/net/rocker/rocker_fp.c @@ -16,7 +16,7 @@ =20 #include "qemu/osdep.h" #include "net/clients.h" - +#include "qapi/qapi-types-rocker.h" #include "rocker.h" #include "rocker_hw.h" #include "rocker_fp.h" diff --git a/include/block/block.h b/include/block/block.h index ae1517f32d..70b90cd767 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -2,7 +2,7 @@ #define BLOCK_H =20 #include "block/aio.h" -#include "qapi-types.h" +#include "qapi/qapi-types-block-core.h" #include "qemu/iov.h" #include "qemu/coroutine.h" #include "block/accounting.h" diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h index 3da8486ab1..1454be358d 100644 --- a/include/block/dirty-bitmap.h +++ b/include/block/dirty-bitmap.h @@ -2,7 +2,7 @@ #define BLOCK_DIRTY_BITMAP_H =20 #include "qemu-common.h" -#include "qapi-types.h" +#include "qapi/qapi-types-block-core.h" #include "qemu/hbitmap.h" =20 BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs, diff --git a/include/chardev/char.h b/include/chardev/char.h index a381dc3df8..ebf1e0ba04 100644 --- a/include/chardev/char.h +++ b/include/chardev/char.h @@ -1,6 +1,7 @@ #ifndef QEMU_CHAR_H #define QEMU_CHAR_H =20 +#include "qapi/qapi-types-char.h" #include "qemu/main-loop.h" #include "qemu/bitmap.h" #include "qom/object.h" diff --git a/include/crypto/cipher.h b/include/crypto/cipher.h index 984fb8243f..bce2d4c8e4 100644 --- a/include/crypto/cipher.h +++ b/include/crypto/cipher.h @@ -21,7 +21,7 @@ #ifndef QCRYPTO_CIPHER_H #define QCRYPTO_CIPHER_H =20 -#include "qapi-types.h" +#include "qapi/qapi-types-crypto.h" =20 typedef struct QCryptoCipher QCryptoCipher; =20 diff --git a/include/crypto/hash.h b/include/crypto/hash.h index ca3267f3df..077ac7bea0 100644 --- a/include/crypto/hash.h +++ b/include/crypto/hash.h @@ -21,7 +21,7 @@ #ifndef QCRYPTO_HASH_H #define QCRYPTO_HASH_H =20 -#include "qapi-types.h" +#include "qapi/qapi-types-crypto.h" =20 /* See also "QCryptoHashAlgorithm" defined in qapi/crypto.json */ =20 diff --git a/include/crypto/hmac.h b/include/crypto/hmac.h index 5e88905989..aa3c97a2ff 100644 --- a/include/crypto/hmac.h +++ b/include/crypto/hmac.h @@ -12,7 +12,7 @@ #ifndef QCRYPTO_HMAC_H #define QCRYPTO_HMAC_H =20 -#include "qapi-types.h" +#include "qapi/qapi-types-crypto.h" =20 typedef struct QCryptoHmac QCryptoHmac; struct QCryptoHmac { diff --git a/include/crypto/secret.h b/include/crypto/secret.h index 07a963e794..edd0e13236 100644 --- a/include/crypto/secret.h +++ b/include/crypto/secret.h @@ -21,6 +21,7 @@ #ifndef QCRYPTO_SECRET_H #define QCRYPTO_SECRET_H =20 +#include "qapi/qapi-types-crypto.h" #include "qom/object.h" =20 #define TYPE_QCRYPTO_SECRET "secret" diff --git a/include/crypto/tlscreds.h b/include/crypto/tlscreds.h index ad47d88be7..6b011e1dbc 100644 --- a/include/crypto/tlscreds.h +++ b/include/crypto/tlscreds.h @@ -21,6 +21,7 @@ #ifndef QCRYPTO_TLSCREDS_H #define QCRYPTO_TLSCREDS_H =20 +#include "qapi/qapi-types-crypto.h" #include "qom/object.h" =20 #ifdef CONFIG_GNUTLS diff --git a/include/hw/block/block.h b/include/hw/block/block.h index f532d10e35..d4f4dfffab 100644 --- a/include/hw/block/block.h +++ b/include/hw/block/block.h @@ -12,7 +12,7 @@ #define HW_BLOCK_H =20 #include "qemu-common.h" -#include "qapi-types.h" +#include "qapi/qapi-types-block-core.h" =20 /* Configuration */ =20 diff --git a/include/hw/block/fdc.h b/include/hw/block/fdc.h index 68a0c904ea..3b813c7f7d 100644 --- a/include/hw/block/fdc.h +++ b/include/hw/block/fdc.h @@ -2,7 +2,7 @@ #define HW_FDC_H =20 #include "qemu-common.h" -#include "qapi-types.h" +#include "qapi/qapi-types-block.h" =20 /* fdc.c */ #define MAX_FD 2 diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h index f8d9f5b231..f6ff32e7e2 100644 --- a/include/hw/ppc/spapr_drc.h +++ b/include/hw/ppc/spapr_drc.h @@ -14,6 +14,7 @@ #define HW_SPAPR_DRC_H =20 #include +#include "qapi/qapi-types-run-state.h" #include "qom/object.h" #include "sysemu/sysemu.h" #include "hw/qdev.h" diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 5bbfec634b..c5d1b1bd63 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -1,6 +1,7 @@ #ifndef QEMU_QDEV_PROPERTIES_H #define QEMU_QDEV_PROPERTIES_H =20 +#include "qapi-types.h" #include "hw/qdev-core.h" =20 /*** qdev-properties.c ***/ diff --git a/include/io/dns-resolver.h b/include/io/dns-resolver.h index 2f69c08c13..1a162185cc 100644 --- a/include/io/dns-resolver.h +++ b/include/io/dns-resolver.h @@ -22,6 +22,7 @@ #define QIO_DNS_RESOLVER_H =20 #include "qemu-common.h" +#include "qapi/qapi-types-sockets.h" #include "qom/object.h" #include "io/task.h" =20 diff --git a/include/migration/colo.h b/include/migration/colo.h index 50ace16205..2fe48ad353 100644 --- a/include/migration/colo.h +++ b/include/migration/colo.h @@ -14,7 +14,7 @@ #define QEMU_COLO_H =20 #include "qemu-common.h" -#include "qapi-types.h" +#include "qapi/qapi-types-migration.h" =20 void colo_info_init(void); =20 diff --git a/include/migration/failover.h b/include/migration/failover.h index ad91ef2381..4c37218dcc 100644 --- a/include/migration/failover.h +++ b/include/migration/failover.h @@ -14,7 +14,7 @@ #define QEMU_FAILOVER_H =20 #include "qemu-common.h" -#include "qapi-types.h" +#include "qapi/qapi-types-migration.h" =20 void failover_init_state(void); FailoverStatus failover_set_state(FailoverStatus old_state, diff --git a/include/migration/global_state.h b/include/migration/global_st= ate.h index d307de8350..fd22dd3034 100644 --- a/include/migration/global_state.h +++ b/include/migration/global_state.h @@ -13,6 +13,7 @@ #ifndef QEMU_MIGRATION_GLOBAL_STATE_H #define QEMU_MIGRATION_GLOBAL_STATE_H =20 +#include "qapi/qapi-types-run-state.h" #include "sysemu/sysemu.h" =20 void register_global_state(void); diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index ad64ad8e68..50f7cea057 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -3,6 +3,7 @@ =20 #include "qemu-common.h" #include "block/block.h" +#include "qapi-types.h" #include "qemu/readline.h" =20 extern Monitor *cur_mon; diff --git a/include/net/filter.h b/include/net/filter.h index 0c4a2ea6c9..435acd6f82 100644 --- a/include/net/filter.h +++ b/include/net/filter.h @@ -9,6 +9,7 @@ #ifndef QEMU_NET_FILTER_H #define QEMU_NET_FILTER_H =20 +#include "qapi/qapi-types-net.h" #include "qom/object.h" #include "qemu-common.h" #include "net/queue.h" diff --git a/include/net/net.h b/include/net/net.h index 3fc48e4f51..727643032c 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -2,7 +2,7 @@ #define QEMU_NET_H =20 #include "qemu/queue.h" -#include "qapi-types.h" +#include "qapi/qapi-types-net.h" #include "net/queue.h" #include "migration/vmstate.h" =20 diff --git a/include/qapi/error.h b/include/qapi/error.h index 341b229066..36065da35d 100644 --- a/include/qapi/error.h +++ b/include/qapi/error.h @@ -115,7 +115,7 @@ #ifndef ERROR_H #define ERROR_H =20 -#include "qapi-types.h" +#include "qapi/qapi-types-common.h" =20 /* * Overall category of an error. diff --git a/include/qapi/qmp/qobject.h b/include/qapi/qmp/qobject.h index 38ac68845c..a2964fbf25 100644 --- a/include/qapi/qmp/qobject.h +++ b/include/qapi/qmp/qobject.h @@ -32,7 +32,7 @@ #ifndef QOBJECT_H #define QOBJECT_H =20 -#include "qapi-types.h" +#include "qapi-builtin-types.h" =20 struct QObject { QType type; diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index ecff296c11..9e57508446 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -15,7 +15,7 @@ #ifndef QAPI_VISITOR_H #define QAPI_VISITOR_H =20 -#include "qapi-types.h" +#include "qapi-builtin-types.h" =20 /* * The QAPI schema defines both a set of C data types, and a QMP wire diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h index 8889bcb1ec..e88d4c37ab 100644 --- a/include/qemu/sockets.h +++ b/include/qemu/sockets.h @@ -9,7 +9,7 @@ int inet_aton(const char *cp, struct in_addr *ia); =20 #endif /* !_WIN32 */ =20 -#include "qapi-types.h" +#include "qapi/qapi-types-sockets.h" =20 /* misc helpers */ int qemu_socket(int domain, int type, int protocol); diff --git a/include/qemu/throttle.h b/include/qemu/throttle.h index 03d45f44f8..abeb886d93 100644 --- a/include/qemu/throttle.h +++ b/include/qemu/throttle.h @@ -26,7 +26,7 @@ #define THROTTLE_H =20 #include "qemu-common.h" -#include "qapi-types.h" +#include "qapi/qapi-types-block-core.h" #include "qemu/timer.h" =20 #define THROTTLE_VALUE_MAX 1000000000000000LL diff --git a/include/qom/cpu.h b/include/qom/cpu.h index aff88fa16f..dc6d4956a8 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -24,6 +24,7 @@ #include "disas/bfd.h" #include "exec/hwaddr.h" #include "exec/memattrs.h" +#include "qapi/qapi-types-run-state.h" #include "qemu/bitmap.h" #include "qemu/queue.h" #include "qemu/thread.h" diff --git a/include/qom/object.h b/include/qom/object.h index dc73d59660..5b5c016d8f 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -14,7 +14,7 @@ #ifndef QEMU_OBJECT_H #define QEMU_OBJECT_H =20 -#include "qapi-types.h" +#include "qapi-builtin-types.h" #include "qemu/queue.h" =20 struct TypeImpl; diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h index c14bcfe8c6..2424e31425 100644 --- a/include/sysemu/dump.h +++ b/include/sysemu/dump.h @@ -14,6 +14,8 @@ #ifndef DUMP_H #define DUMP_H =20 +#include "qapi-types.h" + #define MAKEDUMPFILE_SIGNATURE "makedumpfile" #define MAX_SIZE_MDF_HEADER (4096) /* max size of makedumpfile_hea= der */ #define TYPE_FLAT_HEADER (1) /* type of flattened format */ diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h index 621a3f9d42..6424f96df9 100644 --- a/include/sysemu/hostmem.h +++ b/include/sysemu/hostmem.h @@ -14,6 +14,7 @@ #define SYSEMU_HOSTMEM_H =20 #include "sysemu/sysemu.h" /* for MAX_NODES */ +#include "qapi-types.h" #include "qom/object.h" #include "exec/memory.h" #include "qemu/bitmap.h" diff --git a/include/sysemu/replay.h b/include/sysemu/replay.h index dc8ae7b6b1..fb533ed9b6 100644 --- a/include/sysemu/replay.h +++ b/include/sysemu/replay.h @@ -13,6 +13,7 @@ */ =20 #include "sysemu.h" +#include "qapi-types.h" =20 /* replay clock kinds */ enum ReplayClockKind { diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 77bb3da582..bfbef9e69c 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -2,6 +2,7 @@ #define SYSEMU_H /* Misc. things related to the system emulator. */ =20 +#include "qapi/qapi-types-run-state.h" #include "qemu/queue.h" #include "qemu/timer.h" #include "qemu/notify.h" diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h index 00be220248..20ac1b2993 100644 --- a/include/sysemu/tpm.h +++ b/include/sysemu/tpm.h @@ -12,6 +12,7 @@ #ifndef QEMU_TPM_H #define QEMU_TPM_H =20 +#include "qapi/qapi-types-tpm.h" #include "qom/object.h" =20 int tpm_config_parse(QemuOptsList *opts_list, const char *optarg); diff --git a/include/sysemu/watchdog.h b/include/sysemu/watchdog.h index 677ace3945..a08d16380d 100644 --- a/include/sysemu/watchdog.h +++ b/include/sysemu/watchdog.h @@ -23,7 +23,7 @@ #define QEMU_WATCHDOG_H =20 #include "qemu/queue.h" -#include "qapi-types.h" +#include "qapi/qapi-types-run-state.h" =20 struct WatchdogTimerModel { QLIST_ENTRY(WatchdogTimerModel) entry; diff --git a/include/ui/input.h b/include/ui/input.h index 05aab2db5c..fc70f503fb 100644 --- a/include/ui/input.h +++ b/include/ui/input.h @@ -1,7 +1,7 @@ #ifndef INPUT_H #define INPUT_H =20 -#include "qapi-types.h" +#include "qapi/qapi-types-ui.h" =20 #define INPUT_EVENT_MASK_KEY (1< Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517590785552962.8865277505947; Fri, 2 Feb 2018 08:59:45 -0800 (PST) Received: from localhost ([::1]:39953 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehegb-0001IU-Vw for importer@patchew.org; Fri, 02 Feb 2018 11:59:38 -0500 Received: from eggs.gnu.org ([208.118.235.92]:55455) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehdNR-0002Ua-6q for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:36:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ehdMH-0005gr-PT for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:35:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39758) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ehdMF-0005cc-VJ for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:34:33 -0500 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 929EE3111; Fri, 2 Feb 2018 13:05:06 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-148.ams2.redhat.com [10.36.116.148]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B34537A25D; Fri, 2 Feb 2018 13:04:54 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 04C2A11386AB; Fri, 2 Feb 2018 14:03:37 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 2 Feb 2018 14:03:36 +0100 Message-Id: <20180202130336.24719-22-armbru@redhat.com> In-Reply-To: <20180202130336.24719-1-armbru@redhat.com> References: <20180202130336.24719-1-armbru@redhat.com> 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]); Fri, 02 Feb 2018 13:05:06 +0000 (UTC) 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 RFC 21/21] qapi: Empty out qapi-schema.json 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: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Types defined directly in qapi-schema.json end up in qapi-types.h, and including that pulls in everything else. Move everything but include directives from qapi-schema.json to new sub-module qapi/misc.json, and replace the remaining includes of qapi-types.h. Adding a type to qapi/migration.json now recompiles less than 200 instead of 2300 out of 4500 objects. Signed-off-by: Markus Armbruster --- Makefile | 2 + Makefile.objs | 1 + include/hw/qdev-properties.h | 3 +- include/monitor/monitor.h | 2 +- include/sysemu/arch_init.h | 2 +- include/sysemu/balloon.h | 2 +- include/sysemu/dump.h | 2 +- include/sysemu/hostmem.h | 2 +- include/sysemu/replay.h | 3 +- qapi-schema.json | 3098 +-------------------------------------= ---- qapi/misc.json | 3090 ++++++++++++++++++++++++++++++++++++++= +++ qapi/run-state.json | 10 + 12 files changed, 3113 insertions(+), 3104 deletions(-) create mode 100644 qapi/misc.json diff --git a/Makefile b/Makefile index f1b68dca9b..0cf2a9caba 100644 --- a/Makefile +++ b/Makefile @@ -98,6 +98,7 @@ GENERATED_FILES +=3D qapi/qapi-types-common.h qapi/qapi-t= ypes-common.c GENERATED_FILES +=3D qapi/qapi-types-crypto.h qapi/qapi-types-crypto.c GENERATED_FILES +=3D qapi/qapi-types-introspect.h qapi/qapi-types-introspe= ct.c GENERATED_FILES +=3D qapi/qapi-types-migration.h qapi/qapi-types-migration= .c +GENERATED_FILES +=3D qapi/qapi-types-misc.h qapi/qapi-types-misc.c GENERATED_FILES +=3D qapi/qapi-types-net.h qapi/qapi-types-net.c GENERATED_FILES +=3D qapi/qapi-types-rocker.h qapi/qapi-types-rocker.c GENERATED_FILES +=3D qapi/qapi-types-run-state.h qapi/qapi-types-run-state= .c @@ -541,6 +542,7 @@ qapi/qapi-types-common.c qapi/qapi-types-common.h \ qapi/qapi-types-crypto.c qapi/qapi-types-crypto.h \ qapi/qapi-types-introspect.c qapi/qapi-types-introspect.h \ qapi/qapi-types-migration.c qapi/qapi-types-migration.h \ +qapi/qapi-types-misc.c qapi/qapi-types-misc.h \ qapi/qapi-types-net.c qapi/qapi-types-net.h \ qapi/qapi-types-rocker.c qapi/qapi-types-rocker.h \ qapi/qapi-types-run-state.c qapi/qapi-types-run-state.h \ diff --git a/Makefile.objs b/Makefile.objs index e7411a2658..efef7f095b 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -11,6 +11,7 @@ util-obj-y +=3D qapi/qapi-types-common.o util-obj-y +=3D qapi/qapi-types-crypto.o util-obj-y +=3D qapi/qapi-types-introspect.o util-obj-y +=3D qapi/qapi-types-migration.o +util-obj-y +=3D qapi/qapi-types-misc.o util-obj-y +=3D qapi/qapi-types-net.o util-obj-y +=3D qapi/qapi-types-rocker.o util-obj-y +=3D qapi/qapi-types-run-state.o diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index c5d1b1bd63..2f6bd7d73d 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -1,7 +1,8 @@ #ifndef QEMU_QDEV_PROPERTIES_H #define QEMU_QDEV_PROPERTIES_H =20 -#include "qapi-types.h" +#include "qapi/qapi-types-block.h" +#include "qapi/qapi-types-misc.h" #include "hw/qdev-core.h" =20 /*** qdev-properties.c ***/ diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index 50f7cea057..d1024d4bdc 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -3,7 +3,7 @@ =20 #include "qemu-common.h" #include "block/block.h" -#include "qapi-types.h" +#include "qapi/qapi-types-misc.h" #include "qemu/readline.h" =20 extern Monitor *cur_mon; diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h index ced67c7842..979fd022d0 100644 --- a/include/sysemu/arch_init.h +++ b/include/sysemu/arch_init.h @@ -1,7 +1,7 @@ #ifndef QEMU_ARCH_INIT_H #define QEMU_ARCH_INIT_H =20 -#include "qapi-types.h" +#include "qapi/qapi-types-misc.h" =20 enum { QEMU_ARCH_ALL =3D -1, diff --git a/include/sysemu/balloon.h b/include/sysemu/balloon.h index af49e19c78..66543ae8f4 100644 --- a/include/sysemu/balloon.h +++ b/include/sysemu/balloon.h @@ -14,7 +14,7 @@ #ifndef QEMU_BALLOON_H #define QEMU_BALLOON_H =20 -#include "qapi-types.h" +#include "qapi/qapi-types-misc.h" =20 typedef void (QEMUBalloonEvent)(void *opaque, ram_addr_t target); typedef void (QEMUBalloonStatus)(void *opaque, BalloonInfo *info); diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h index 2424e31425..d824bc0941 100644 --- a/include/sysemu/dump.h +++ b/include/sysemu/dump.h @@ -14,7 +14,7 @@ #ifndef DUMP_H #define DUMP_H =20 -#include "qapi-types.h" +#include "qapi/qapi-types-misc.h" =20 #define MAKEDUMPFILE_SIGNATURE "makedumpfile" #define MAX_SIZE_MDF_HEADER (4096) /* max size of makedumpfile_hea= der */ diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h index 6424f96df9..dc3ac3d301 100644 --- a/include/sysemu/hostmem.h +++ b/include/sysemu/hostmem.h @@ -14,7 +14,7 @@ #define SYSEMU_HOSTMEM_H =20 #include "sysemu/sysemu.h" /* for MAX_NODES */ -#include "qapi-types.h" +#include "qapi/qapi-types-misc.h" #include "qom/object.h" #include "exec/memory.h" #include "qemu/bitmap.h" diff --git a/include/sysemu/replay.h b/include/sysemu/replay.h index fb533ed9b6..c0204e641c 100644 --- a/include/sysemu/replay.h +++ b/include/sysemu/replay.h @@ -13,7 +13,8 @@ */ =20 #include "sysemu.h" -#include "qapi-types.h" +#include "qapi/qapi-types-misc.h" +#include "qapi/qapi-types-ui.h" =20 /* replay clock kinds */ enum ReplayClockKind { diff --git a/qapi-schema.json b/qapi-schema.json index 5c06745c79..541e0c3fcb 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -92,3100 +92,4 @@ { 'include': 'qapi/transaction.json' } { 'include': 'qapi/trace.json' } { 'include': 'qapi/introspect.json' } - -## -# =3D Miscellanea -## - -## -# @qmp_capabilities: -# -# Enable QMP capabilities. -# -# Arguments: None. -# -# Example: -# -# -> { "execute": "qmp_capabilities" } -# <- { "return": {} } -# -# Notes: This command is valid exactly when first connecting: it must be -# issued before any other command will be accepted, and will fail once the -# monitor is accepting other commands. (see qemu docs/interop/qmp-spec.txt) -# -# Since: 0.13 -# -## -{ 'command': 'qmp_capabilities' } - -## -# @VersionTriple: -# -# A three-part version number. -# -# @major: The major version number. -# -# @minor: The minor version number. -# -# @micro: The micro version number. -# -# Since: 2.4 -## -{ 'struct': 'VersionTriple', - 'data': {'major': 'int', 'minor': 'int', 'micro': 'int'} } - - -## -# @VersionInfo: -# -# A description of QEMU's version. -# -# @qemu: The version of QEMU. By current convention, a micro -# version of 50 signifies a development branch. A micro ver= sion -# greater than or equal to 90 signifies a release candidate = for -# the next minor version. A micro version of less than 50 -# signifies a stable release. -# -# @package: QEMU will always set this field to an empty string. Downs= tream -# versions of QEMU should set this to a non-empty string. T= he -# exact format depends on the downstream however it highly -# recommended that a unique name is used. -# -# Since: 0.14.0 -## -{ 'struct': 'VersionInfo', - 'data': {'qemu': 'VersionTriple', 'package': 'str'} } - -## -# @query-version: -# -# Returns the current version of QEMU. -# -# Returns: A @VersionInfo object describing the current version of QEMU. -# -# Since: 0.14.0 -# -# Example: -# -# -> { "execute": "query-version" } -# <- { -# "return":{ -# "qemu":{ -# "major":0, -# "minor":11, -# "micro":5 -# }, -# "package":"" -# } -# } -# -## -{ 'command': 'query-version', 'returns': 'VersionInfo' } - -## -# @CommandInfo: -# -# Information about a QMP command -# -# @name: The command name -# -# Since: 0.14.0 -## -{ 'struct': 'CommandInfo', 'data': {'name': 'str'} } - -## -# @query-commands: -# -# Return a list of supported QMP commands by this server -# -# Returns: A list of @CommandInfo for all supported commands -# -# Since: 0.14.0 -# -# Example: -# -# -> { "execute": "query-commands" } -# <- { -# "return":[ -# { -# "name":"query-balloon" -# }, -# { -# "name":"system_powerdown" -# } -# ] -# } -# -# Note: This example has been shortened as the real response is too long. -# -## -{ 'command': 'query-commands', 'returns': ['CommandInfo'] } - -## -# @LostTickPolicy: -# -# Policy for handling lost ticks in timer devices. -# -# @discard: throw away the missed tick(s) and continue with future injecti= on -# normally. Guest time may be delayed, unless the OS has explic= it -# handling of lost ticks -# -# @delay: continue to deliver ticks at the normal rate. Guest time will be -# delayed due to the late tick -# -# @merge: merge the missed tick(s) into one tick and inject. Guest time -# may be delayed, depending on how the OS reacts to the merging -# of ticks -# -# @slew: deliver ticks at a higher rate to catch up with the missed tick. = The -# guest time should not be delayed once catchup is complete. -# -# Since: 2.0 -## -{ 'enum': 'LostTickPolicy', - 'data': ['discard', 'delay', 'merge', 'slew' ] } - -## -# @add_client: -# -# Allow client connections for VNC, Spice and socket based -# character devices to be passed in to QEMU via SCM_RIGHTS. -# -# @protocol: protocol name. Valid names are "vnc", "spice" or the -# name of a character device (eg. from -chardev id=3DXXXX) -# -# @fdname: file descriptor name previously passed via 'getfd' command -# -# @skipauth: whether to skip authentication. Only applies -# to "vnc" and "spice" protocols -# -# @tls: whether to perform TLS. Only applies to the "spice" -# protocol -# -# Returns: nothing on success. -# -# Since: 0.14.0 -# -# Example: -# -# -> { "execute": "add_client", "arguments": { "protocol": "vnc", -# "fdname": "myclient" } } -# <- { "return": {} } -# -## -{ 'command': 'add_client', - 'data': { 'protocol': 'str', 'fdname': 'str', '*skipauth': 'bool', - '*tls': 'bool' } } - -## -# @NameInfo: -# -# Guest name information. -# -# @name: The name of the guest -# -# Since: 0.14.0 -## -{ 'struct': 'NameInfo', 'data': {'*name': 'str'} } - -## -# @query-name: -# -# Return the name information of a guest. -# -# Returns: @NameInfo of the guest -# -# Since: 0.14.0 -# -# Example: -# -# -> { "execute": "query-name" } -# <- { "return": { "name": "qemu-name" } } -# -## -{ 'command': 'query-name', 'returns': 'NameInfo' } - -## -# @KvmInfo: -# -# Information about support for KVM acceleration -# -# @enabled: true if KVM acceleration is active -# -# @present: true if KVM acceleration is built into this executable -# -# Since: 0.14.0 -## -{ 'struct': 'KvmInfo', 'data': {'enabled': 'bool', 'present': 'bool'} } - -## -# @query-kvm: -# -# Returns information about KVM acceleration -# -# Returns: @KvmInfo -# -# Since: 0.14.0 -# -# Example: -# -# -> { "execute": "query-kvm" } -# <- { "return": { "enabled": true, "present": true } } -# -## -{ 'command': 'query-kvm', 'returns': 'KvmInfo' } - -## -# @UuidInfo: -# -# Guest UUID information (Universally Unique Identifier). -# -# @UUID: the UUID of the guest -# -# Since: 0.14.0 -# -# Notes: If no UUID was specified for the guest, a null UUID is returned. -## -{ 'struct': 'UuidInfo', 'data': {'UUID': 'str'} } - -## -# @query-uuid: -# -# Query the guest UUID information. -# -# Returns: The @UuidInfo for the guest -# -# Since: 0.14.0 -# -# Example: -# -# -> { "execute": "query-uuid" } -# <- { "return": { "UUID": "550e8400-e29b-41d4-a716-446655440000" } } -# -## -{ 'command': 'query-uuid', 'returns': 'UuidInfo' } - -## -# @EventInfo: -# -# Information about a QMP event -# -# @name: The event name -# -# Since: 1.2.0 -## -{ 'struct': 'EventInfo', 'data': {'name': 'str'} } - -## -# @query-events: -# -# Return a list of supported QMP events by this server -# -# Returns: A list of @EventInfo for all supported events -# -# Since: 1.2.0 -# -# Example: -# -# -> { "execute": "query-events" } -# <- { -# "return": [ -# { -# "name":"SHUTDOWN" -# }, -# { -# "name":"RESET" -# } -# ] -# } -# -# Note: This example has been shortened as the real response is too long. -# -## -{ 'command': 'query-events', 'returns': ['EventInfo'] } - -## -# @CpuInfoArch: -# -# An enumeration of cpu types that enable additional information during -# @query-cpus. -# -# Since: 2.6 -## -{ 'enum': 'CpuInfoArch', - 'data': ['x86', 'sparc', 'ppc', 'mips', 'tricore', 'other' ] } - -## -# @CpuInfo: -# -# Information about a virtual CPU -# -# @CPU: the index of the virtual CPU -# -# @current: this only exists for backwards compatibility and should be ign= ored -# -# @halted: true if the virtual CPU is in the halt state. Halt usually ref= ers -# to a processor specific low power mode. -# -# @qom_path: path to the CPU object in the QOM tree (since 2.4) -# -# @thread_id: ID of the underlying host thread -# -# @props: properties describing to which node/socket/core/thread -# virtual CPU belongs to, provided if supported by board (since 2.= 10) -# -# @arch: architecture of the cpu, which determines which additional fields -# will be listed (since 2.6) -# -# Since: 0.14.0 -# -# Notes: @halted is a transient state that changes frequently. By the tim= e the -# data is sent to the client, the guest may no longer be halted. -## -{ 'union': 'CpuInfo', - 'base': {'CPU': 'int', 'current': 'bool', 'halted': 'bool', - 'qom_path': 'str', 'thread_id': 'int', - '*props': 'CpuInstanceProperties', 'arch': 'CpuInfoArch' }, - 'discriminator': 'arch', - 'data': { 'x86': 'CpuInfoX86', - 'sparc': 'CpuInfoSPARC', - 'ppc': 'CpuInfoPPC', - 'mips': 'CpuInfoMIPS', - 'tricore': 'CpuInfoTricore', - 'other': 'CpuInfoOther' } } - -## -# @CpuInfoX86: -# -# Additional information about a virtual i386 or x86_64 CPU -# -# @pc: the 64-bit instruction pointer -# -# Since: 2.6 -## -{ 'struct': 'CpuInfoX86', 'data': { 'pc': 'int' } } - -## -# @CpuInfoSPARC: -# -# Additional information about a virtual SPARC CPU -# -# @pc: the PC component of the instruction pointer -# -# @npc: the NPC component of the instruction pointer -# -# Since: 2.6 -## -{ 'struct': 'CpuInfoSPARC', 'data': { 'pc': 'int', 'npc': 'int' } } - -## -# @CpuInfoPPC: -# -# Additional information about a virtual PPC CPU -# -# @nip: the instruction pointer -# -# Since: 2.6 -## -{ 'struct': 'CpuInfoPPC', 'data': { 'nip': 'int' } } - -## -# @CpuInfoMIPS: -# -# Additional information about a virtual MIPS CPU -# -# @PC: the instruction pointer -# -# Since: 2.6 -## -{ 'struct': 'CpuInfoMIPS', 'data': { 'PC': 'int' } } - -## -# @CpuInfoTricore: -# -# Additional information about a virtual Tricore CPU -# -# @PC: the instruction pointer -# -# Since: 2.6 -## -{ 'struct': 'CpuInfoTricore', 'data': { 'PC': 'int' } } - -## -# @CpuInfoOther: -# -# No additional information is available about the virtual CPU -# -# Since: 2.6 -# -## -{ 'struct': 'CpuInfoOther', 'data': { } } - -## -# @query-cpus: -# -# Returns a list of information about each virtual CPU. -# -# Returns: a list of @CpuInfo for each virtual CPU -# -# Since: 0.14.0 -# -# Example: -# -# -> { "execute": "query-cpus" } -# <- { "return": [ -# { -# "CPU":0, -# "current":true, -# "halted":false, -# "qom_path":"/machine/unattached/device[0]", -# "arch":"x86", -# "pc":3227107138, -# "thread_id":3134 -# }, -# { -# "CPU":1, -# "current":false, -# "halted":true, -# "qom_path":"/machine/unattached/device[2]", -# "arch":"x86", -# "pc":7108165, -# "thread_id":3135 -# } -# ] -# } -# -## -{ 'command': 'query-cpus', 'returns': ['CpuInfo'] } - -## -# @IOThreadInfo: -# -# Information about an iothread -# -# @id: the identifier of the iothread -# -# @thread-id: ID of the underlying host thread -# -# @poll-max-ns: maximum polling time in ns, 0 means polling is disabled -# (since 2.9) -# -# @poll-grow: how many ns will be added to polling time, 0 means that it's= not -# configured (since 2.9) -# -# @poll-shrink: how many ns will be removed from polling time, 0 means that -# it's not configured (since 2.9) -# -# Since: 2.0 -## -{ 'struct': 'IOThreadInfo', - 'data': {'id': 'str', - 'thread-id': 'int', - 'poll-max-ns': 'int', - 'poll-grow': 'int', - 'poll-shrink': 'int' } } - -## -# @query-iothreads: -# -# Returns a list of information about each iothread. -# -# Note: this list excludes the QEMU main loop thread, which is not declared -# using the -object iothread command-line option. It is always the main t= hread -# of the process. -# -# Returns: a list of @IOThreadInfo for each iothread -# -# Since: 2.0 -# -# Example: -# -# -> { "execute": "query-iothreads" } -# <- { "return": [ -# { -# "id":"iothread0", -# "thread-id":3134 -# }, -# { -# "id":"iothread1", -# "thread-id":3135 -# } -# ] -# } -# -## -{ 'command': 'query-iothreads', 'returns': ['IOThreadInfo'] } - -## -# @BalloonInfo: -# -# Information about the guest balloon device. -# -# @actual: the number of bytes the balloon currently contains -# -# Since: 0.14.0 -# -## -{ 'struct': 'BalloonInfo', 'data': {'actual': 'int' } } - -## -# @query-balloon: -# -# Return information about the balloon device. -# -# Returns: @BalloonInfo on success -# -# If the balloon driver is enabled but not functional because the= KVM -# kernel module cannot support it, KvmMissingCap -# -# If no balloon device is present, DeviceNotActive -# -# Since: 0.14.0 -# -# Example: -# -# -> { "execute": "query-balloon" } -# <- { "return": { -# "actual": 1073741824, -# } -# } -# -## -{ 'command': 'query-balloon', 'returns': 'BalloonInfo' } - -## -# @BALLOON_CHANGE: -# -# Emitted when the guest changes the actual BALLOON level. This value is -# equivalent to the @actual field return by the 'query-balloon' command -# -# @actual: actual level of the guest memory balloon in bytes -# -# Note: this event is rate-limited. -# -# Since: 1.2 -# -# Example: -# -# <- { "event": "BALLOON_CHANGE", -# "data": { "actual": 944766976 }, -# "timestamp": { "seconds": 1267020223, "microseconds": 435656 } } -# -## -{ 'event': 'BALLOON_CHANGE', - 'data': { 'actual': 'int' } } - -## -# @PciMemoryRange: -# -# A PCI device memory region -# -# @base: the starting address (guest physical) -# -# @limit: the ending address (guest physical) -# -# Since: 0.14.0 -## -{ 'struct': 'PciMemoryRange', 'data': {'base': 'int', 'limit': 'int'} } - -## -# @PciMemoryRegion: -# -# Information about a PCI device I/O region. -# -# @bar: the index of the Base Address Register for this region -# -# @type: 'io' if the region is a PIO region -# 'memory' if the region is a MMIO region -# -# @size: memory size -# -# @prefetch: if @type is 'memory', true if the memory is prefetchable -# -# @mem_type_64: if @type is 'memory', true if the BAR is 64-bit -# -# Since: 0.14.0 -## -{ 'struct': 'PciMemoryRegion', - 'data': {'bar': 'int', 'type': 'str', 'address': 'int', 'size': 'int', - '*prefetch': 'bool', '*mem_type_64': 'bool' } } - -## -# @PciBusInfo: -# -# Information about a bus of a PCI Bridge device -# -# @number: primary bus interface number. This should be the number of the -# bus the device resides on. -# -# @secondary: secondary bus interface number. This is the number of the -# main bus for the bridge -# -# @subordinate: This is the highest number bus that resides below the -# bridge. -# -# @io_range: The PIO range for all devices on this bridge -# -# @memory_range: The MMIO range for all devices on this bridge -# -# @prefetchable_range: The range of prefetchable MMIO for all devices on -# this bridge -# -# Since: 2.4 -## -{ 'struct': 'PciBusInfo', - 'data': {'number': 'int', 'secondary': 'int', 'subordinate': 'int', - 'io_range': 'PciMemoryRange', - 'memory_range': 'PciMemoryRange', - 'prefetchable_range': 'PciMemoryRange' } } - -## -# @PciBridgeInfo: -# -# Information about a PCI Bridge device -# -# @bus: information about the bus the device resides on -# -# @devices: a list of @PciDeviceInfo for each device on this bridge -# -# Since: 0.14.0 -## -{ 'struct': 'PciBridgeInfo', - 'data': {'bus': 'PciBusInfo', '*devices': ['PciDeviceInfo']} } - -## -# @PciDeviceClass: -# -# Information about the Class of a PCI device -# -# @desc: a string description of the device's class -# -# @class: the class code of the device -# -# Since: 2.4 -## -{ 'struct': 'PciDeviceClass', - 'data': {'*desc': 'str', 'class': 'int'} } - -## -# @PciDeviceId: -# -# Information about the Id of a PCI device -# -# @device: the PCI device id -# -# @vendor: the PCI vendor id -# -# Since: 2.4 -## -{ 'struct': 'PciDeviceId', - 'data': {'device': 'int', 'vendor': 'int'} } - -## -# @PciDeviceInfo: -# -# Information about a PCI device -# -# @bus: the bus number of the device -# -# @slot: the slot the device is located in -# -# @function: the function of the slot used by the device -# -# @class_info: the class of the device -# -# @id: the PCI device id -# -# @irq: if an IRQ is assigned to the device, the IRQ number -# -# @qdev_id: the device name of the PCI device -# -# @pci_bridge: if the device is a PCI bridge, the bridge information -# -# @regions: a list of the PCI I/O regions associated with the device -# -# Notes: the contents of @class_info.desc are not stable and should only be -# treated as informational. -# -# Since: 0.14.0 -## -{ 'struct': 'PciDeviceInfo', - 'data': {'bus': 'int', 'slot': 'int', 'function': 'int', - 'class_info': 'PciDeviceClass', 'id': 'PciDeviceId', - '*irq': 'int', 'qdev_id': 'str', '*pci_bridge': 'PciBridgeInfo', - 'regions': ['PciMemoryRegion']} } - -## -# @PciInfo: -# -# Information about a PCI bus -# -# @bus: the bus index -# -# @devices: a list of devices on this bus -# -# Since: 0.14.0 -## -{ 'struct': 'PciInfo', 'data': {'bus': 'int', 'devices': ['PciDeviceInfo']= } } - -## -# @query-pci: -# -# Return information about the PCI bus topology of the guest. -# -# Returns: a list of @PciInfo for each PCI bus. Each bus is -# represented by a json-object, which has a key with a json-array of -# all PCI devices attached to it. Each device is represented by a -# json-object. -# -# Since: 0.14.0 -# -# Example: -# -# -> { "execute": "query-pci" } -# <- { "return": [ -# { -# "bus": 0, -# "devices": [ -# { -# "bus": 0, -# "qdev_id": "", -# "slot": 0, -# "class_info": { -# "class": 1536, -# "desc": "Host bridge" -# }, -# "id": { -# "device": 32902, -# "vendor": 4663 -# }, -# "function": 0, -# "regions": [ -# ] -# }, -# { -# "bus": 0, -# "qdev_id": "", -# "slot": 1, -# "class_info": { -# "class": 1537, -# "desc": "ISA bridge" -# }, -# "id": { -# "device": 32902, -# "vendor": 28672 -# }, -# "function": 0, -# "regions": [ -# ] -# }, -# { -# "bus": 0, -# "qdev_id": "", -# "slot": 1, -# "class_info": { -# "class": 257, -# "desc": "IDE controller" -# }, -# "id": { -# "device": 32902, -# "vendor": 28688 -# }, -# "function": 1, -# "regions": [ -# { -# "bar": 4, -# "size": 16, -# "address": 49152, -# "type": "io" -# } -# ] -# }, -# { -# "bus": 0, -# "qdev_id": "", -# "slot": 2, -# "class_info": { -# "class": 768, -# "desc": "VGA controller" -# }, -# "id": { -# "device": 4115, -# "vendor": 184 -# }, -# "function": 0, -# "regions": [ -# { -# "prefetch": true, -# "mem_type_64": false, -# "bar": 0, -# "size": 33554432, -# "address": 4026531840, -# "type": "memory" -# }, -# { -# "prefetch": false, -# "mem_type_64": false, -# "bar": 1, -# "size": 4096, -# "address": 4060086272, -# "type": "memory" -# }, -# { -# "prefetch": false, -# "mem_type_64": false, -# "bar": 6, -# "size": 65536, -# "address": -1, -# "type": "memory" -# } -# ] -# }, -# { -# "bus": 0, -# "qdev_id": "", -# "irq": 11, -# "slot": 4, -# "class_info": { -# "class": 1280, -# "desc": "RAM controller" -# }, -# "id": { -# "device": 6900, -# "vendor": 4098 -# }, -# "function": 0, -# "regions": [ -# { -# "bar": 0, -# "size": 32, -# "address": 49280, -# "type": "io" -# } -# ] -# } -# ] -# } -# ] -# } -# -# Note: This example has been shortened as the real response is too long. -# -## -{ 'command': 'query-pci', 'returns': ['PciInfo'] } - -## -# @quit: -# -# This command will cause the QEMU process to exit gracefully. While every -# attempt is made to send the QMP response before terminating, this is not -# guaranteed. When using this interface, a premature EOF would not be -# unexpected. -# -# Since: 0.14.0 -# -# Example: -# -# -> { "execute": "quit" } -# <- { "return": {} } -## -{ 'command': 'quit' } - -## -# @stop: -# -# Stop all guest VCPU execution. -# -# Since: 0.14.0 -# -# Notes: This function will succeed even if the guest is already in the s= topped -# state. In "inmigrate" state, it will ensure that the guest -# remains paused once migration finishes, as if the -S option was -# passed on the command line. -# -# Example: -# -# -> { "execute": "stop" } -# <- { "return": {} } -# -## -{ 'command': 'stop' } - -## -# @system_reset: -# -# Performs a hard reset of a guest. -# -# Since: 0.14.0 -# -# Example: -# -# -> { "execute": "system_reset" } -# <- { "return": {} } -# -## -{ 'command': 'system_reset' } - -## -# @system_powerdown: -# -# Requests that a guest perform a powerdown operation. -# -# Since: 0.14.0 -# -# Notes: A guest may or may not respond to this command. This command -# returning does not indicate that a guest has accepted the request= or -# that it has shut down. Many guests will respond to this command = by -# prompting the user in some way. -# Example: -# -# -> { "execute": "system_powerdown" } -# <- { "return": {} } -# -## -{ 'command': 'system_powerdown' } - -## -# @cpu-add: -# -# Adds CPU with specified ID -# -# @id: ID of CPU to be created, valid values [0..max_cpus) -# -# Returns: Nothing on success -# -# Since: 1.5 -# -# Example: -# -# -> { "execute": "cpu-add", "arguments": { "id": 2 } } -# <- { "return": {} } -# -## -{ 'command': 'cpu-add', 'data': {'id': 'int'} } - -## -# @memsave: -# -# Save a portion of guest memory to a file. -# -# @val: the virtual address of the guest to start from -# -# @size: the size of memory region to save -# -# @filename: the file to save the memory to as binary data -# -# @cpu-index: the index of the virtual CPU to use for translating the -# virtual address (defaults to CPU 0) -# -# Returns: Nothing on success -# -# Since: 0.14.0 -# -# Notes: Errors were not reliably returned until 1.1 -# -# Example: -# -# -> { "execute": "memsave", -# "arguments": { "val": 10, -# "size": 100, -# "filename": "/tmp/virtual-mem-dump" } } -# <- { "return": {} } -# -## -{ 'command': 'memsave', - 'data': {'val': 'int', 'size': 'int', 'filename': 'str', '*cpu-index': '= int'} } - -## -# @pmemsave: -# -# Save a portion of guest physical memory to a file. -# -# @val: the physical address of the guest to start from -# -# @size: the size of memory region to save -# -# @filename: the file to save the memory to as binary data -# -# Returns: Nothing on success -# -# Since: 0.14.0 -# -# Notes: Errors were not reliably returned until 1.1 -# -# Example: -# -# -> { "execute": "pmemsave", -# "arguments": { "val": 10, -# "size": 100, -# "filename": "/tmp/physical-mem-dump" } } -# <- { "return": {} } -# -## -{ 'command': 'pmemsave', - 'data': {'val': 'int', 'size': 'int', 'filename': 'str'} } - -## -# @cont: -# -# Resume guest VCPU execution. -# -# Since: 0.14.0 -# -# Returns: If successful, nothing -# -# Notes: This command will succeed if the guest is currently running. It -# will also succeed if the guest is in the "inmigrate" state; in -# this case, the effect of the command is to make sure the guest -# starts once migration finishes, removing the effect of the -S -# command line option if it was passed. -# -# Example: -# -# -> { "execute": "cont" } -# <- { "return": {} } -# -## -{ 'command': 'cont' } - -## -# @system_wakeup: -# -# Wakeup guest from suspend. Does nothing in case the guest isn't suspend= ed. -# -# Since: 1.1 -# -# Returns: nothing. -# -# Example: -# -# -> { "execute": "system_wakeup" } -# <- { "return": {} } -# -## -{ 'command': 'system_wakeup' } - -## -# @inject-nmi: -# -# Injects a Non-Maskable Interrupt into the default CPU (x86/s390) or all = CPUs (ppc64). -# The command fails when the guest doesn't support injecting. -# -# Returns: If successful, nothing -# -# Since: 0.14.0 -# -# Note: prior to 2.1, this command was only supported for x86 and s390 VMs -# -# Example: -# -# -> { "execute": "inject-nmi" } -# <- { "return": {} } -# -## -{ 'command': 'inject-nmi' } - -## -# @balloon: -# -# Request the balloon driver to change its balloon size. -# -# @value: the target size of the balloon in bytes -# -# Returns: Nothing on success -# If the balloon driver is enabled but not functional because the= KVM -# kernel module cannot support it, KvmMissingCap -# If no balloon device is present, DeviceNotActive -# -# Notes: This command just issues a request to the guest. When it returns, -# the balloon size may not have changed. A guest can change the ba= lloon -# size independent of this command. -# -# Since: 0.14.0 -# -# Example: -# -# -> { "execute": "balloon", "arguments": { "value": 536870912 } } -# <- { "return": {} } -# -## -{ 'command': 'balloon', 'data': {'value': 'int'} } - -## -# @human-monitor-command: -# -# Execute a command on the human monitor and return the output. -# -# @command-line: the command to execute in the human monitor -# -# @cpu-index: The CPU to use for commands that require an implicit CPU -# -# Returns: the output of the command as a string -# -# Since: 0.14.0 -# -# Notes: This command only exists as a stop-gap. Its use is highly -# discouraged. The semantics of this command are not -# guaranteed: this means that command names, arguments and -# responses can change or be removed at ANY time. Applications -# that rely on long term stability guarantees should NOT -# use this command. -# -# Known limitations: -# -# * This command is stateless, this means that commands that depend -# on state information (such as getfd) might not work -# -# * Commands that prompt the user for data don't currently work -# -# Example: -# -# -> { "execute": "human-monitor-command", -# "arguments": { "command-line": "info kvm" } } -# <- { "return": "kvm support: enabled\r\n" } -# -## -{ 'command': 'human-monitor-command', - 'data': {'command-line': 'str', '*cpu-index': 'int'}, - 'returns': 'str' } - -## -# @ObjectPropertyInfo: -# -# @name: the name of the property -# -# @type: the type of the property. This will typically come in one of four -# forms: -# -# 1) A primitive type such as 'u8', 'u16', 'bool', 'str', or 'doubl= e'. -# These types are mapped to the appropriate JSON type. -# -# 2) A child type in the form 'child' where subtype is a q= dev -# device type name. Child properties create the composition tre= e. -# -# 3) A link type in the form 'link' where subtype is a qdev -# device type name. Link properties form the device model graph. -# -# Since: 1.2 -## -{ 'struct': 'ObjectPropertyInfo', - 'data': { 'name': 'str', 'type': 'str' } } - -## -# @qom-list: -# -# This command will list any properties of a object given a path in the ob= ject -# model. -# -# @path: the path within the object model. See @qom-get for a description= of -# this parameter. -# -# Returns: a list of @ObjectPropertyInfo that describe the properties of t= he -# object. -# -# Since: 1.2 -## -{ 'command': 'qom-list', - 'data': { 'path': 'str' }, - 'returns': [ 'ObjectPropertyInfo' ] } - -## -# @qom-get: -# -# This command will get a property from a object model path and return the -# value. -# -# @path: The path within the object model. There are two forms of support= ed -# paths--absolute and partial paths. -# -# Absolute paths are derived from the root object and can follow ch= ild<> -# or link<> properties. Since they can follow link<> properties, t= hey -# can be arbitrarily long. Absolute paths look like absolute filen= ames -# and are prefixed with a leading slash. -# -# Partial paths look like relative filenames. They do not begin -# with a prefix. The matching rules for partial paths are subtle b= ut -# designed to make specifying objects easy. At each level of the -# composition tree, the partial path is matched as an absolute path. -# The first match is not returned. At least two matches are search= ed -# for. A successful result is only returned if only one match is -# found. If more than one match is found, a flag is return to -# indicate that the match was ambiguous. -# -# @property: The property name to read -# -# Returns: The property value. The type depends on the property -# type. child<> and link<> properties are returned as #str -# pathnames. All integer property types (u8, u16, etc) are -# returned as #int. -# -# Since: 1.2 -## -{ 'command': 'qom-get', - 'data': { 'path': 'str', 'property': 'str' }, - 'returns': 'any' } - -## -# @qom-set: -# -# This command will set a property from a object model path. -# -# @path: see @qom-get for a description of this parameter -# -# @property: the property name to set -# -# @value: a value who's type is appropriate for the property type. See @q= om-get -# for a description of type mapping. -# -# Since: 1.2 -## -{ 'command': 'qom-set', - 'data': { 'path': 'str', 'property': 'str', 'value': 'any' } } - -## -# @change: -# -# This command is multiple commands multiplexed together. -# -# @device: This is normally the name of a block device but it may also be = 'vnc'. -# when it's 'vnc', then sub command depends on @target -# -# @target: If @device is a block device, then this is the new filename. -# If @device is 'vnc', then if the value 'password' selects the v= nc -# change password command. Otherwise, this specifies a new serv= er URI -# address to listen to for VNC connections. -# -# @arg: If @device is a block device, then this is an optional format t= o open -# the device with. -# If @device is 'vnc' and @target is 'password', this is the new = VNC -# password to set. See change-vnc-password for additional notes. -# -# Returns: Nothing on success. -# If @device is not a valid block device, DeviceNotFound -# -# Notes: This interface is deprecated, and it is strongly recommended tha= t you -# avoid using it. For changing block devices, use -# blockdev-change-medium; for changing VNC parameters, use -# change-vnc-password. -# -# Since: 0.14.0 -# -# Example: -# -# 1. Change a removable medium -# -# -> { "execute": "change", -# "arguments": { "device": "ide1-cd0", -# "target": "/srv/images/Fedora-12-x86_64-DVD.iso" } } -# <- { "return": {} } -# -# 2. Change VNC password -# -# -> { "execute": "change", -# "arguments": { "device": "vnc", "target": "password", -# "arg": "foobar1" } } -# <- { "return": {} } -# -## -{ 'command': 'change', - 'data': {'device': 'str', 'target': 'str', '*arg': 'str'} } - -## -# @ObjectTypeInfo: -# -# This structure describes a search result from @qom-list-types -# -# @name: the type name found in the search -# -# @abstract: the type is abstract and can't be directly instantiated. -# Omitted if false. (since 2.10) -# -# @parent: Name of parent type, if any (since 2.10) -# -# Since: 1.1 -## -{ 'struct': 'ObjectTypeInfo', - 'data': { 'name': 'str', '*abstract': 'bool', '*parent': 'str' } } - -## -# @qom-list-types: -# -# This command will return a list of types given search parameters -# -# @implements: if specified, only return types that implement this type na= me -# -# @abstract: if true, include abstract types in the results -# -# Returns: a list of @ObjectTypeInfo or an empty list if no results are fo= und -# -# Since: 1.1 -## -{ 'command': 'qom-list-types', - 'data': { '*implements': 'str', '*abstract': 'bool' }, - 'returns': [ 'ObjectTypeInfo' ] } - -## -# @DevicePropertyInfo: -# -# Information about device properties. -# -# @name: the name of the property -# @type: the typename of the property -# @description: if specified, the description of the property. -# (since 2.2) -# -# Since: 1.2 -## -{ 'struct': 'DevicePropertyInfo', - 'data': { 'name': 'str', 'type': 'str', '*description': 'str' } } - -## -# @device-list-properties: -# -# List properties associated with a device. -# -# @typename: the type name of a device -# -# Returns: a list of DevicePropertyInfo describing a devices properties -# -# Since: 1.2 -## -{ 'command': 'device-list-properties', - 'data': { 'typename': 'str'}, - 'returns': [ 'DevicePropertyInfo' ] } - -## -# @xen-set-global-dirty-log: -# -# Enable or disable the global dirty log mode. -# -# @enable: true to enable, false to disable. -# -# Returns: nothing -# -# Since: 1.3 -# -# Example: -# -# -> { "execute": "xen-set-global-dirty-log", -# "arguments": { "enable": true } } -# <- { "return": {} } -# -## -{ 'command': 'xen-set-global-dirty-log', 'data': { 'enable': 'bool' } } - -## -# @device_add: -# -# @driver: the name of the new device's driver -# -# @bus: the device's parent bus (device tree path) -# -# @id: the device's ID, must be unique -# -# Additional arguments depend on the type. -# -# Add a device. -# -# Notes: -# 1. For detailed information about this command, please refer to the -# 'docs/qdev-device-use.txt' file. -# -# 2. It's possible to list device properties by running QEMU with the -# "-device DEVICE,help" command-line argument, where DEVICE is the -# device's name -# -# Example: -# -# -> { "execute": "device_add", -# "arguments": { "driver": "e1000", "id": "net1", -# "bus": "pci.0", -# "mac": "52:54:00:12:34:56" } } -# <- { "return": {} } -# -# TODO: This command effectively bypasses QAPI completely due to its -# "additional arguments" business. It shouldn't have been added to -# the schema in this form. It should be qapified properly, or -# replaced by a properly qapified command. -# -# Since: 0.13 -## -{ 'command': 'device_add', - 'data': {'driver': 'str', '*bus': 'str', '*id': 'str'}, - 'gen': false } # so we can get the additional arguments - -## -# @device_del: -# -# Remove a device from a guest -# -# @id: the device's ID or QOM path -# -# Returns: Nothing on success -# If @id is not a valid device, DeviceNotFound -# -# Notes: When this command completes, the device may not be removed from t= he -# guest. Hot removal is an operation that requires guest cooperati= on. -# This command merely requests that the guest begin the hot removal -# process. Completion of the device removal process is signaled wi= th a -# DEVICE_DELETED event. Guest reset will automatically complete rem= oval -# for all devices. -# -# Since: 0.14.0 -# -# Example: -# -# -> { "execute": "device_del", -# "arguments": { "id": "net1" } } -# <- { "return": {} } -# -# -> { "execute": "device_del", -# "arguments": { "id": "/machine/peripheral-anon/device[0]" } } -# <- { "return": {} } -# -## -{ 'command': 'device_del', 'data': {'id': 'str'} } - -## -# @DEVICE_DELETED: -# -# Emitted whenever the device removal completion is acknowledged by the gu= est. -# At this point, it's safe to reuse the specified device ID. Device remova= l can -# be initiated by the guest or by HMP/QMP commands. -# -# @device: device name -# -# @path: device path -# -# Since: 1.5 -# -# Example: -# -# <- { "event": "DEVICE_DELETED", -# "data": { "device": "virtio-net-pci-0", -# "path": "/machine/peripheral/virtio-net-pci-0" }, -# "timestamp": { "seconds": 1265044230, "microseconds": 450486 } } -# -## -{ 'event': 'DEVICE_DELETED', - 'data': { '*device': 'str', 'path': 'str' } } - -## -# @DumpGuestMemoryFormat: -# -# An enumeration of guest-memory-dump's format. -# -# @elf: elf format -# -# @kdump-zlib: kdump-compressed format with zlib-compressed -# -# @kdump-lzo: kdump-compressed format with lzo-compressed -# -# @kdump-snappy: kdump-compressed format with snappy-compressed -# -# Since: 2.0 -## -{ 'enum': 'DumpGuestMemoryFormat', - 'data': [ 'elf', 'kdump-zlib', 'kdump-lzo', 'kdump-snappy' ] } - -## -# @dump-guest-memory: -# -# Dump guest's memory to vmcore. It is a synchronous operation that can ta= ke -# very long depending on the amount of guest memory. -# -# @paging: if true, do paging to get guest's memory mapping. This allows -# using gdb to process the core file. -# -# IMPORTANT: this option can make QEMU allocate several gigabytes -# of RAM. This can happen for a large guest, or a -# malicious guest pretending to be large. -# -# Also, paging=3Dtrue has the following limitations: -# -# 1. The guest may be in a catastrophic state or can have corr= upted -# memory, which cannot be trusted -# 2. The guest can be in real-mode even if paging is enabled. = For -# example, the guest uses ACPI to sleep, and ACPI sleep sta= te -# goes in real-mode -# 3. Currently only supported on i386 and x86_64. -# -# @protocol: the filename or file descriptor of the vmcore. The supported -# protocols are: -# -# 1. file: the protocol starts with "file:", and the following -# string is the file's path. -# 2. fd: the protocol starts with "fd:", and the following stri= ng -# is the fd's name. -# -# @detach: if true, QMP will return immediately rather than -# waiting for the dump to finish. The user can track progress -# using "query-dump". (since 2.6). -# -# @begin: if specified, the starting physical address. -# -# @length: if specified, the memory size, in bytes. If you don't -# want to dump all guest's memory, please specify the start @begin -# and @length -# -# @format: if specified, the format of guest memory dump. But non-elf -# format is conflict with paging and filter, ie. @paging, @begin = and -# @length is not allowed to be specified with non-elf @format at = the -# same time (since 2.0) -# -# Note: All boolean arguments default to false -# -# Returns: nothing on success -# -# Since: 1.2 -# -# Example: -# -# -> { "execute": "dump-guest-memory", -# "arguments": { "protocol": "fd:dump" } } -# <- { "return": {} } -# -## -{ 'command': 'dump-guest-memory', - 'data': { 'paging': 'bool', 'protocol': 'str', '*detach': 'bool', - '*begin': 'int', '*length': 'int', - '*format': 'DumpGuestMemoryFormat'} } - -## -# @DumpStatus: -# -# Describe the status of a long-running background guest memory dump. -# -# @none: no dump-guest-memory has started yet. -# -# @active: there is one dump running in background. -# -# @completed: the last dump has finished successfully. -# -# @failed: the last dump has failed. -# -# Since: 2.6 -## -{ 'enum': 'DumpStatus', - 'data': [ 'none', 'active', 'completed', 'failed' ] } - -## -# @DumpQueryResult: -# -# The result format for 'query-dump'. -# -# @status: enum of @DumpStatus, which shows current dump status -# -# @completed: bytes written in latest dump (uncompressed) -# -# @total: total bytes to be written in latest dump (uncompressed) -# -# Since: 2.6 -## -{ 'struct': 'DumpQueryResult', - 'data': { 'status': 'DumpStatus', - 'completed': 'int', - 'total': 'int' } } - -## -# @query-dump: -# -# Query latest dump status. -# -# Returns: A @DumpStatus object showing the dump status. -# -# Since: 2.6 -# -# Example: -# -# -> { "execute": "query-dump" } -# <- { "return": { "status": "active", "completed": 1024000, -# "total": 2048000 } } -# -## -{ 'command': 'query-dump', 'returns': 'DumpQueryResult' } - -## -# @DUMP_COMPLETED: -# -# Emitted when background dump has completed -# -# @result: DumpQueryResult type described in qapi-schema.json. -# -# @error: human-readable error string that provides -# hint on why dump failed. Only presents on failure. The -# user should not try to interpret the error string. -# -# Since: 2.6 -# -# Example: -# -# { "event": "DUMP_COMPLETED", -# "data": {"result": {"total": 1090650112, "status": "completed", -# "completed": 1090650112} } } -# -## -{ 'event': 'DUMP_COMPLETED' , - 'data': { 'result': 'DumpQueryResult', '*error': 'str' } } - -## -# @DumpGuestMemoryCapability: -# -# A list of the available formats for dump-guest-memory -# -# Since: 2.0 -## -{ 'struct': 'DumpGuestMemoryCapability', - 'data': { - 'formats': ['DumpGuestMemoryFormat'] } } - -## -# @query-dump-guest-memory-capability: -# -# Returns the available formats for dump-guest-memory -# -# Returns: A @DumpGuestMemoryCapability object listing available formats = for -# dump-guest-memory -# -# Since: 2.0 -# -# Example: -# -# -> { "execute": "query-dump-guest-memory-capability" } -# <- { "return": { "formats": -# ["elf", "kdump-zlib", "kdump-lzo", "kdump-snappy"] } -# -## -{ 'command': 'query-dump-guest-memory-capability', - 'returns': 'DumpGuestMemoryCapability' } - -## -# @dump-skeys: -# -# Dump guest's storage keys -# -# @filename: the path to the file to dump to -# -# This command is only supported on s390 architecture. -# -# Since: 2.5 -# -# Example: -# -# -> { "execute": "dump-skeys", -# "arguments": { "filename": "/tmp/skeys" } } -# <- { "return": {} } -# -## -{ 'command': 'dump-skeys', - 'data': { 'filename': 'str' } } - -## -# @object-add: -# -# Create a QOM object. -# -# @qom-type: the class name for the object to be created -# -# @id: the name of the new object -# -# @props: a dictionary of properties to be passed to the backend -# -# Returns: Nothing on success -# Error if @qom-type is not a valid class name -# -# Since: 2.0 -# -# Example: -# -# -> { "execute": "object-add", -# "arguments": { "qom-type": "rng-random", "id": "rng1", -# "props": { "filename": "/dev/hwrng" } } } -# <- { "return": {} } -# -## -{ 'command': 'object-add', - 'data': {'qom-type': 'str', 'id': 'str', '*props': 'any'} } - -## -# @object-del: -# -# Remove a QOM object. -# -# @id: the name of the QOM object to remove -# -# Returns: Nothing on success -# Error if @id is not a valid id for a QOM object -# -# Since: 2.0 -# -# Example: -# -# -> { "execute": "object-del", "arguments": { "id": "rng1" } } -# <- { "return": {} } -# -## -{ 'command': 'object-del', 'data': {'id': 'str'} } - -## -# @getfd: -# -# Receive a file descriptor via SCM rights and assign it a name -# -# @fdname: file descriptor name -# -# Returns: Nothing on success -# -# Since: 0.14.0 -# -# Notes: If @fdname already exists, the file descriptor assigned to -# it will be closed and replaced by the received file -# descriptor. -# -# The 'closefd' command can be used to explicitly close the -# file descriptor when it is no longer needed. -# -# Example: -# -# -> { "execute": "getfd", "arguments": { "fdname": "fd1" } } -# <- { "return": {} } -# -## -{ 'command': 'getfd', 'data': {'fdname': 'str'} } - -## -# @closefd: -# -# Close a file descriptor previously passed via SCM rights -# -# @fdname: file descriptor name -# -# Returns: Nothing on success -# -# Since: 0.14.0 -# -# Example: -# -# -> { "execute": "closefd", "arguments": { "fdname": "fd1" } } -# <- { "return": {} } -# -## -{ 'command': 'closefd', 'data': {'fdname': 'str'} } - -## -# @MachineInfo: -# -# Information describing a machine. -# -# @name: the name of the machine -# -# @alias: an alias for the machine name -# -# @is-default: whether the machine is default -# -# @cpu-max: maximum number of CPUs supported by the machine type -# (since 1.5.0) -# -# @hotpluggable-cpus: cpu hotplug via -device is supported (since 2.7.0) -# -# Since: 1.2.0 -## -{ 'struct': 'MachineInfo', - 'data': { 'name': 'str', '*alias': 'str', - '*is-default': 'bool', 'cpu-max': 'int', - 'hotpluggable-cpus': 'bool'} } - -## -# @query-machines: -# -# Return a list of supported machines -# -# Returns: a list of MachineInfo -# -# Since: 1.2.0 -## -{ 'command': 'query-machines', 'returns': ['MachineInfo'] } - -## -# @CpuDefinitionInfo: -# -# Virtual CPU definition. -# -# @name: the name of the CPU definition -# -# @migration-safe: whether a CPU definition can be safely used for -# migration in combination with a QEMU compatibility mach= ine -# when migrating between different QMU versions and betwe= en -# hosts with different sets of (hardware or software) -# capabilities. If not provided, information is not avail= able -# and callers should not assume the CPU definition to be -# migration-safe. (since 2.8) -# -# @static: whether a CPU definition is static and will not change dependin= g on -# QEMU version, machine type, machine options and accelerator opt= ions. -# A static model is always migration-safe. (since 2.8) -# -# @unavailable-features: List of properties that prevent -# the CPU model from running in the current -# host. (since 2.8) -# @typename: Type name that can be used as argument to @device-list-proper= ties, -# to introspect properties configurable using -cpu or -global. -# (since 2.9) -# -# @unavailable-features is a list of QOM property names that -# represent CPU model attributes that prevent the CPU from running. -# If the QOM property is read-only, that means there's no known -# way to make the CPU model run in the current host. Implementations -# that choose not to provide specific information return the -# property name "type". -# If the property is read-write, it means that it MAY be possible -# to run the CPU model in the current host if that property is -# changed. Management software can use it as hints to suggest or -# choose an alternative for the user, or just to generate meaningful -# error messages explaining why the CPU model can't be used. -# If @unavailable-features is an empty list, the CPU model is -# runnable using the current host and machine-type. -# If @unavailable-features is not present, runnability -# information for the CPU is not available. -# -# Since: 1.2.0 -## -{ 'struct': 'CpuDefinitionInfo', - 'data': { 'name': 'str', '*migration-safe': 'bool', 'static': 'bool', - '*unavailable-features': [ 'str' ], 'typename': 'str' } } - -## -# @MemoryInfo: -# -# Actual memory information in bytes. -# -# @base-memory: size of "base" memory specified with command line -# option -m. -# -# @plugged-memory: size of memory that can be hot-unplugged. This field -# is omitted if target doesn't support memory hotplug -# (i.e. CONFIG_MEM_HOTPLUG not defined on build time). -# -# Since: 2.11.0 -## -{ 'struct': 'MemoryInfo', - 'data' : { 'base-memory': 'size', '*plugged-memory': 'size' } } - -## -# @query-memory-size-summary: -# -# Return the amount of initially allocated and present hotpluggable (if -# enabled) memory in bytes. -# -# Example: -# -# -> { "execute": "query-memory-size-summary" } -# <- { "return": { "base-memory": 4294967296, "plugged-memory": 0 } } -# -# Since: 2.11.0 -## -{ 'command': 'query-memory-size-summary', 'returns': 'MemoryInfo' } - -## -# @query-cpu-definitions: -# -# Return a list of supported virtual CPU definitions -# -# Returns: a list of CpuDefInfo -# -# Since: 1.2.0 -## -{ 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'] } - -## -# @CpuModelInfo: -# -# Virtual CPU model. -# -# A CPU model consists of the name of a CPU definition, to which -# delta changes are applied (e.g. features added/removed). Most magic valu= es -# that an architecture might require should be hidden behind the name. -# However, if required, architectures can expose relevant properties. -# -# @name: the name of the CPU definition the model is based on -# @props: a dictionary of QOM properties to be applied -# -# Since: 2.8.0 -## -{ 'struct': 'CpuModelInfo', - 'data': { 'name': 'str', - '*props': 'any' } } - -## -# @CpuModelExpansionType: -# -# An enumeration of CPU model expansion types. -# -# @static: Expand to a static CPU model, a combination of a static base -# model name and property delta changes. As the static base model= will -# never change, the expanded CPU model will be the same, independ= ant of -# independent of QEMU version, machine type, machine options, and -# accelerator options. Therefore, the resulting model can be used= by -# tooling without having to specify a compatibility machine - e.g= . when -# displaying the "host" model. static CPU models are migration-sa= fe. -# -# @full: Expand all properties. The produced model is not guaranteed to be -# migration-safe, but allows tooling to get an insight and work with -# model details. -# -# Note: When a non-migration-safe CPU model is expanded in static mode, so= me -# features enabled by the CPU model may be omitted, because they can't be -# implemented by a static CPU model definition (e.g. cache info passthroug= h and -# PMU passthrough in x86). If you need an accurate representation of the -# features enabled by a non-migration-safe CPU model, use @full. If you ne= ed a -# static representation that will keep ABI compatibility even when changin= g QEMU -# version or machine-type, use @static (but keep in mind that some feature= s may -# be omitted). -# -# Since: 2.8.0 -## -{ 'enum': 'CpuModelExpansionType', - 'data': [ 'static', 'full' ] } - - -## -# @CpuModelExpansionInfo: -# -# The result of a cpu model expansion. -# -# @model: the expanded CpuModelInfo. -# -# Since: 2.8.0 -## -{ 'struct': 'CpuModelExpansionInfo', - 'data': { 'model': 'CpuModelInfo' } } - - -## -# @query-cpu-model-expansion: -# -# Expands a given CPU model (or a combination of CPU model + additional op= tions) -# to different granularities, allowing tooling to get an understanding wha= t a -# specific CPU model looks like in QEMU under a certain configuration. -# -# This interface can be used to query the "host" CPU model. -# -# The data returned by this command may be affected by: -# -# * QEMU version: CPU models may look different depending on the QEMU vers= ion. -# (Except for CPU models reported as "static" in query-cpu-definitions.) -# * machine-type: CPU model may look different depending on the machine-t= ype. -# (Except for CPU models reported as "static" in query-cpu-definitions.) -# * machine options (including accelerator): in some architectures, CPU mo= dels -# may look different depending on machine and accelerator options. (Exce= pt for -# CPU models reported as "static" in query-cpu-definitions.) -# * "-cpu" arguments and global properties: arguments to the -cpu option a= nd -# global properties may affect expansion of CPU models. Using -# query-cpu-model-expansion while using these is not advised. -# -# Some architectures may not support all expansion types. s390x supports -# "full" and "static". -# -# Returns: a CpuModelExpansionInfo. Returns an error if expanding CPU mode= ls is -# not supported, if the model cannot be expanded, if the model co= ntains -# an unknown CPU definition name, unknown properties or properties -# with a wrong type. Also returns an error if an expansion type is -# not supported. -# -# Since: 2.8.0 -## -{ 'command': 'query-cpu-model-expansion', - 'data': { 'type': 'CpuModelExpansionType', - 'model': 'CpuModelInfo' }, - 'returns': 'CpuModelExpansionInfo' } - -## -# @CpuModelCompareResult: -# -# An enumeration of CPU model comparation results. The result is usually -# calculated using e.g. CPU features or CPU generations. -# -# @incompatible: If model A is incompatible to model B, model A is not -# guaranteed to run where model B runs and the other way ar= ound. -# -# @identical: If model A is identical to model B, model A is guaranteed to= run -# where model B runs and the other way around. -# -# @superset: If model A is a superset of model B, model B is guaranteed to= run -# where model A runs. There are no guarantees about the other w= ay. -# -# @subset: If model A is a subset of model B, model A is guaranteed to run -# where model B runs. There are no guarantees about the other way. -# -# Since: 2.8.0 -## -{ 'enum': 'CpuModelCompareResult', - 'data': [ 'incompatible', 'identical', 'superset', 'subset' ] } - -## -# @CpuModelCompareInfo: -# -# The result of a CPU model comparison. -# -# @result: The result of the compare operation. -# @responsible-properties: List of properties that led to the comparison r= esult -# not being identical. -# -# @responsible-properties is a list of QOM property names that led to -# both CPUs not being detected as identical. For identical models, this -# list is empty. -# If a QOM property is read-only, that means there's no known way to make = the -# CPU models identical. If the special property name "type" is included, t= he -# models are by definition not identical and cannot be made identical. -# -# Since: 2.8.0 -## -{ 'struct': 'CpuModelCompareInfo', - 'data': {'result': 'CpuModelCompareResult', - 'responsible-properties': ['str'] - } -} - -## -# @query-cpu-model-comparison: -# -# Compares two CPU models, returning how they compare in a specific -# configuration. The results indicates how both models compare regarding -# runnability. This result can be used by tooling to make decisions if a -# certain CPU model will run in a certain configuration or if a compatible -# CPU model has to be created by baselining. -# -# Usually, a CPU model is compared against the maximum possible CPU model -# of a certain configuration (e.g. the "host" model for KVM). If that CPU -# model is identical or a subset, it will run in that configuration. -# -# The result returned by this command may be affected by: -# -# * QEMU version: CPU models may look different depending on the QEMU vers= ion. -# (Except for CPU models reported as "static" in query-cpu-definitions.) -# * machine-type: CPU model may look different depending on the machine-ty= pe. -# (Except for CPU models reported as "static" in query-cpu-definitions.) -# * machine options (including accelerator): in some architectures, CPU mo= dels -# may look different depending on machine and accelerator options. (Exce= pt for -# CPU models reported as "static" in query-cpu-definitions.) -# * "-cpu" arguments and global properties: arguments to the -cpu option a= nd -# global properties may affect expansion of CPU models. Using -# query-cpu-model-expansion while using these is not advised. -# -# Some architectures may not support comparing CPU models. s390x supports -# comparing CPU models. -# -# Returns: a CpuModelBaselineInfo. Returns an error if comparing CPU model= s is -# not supported, if a model cannot be used, if a model contains -# an unknown cpu definition name, unknown properties or properties -# with wrong types. -# -# Since: 2.8.0 -## -{ 'command': 'query-cpu-model-comparison', - 'data': { 'modela': 'CpuModelInfo', 'modelb': 'CpuModelInfo' }, - 'returns': 'CpuModelCompareInfo' } - -## -# @CpuModelBaselineInfo: -# -# The result of a CPU model baseline. -# -# @model: the baselined CpuModelInfo. -# -# Since: 2.8.0 -## -{ 'struct': 'CpuModelBaselineInfo', - 'data': { 'model': 'CpuModelInfo' } } - -## -# @query-cpu-model-baseline: -# -# Baseline two CPU models, creating a compatible third model. The created -# model will always be a static, migration-safe CPU model (see "static" -# CPU model expansion for details). -# -# This interface can be used by tooling to create a compatible CPU model o= ut -# two CPU models. The created CPU model will be identical to or a subset of -# both CPU models when comparing them. Therefore, the created CPU model is -# guaranteed to run where the given CPU models run. -# -# The result returned by this command may be affected by: -# -# * QEMU version: CPU models may look different depending on the QEMU vers= ion. -# (Except for CPU models reported as "static" in query-cpu-definitions.) -# * machine-type: CPU model may look different depending on the machine-ty= pe. -# (Except for CPU models reported as "static" in query-cpu-definitions.) -# * machine options (including accelerator): in some architectures, CPU mo= dels -# may look different depending on machine and accelerator options. (Exce= pt for -# CPU models reported as "static" in query-cpu-definitions.) -# * "-cpu" arguments and global properties: arguments to the -cpu option a= nd -# global properties may affect expansion of CPU models. Using -# query-cpu-model-expansion while using these is not advised. -# -# Some architectures may not support baselining CPU models. s390x supports -# baselining CPU models. -# -# Returns: a CpuModelBaselineInfo. Returns an error if baselining CPU mode= ls is -# not supported, if a model cannot be used, if a model contains -# an unknown cpu definition name, unknown properties or properties -# with wrong types. -# -# Since: 2.8.0 -## -{ 'command': 'query-cpu-model-baseline', - 'data': { 'modela': 'CpuModelInfo', - 'modelb': 'CpuModelInfo' }, - 'returns': 'CpuModelBaselineInfo' } - -## -# @AddfdInfo: -# -# Information about a file descriptor that was added to an fd set. -# -# @fdset-id: The ID of the fd set that @fd was added to. -# -# @fd: The file descriptor that was received via SCM rights and -# added to the fd set. -# -# Since: 1.2.0 -## -{ 'struct': 'AddfdInfo', 'data': {'fdset-id': 'int', 'fd': 'int'} } - -## -# @add-fd: -# -# Add a file descriptor, that was passed via SCM rights, to an fd set. -# -# @fdset-id: The ID of the fd set to add the file descriptor to. -# -# @opaque: A free-form string that can be used to describe the fd. -# -# Returns: @AddfdInfo on success -# -# If file descriptor was not received, FdNotSupplied -# -# If @fdset-id is a negative value, InvalidParameterValue -# -# Notes: The list of fd sets is shared by all monitor connections. -# -# If @fdset-id is not specified, a new fd set will be created. -# -# Since: 1.2.0 -# -# Example: -# -# -> { "execute": "add-fd", "arguments": { "fdset-id": 1 } } -# <- { "return": { "fdset-id": 1, "fd": 3 } } -# -## -{ 'command': 'add-fd', 'data': {'*fdset-id': 'int', '*opaque': 'str'}, - 'returns': 'AddfdInfo' } - -## -# @remove-fd: -# -# Remove a file descriptor from an fd set. -# -# @fdset-id: The ID of the fd set that the file descriptor belongs to. -# -# @fd: The file descriptor that is to be removed. -# -# Returns: Nothing on success -# If @fdset-id or @fd is not found, FdNotFound -# -# Since: 1.2.0 -# -# Notes: The list of fd sets is shared by all monitor connections. -# -# If @fd is not specified, all file descriptors in @fdset-id -# will be removed. -# -# Example: -# -# -> { "execute": "remove-fd", "arguments": { "fdset-id": 1, "fd": 3 } } -# <- { "return": {} } -# -## -{ 'command': 'remove-fd', 'data': {'fdset-id': 'int', '*fd': 'int'} } - -## -# @FdsetFdInfo: -# -# Information about a file descriptor that belongs to an fd set. -# -# @fd: The file descriptor value. -# -# @opaque: A free-form string that can be used to describe the fd. -# -# Since: 1.2.0 -## -{ 'struct': 'FdsetFdInfo', - 'data': {'fd': 'int', '*opaque': 'str'} } - -## -# @FdsetInfo: -# -# Information about an fd set. -# -# @fdset-id: The ID of the fd set. -# -# @fds: A list of file descriptors that belong to this fd set. -# -# Since: 1.2.0 -## -{ 'struct': 'FdsetInfo', - 'data': {'fdset-id': 'int', 'fds': ['FdsetFdInfo']} } - -## -# @query-fdsets: -# -# Return information describing all fd sets. -# -# Returns: A list of @FdsetInfo -# -# Since: 1.2.0 -# -# Note: The list of fd sets is shared by all monitor connections. -# -# Example: -# -# -> { "execute": "query-fdsets" } -# <- { "return": [ -# { -# "fds": [ -# { -# "fd": 30, -# "opaque": "rdonly:/path/to/file" -# }, -# { -# "fd": 24, -# "opaque": "rdwr:/path/to/file" -# } -# ], -# "fdset-id": 1 -# }, -# { -# "fds": [ -# { -# "fd": 28 -# }, -# { -# "fd": 29 -# } -# ], -# "fdset-id": 0 -# } -# ] -# } -# -## -{ 'command': 'query-fdsets', 'returns': ['FdsetInfo'] } - -## -# @TargetInfo: -# -# Information describing the QEMU target. -# -# @arch: the target architecture (eg "x86_64", "i386", etc) -# -# Since: 1.2.0 -## -{ 'struct': 'TargetInfo', - 'data': { 'arch': 'str' } } - -## -# @query-target: -# -# Return information about the target for this QEMU -# -# Returns: TargetInfo -# -# Since: 1.2.0 -## -{ 'command': 'query-target', 'returns': 'TargetInfo' } - -## -# @AcpiTableOptions: -# -# Specify an ACPI table on the command line to load. -# -# At most one of @file and @data can be specified. The list of files speci= fied -# by any one of them is loaded and concatenated in order. If both are omit= ted, -# @data is implied. -# -# Other fields / optargs can be used to override fields of the generic ACPI -# table header; refer to the ACPI specification 5.0, section 5.2.6 System -# Description Table Header. If a header field is not overridden, then the -# corresponding value from the concatenated blob is used (in case of @file= ), or -# it is filled in with a hard-coded value (in case of @data). -# -# String fields are copied into the matching ACPI member from lowest addre= ss -# upwards, and silently truncated / NUL-padded to length. -# -# @sig: table signature / identifier (4 bytes) -# -# @rev: table revision number (dependent on signature, 1 byte) -# -# @oem_id: OEM identifier (6 bytes) -# -# @oem_table_id: OEM table identifier (8 bytes) -# -# @oem_rev: OEM-supplied revision number (4 bytes) -# -# @asl_compiler_id: identifier of the utility that created the table -# (4 bytes) -# -# @asl_compiler_rev: revision number of the utility that created the -# table (4 bytes) -# -# @file: colon (:) separated list of pathnames to load and -# concatenate as table data. The resultant binary blob is expected = to -# have an ACPI table header. At least one file is required. This fi= eld -# excludes @data. -# -# @data: colon (:) separated list of pathnames to load and -# concatenate as table data. The resultant binary blob must not hav= e an -# ACPI table header. At least one file is required. This field excl= udes -# @file. -# -# Since: 1.5 -## -{ 'struct': 'AcpiTableOptions', - 'data': { - '*sig': 'str', - '*rev': 'uint8', - '*oem_id': 'str', - '*oem_table_id': 'str', - '*oem_rev': 'uint32', - '*asl_compiler_id': 'str', - '*asl_compiler_rev': 'uint32', - '*file': 'str', - '*data': 'str' }} - -## -# @CommandLineParameterType: -# -# Possible types for an option parameter. -# -# @string: accepts a character string -# -# @boolean: accepts "on" or "off" -# -# @number: accepts a number -# -# @size: accepts a number followed by an optional suffix (K)ilo, -# (M)ega, (G)iga, (T)era -# -# Since: 1.5 -## -{ 'enum': 'CommandLineParameterType', - 'data': ['string', 'boolean', 'number', 'size'] } - -## -# @CommandLineParameterInfo: -# -# Details about a single parameter of a command line option. -# -# @name: parameter name -# -# @type: parameter @CommandLineParameterType -# -# @help: human readable text string, not suitable for parsing. -# -# @default: default value string (since 2.1) -# -# Since: 1.5 -## -{ 'struct': 'CommandLineParameterInfo', - 'data': { 'name': 'str', - 'type': 'CommandLineParameterType', - '*help': 'str', - '*default': 'str' } } - -## -# @CommandLineOptionInfo: -# -# Details about a command line option, including its list of parameter det= ails -# -# @option: option name -# -# @parameters: an array of @CommandLineParameterInfo -# -# Since: 1.5 -## -{ 'struct': 'CommandLineOptionInfo', - 'data': { 'option': 'str', 'parameters': ['CommandLineParameterInfo'] } } - -## -# @query-command-line-options: -# -# Query command line option schema. -# -# @option: option name -# -# Returns: list of @CommandLineOptionInfo for all options (or for the given -# @option). Returns an error if the given @option doesn't exist. -# -# Since: 1.5 -# -# Example: -# -# -> { "execute": "query-command-line-options", -# "arguments": { "option": "option-rom" } } -# <- { "return": [ -# { -# "parameters": [ -# { -# "name": "romfile", -# "type": "string" -# }, -# { -# "name": "bootindex", -# "type": "number" -# } -# ], -# "option": "option-rom" -# } -# ] -# } -# -## -{'command': 'query-command-line-options', 'data': { '*option': 'str' }, - 'returns': ['CommandLineOptionInfo'] } - -## -# @X86CPURegister32: -# -# A X86 32-bit register -# -# Since: 1.5 -## -{ 'enum': 'X86CPURegister32', - 'data': [ 'EAX', 'EBX', 'ECX', 'EDX', 'ESP', 'EBP', 'ESI', 'EDI' ] } - -## -# @X86CPUFeatureWordInfo: -# -# Information about a X86 CPU feature word -# -# @cpuid-input-eax: Input EAX value for CPUID instruction for that feature= word -# -# @cpuid-input-ecx: Input ECX value for CPUID instruction for that -# feature word -# -# @cpuid-register: Output register containing the feature bits -# -# @features: value of output register, containing the feature bits -# -# Since: 1.5 -## -{ 'struct': 'X86CPUFeatureWordInfo', - 'data': { 'cpuid-input-eax': 'int', - '*cpuid-input-ecx': 'int', - 'cpuid-register': 'X86CPURegister32', - 'features': 'int' } } - -## -# @DummyForceArrays: -# -# Not used by QMP; hack to let us use X86CPUFeatureWordInfoList internally -# -# Since: 2.5 -## -{ 'struct': 'DummyForceArrays', - 'data': { 'unused': ['X86CPUFeatureWordInfo'] } } - - -## -# @NumaOptionsType: -# -# @node: NUMA nodes configuration -# -# @dist: NUMA distance configuration (since 2.10) -# -# @cpu: property based CPU(s) to node mapping (Since: 2.10) -# -# Since: 2.1 -## -{ 'enum': 'NumaOptionsType', - 'data': [ 'node', 'dist', 'cpu' ] } - -## -# @NumaOptions: -# -# A discriminated record of NUMA options. (for OptsVisitor) -# -# Since: 2.1 -## -{ 'union': 'NumaOptions', - 'base': { 'type': 'NumaOptionsType' }, - 'discriminator': 'type', - 'data': { - 'node': 'NumaNodeOptions', - 'dist': 'NumaDistOptions', - 'cpu': 'NumaCpuOptions' }} - -## -# @NumaNodeOptions: -# -# Create a guest NUMA node. (for OptsVisitor) -# -# @nodeid: NUMA node ID (increase by 1 from 0 if omitted) -# -# @cpus: VCPUs belonging to this node (assign VCPUS round-robin -# if omitted) -# -# @mem: memory size of this node; mutually exclusive with @memdev. -# Equally divide total memory among nodes if both @mem and @memdev a= re -# omitted. -# -# @memdev: memory backend object. If specified for one node, -# it must be specified for all nodes. -# -# Since: 2.1 -## -{ 'struct': 'NumaNodeOptions', - 'data': { - '*nodeid': 'uint16', - '*cpus': ['uint16'], - '*mem': 'size', - '*memdev': 'str' }} - -## -# @NumaDistOptions: -# -# Set the distance between 2 NUMA nodes. -# -# @src: source NUMA node. -# -# @dst: destination NUMA node. -# -# @val: NUMA distance from source node to destination node. -# When a node is unreachable from another node, set the distance -# between them to 255. -# -# Since: 2.10 -## -{ 'struct': 'NumaDistOptions', - 'data': { - 'src': 'uint16', - 'dst': 'uint16', - 'val': 'uint8' }} - -## -# @NumaCpuOptions: -# -# Option "-numa cpu" overrides default cpu to node mapping. -# It accepts the same set of cpu properties as returned by -# query-hotpluggable-cpus[].props, where node-id could be used to -# override default node mapping. -# -# Since: 2.10 -## -{ 'struct': 'NumaCpuOptions', - 'base': 'CpuInstanceProperties', - 'data' : {} } - -## -# @HostMemPolicy: -# -# Host memory policy types -# -# @default: restore default policy, remove any nondefault policy -# -# @preferred: set the preferred host nodes for allocation -# -# @bind: a strict policy that restricts memory allocation to the -# host nodes specified -# -# @interleave: memory allocations are interleaved across the set -# of host nodes specified -# -# Since: 2.1 -## -{ 'enum': 'HostMemPolicy', - 'data': [ 'default', 'preferred', 'bind', 'interleave' ] } - -## -# @Memdev: -# -# Information about memory backend -# -# @id: backend's ID if backend has 'id' property (since 2.9) -# -# @size: memory backend size -# -# @merge: enables or disables memory merge support -# -# @dump: includes memory backend's memory in a core dump or not -# -# @prealloc: enables or disables memory preallocation -# -# @host-nodes: host nodes for its memory policy -# -# @policy: memory policy of memory backend -# -# Since: 2.1 -## -{ 'struct': 'Memdev', - 'data': { - '*id': 'str', - 'size': 'size', - 'merge': 'bool', - 'dump': 'bool', - 'prealloc': 'bool', - 'host-nodes': ['uint16'], - 'policy': 'HostMemPolicy' }} - -## -# @query-memdev: -# -# Returns information for all memory backends. -# -# Returns: a list of @Memdev. -# -# Since: 2.1 -# -# Example: -# -# -> { "execute": "query-memdev" } -# <- { "return": [ -# { -# "id": "mem1", -# "size": 536870912, -# "merge": false, -# "dump": true, -# "prealloc": false, -# "host-nodes": [0, 1], -# "policy": "bind" -# }, -# { -# "size": 536870912, -# "merge": false, -# "dump": true, -# "prealloc": true, -# "host-nodes": [2, 3], -# "policy": "preferred" -# } -# ] -# } -# -## -{ 'command': 'query-memdev', 'returns': ['Memdev'] } - -## -# @PCDIMMDeviceInfo: -# -# PCDIMMDevice state information -# -# @id: device's ID -# -# @addr: physical address, where device is mapped -# -# @size: size of memory that the device provides -# -# @slot: slot number at which device is plugged in -# -# @node: NUMA node number where device is plugged in -# -# @memdev: memory backend linked with device -# -# @hotplugged: true if device was hotplugged -# -# @hotpluggable: true if device if could be added/removed while machine is= running -# -# Since: 2.1 -## -{ 'struct': 'PCDIMMDeviceInfo', - 'data': { '*id': 'str', - 'addr': 'int', - 'size': 'int', - 'slot': 'int', - 'node': 'int', - 'memdev': 'str', - 'hotplugged': 'bool', - 'hotpluggable': 'bool' - } -} - -## -# @MemoryDeviceInfo: -# -# Union containing information about a memory device -# -# Since: 2.1 -## -{ 'union': 'MemoryDeviceInfo', 'data': {'dimm': 'PCDIMMDeviceInfo'} } - -## -# @query-memory-devices: -# -# Lists available memory devices and their state -# -# Since: 2.1 -# -# Example: -# -# -> { "execute": "query-memory-devices" } -# <- { "return": [ { "data": -# { "addr": 5368709120, -# "hotpluggable": true, -# "hotplugged": true, -# "id": "d1", -# "memdev": "/objects/memX", -# "node": 0, -# "size": 1073741824, -# "slot": 0}, -# "type": "dimm" -# } ] } -# -## -{ 'command': 'query-memory-devices', 'returns': ['MemoryDeviceInfo'] } - -## -# @MEM_UNPLUG_ERROR: -# -# Emitted when memory hot unplug error occurs. -# -# @device: device name -# -# @msg: Informative message -# -# Since: 2.4 -# -# Example: -# -# <- { "event": "MEM_UNPLUG_ERROR" -# "data": { "device": "dimm1", -# "msg": "acpi: device unplug for unsupported device" -# }, -# "timestamp": { "seconds": 1265044230, "microseconds": 450486 } } -# -## -{ 'event': 'MEM_UNPLUG_ERROR', - 'data': { 'device': 'str', 'msg': 'str' } } - -## -# @ACPISlotType: -# -# @DIMM: memory slot -# @CPU: logical CPU slot (since 2.7) -## -{ 'enum': 'ACPISlotType', 'data': [ 'DIMM', 'CPU' ] } - -## -# @ACPIOSTInfo: -# -# OSPM Status Indication for a device -# For description of possible values of @source and @status fields -# see "_OST (OSPM Status Indication)" chapter of ACPI5.0 spec. -# -# @device: device ID associated with slot -# -# @slot: slot ID, unique per slot of a given @slot-type -# -# @slot-type: type of the slot -# -# @source: an integer containing the source event -# -# @status: an integer containing the status code -# -# Since: 2.1 -## -{ 'struct': 'ACPIOSTInfo', - 'data' : { '*device': 'str', - 'slot': 'str', - 'slot-type': 'ACPISlotType', - 'source': 'int', - 'status': 'int' } } - -## -# @query-acpi-ospm-status: -# -# Return a list of ACPIOSTInfo for devices that support status -# reporting via ACPI _OST method. -# -# Since: 2.1 -# -# Example: -# -# -> { "execute": "query-acpi-ospm-status" } -# <- { "return": [ { "device": "d1", "slot": "0", "slot-type": "DIMM", "so= urce": 1, "status": 0}, -# { "slot": "1", "slot-type": "DIMM", "source": 0, "statu= s": 0}, -# { "slot": "2", "slot-type": "DIMM", "source": 0, "statu= s": 0}, -# { "slot": "3", "slot-type": "DIMM", "source": 0, "statu= s": 0} -# ]} -# -## -{ 'command': 'query-acpi-ospm-status', 'returns': ['ACPIOSTInfo'] } - -## -# @ACPI_DEVICE_OST: -# -# Emitted when guest executes ACPI _OST method. -# -# @info: ACPIOSTInfo type as described in qapi-schema.json -# -# Since: 2.1 -# -# Example: -# -# <- { "event": "ACPI_DEVICE_OST", -# "data": { "device": "d1", "slot": "0", -# "slot-type": "DIMM", "source": 1, "status": 0 } } -# -## -{ 'event': 'ACPI_DEVICE_OST', - 'data': { 'info': 'ACPIOSTInfo' } } - -## -# @rtc-reset-reinjection: -# -# This command will reset the RTC interrupt reinjection backlog. -# Can be used if another mechanism to synchronize guest time -# is in effect, for example QEMU guest agent's guest-set-time -# command. -# -# Since: 2.1 -# -# Example: -# -# -> { "execute": "rtc-reset-reinjection" } -# <- { "return": {} } -# -## -{ 'command': 'rtc-reset-reinjection' } - -## -# @RTC_CHANGE: -# -# Emitted when the guest changes the RTC time. -# -# @offset: offset between base RTC clock (as specified by -rtc base), and -# new RTC clock value -# -# Note: This event is rate-limited. -# -# Since: 0.13.0 -# -# Example: -# -# <- { "event": "RTC_CHANGE", -# "data": { "offset": 78 }, -# "timestamp": { "seconds": 1267020223, "microseconds": 435656 } } -# -## -{ 'event': 'RTC_CHANGE', - 'data': { 'offset': 'int' } } - -## -# @ReplayMode: -# -# Mode of the replay subsystem. -# -# @none: normal execution mode. Replay or record are not enabled. -# -# @record: record mode. All non-deterministic data is written into the -# replay log. -# -# @play: replay mode. Non-deterministic data required for system execution -# is read from the log. -# -# Since: 2.5 -## -{ 'enum': 'ReplayMode', - 'data': [ 'none', 'record', 'play' ] } - -## -# @xen-load-devices-state: -# -# Load the state of all devices from file. The RAM and the block devices -# of the VM are not loaded by this command. -# -# @filename: the file to load the state of the devices from as binary -# data. See xen-save-devices-state.txt for a description of the binary -# format. -# -# Since: 2.7 -# -# Example: -# -# -> { "execute": "xen-load-devices-state", -# "arguments": { "filename": "/tmp/resume" } } -# <- { "return": {} } -# -## -{ 'command': 'xen-load-devices-state', 'data': {'filename': 'str'} } - -## -# @GICCapability: -# -# The struct describes capability for a specific GIC (Generic -# Interrupt Controller) version. These bits are not only decided by -# QEMU/KVM software version, but also decided by the hardware that -# the program is running upon. -# -# @version: version of GIC to be described. Currently, only 2 and 3 -# are supported. -# -# @emulated: whether current QEMU/hardware supports emulated GIC -# device in user space. -# -# @kernel: whether current QEMU/hardware supports hardware -# accelerated GIC device in kernel. -# -# Since: 2.6 -## -{ 'struct': 'GICCapability', - 'data': { 'version': 'int', - 'emulated': 'bool', - 'kernel': 'bool' } } - -## -# @query-gic-capabilities: -# -# This command is ARM-only. It will return a list of GICCapability -# objects that describe its capability bits. -# -# Returns: a list of GICCapability objects. -# -# Since: 2.6 -# -# Example: -# -# -> { "execute": "query-gic-capabilities" } -# <- { "return": [{ "version": 2, "emulated": true, "kernel": false }, -# { "version": 3, "emulated": false, "kernel": true } ] } -# -## -{ 'command': 'query-gic-capabilities', 'returns': ['GICCapability'] } - -## -# @CpuInstanceProperties: -# -# List of properties to be used for hotplugging a CPU instance, -# it should be passed by management with device_add command when -# a CPU is being hotplugged. -# -# @node-id: NUMA node ID the CPU belongs to -# @socket-id: socket number within node/board the CPU belongs to -# @core-id: core number within socket the CPU belongs to -# @thread-id: thread number within core the CPU belongs to -# -# Note: currently there are 4 properties that could be present -# but management should be prepared to pass through other -# properties with device_add command to allow for future -# interface extension. This also requires the filed names to be kept in -# sync with the properties passed to -device/device_add. -# -# Since: 2.7 -## -{ 'struct': 'CpuInstanceProperties', - 'data': { '*node-id': 'int', - '*socket-id': 'int', - '*core-id': 'int', - '*thread-id': 'int' - } -} - -## -# @HotpluggableCPU: -# -# @type: CPU object type for usage with device_add command -# @props: list of properties to be used for hotplugging CPU -# @vcpus-count: number of logical VCPU threads @HotpluggableCPU provides -# @qom-path: link to existing CPU object if CPU is present or -# omitted if CPU is not present. -# -# Since: 2.7 -## -{ 'struct': 'HotpluggableCPU', - 'data': { 'type': 'str', - 'vcpus-count': 'int', - 'props': 'CpuInstanceProperties', - '*qom-path': 'str' - } -} - -## -# @query-hotpluggable-cpus: -# -# Returns: a list of HotpluggableCPU objects. -# -# Since: 2.7 -# -# Example: -# -# For pseries machine type started with -smp 2,cores=3D2,maxcpus=3D4 -cpu = POWER8: -# -# -> { "execute": "query-hotpluggable-cpus" } -# <- {"return": [ -# { "props": { "core": 8 }, "type": "POWER8-spapr-cpu-core", -# "vcpus-count": 1 }, -# { "props": { "core": 0 }, "type": "POWER8-spapr-cpu-core", -# "vcpus-count": 1, "qom-path": "/machine/unattached/device[0]"} -# ]}' -# -# For pc machine type started with -smp 1,maxcpus=3D2: -# -# -> { "execute": "query-hotpluggable-cpus" } -# <- {"return": [ -# { -# "type": "qemu64-x86_64-cpu", "vcpus-count": 1, -# "props": {"core-id": 0, "socket-id": 1, "thread-id": 0} -# }, -# { -# "qom-path": "/machine/unattached/device[0]", -# "type": "qemu64-x86_64-cpu", "vcpus-count": 1, -# "props": {"core-id": 0, "socket-id": 0, "thread-id": 0} -# } -# ]} -# -# For s390x-virtio-ccw machine type started with -smp 1,maxcpus=3D2 -cpu q= emu -# (Since: 2.11): -# -# -> { "execute": "query-hotpluggable-cpus" } -# <- {"return": [ -# { -# "type": "qemu-s390x-cpu", "vcpus-count": 1, -# "props": { "core-id": 1 } -# }, -# { -# "qom-path": "/machine/unattached/device[0]", -# "type": "qemu-s390x-cpu", "vcpus-count": 1, -# "props": { "core-id": 0 } -# } -# ]} -# -## -{ 'command': 'query-hotpluggable-cpus', 'returns': ['HotpluggableCPU'] } - -## -# @GuidInfo: -# -# GUID information. -# -# @guid: the globally unique identifier -# -# Since: 2.9 -## -{ 'struct': 'GuidInfo', 'data': {'guid': 'str'} } - -## -# @query-vm-generation-id: -# -# Show Virtual Machine Generation ID -# -# Since: 2.9 -## -{ 'command': 'query-vm-generation-id', 'returns': 'GuidInfo' } - -## -# @watchdog-set-action: -# -# Set watchdog action -# -# Since: 2.11 -## -{ 'command': 'watchdog-set-action', 'data' : {'action': 'WatchdogAction'} } +{ 'include': 'qapi/misc.json' } diff --git a/qapi/misc.json b/qapi/misc.json new file mode 100644 index 0000000000..225631bf7d --- /dev/null +++ b/qapi/misc.json @@ -0,0 +1,3090 @@ +# -*- Mode: Python -*- +# + +## +# =3D Miscellanea +## + +## +# @qmp_capabilities: +# +# Enable QMP capabilities. +# +# Arguments: None. +# +# Example: +# +# -> { "execute": "qmp_capabilities" } +# <- { "return": {} } +# +# Notes: This command is valid exactly when first connecting: it must be +# issued before any other command will be accepted, and will fail once the +# monitor is accepting other commands. (see qemu docs/interop/qmp-spec.txt) +# +# Since: 0.13 +# +## +{ 'command': 'qmp_capabilities' } + +## +# @VersionTriple: +# +# A three-part version number. +# +# @major: The major version number. +# +# @minor: The minor version number. +# +# @micro: The micro version number. +# +# Since: 2.4 +## +{ 'struct': 'VersionTriple', + 'data': {'major': 'int', 'minor': 'int', 'micro': 'int'} } + + +## +# @VersionInfo: +# +# A description of QEMU's version. +# +# @qemu: The version of QEMU. By current convention, a micro +# version of 50 signifies a development branch. A micro ver= sion +# greater than or equal to 90 signifies a release candidate = for +# the next minor version. A micro version of less than 50 +# signifies a stable release. +# +# @package: QEMU will always set this field to an empty string. Downs= tream +# versions of QEMU should set this to a non-empty string. T= he +# exact format depends on the downstream however it highly +# recommended that a unique name is used. +# +# Since: 0.14.0 +## +{ 'struct': 'VersionInfo', + 'data': {'qemu': 'VersionTriple', 'package': 'str'} } + +## +# @query-version: +# +# Returns the current version of QEMU. +# +# Returns: A @VersionInfo object describing the current version of QEMU. +# +# Since: 0.14.0 +# +# Example: +# +# -> { "execute": "query-version" } +# <- { +# "return":{ +# "qemu":{ +# "major":0, +# "minor":11, +# "micro":5 +# }, +# "package":"" +# } +# } +# +## +{ 'command': 'query-version', 'returns': 'VersionInfo' } + +## +# @CommandInfo: +# +# Information about a QMP command +# +# @name: The command name +# +# Since: 0.14.0 +## +{ 'struct': 'CommandInfo', 'data': {'name': 'str'} } + +## +# @query-commands: +# +# Return a list of supported QMP commands by this server +# +# Returns: A list of @CommandInfo for all supported commands +# +# Since: 0.14.0 +# +# Example: +# +# -> { "execute": "query-commands" } +# <- { +# "return":[ +# { +# "name":"query-balloon" +# }, +# { +# "name":"system_powerdown" +# } +# ] +# } +# +# Note: This example has been shortened as the real response is too long. +# +## +{ 'command': 'query-commands', 'returns': ['CommandInfo'] } + +## +# @LostTickPolicy: +# +# Policy for handling lost ticks in timer devices. +# +# @discard: throw away the missed tick(s) and continue with future injecti= on +# normally. Guest time may be delayed, unless the OS has explic= it +# handling of lost ticks +# +# @delay: continue to deliver ticks at the normal rate. Guest time will be +# delayed due to the late tick +# +# @merge: merge the missed tick(s) into one tick and inject. Guest time +# may be delayed, depending on how the OS reacts to the merging +# of ticks +# +# @slew: deliver ticks at a higher rate to catch up with the missed tick. = The +# guest time should not be delayed once catchup is complete. +# +# Since: 2.0 +## +{ 'enum': 'LostTickPolicy', + 'data': ['discard', 'delay', 'merge', 'slew' ] } + +## +# @add_client: +# +# Allow client connections for VNC, Spice and socket based +# character devices to be passed in to QEMU via SCM_RIGHTS. +# +# @protocol: protocol name. Valid names are "vnc", "spice" or the +# name of a character device (eg. from -chardev id=3DXXXX) +# +# @fdname: file descriptor name previously passed via 'getfd' command +# +# @skipauth: whether to skip authentication. Only applies +# to "vnc" and "spice" protocols +# +# @tls: whether to perform TLS. Only applies to the "spice" +# protocol +# +# Returns: nothing on success. +# +# Since: 0.14.0 +# +# Example: +# +# -> { "execute": "add_client", "arguments": { "protocol": "vnc", +# "fdname": "myclient" } } +# <- { "return": {} } +# +## +{ 'command': 'add_client', + 'data': { 'protocol': 'str', 'fdname': 'str', '*skipauth': 'bool', + '*tls': 'bool' } } + +## +# @NameInfo: +# +# Guest name information. +# +# @name: The name of the guest +# +# Since: 0.14.0 +## +{ 'struct': 'NameInfo', 'data': {'*name': 'str'} } + +## +# @query-name: +# +# Return the name information of a guest. +# +# Returns: @NameInfo of the guest +# +# Since: 0.14.0 +# +# Example: +# +# -> { "execute": "query-name" } +# <- { "return": { "name": "qemu-name" } } +# +## +{ 'command': 'query-name', 'returns': 'NameInfo' } + +## +# @KvmInfo: +# +# Information about support for KVM acceleration +# +# @enabled: true if KVM acceleration is active +# +# @present: true if KVM acceleration is built into this executable +# +# Since: 0.14.0 +## +{ 'struct': 'KvmInfo', 'data': {'enabled': 'bool', 'present': 'bool'} } + +## +# @query-kvm: +# +# Returns information about KVM acceleration +# +# Returns: @KvmInfo +# +# Since: 0.14.0 +# +# Example: +# +# -> { "execute": "query-kvm" } +# <- { "return": { "enabled": true, "present": true } } +# +## +{ 'command': 'query-kvm', 'returns': 'KvmInfo' } + +## +# @UuidInfo: +# +# Guest UUID information (Universally Unique Identifier). +# +# @UUID: the UUID of the guest +# +# Since: 0.14.0 +# +# Notes: If no UUID was specified for the guest, a null UUID is returned. +## +{ 'struct': 'UuidInfo', 'data': {'UUID': 'str'} } + +## +# @query-uuid: +# +# Query the guest UUID information. +# +# Returns: The @UuidInfo for the guest +# +# Since: 0.14.0 +# +# Example: +# +# -> { "execute": "query-uuid" } +# <- { "return": { "UUID": "550e8400-e29b-41d4-a716-446655440000" } } +# +## +{ 'command': 'query-uuid', 'returns': 'UuidInfo' } + +## +# @EventInfo: +# +# Information about a QMP event +# +# @name: The event name +# +# Since: 1.2.0 +## +{ 'struct': 'EventInfo', 'data': {'name': 'str'} } + +## +# @query-events: +# +# Return a list of supported QMP events by this server +# +# Returns: A list of @EventInfo for all supported events +# +# Since: 1.2.0 +# +# Example: +# +# -> { "execute": "query-events" } +# <- { +# "return": [ +# { +# "name":"SHUTDOWN" +# }, +# { +# "name":"RESET" +# } +# ] +# } +# +# Note: This example has been shortened as the real response is too long. +# +## +{ 'command': 'query-events', 'returns': ['EventInfo'] } + +## +# @CpuInfoArch: +# +# An enumeration of cpu types that enable additional information during +# @query-cpus. +# +# Since: 2.6 +## +{ 'enum': 'CpuInfoArch', + 'data': ['x86', 'sparc', 'ppc', 'mips', 'tricore', 'other' ] } + +## +# @CpuInfo: +# +# Information about a virtual CPU +# +# @CPU: the index of the virtual CPU +# +# @current: this only exists for backwards compatibility and should be ign= ored +# +# @halted: true if the virtual CPU is in the halt state. Halt usually ref= ers +# to a processor specific low power mode. +# +# @qom_path: path to the CPU object in the QOM tree (since 2.4) +# +# @thread_id: ID of the underlying host thread +# +# @props: properties describing to which node/socket/core/thread +# virtual CPU belongs to, provided if supported by board (since 2.= 10) +# +# @arch: architecture of the cpu, which determines which additional fields +# will be listed (since 2.6) +# +# Since: 0.14.0 +# +# Notes: @halted is a transient state that changes frequently. By the tim= e the +# data is sent to the client, the guest may no longer be halted. +## +{ 'union': 'CpuInfo', + 'base': {'CPU': 'int', 'current': 'bool', 'halted': 'bool', + 'qom_path': 'str', 'thread_id': 'int', + '*props': 'CpuInstanceProperties', 'arch': 'CpuInfoArch' }, + 'discriminator': 'arch', + 'data': { 'x86': 'CpuInfoX86', + 'sparc': 'CpuInfoSPARC', + 'ppc': 'CpuInfoPPC', + 'mips': 'CpuInfoMIPS', + 'tricore': 'CpuInfoTricore', + 'other': 'CpuInfoOther' } } + +## +# @CpuInfoX86: +# +# Additional information about a virtual i386 or x86_64 CPU +# +# @pc: the 64-bit instruction pointer +# +# Since: 2.6 +## +{ 'struct': 'CpuInfoX86', 'data': { 'pc': 'int' } } + +## +# @CpuInfoSPARC: +# +# Additional information about a virtual SPARC CPU +# +# @pc: the PC component of the instruction pointer +# +# @npc: the NPC component of the instruction pointer +# +# Since: 2.6 +## +{ 'struct': 'CpuInfoSPARC', 'data': { 'pc': 'int', 'npc': 'int' } } + +## +# @CpuInfoPPC: +# +# Additional information about a virtual PPC CPU +# +# @nip: the instruction pointer +# +# Since: 2.6 +## +{ 'struct': 'CpuInfoPPC', 'data': { 'nip': 'int' } } + +## +# @CpuInfoMIPS: +# +# Additional information about a virtual MIPS CPU +# +# @PC: the instruction pointer +# +# Since: 2.6 +## +{ 'struct': 'CpuInfoMIPS', 'data': { 'PC': 'int' } } + +## +# @CpuInfoTricore: +# +# Additional information about a virtual Tricore CPU +# +# @PC: the instruction pointer +# +# Since: 2.6 +## +{ 'struct': 'CpuInfoTricore', 'data': { 'PC': 'int' } } + +## +# @CpuInfoOther: +# +# No additional information is available about the virtual CPU +# +# Since: 2.6 +# +## +{ 'struct': 'CpuInfoOther', 'data': { } } + +## +# @query-cpus: +# +# Returns a list of information about each virtual CPU. +# +# Returns: a list of @CpuInfo for each virtual CPU +# +# Since: 0.14.0 +# +# Example: +# +# -> { "execute": "query-cpus" } +# <- { "return": [ +# { +# "CPU":0, +# "current":true, +# "halted":false, +# "qom_path":"/machine/unattached/device[0]", +# "arch":"x86", +# "pc":3227107138, +# "thread_id":3134 +# }, +# { +# "CPU":1, +# "current":false, +# "halted":true, +# "qom_path":"/machine/unattached/device[2]", +# "arch":"x86", +# "pc":7108165, +# "thread_id":3135 +# } +# ] +# } +# +## +{ 'command': 'query-cpus', 'returns': ['CpuInfo'] } + +## +# @IOThreadInfo: +# +# Information about an iothread +# +# @id: the identifier of the iothread +# +# @thread-id: ID of the underlying host thread +# +# @poll-max-ns: maximum polling time in ns, 0 means polling is disabled +# (since 2.9) +# +# @poll-grow: how many ns will be added to polling time, 0 means that it's= not +# configured (since 2.9) +# +# @poll-shrink: how many ns will be removed from polling time, 0 means that +# it's not configured (since 2.9) +# +# Since: 2.0 +## +{ 'struct': 'IOThreadInfo', + 'data': {'id': 'str', + 'thread-id': 'int', + 'poll-max-ns': 'int', + 'poll-grow': 'int', + 'poll-shrink': 'int' } } + +## +# @query-iothreads: +# +# Returns a list of information about each iothread. +# +# Note: this list excludes the QEMU main loop thread, which is not declared +# using the -object iothread command-line option. It is always the main t= hread +# of the process. +# +# Returns: a list of @IOThreadInfo for each iothread +# +# Since: 2.0 +# +# Example: +# +# -> { "execute": "query-iothreads" } +# <- { "return": [ +# { +# "id":"iothread0", +# "thread-id":3134 +# }, +# { +# "id":"iothread1", +# "thread-id":3135 +# } +# ] +# } +# +## +{ 'command': 'query-iothreads', 'returns': ['IOThreadInfo'] } + +## +# @BalloonInfo: +# +# Information about the guest balloon device. +# +# @actual: the number of bytes the balloon currently contains +# +# Since: 0.14.0 +# +## +{ 'struct': 'BalloonInfo', 'data': {'actual': 'int' } } + +## +# @query-balloon: +# +# Return information about the balloon device. +# +# Returns: @BalloonInfo on success +# +# If the balloon driver is enabled but not functional because the= KVM +# kernel module cannot support it, KvmMissingCap +# +# If no balloon device is present, DeviceNotActive +# +# Since: 0.14.0 +# +# Example: +# +# -> { "execute": "query-balloon" } +# <- { "return": { +# "actual": 1073741824, +# } +# } +# +## +{ 'command': 'query-balloon', 'returns': 'BalloonInfo' } + +## +# @BALLOON_CHANGE: +# +# Emitted when the guest changes the actual BALLOON level. This value is +# equivalent to the @actual field return by the 'query-balloon' command +# +# @actual: actual level of the guest memory balloon in bytes +# +# Note: this event is rate-limited. +# +# Since: 1.2 +# +# Example: +# +# <- { "event": "BALLOON_CHANGE", +# "data": { "actual": 944766976 }, +# "timestamp": { "seconds": 1267020223, "microseconds": 435656 } } +# +## +{ 'event': 'BALLOON_CHANGE', + 'data': { 'actual': 'int' } } + +## +# @PciMemoryRange: +# +# A PCI device memory region +# +# @base: the starting address (guest physical) +# +# @limit: the ending address (guest physical) +# +# Since: 0.14.0 +## +{ 'struct': 'PciMemoryRange', 'data': {'base': 'int', 'limit': 'int'} } + +## +# @PciMemoryRegion: +# +# Information about a PCI device I/O region. +# +# @bar: the index of the Base Address Register for this region +# +# @type: 'io' if the region is a PIO region +# 'memory' if the region is a MMIO region +# +# @size: memory size +# +# @prefetch: if @type is 'memory', true if the memory is prefetchable +# +# @mem_type_64: if @type is 'memory', true if the BAR is 64-bit +# +# Since: 0.14.0 +## +{ 'struct': 'PciMemoryRegion', + 'data': {'bar': 'int', 'type': 'str', 'address': 'int', 'size': 'int', + '*prefetch': 'bool', '*mem_type_64': 'bool' } } + +## +# @PciBusInfo: +# +# Information about a bus of a PCI Bridge device +# +# @number: primary bus interface number. This should be the number of the +# bus the device resides on. +# +# @secondary: secondary bus interface number. This is the number of the +# main bus for the bridge +# +# @subordinate: This is the highest number bus that resides below the +# bridge. +# +# @io_range: The PIO range for all devices on this bridge +# +# @memory_range: The MMIO range for all devices on this bridge +# +# @prefetchable_range: The range of prefetchable MMIO for all devices on +# this bridge +# +# Since: 2.4 +## +{ 'struct': 'PciBusInfo', + 'data': {'number': 'int', 'secondary': 'int', 'subordinate': 'int', + 'io_range': 'PciMemoryRange', + 'memory_range': 'PciMemoryRange', + 'prefetchable_range': 'PciMemoryRange' } } + +## +# @PciBridgeInfo: +# +# Information about a PCI Bridge device +# +# @bus: information about the bus the device resides on +# +# @devices: a list of @PciDeviceInfo for each device on this bridge +# +# Since: 0.14.0 +## +{ 'struct': 'PciBridgeInfo', + 'data': {'bus': 'PciBusInfo', '*devices': ['PciDeviceInfo']} } + +## +# @PciDeviceClass: +# +# Information about the Class of a PCI device +# +# @desc: a string description of the device's class +# +# @class: the class code of the device +# +# Since: 2.4 +## +{ 'struct': 'PciDeviceClass', + 'data': {'*desc': 'str', 'class': 'int'} } + +## +# @PciDeviceId: +# +# Information about the Id of a PCI device +# +# @device: the PCI device id +# +# @vendor: the PCI vendor id +# +# Since: 2.4 +## +{ 'struct': 'PciDeviceId', + 'data': {'device': 'int', 'vendor': 'int'} } + +## +# @PciDeviceInfo: +# +# Information about a PCI device +# +# @bus: the bus number of the device +# +# @slot: the slot the device is located in +# +# @function: the function of the slot used by the device +# +# @class_info: the class of the device +# +# @id: the PCI device id +# +# @irq: if an IRQ is assigned to the device, the IRQ number +# +# @qdev_id: the device name of the PCI device +# +# @pci_bridge: if the device is a PCI bridge, the bridge information +# +# @regions: a list of the PCI I/O regions associated with the device +# +# Notes: the contents of @class_info.desc are not stable and should only be +# treated as informational. +# +# Since: 0.14.0 +## +{ 'struct': 'PciDeviceInfo', + 'data': {'bus': 'int', 'slot': 'int', 'function': 'int', + 'class_info': 'PciDeviceClass', 'id': 'PciDeviceId', + '*irq': 'int', 'qdev_id': 'str', '*pci_bridge': 'PciBridgeInfo', + 'regions': ['PciMemoryRegion']} } + +## +# @PciInfo: +# +# Information about a PCI bus +# +# @bus: the bus index +# +# @devices: a list of devices on this bus +# +# Since: 0.14.0 +## +{ 'struct': 'PciInfo', 'data': {'bus': 'int', 'devices': ['PciDeviceInfo']= } } + +## +# @query-pci: +# +# Return information about the PCI bus topology of the guest. +# +# Returns: a list of @PciInfo for each PCI bus. Each bus is +# represented by a json-object, which has a key with a json-array of +# all PCI devices attached to it. Each device is represented by a +# json-object. +# +# Since: 0.14.0 +# +# Example: +# +# -> { "execute": "query-pci" } +# <- { "return": [ +# { +# "bus": 0, +# "devices": [ +# { +# "bus": 0, +# "qdev_id": "", +# "slot": 0, +# "class_info": { +# "class": 1536, +# "desc": "Host bridge" +# }, +# "id": { +# "device": 32902, +# "vendor": 4663 +# }, +# "function": 0, +# "regions": [ +# ] +# }, +# { +# "bus": 0, +# "qdev_id": "", +# "slot": 1, +# "class_info": { +# "class": 1537, +# "desc": "ISA bridge" +# }, +# "id": { +# "device": 32902, +# "vendor": 28672 +# }, +# "function": 0, +# "regions": [ +# ] +# }, +# { +# "bus": 0, +# "qdev_id": "", +# "slot": 1, +# "class_info": { +# "class": 257, +# "desc": "IDE controller" +# }, +# "id": { +# "device": 32902, +# "vendor": 28688 +# }, +# "function": 1, +# "regions": [ +# { +# "bar": 4, +# "size": 16, +# "address": 49152, +# "type": "io" +# } +# ] +# }, +# { +# "bus": 0, +# "qdev_id": "", +# "slot": 2, +# "class_info": { +# "class": 768, +# "desc": "VGA controller" +# }, +# "id": { +# "device": 4115, +# "vendor": 184 +# }, +# "function": 0, +# "regions": [ +# { +# "prefetch": true, +# "mem_type_64": false, +# "bar": 0, +# "size": 33554432, +# "address": 4026531840, +# "type": "memory" +# }, +# { +# "prefetch": false, +# "mem_type_64": false, +# "bar": 1, +# "size": 4096, +# "address": 4060086272, +# "type": "memory" +# }, +# { +# "prefetch": false, +# "mem_type_64": false, +# "bar": 6, +# "size": 65536, +# "address": -1, +# "type": "memory" +# } +# ] +# }, +# { +# "bus": 0, +# "qdev_id": "", +# "irq": 11, +# "slot": 4, +# "class_info": { +# "class": 1280, +# "desc": "RAM controller" +# }, +# "id": { +# "device": 6900, +# "vendor": 4098 +# }, +# "function": 0, +# "regions": [ +# { +# "bar": 0, +# "size": 32, +# "address": 49280, +# "type": "io" +# } +# ] +# } +# ] +# } +# ] +# } +# +# Note: This example has been shortened as the real response is too long. +# +## +{ 'command': 'query-pci', 'returns': ['PciInfo'] } + +## +# @quit: +# +# This command will cause the QEMU process to exit gracefully. While every +# attempt is made to send the QMP response before terminating, this is not +# guaranteed. When using this interface, a premature EOF would not be +# unexpected. +# +# Since: 0.14.0 +# +# Example: +# +# -> { "execute": "quit" } +# <- { "return": {} } +## +{ 'command': 'quit' } + +## +# @stop: +# +# Stop all guest VCPU execution. +# +# Since: 0.14.0 +# +# Notes: This function will succeed even if the guest is already in the s= topped +# state. In "inmigrate" state, it will ensure that the guest +# remains paused once migration finishes, as if the -S option was +# passed on the command line. +# +# Example: +# +# -> { "execute": "stop" } +# <- { "return": {} } +# +## +{ 'command': 'stop' } + +## +# @system_reset: +# +# Performs a hard reset of a guest. +# +# Since: 0.14.0 +# +# Example: +# +# -> { "execute": "system_reset" } +# <- { "return": {} } +# +## +{ 'command': 'system_reset' } + +## +# @system_powerdown: +# +# Requests that a guest perform a powerdown operation. +# +# Since: 0.14.0 +# +# Notes: A guest may or may not respond to this command. This command +# returning does not indicate that a guest has accepted the request= or +# that it has shut down. Many guests will respond to this command = by +# prompting the user in some way. +# Example: +# +# -> { "execute": "system_powerdown" } +# <- { "return": {} } +# +## +{ 'command': 'system_powerdown' } + +## +# @cpu-add: +# +# Adds CPU with specified ID +# +# @id: ID of CPU to be created, valid values [0..max_cpus) +# +# Returns: Nothing on success +# +# Since: 1.5 +# +# Example: +# +# -> { "execute": "cpu-add", "arguments": { "id": 2 } } +# <- { "return": {} } +# +## +{ 'command': 'cpu-add', 'data': {'id': 'int'} } + +## +# @memsave: +# +# Save a portion of guest memory to a file. +# +# @val: the virtual address of the guest to start from +# +# @size: the size of memory region to save +# +# @filename: the file to save the memory to as binary data +# +# @cpu-index: the index of the virtual CPU to use for translating the +# virtual address (defaults to CPU 0) +# +# Returns: Nothing on success +# +# Since: 0.14.0 +# +# Notes: Errors were not reliably returned until 1.1 +# +# Example: +# +# -> { "execute": "memsave", +# "arguments": { "val": 10, +# "size": 100, +# "filename": "/tmp/virtual-mem-dump" } } +# <- { "return": {} } +# +## +{ 'command': 'memsave', + 'data': {'val': 'int', 'size': 'int', 'filename': 'str', '*cpu-index': '= int'} } + +## +# @pmemsave: +# +# Save a portion of guest physical memory to a file. +# +# @val: the physical address of the guest to start from +# +# @size: the size of memory region to save +# +# @filename: the file to save the memory to as binary data +# +# Returns: Nothing on success +# +# Since: 0.14.0 +# +# Notes: Errors were not reliably returned until 1.1 +# +# Example: +# +# -> { "execute": "pmemsave", +# "arguments": { "val": 10, +# "size": 100, +# "filename": "/tmp/physical-mem-dump" } } +# <- { "return": {} } +# +## +{ 'command': 'pmemsave', + 'data': {'val': 'int', 'size': 'int', 'filename': 'str'} } + +## +# @cont: +# +# Resume guest VCPU execution. +# +# Since: 0.14.0 +# +# Returns: If successful, nothing +# +# Notes: This command will succeed if the guest is currently running. It +# will also succeed if the guest is in the "inmigrate" state; in +# this case, the effect of the command is to make sure the guest +# starts once migration finishes, removing the effect of the -S +# command line option if it was passed. +# +# Example: +# +# -> { "execute": "cont" } +# <- { "return": {} } +# +## +{ 'command': 'cont' } + +## +# @system_wakeup: +# +# Wakeup guest from suspend. Does nothing in case the guest isn't suspend= ed. +# +# Since: 1.1 +# +# Returns: nothing. +# +# Example: +# +# -> { "execute": "system_wakeup" } +# <- { "return": {} } +# +## +{ 'command': 'system_wakeup' } + +## +# @inject-nmi: +# +# Injects a Non-Maskable Interrupt into the default CPU (x86/s390) or all = CPUs (ppc64). +# The command fails when the guest doesn't support injecting. +# +# Returns: If successful, nothing +# +# Since: 0.14.0 +# +# Note: prior to 2.1, this command was only supported for x86 and s390 VMs +# +# Example: +# +# -> { "execute": "inject-nmi" } +# <- { "return": {} } +# +## +{ 'command': 'inject-nmi' } + +## +# @balloon: +# +# Request the balloon driver to change its balloon size. +# +# @value: the target size of the balloon in bytes +# +# Returns: Nothing on success +# If the balloon driver is enabled but not functional because the= KVM +# kernel module cannot support it, KvmMissingCap +# If no balloon device is present, DeviceNotActive +# +# Notes: This command just issues a request to the guest. When it returns, +# the balloon size may not have changed. A guest can change the ba= lloon +# size independent of this command. +# +# Since: 0.14.0 +# +# Example: +# +# -> { "execute": "balloon", "arguments": { "value": 536870912 } } +# <- { "return": {} } +# +## +{ 'command': 'balloon', 'data': {'value': 'int'} } + +## +# @human-monitor-command: +# +# Execute a command on the human monitor and return the output. +# +# @command-line: the command to execute in the human monitor +# +# @cpu-index: The CPU to use for commands that require an implicit CPU +# +# Returns: the output of the command as a string +# +# Since: 0.14.0 +# +# Notes: This command only exists as a stop-gap. Its use is highly +# discouraged. The semantics of this command are not +# guaranteed: this means that command names, arguments and +# responses can change or be removed at ANY time. Applications +# that rely on long term stability guarantees should NOT +# use this command. +# +# Known limitations: +# +# * This command is stateless, this means that commands that depend +# on state information (such as getfd) might not work +# +# * Commands that prompt the user for data don't currently work +# +# Example: +# +# -> { "execute": "human-monitor-command", +# "arguments": { "command-line": "info kvm" } } +# <- { "return": "kvm support: enabled\r\n" } +# +## +{ 'command': 'human-monitor-command', + 'data': {'command-line': 'str', '*cpu-index': 'int'}, + 'returns': 'str' } + +## +# @ObjectPropertyInfo: +# +# @name: the name of the property +# +# @type: the type of the property. This will typically come in one of four +# forms: +# +# 1) A primitive type such as 'u8', 'u16', 'bool', 'str', or 'doubl= e'. +# These types are mapped to the appropriate JSON type. +# +# 2) A child type in the form 'child' where subtype is a q= dev +# device type name. Child properties create the composition tre= e. +# +# 3) A link type in the form 'link' where subtype is a qdev +# device type name. Link properties form the device model graph. +# +# Since: 1.2 +## +{ 'struct': 'ObjectPropertyInfo', + 'data': { 'name': 'str', 'type': 'str' } } + +## +# @qom-list: +# +# This command will list any properties of a object given a path in the ob= ject +# model. +# +# @path: the path within the object model. See @qom-get for a description= of +# this parameter. +# +# Returns: a list of @ObjectPropertyInfo that describe the properties of t= he +# object. +# +# Since: 1.2 +## +{ 'command': 'qom-list', + 'data': { 'path': 'str' }, + 'returns': [ 'ObjectPropertyInfo' ] } + +## +# @qom-get: +# +# This command will get a property from a object model path and return the +# value. +# +# @path: The path within the object model. There are two forms of support= ed +# paths--absolute and partial paths. +# +# Absolute paths are derived from the root object and can follow ch= ild<> +# or link<> properties. Since they can follow link<> properties, t= hey +# can be arbitrarily long. Absolute paths look like absolute filen= ames +# and are prefixed with a leading slash. +# +# Partial paths look like relative filenames. They do not begin +# with a prefix. The matching rules for partial paths are subtle b= ut +# designed to make specifying objects easy. At each level of the +# composition tree, the partial path is matched as an absolute path. +# The first match is not returned. At least two matches are search= ed +# for. A successful result is only returned if only one match is +# found. If more than one match is found, a flag is return to +# indicate that the match was ambiguous. +# +# @property: The property name to read +# +# Returns: The property value. The type depends on the property +# type. child<> and link<> properties are returned as #str +# pathnames. All integer property types (u8, u16, etc) are +# returned as #int. +# +# Since: 1.2 +## +{ 'command': 'qom-get', + 'data': { 'path': 'str', 'property': 'str' }, + 'returns': 'any' } + +## +# @qom-set: +# +# This command will set a property from a object model path. +# +# @path: see @qom-get for a description of this parameter +# +# @property: the property name to set +# +# @value: a value who's type is appropriate for the property type. See @q= om-get +# for a description of type mapping. +# +# Since: 1.2 +## +{ 'command': 'qom-set', + 'data': { 'path': 'str', 'property': 'str', 'value': 'any' } } + +## +# @change: +# +# This command is multiple commands multiplexed together. +# +# @device: This is normally the name of a block device but it may also be = 'vnc'. +# when it's 'vnc', then sub command depends on @target +# +# @target: If @device is a block device, then this is the new filename. +# If @device is 'vnc', then if the value 'password' selects the v= nc +# change password command. Otherwise, this specifies a new serv= er URI +# address to listen to for VNC connections. +# +# @arg: If @device is a block device, then this is an optional format t= o open +# the device with. +# If @device is 'vnc' and @target is 'password', this is the new = VNC +# password to set. See change-vnc-password for additional notes. +# +# Returns: Nothing on success. +# If @device is not a valid block device, DeviceNotFound +# +# Notes: This interface is deprecated, and it is strongly recommended tha= t you +# avoid using it. For changing block devices, use +# blockdev-change-medium; for changing VNC parameters, use +# change-vnc-password. +# +# Since: 0.14.0 +# +# Example: +# +# 1. Change a removable medium +# +# -> { "execute": "change", +# "arguments": { "device": "ide1-cd0", +# "target": "/srv/images/Fedora-12-x86_64-DVD.iso" } } +# <- { "return": {} } +# +# 2. Change VNC password +# +# -> { "execute": "change", +# "arguments": { "device": "vnc", "target": "password", +# "arg": "foobar1" } } +# <- { "return": {} } +# +## +{ 'command': 'change', + 'data': {'device': 'str', 'target': 'str', '*arg': 'str'} } + +## +# @ObjectTypeInfo: +# +# This structure describes a search result from @qom-list-types +# +# @name: the type name found in the search +# +# @abstract: the type is abstract and can't be directly instantiated. +# Omitted if false. (since 2.10) +# +# @parent: Name of parent type, if any (since 2.10) +# +# Since: 1.1 +## +{ 'struct': 'ObjectTypeInfo', + 'data': { 'name': 'str', '*abstract': 'bool', '*parent': 'str' } } + +## +# @qom-list-types: +# +# This command will return a list of types given search parameters +# +# @implements: if specified, only return types that implement this type na= me +# +# @abstract: if true, include abstract types in the results +# +# Returns: a list of @ObjectTypeInfo or an empty list if no results are fo= und +# +# Since: 1.1 +## +{ 'command': 'qom-list-types', + 'data': { '*implements': 'str', '*abstract': 'bool' }, + 'returns': [ 'ObjectTypeInfo' ] } + +## +# @DevicePropertyInfo: +# +# Information about device properties. +# +# @name: the name of the property +# @type: the typename of the property +# @description: if specified, the description of the property. +# (since 2.2) +# +# Since: 1.2 +## +{ 'struct': 'DevicePropertyInfo', + 'data': { 'name': 'str', 'type': 'str', '*description': 'str' } } + +## +# @device-list-properties: +# +# List properties associated with a device. +# +# @typename: the type name of a device +# +# Returns: a list of DevicePropertyInfo describing a devices properties +# +# Since: 1.2 +## +{ 'command': 'device-list-properties', + 'data': { 'typename': 'str'}, + 'returns': [ 'DevicePropertyInfo' ] } + +## +# @xen-set-global-dirty-log: +# +# Enable or disable the global dirty log mode. +# +# @enable: true to enable, false to disable. +# +# Returns: nothing +# +# Since: 1.3 +# +# Example: +# +# -> { "execute": "xen-set-global-dirty-log", +# "arguments": { "enable": true } } +# <- { "return": {} } +# +## +{ 'command': 'xen-set-global-dirty-log', 'data': { 'enable': 'bool' } } + +## +# @device_add: +# +# @driver: the name of the new device's driver +# +# @bus: the device's parent bus (device tree path) +# +# @id: the device's ID, must be unique +# +# Additional arguments depend on the type. +# +# Add a device. +# +# Notes: +# 1. For detailed information about this command, please refer to the +# 'docs/qdev-device-use.txt' file. +# +# 2. It's possible to list device properties by running QEMU with the +# "-device DEVICE,help" command-line argument, where DEVICE is the +# device's name +# +# Example: +# +# -> { "execute": "device_add", +# "arguments": { "driver": "e1000", "id": "net1", +# "bus": "pci.0", +# "mac": "52:54:00:12:34:56" } } +# <- { "return": {} } +# +# TODO: This command effectively bypasses QAPI completely due to its +# "additional arguments" business. It shouldn't have been added to +# the schema in this form. It should be qapified properly, or +# replaced by a properly qapified command. +# +# Since: 0.13 +## +{ 'command': 'device_add', + 'data': {'driver': 'str', '*bus': 'str', '*id': 'str'}, + 'gen': false } # so we can get the additional arguments + +## +# @device_del: +# +# Remove a device from a guest +# +# @id: the device's ID or QOM path +# +# Returns: Nothing on success +# If @id is not a valid device, DeviceNotFound +# +# Notes: When this command completes, the device may not be removed from t= he +# guest. Hot removal is an operation that requires guest cooperati= on. +# This command merely requests that the guest begin the hot removal +# process. Completion of the device removal process is signaled wi= th a +# DEVICE_DELETED event. Guest reset will automatically complete rem= oval +# for all devices. +# +# Since: 0.14.0 +# +# Example: +# +# -> { "execute": "device_del", +# "arguments": { "id": "net1" } } +# <- { "return": {} } +# +# -> { "execute": "device_del", +# "arguments": { "id": "/machine/peripheral-anon/device[0]" } } +# <- { "return": {} } +# +## +{ 'command': 'device_del', 'data': {'id': 'str'} } + +## +# @DEVICE_DELETED: +# +# Emitted whenever the device removal completion is acknowledged by the gu= est. +# At this point, it's safe to reuse the specified device ID. Device remova= l can +# be initiated by the guest or by HMP/QMP commands. +# +# @device: device name +# +# @path: device path +# +# Since: 1.5 +# +# Example: +# +# <- { "event": "DEVICE_DELETED", +# "data": { "device": "virtio-net-pci-0", +# "path": "/machine/peripheral/virtio-net-pci-0" }, +# "timestamp": { "seconds": 1265044230, "microseconds": 450486 } } +# +## +{ 'event': 'DEVICE_DELETED', + 'data': { '*device': 'str', 'path': 'str' } } + +## +# @DumpGuestMemoryFormat: +# +# An enumeration of guest-memory-dump's format. +# +# @elf: elf format +# +# @kdump-zlib: kdump-compressed format with zlib-compressed +# +# @kdump-lzo: kdump-compressed format with lzo-compressed +# +# @kdump-snappy: kdump-compressed format with snappy-compressed +# +# Since: 2.0 +## +{ 'enum': 'DumpGuestMemoryFormat', + 'data': [ 'elf', 'kdump-zlib', 'kdump-lzo', 'kdump-snappy' ] } + +## +# @dump-guest-memory: +# +# Dump guest's memory to vmcore. It is a synchronous operation that can ta= ke +# very long depending on the amount of guest memory. +# +# @paging: if true, do paging to get guest's memory mapping. This allows +# using gdb to process the core file. +# +# IMPORTANT: this option can make QEMU allocate several gigabytes +# of RAM. This can happen for a large guest, or a +# malicious guest pretending to be large. +# +# Also, paging=3Dtrue has the following limitations: +# +# 1. The guest may be in a catastrophic state or can have corr= upted +# memory, which cannot be trusted +# 2. The guest can be in real-mode even if paging is enabled. = For +# example, the guest uses ACPI to sleep, and ACPI sleep sta= te +# goes in real-mode +# 3. Currently only supported on i386 and x86_64. +# +# @protocol: the filename or file descriptor of the vmcore. The supported +# protocols are: +# +# 1. file: the protocol starts with "file:", and the following +# string is the file's path. +# 2. fd: the protocol starts with "fd:", and the following stri= ng +# is the fd's name. +# +# @detach: if true, QMP will return immediately rather than +# waiting for the dump to finish. The user can track progress +# using "query-dump". (since 2.6). +# +# @begin: if specified, the starting physical address. +# +# @length: if specified, the memory size, in bytes. If you don't +# want to dump all guest's memory, please specify the start @begin +# and @length +# +# @format: if specified, the format of guest memory dump. But non-elf +# format is conflict with paging and filter, ie. @paging, @begin = and +# @length is not allowed to be specified with non-elf @format at = the +# same time (since 2.0) +# +# Note: All boolean arguments default to false +# +# Returns: nothing on success +# +# Since: 1.2 +# +# Example: +# +# -> { "execute": "dump-guest-memory", +# "arguments": { "protocol": "fd:dump" } } +# <- { "return": {} } +# +## +{ 'command': 'dump-guest-memory', + 'data': { 'paging': 'bool', 'protocol': 'str', '*detach': 'bool', + '*begin': 'int', '*length': 'int', + '*format': 'DumpGuestMemoryFormat'} } + +## +# @DumpStatus: +# +# Describe the status of a long-running background guest memory dump. +# +# @none: no dump-guest-memory has started yet. +# +# @active: there is one dump running in background. +# +# @completed: the last dump has finished successfully. +# +# @failed: the last dump has failed. +# +# Since: 2.6 +## +{ 'enum': 'DumpStatus', + 'data': [ 'none', 'active', 'completed', 'failed' ] } + +## +# @DumpQueryResult: +# +# The result format for 'query-dump'. +# +# @status: enum of @DumpStatus, which shows current dump status +# +# @completed: bytes written in latest dump (uncompressed) +# +# @total: total bytes to be written in latest dump (uncompressed) +# +# Since: 2.6 +## +{ 'struct': 'DumpQueryResult', + 'data': { 'status': 'DumpStatus', + 'completed': 'int', + 'total': 'int' } } + +## +# @query-dump: +# +# Query latest dump status. +# +# Returns: A @DumpStatus object showing the dump status. +# +# Since: 2.6 +# +# Example: +# +# -> { "execute": "query-dump" } +# <- { "return": { "status": "active", "completed": 1024000, +# "total": 2048000 } } +# +## +{ 'command': 'query-dump', 'returns': 'DumpQueryResult' } + +## +# @DUMP_COMPLETED: +# +# Emitted when background dump has completed +# +# @result: DumpQueryResult type described in qapi-schema.json. +# +# @error: human-readable error string that provides +# hint on why dump failed. Only presents on failure. The +# user should not try to interpret the error string. +# +# Since: 2.6 +# +# Example: +# +# { "event": "DUMP_COMPLETED", +# "data": {"result": {"total": 1090650112, "status": "completed", +# "completed": 1090650112} } } +# +## +{ 'event': 'DUMP_COMPLETED' , + 'data': { 'result': 'DumpQueryResult', '*error': 'str' } } + +## +# @DumpGuestMemoryCapability: +# +# A list of the available formats for dump-guest-memory +# +# Since: 2.0 +## +{ 'struct': 'DumpGuestMemoryCapability', + 'data': { + 'formats': ['DumpGuestMemoryFormat'] } } + +## +# @query-dump-guest-memory-capability: +# +# Returns the available formats for dump-guest-memory +# +# Returns: A @DumpGuestMemoryCapability object listing available formats = for +# dump-guest-memory +# +# Since: 2.0 +# +# Example: +# +# -> { "execute": "query-dump-guest-memory-capability" } +# <- { "return": { "formats": +# ["elf", "kdump-zlib", "kdump-lzo", "kdump-snappy"] } +# +## +{ 'command': 'query-dump-guest-memory-capability', + 'returns': 'DumpGuestMemoryCapability' } + +## +# @dump-skeys: +# +# Dump guest's storage keys +# +# @filename: the path to the file to dump to +# +# This command is only supported on s390 architecture. +# +# Since: 2.5 +# +# Example: +# +# -> { "execute": "dump-skeys", +# "arguments": { "filename": "/tmp/skeys" } } +# <- { "return": {} } +# +## +{ 'command': 'dump-skeys', + 'data': { 'filename': 'str' } } + +## +# @object-add: +# +# Create a QOM object. +# +# @qom-type: the class name for the object to be created +# +# @id: the name of the new object +# +# @props: a dictionary of properties to be passed to the backend +# +# Returns: Nothing on success +# Error if @qom-type is not a valid class name +# +# Since: 2.0 +# +# Example: +# +# -> { "execute": "object-add", +# "arguments": { "qom-type": "rng-random", "id": "rng1", +# "props": { "filename": "/dev/hwrng" } } } +# <- { "return": {} } +# +## +{ 'command': 'object-add', + 'data': {'qom-type': 'str', 'id': 'str', '*props': 'any'} } + +## +# @object-del: +# +# Remove a QOM object. +# +# @id: the name of the QOM object to remove +# +# Returns: Nothing on success +# Error if @id is not a valid id for a QOM object +# +# Since: 2.0 +# +# Example: +# +# -> { "execute": "object-del", "arguments": { "id": "rng1" } } +# <- { "return": {} } +# +## +{ 'command': 'object-del', 'data': {'id': 'str'} } + +## +# @getfd: +# +# Receive a file descriptor via SCM rights and assign it a name +# +# @fdname: file descriptor name +# +# Returns: Nothing on success +# +# Since: 0.14.0 +# +# Notes: If @fdname already exists, the file descriptor assigned to +# it will be closed and replaced by the received file +# descriptor. +# +# The 'closefd' command can be used to explicitly close the +# file descriptor when it is no longer needed. +# +# Example: +# +# -> { "execute": "getfd", "arguments": { "fdname": "fd1" } } +# <- { "return": {} } +# +## +{ 'command': 'getfd', 'data': {'fdname': 'str'} } + +## +# @closefd: +# +# Close a file descriptor previously passed via SCM rights +# +# @fdname: file descriptor name +# +# Returns: Nothing on success +# +# Since: 0.14.0 +# +# Example: +# +# -> { "execute": "closefd", "arguments": { "fdname": "fd1" } } +# <- { "return": {} } +# +## +{ 'command': 'closefd', 'data': {'fdname': 'str'} } + +## +# @MachineInfo: +# +# Information describing a machine. +# +# @name: the name of the machine +# +# @alias: an alias for the machine name +# +# @is-default: whether the machine is default +# +# @cpu-max: maximum number of CPUs supported by the machine type +# (since 1.5.0) +# +# @hotpluggable-cpus: cpu hotplug via -device is supported (since 2.7.0) +# +# Since: 1.2.0 +## +{ 'struct': 'MachineInfo', + 'data': { 'name': 'str', '*alias': 'str', + '*is-default': 'bool', 'cpu-max': 'int', + 'hotpluggable-cpus': 'bool'} } + +## +# @query-machines: +# +# Return a list of supported machines +# +# Returns: a list of MachineInfo +# +# Since: 1.2.0 +## +{ 'command': 'query-machines', 'returns': ['MachineInfo'] } + +## +# @CpuDefinitionInfo: +# +# Virtual CPU definition. +# +# @name: the name of the CPU definition +# +# @migration-safe: whether a CPU definition can be safely used for +# migration in combination with a QEMU compatibility mach= ine +# when migrating between different QMU versions and betwe= en +# hosts with different sets of (hardware or software) +# capabilities. If not provided, information is not avail= able +# and callers should not assume the CPU definition to be +# migration-safe. (since 2.8) +# +# @static: whether a CPU definition is static and will not change dependin= g on +# QEMU version, machine type, machine options and accelerator opt= ions. +# A static model is always migration-safe. (since 2.8) +# +# @unavailable-features: List of properties that prevent +# the CPU model from running in the current +# host. (since 2.8) +# @typename: Type name that can be used as argument to @device-list-proper= ties, +# to introspect properties configurable using -cpu or -global. +# (since 2.9) +# +# @unavailable-features is a list of QOM property names that +# represent CPU model attributes that prevent the CPU from running. +# If the QOM property is read-only, that means there's no known +# way to make the CPU model run in the current host. Implementations +# that choose not to provide specific information return the +# property name "type". +# If the property is read-write, it means that it MAY be possible +# to run the CPU model in the current host if that property is +# changed. Management software can use it as hints to suggest or +# choose an alternative for the user, or just to generate meaningful +# error messages explaining why the CPU model can't be used. +# If @unavailable-features is an empty list, the CPU model is +# runnable using the current host and machine-type. +# If @unavailable-features is not present, runnability +# information for the CPU is not available. +# +# Since: 1.2.0 +## +{ 'struct': 'CpuDefinitionInfo', + 'data': { 'name': 'str', '*migration-safe': 'bool', 'static': 'bool', + '*unavailable-features': [ 'str' ], 'typename': 'str' } } + +## +# @MemoryInfo: +# +# Actual memory information in bytes. +# +# @base-memory: size of "base" memory specified with command line +# option -m. +# +# @plugged-memory: size of memory that can be hot-unplugged. This field +# is omitted if target doesn't support memory hotplug +# (i.e. CONFIG_MEM_HOTPLUG not defined on build time). +# +# Since: 2.11.0 +## +{ 'struct': 'MemoryInfo', + 'data' : { 'base-memory': 'size', '*plugged-memory': 'size' } } + +## +# @query-memory-size-summary: +# +# Return the amount of initially allocated and present hotpluggable (if +# enabled) memory in bytes. +# +# Example: +# +# -> { "execute": "query-memory-size-summary" } +# <- { "return": { "base-memory": 4294967296, "plugged-memory": 0 } } +# +# Since: 2.11.0 +## +{ 'command': 'query-memory-size-summary', 'returns': 'MemoryInfo' } + +## +# @query-cpu-definitions: +# +# Return a list of supported virtual CPU definitions +# +# Returns: a list of CpuDefInfo +# +# Since: 1.2.0 +## +{ 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'] } + +## +# @CpuModelInfo: +# +# Virtual CPU model. +# +# A CPU model consists of the name of a CPU definition, to which +# delta changes are applied (e.g. features added/removed). Most magic valu= es +# that an architecture might require should be hidden behind the name. +# However, if required, architectures can expose relevant properties. +# +# @name: the name of the CPU definition the model is based on +# @props: a dictionary of QOM properties to be applied +# +# Since: 2.8.0 +## +{ 'struct': 'CpuModelInfo', + 'data': { 'name': 'str', + '*props': 'any' } } + +## +# @CpuModelExpansionType: +# +# An enumeration of CPU model expansion types. +# +# @static: Expand to a static CPU model, a combination of a static base +# model name and property delta changes. As the static base model= will +# never change, the expanded CPU model will be the same, independ= ant of +# independent of QEMU version, machine type, machine options, and +# accelerator options. Therefore, the resulting model can be used= by +# tooling without having to specify a compatibility machine - e.g= . when +# displaying the "host" model. static CPU models are migration-sa= fe. +# +# @full: Expand all properties. The produced model is not guaranteed to be +# migration-safe, but allows tooling to get an insight and work with +# model details. +# +# Note: When a non-migration-safe CPU model is expanded in static mode, so= me +# features enabled by the CPU model may be omitted, because they can't be +# implemented by a static CPU model definition (e.g. cache info passthroug= h and +# PMU passthrough in x86). If you need an accurate representation of the +# features enabled by a non-migration-safe CPU model, use @full. If you ne= ed a +# static representation that will keep ABI compatibility even when changin= g QEMU +# version or machine-type, use @static (but keep in mind that some feature= s may +# be omitted). +# +# Since: 2.8.0 +## +{ 'enum': 'CpuModelExpansionType', + 'data': [ 'static', 'full' ] } + + +## +# @CpuModelExpansionInfo: +# +# The result of a cpu model expansion. +# +# @model: the expanded CpuModelInfo. +# +# Since: 2.8.0 +## +{ 'struct': 'CpuModelExpansionInfo', + 'data': { 'model': 'CpuModelInfo' } } + + +## +# @query-cpu-model-expansion: +# +# Expands a given CPU model (or a combination of CPU model + additional op= tions) +# to different granularities, allowing tooling to get an understanding wha= t a +# specific CPU model looks like in QEMU under a certain configuration. +# +# This interface can be used to query the "host" CPU model. +# +# The data returned by this command may be affected by: +# +# * QEMU version: CPU models may look different depending on the QEMU vers= ion. +# (Except for CPU models reported as "static" in query-cpu-definitions.) +# * machine-type: CPU model may look different depending on the machine-t= ype. +# (Except for CPU models reported as "static" in query-cpu-definitions.) +# * machine options (including accelerator): in some architectures, CPU mo= dels +# may look different depending on machine and accelerator options. (Exce= pt for +# CPU models reported as "static" in query-cpu-definitions.) +# * "-cpu" arguments and global properties: arguments to the -cpu option a= nd +# global properties may affect expansion of CPU models. Using +# query-cpu-model-expansion while using these is not advised. +# +# Some architectures may not support all expansion types. s390x supports +# "full" and "static". +# +# Returns: a CpuModelExpansionInfo. Returns an error if expanding CPU mode= ls is +# not supported, if the model cannot be expanded, if the model co= ntains +# an unknown CPU definition name, unknown properties or properties +# with a wrong type. Also returns an error if an expansion type is +# not supported. +# +# Since: 2.8.0 +## +{ 'command': 'query-cpu-model-expansion', + 'data': { 'type': 'CpuModelExpansionType', + 'model': 'CpuModelInfo' }, + 'returns': 'CpuModelExpansionInfo' } + +## +# @CpuModelCompareResult: +# +# An enumeration of CPU model comparation results. The result is usually +# calculated using e.g. CPU features or CPU generations. +# +# @incompatible: If model A is incompatible to model B, model A is not +# guaranteed to run where model B runs and the other way ar= ound. +# +# @identical: If model A is identical to model B, model A is guaranteed to= run +# where model B runs and the other way around. +# +# @superset: If model A is a superset of model B, model B is guaranteed to= run +# where model A runs. There are no guarantees about the other w= ay. +# +# @subset: If model A is a subset of model B, model A is guaranteed to run +# where model B runs. There are no guarantees about the other way. +# +# Since: 2.8.0 +## +{ 'enum': 'CpuModelCompareResult', + 'data': [ 'incompatible', 'identical', 'superset', 'subset' ] } + +## +# @CpuModelCompareInfo: +# +# The result of a CPU model comparison. +# +# @result: The result of the compare operation. +# @responsible-properties: List of properties that led to the comparison r= esult +# not being identical. +# +# @responsible-properties is a list of QOM property names that led to +# both CPUs not being detected as identical. For identical models, this +# list is empty. +# If a QOM property is read-only, that means there's no known way to make = the +# CPU models identical. If the special property name "type" is included, t= he +# models are by definition not identical and cannot be made identical. +# +# Since: 2.8.0 +## +{ 'struct': 'CpuModelCompareInfo', + 'data': {'result': 'CpuModelCompareResult', + 'responsible-properties': ['str'] + } +} + +## +# @query-cpu-model-comparison: +# +# Compares two CPU models, returning how they compare in a specific +# configuration. The results indicates how both models compare regarding +# runnability. This result can be used by tooling to make decisions if a +# certain CPU model will run in a certain configuration or if a compatible +# CPU model has to be created by baselining. +# +# Usually, a CPU model is compared against the maximum possible CPU model +# of a certain configuration (e.g. the "host" model for KVM). If that CPU +# model is identical or a subset, it will run in that configuration. +# +# The result returned by this command may be affected by: +# +# * QEMU version: CPU models may look different depending on the QEMU vers= ion. +# (Except for CPU models reported as "static" in query-cpu-definitions.) +# * machine-type: CPU model may look different depending on the machine-ty= pe. +# (Except for CPU models reported as "static" in query-cpu-definitions.) +# * machine options (including accelerator): in some architectures, CPU mo= dels +# may look different depending on machine and accelerator options. (Exce= pt for +# CPU models reported as "static" in query-cpu-definitions.) +# * "-cpu" arguments and global properties: arguments to the -cpu option a= nd +# global properties may affect expansion of CPU models. Using +# query-cpu-model-expansion while using these is not advised. +# +# Some architectures may not support comparing CPU models. s390x supports +# comparing CPU models. +# +# Returns: a CpuModelBaselineInfo. Returns an error if comparing CPU model= s is +# not supported, if a model cannot be used, if a model contains +# an unknown cpu definition name, unknown properties or properties +# with wrong types. +# +# Since: 2.8.0 +## +{ 'command': 'query-cpu-model-comparison', + 'data': { 'modela': 'CpuModelInfo', 'modelb': 'CpuModelInfo' }, + 'returns': 'CpuModelCompareInfo' } + +## +# @CpuModelBaselineInfo: +# +# The result of a CPU model baseline. +# +# @model: the baselined CpuModelInfo. +# +# Since: 2.8.0 +## +{ 'struct': 'CpuModelBaselineInfo', + 'data': { 'model': 'CpuModelInfo' } } + +## +# @query-cpu-model-baseline: +# +# Baseline two CPU models, creating a compatible third model. The created +# model will always be a static, migration-safe CPU model (see "static" +# CPU model expansion for details). +# +# This interface can be used by tooling to create a compatible CPU model o= ut +# two CPU models. The created CPU model will be identical to or a subset of +# both CPU models when comparing them. Therefore, the created CPU model is +# guaranteed to run where the given CPU models run. +# +# The result returned by this command may be affected by: +# +# * QEMU version: CPU models may look different depending on the QEMU vers= ion. +# (Except for CPU models reported as "static" in query-cpu-definitions.) +# * machine-type: CPU model may look different depending on the machine-ty= pe. +# (Except for CPU models reported as "static" in query-cpu-definitions.) +# * machine options (including accelerator): in some architectures, CPU mo= dels +# may look different depending on machine and accelerator options. (Exce= pt for +# CPU models reported as "static" in query-cpu-definitions.) +# * "-cpu" arguments and global properties: arguments to the -cpu option a= nd +# global properties may affect expansion of CPU models. Using +# query-cpu-model-expansion while using these is not advised. +# +# Some architectures may not support baselining CPU models. s390x supports +# baselining CPU models. +# +# Returns: a CpuModelBaselineInfo. Returns an error if baselining CPU mode= ls is +# not supported, if a model cannot be used, if a model contains +# an unknown cpu definition name, unknown properties or properties +# with wrong types. +# +# Since: 2.8.0 +## +{ 'command': 'query-cpu-model-baseline', + 'data': { 'modela': 'CpuModelInfo', + 'modelb': 'CpuModelInfo' }, + 'returns': 'CpuModelBaselineInfo' } + +## +# @AddfdInfo: +# +# Information about a file descriptor that was added to an fd set. +# +# @fdset-id: The ID of the fd set that @fd was added to. +# +# @fd: The file descriptor that was received via SCM rights and +# added to the fd set. +# +# Since: 1.2.0 +## +{ 'struct': 'AddfdInfo', 'data': {'fdset-id': 'int', 'fd': 'int'} } + +## +# @add-fd: +# +# Add a file descriptor, that was passed via SCM rights, to an fd set. +# +# @fdset-id: The ID of the fd set to add the file descriptor to. +# +# @opaque: A free-form string that can be used to describe the fd. +# +# Returns: @AddfdInfo on success +# +# If file descriptor was not received, FdNotSupplied +# +# If @fdset-id is a negative value, InvalidParameterValue +# +# Notes: The list of fd sets is shared by all monitor connections. +# +# If @fdset-id is not specified, a new fd set will be created. +# +# Since: 1.2.0 +# +# Example: +# +# -> { "execute": "add-fd", "arguments": { "fdset-id": 1 } } +# <- { "return": { "fdset-id": 1, "fd": 3 } } +# +## +{ 'command': 'add-fd', 'data': {'*fdset-id': 'int', '*opaque': 'str'}, + 'returns': 'AddfdInfo' } + +## +# @remove-fd: +# +# Remove a file descriptor from an fd set. +# +# @fdset-id: The ID of the fd set that the file descriptor belongs to. +# +# @fd: The file descriptor that is to be removed. +# +# Returns: Nothing on success +# If @fdset-id or @fd is not found, FdNotFound +# +# Since: 1.2.0 +# +# Notes: The list of fd sets is shared by all monitor connections. +# +# If @fd is not specified, all file descriptors in @fdset-id +# will be removed. +# +# Example: +# +# -> { "execute": "remove-fd", "arguments": { "fdset-id": 1, "fd": 3 } } +# <- { "return": {} } +# +## +{ 'command': 'remove-fd', 'data': {'fdset-id': 'int', '*fd': 'int'} } + +## +# @FdsetFdInfo: +# +# Information about a file descriptor that belongs to an fd set. +# +# @fd: The file descriptor value. +# +# @opaque: A free-form string that can be used to describe the fd. +# +# Since: 1.2.0 +## +{ 'struct': 'FdsetFdInfo', + 'data': {'fd': 'int', '*opaque': 'str'} } + +## +# @FdsetInfo: +# +# Information about an fd set. +# +# @fdset-id: The ID of the fd set. +# +# @fds: A list of file descriptors that belong to this fd set. +# +# Since: 1.2.0 +## +{ 'struct': 'FdsetInfo', + 'data': {'fdset-id': 'int', 'fds': ['FdsetFdInfo']} } + +## +# @query-fdsets: +# +# Return information describing all fd sets. +# +# Returns: A list of @FdsetInfo +# +# Since: 1.2.0 +# +# Note: The list of fd sets is shared by all monitor connections. +# +# Example: +# +# -> { "execute": "query-fdsets" } +# <- { "return": [ +# { +# "fds": [ +# { +# "fd": 30, +# "opaque": "rdonly:/path/to/file" +# }, +# { +# "fd": 24, +# "opaque": "rdwr:/path/to/file" +# } +# ], +# "fdset-id": 1 +# }, +# { +# "fds": [ +# { +# "fd": 28 +# }, +# { +# "fd": 29 +# } +# ], +# "fdset-id": 0 +# } +# ] +# } +# +## +{ 'command': 'query-fdsets', 'returns': ['FdsetInfo'] } + +## +# @TargetInfo: +# +# Information describing the QEMU target. +# +# @arch: the target architecture (eg "x86_64", "i386", etc) +# +# Since: 1.2.0 +## +{ 'struct': 'TargetInfo', + 'data': { 'arch': 'str' } } + +## +# @query-target: +# +# Return information about the target for this QEMU +# +# Returns: TargetInfo +# +# Since: 1.2.0 +## +{ 'command': 'query-target', 'returns': 'TargetInfo' } + +## +# @AcpiTableOptions: +# +# Specify an ACPI table on the command line to load. +# +# At most one of @file and @data can be specified. The list of files speci= fied +# by any one of them is loaded and concatenated in order. If both are omit= ted, +# @data is implied. +# +# Other fields / optargs can be used to override fields of the generic ACPI +# table header; refer to the ACPI specification 5.0, section 5.2.6 System +# Description Table Header. If a header field is not overridden, then the +# corresponding value from the concatenated blob is used (in case of @file= ), or +# it is filled in with a hard-coded value (in case of @data). +# +# String fields are copied into the matching ACPI member from lowest addre= ss +# upwards, and silently truncated / NUL-padded to length. +# +# @sig: table signature / identifier (4 bytes) +# +# @rev: table revision number (dependent on signature, 1 byte) +# +# @oem_id: OEM identifier (6 bytes) +# +# @oem_table_id: OEM table identifier (8 bytes) +# +# @oem_rev: OEM-supplied revision number (4 bytes) +# +# @asl_compiler_id: identifier of the utility that created the table +# (4 bytes) +# +# @asl_compiler_rev: revision number of the utility that created the +# table (4 bytes) +# +# @file: colon (:) separated list of pathnames to load and +# concatenate as table data. The resultant binary blob is expected = to +# have an ACPI table header. At least one file is required. This fi= eld +# excludes @data. +# +# @data: colon (:) separated list of pathnames to load and +# concatenate as table data. The resultant binary blob must not hav= e an +# ACPI table header. At least one file is required. This field excl= udes +# @file. +# +# Since: 1.5 +## +{ 'struct': 'AcpiTableOptions', + 'data': { + '*sig': 'str', + '*rev': 'uint8', + '*oem_id': 'str', + '*oem_table_id': 'str', + '*oem_rev': 'uint32', + '*asl_compiler_id': 'str', + '*asl_compiler_rev': 'uint32', + '*file': 'str', + '*data': 'str' }} + +## +# @CommandLineParameterType: +# +# Possible types for an option parameter. +# +# @string: accepts a character string +# +# @boolean: accepts "on" or "off" +# +# @number: accepts a number +# +# @size: accepts a number followed by an optional suffix (K)ilo, +# (M)ega, (G)iga, (T)era +# +# Since: 1.5 +## +{ 'enum': 'CommandLineParameterType', + 'data': ['string', 'boolean', 'number', 'size'] } + +## +# @CommandLineParameterInfo: +# +# Details about a single parameter of a command line option. +# +# @name: parameter name +# +# @type: parameter @CommandLineParameterType +# +# @help: human readable text string, not suitable for parsing. +# +# @default: default value string (since 2.1) +# +# Since: 1.5 +## +{ 'struct': 'CommandLineParameterInfo', + 'data': { 'name': 'str', + 'type': 'CommandLineParameterType', + '*help': 'str', + '*default': 'str' } } + +## +# @CommandLineOptionInfo: +# +# Details about a command line option, including its list of parameter det= ails +# +# @option: option name +# +# @parameters: an array of @CommandLineParameterInfo +# +# Since: 1.5 +## +{ 'struct': 'CommandLineOptionInfo', + 'data': { 'option': 'str', 'parameters': ['CommandLineParameterInfo'] } } + +## +# @query-command-line-options: +# +# Query command line option schema. +# +# @option: option name +# +# Returns: list of @CommandLineOptionInfo for all options (or for the given +# @option). Returns an error if the given @option doesn't exist. +# +# Since: 1.5 +# +# Example: +# +# -> { "execute": "query-command-line-options", +# "arguments": { "option": "option-rom" } } +# <- { "return": [ +# { +# "parameters": [ +# { +# "name": "romfile", +# "type": "string" +# }, +# { +# "name": "bootindex", +# "type": "number" +# } +# ], +# "option": "option-rom" +# } +# ] +# } +# +## +{'command': 'query-command-line-options', 'data': { '*option': 'str' }, + 'returns': ['CommandLineOptionInfo'] } + +## +# @X86CPURegister32: +# +# A X86 32-bit register +# +# Since: 1.5 +## +{ 'enum': 'X86CPURegister32', + 'data': [ 'EAX', 'EBX', 'ECX', 'EDX', 'ESP', 'EBP', 'ESI', 'EDI' ] } + +## +# @X86CPUFeatureWordInfo: +# +# Information about a X86 CPU feature word +# +# @cpuid-input-eax: Input EAX value for CPUID instruction for that feature= word +# +# @cpuid-input-ecx: Input ECX value for CPUID instruction for that +# feature word +# +# @cpuid-register: Output register containing the feature bits +# +# @features: value of output register, containing the feature bits +# +# Since: 1.5 +## +{ 'struct': 'X86CPUFeatureWordInfo', + 'data': { 'cpuid-input-eax': 'int', + '*cpuid-input-ecx': 'int', + 'cpuid-register': 'X86CPURegister32', + 'features': 'int' } } + +## +# @DummyForceArrays: +# +# Not used by QMP; hack to let us use X86CPUFeatureWordInfoList internally +# +# Since: 2.5 +## +{ 'struct': 'DummyForceArrays', + 'data': { 'unused': ['X86CPUFeatureWordInfo'] } } + + +## +# @NumaOptionsType: +# +# @node: NUMA nodes configuration +# +# @dist: NUMA distance configuration (since 2.10) +# +# @cpu: property based CPU(s) to node mapping (Since: 2.10) +# +# Since: 2.1 +## +{ 'enum': 'NumaOptionsType', + 'data': [ 'node', 'dist', 'cpu' ] } + +## +# @NumaOptions: +# +# A discriminated record of NUMA options. (for OptsVisitor) +# +# Since: 2.1 +## +{ 'union': 'NumaOptions', + 'base': { 'type': 'NumaOptionsType' }, + 'discriminator': 'type', + 'data': { + 'node': 'NumaNodeOptions', + 'dist': 'NumaDistOptions', + 'cpu': 'NumaCpuOptions' }} + +## +# @NumaNodeOptions: +# +# Create a guest NUMA node. (for OptsVisitor) +# +# @nodeid: NUMA node ID (increase by 1 from 0 if omitted) +# +# @cpus: VCPUs belonging to this node (assign VCPUS round-robin +# if omitted) +# +# @mem: memory size of this node; mutually exclusive with @memdev. +# Equally divide total memory among nodes if both @mem and @memdev a= re +# omitted. +# +# @memdev: memory backend object. If specified for one node, +# it must be specified for all nodes. +# +# Since: 2.1 +## +{ 'struct': 'NumaNodeOptions', + 'data': { + '*nodeid': 'uint16', + '*cpus': ['uint16'], + '*mem': 'size', + '*memdev': 'str' }} + +## +# @NumaDistOptions: +# +# Set the distance between 2 NUMA nodes. +# +# @src: source NUMA node. +# +# @dst: destination NUMA node. +# +# @val: NUMA distance from source node to destination node. +# When a node is unreachable from another node, set the distance +# between them to 255. +# +# Since: 2.10 +## +{ 'struct': 'NumaDistOptions', + 'data': { + 'src': 'uint16', + 'dst': 'uint16', + 'val': 'uint8' }} + +## +# @NumaCpuOptions: +# +# Option "-numa cpu" overrides default cpu to node mapping. +# It accepts the same set of cpu properties as returned by +# query-hotpluggable-cpus[].props, where node-id could be used to +# override default node mapping. +# +# Since: 2.10 +## +{ 'struct': 'NumaCpuOptions', + 'base': 'CpuInstanceProperties', + 'data' : {} } + +## +# @HostMemPolicy: +# +# Host memory policy types +# +# @default: restore default policy, remove any nondefault policy +# +# @preferred: set the preferred host nodes for allocation +# +# @bind: a strict policy that restricts memory allocation to the +# host nodes specified +# +# @interleave: memory allocations are interleaved across the set +# of host nodes specified +# +# Since: 2.1 +## +{ 'enum': 'HostMemPolicy', + 'data': [ 'default', 'preferred', 'bind', 'interleave' ] } + +## +# @Memdev: +# +# Information about memory backend +# +# @id: backend's ID if backend has 'id' property (since 2.9) +# +# @size: memory backend size +# +# @merge: enables or disables memory merge support +# +# @dump: includes memory backend's memory in a core dump or not +# +# @prealloc: enables or disables memory preallocation +# +# @host-nodes: host nodes for its memory policy +# +# @policy: memory policy of memory backend +# +# Since: 2.1 +## +{ 'struct': 'Memdev', + 'data': { + '*id': 'str', + 'size': 'size', + 'merge': 'bool', + 'dump': 'bool', + 'prealloc': 'bool', + 'host-nodes': ['uint16'], + 'policy': 'HostMemPolicy' }} + +## +# @query-memdev: +# +# Returns information for all memory backends. +# +# Returns: a list of @Memdev. +# +# Since: 2.1 +# +# Example: +# +# -> { "execute": "query-memdev" } +# <- { "return": [ +# { +# "id": "mem1", +# "size": 536870912, +# "merge": false, +# "dump": true, +# "prealloc": false, +# "host-nodes": [0, 1], +# "policy": "bind" +# }, +# { +# "size": 536870912, +# "merge": false, +# "dump": true, +# "prealloc": true, +# "host-nodes": [2, 3], +# "policy": "preferred" +# } +# ] +# } +# +## +{ 'command': 'query-memdev', 'returns': ['Memdev'] } + +## +# @PCDIMMDeviceInfo: +# +# PCDIMMDevice state information +# +# @id: device's ID +# +# @addr: physical address, where device is mapped +# +# @size: size of memory that the device provides +# +# @slot: slot number at which device is plugged in +# +# @node: NUMA node number where device is plugged in +# +# @memdev: memory backend linked with device +# +# @hotplugged: true if device was hotplugged +# +# @hotpluggable: true if device if could be added/removed while machine is= running +# +# Since: 2.1 +## +{ 'struct': 'PCDIMMDeviceInfo', + 'data': { '*id': 'str', + 'addr': 'int', + 'size': 'int', + 'slot': 'int', + 'node': 'int', + 'memdev': 'str', + 'hotplugged': 'bool', + 'hotpluggable': 'bool' + } +} + +## +# @MemoryDeviceInfo: +# +# Union containing information about a memory device +# +# Since: 2.1 +## +{ 'union': 'MemoryDeviceInfo', 'data': {'dimm': 'PCDIMMDeviceInfo'} } + +## +# @query-memory-devices: +# +# Lists available memory devices and their state +# +# Since: 2.1 +# +# Example: +# +# -> { "execute": "query-memory-devices" } +# <- { "return": [ { "data": +# { "addr": 5368709120, +# "hotpluggable": true, +# "hotplugged": true, +# "id": "d1", +# "memdev": "/objects/memX", +# "node": 0, +# "size": 1073741824, +# "slot": 0}, +# "type": "dimm" +# } ] } +# +## +{ 'command': 'query-memory-devices', 'returns': ['MemoryDeviceInfo'] } + +## +# @MEM_UNPLUG_ERROR: +# +# Emitted when memory hot unplug error occurs. +# +# @device: device name +# +# @msg: Informative message +# +# Since: 2.4 +# +# Example: +# +# <- { "event": "MEM_UNPLUG_ERROR" +# "data": { "device": "dimm1", +# "msg": "acpi: device unplug for unsupported device" +# }, +# "timestamp": { "seconds": 1265044230, "microseconds": 450486 } } +# +## +{ 'event': 'MEM_UNPLUG_ERROR', + 'data': { 'device': 'str', 'msg': 'str' } } + +## +# @ACPISlotType: +# +# @DIMM: memory slot +# @CPU: logical CPU slot (since 2.7) +## +{ 'enum': 'ACPISlotType', 'data': [ 'DIMM', 'CPU' ] } + +## +# @ACPIOSTInfo: +# +# OSPM Status Indication for a device +# For description of possible values of @source and @status fields +# see "_OST (OSPM Status Indication)" chapter of ACPI5.0 spec. +# +# @device: device ID associated with slot +# +# @slot: slot ID, unique per slot of a given @slot-type +# +# @slot-type: type of the slot +# +# @source: an integer containing the source event +# +# @status: an integer containing the status code +# +# Since: 2.1 +## +{ 'struct': 'ACPIOSTInfo', + 'data' : { '*device': 'str', + 'slot': 'str', + 'slot-type': 'ACPISlotType', + 'source': 'int', + 'status': 'int' } } + +## +# @query-acpi-ospm-status: +# +# Return a list of ACPIOSTInfo for devices that support status +# reporting via ACPI _OST method. +# +# Since: 2.1 +# +# Example: +# +# -> { "execute": "query-acpi-ospm-status" } +# <- { "return": [ { "device": "d1", "slot": "0", "slot-type": "DIMM", "so= urce": 1, "status": 0}, +# { "slot": "1", "slot-type": "DIMM", "source": 0, "statu= s": 0}, +# { "slot": "2", "slot-type": "DIMM", "source": 0, "statu= s": 0}, +# { "slot": "3", "slot-type": "DIMM", "source": 0, "statu= s": 0} +# ]} +# +## +{ 'command': 'query-acpi-ospm-status', 'returns': ['ACPIOSTInfo'] } + +## +# @ACPI_DEVICE_OST: +# +# Emitted when guest executes ACPI _OST method. +# +# @info: ACPIOSTInfo type as described in qapi-schema.json +# +# Since: 2.1 +# +# Example: +# +# <- { "event": "ACPI_DEVICE_OST", +# "data": { "device": "d1", "slot": "0", +# "slot-type": "DIMM", "source": 1, "status": 0 } } +# +## +{ 'event': 'ACPI_DEVICE_OST', + 'data': { 'info': 'ACPIOSTInfo' } } + +## +# @rtc-reset-reinjection: +# +# This command will reset the RTC interrupt reinjection backlog. +# Can be used if another mechanism to synchronize guest time +# is in effect, for example QEMU guest agent's guest-set-time +# command. +# +# Since: 2.1 +# +# Example: +# +# -> { "execute": "rtc-reset-reinjection" } +# <- { "return": {} } +# +## +{ 'command': 'rtc-reset-reinjection' } + +## +# @RTC_CHANGE: +# +# Emitted when the guest changes the RTC time. +# +# @offset: offset between base RTC clock (as specified by -rtc base), and +# new RTC clock value +# +# Note: This event is rate-limited. +# +# Since: 0.13.0 +# +# Example: +# +# <- { "event": "RTC_CHANGE", +# "data": { "offset": 78 }, +# "timestamp": { "seconds": 1267020223, "microseconds": 435656 } } +# +## +{ 'event': 'RTC_CHANGE', + 'data': { 'offset': 'int' } } + +## +# @ReplayMode: +# +# Mode of the replay subsystem. +# +# @none: normal execution mode. Replay or record are not enabled. +# +# @record: record mode. All non-deterministic data is written into the +# replay log. +# +# @play: replay mode. Non-deterministic data required for system execution +# is read from the log. +# +# Since: 2.5 +## +{ 'enum': 'ReplayMode', + 'data': [ 'none', 'record', 'play' ] } + +## +# @xen-load-devices-state: +# +# Load the state of all devices from file. The RAM and the block devices +# of the VM are not loaded by this command. +# +# @filename: the file to load the state of the devices from as binary +# data. See xen-save-devices-state.txt for a description of the binary +# format. +# +# Since: 2.7 +# +# Example: +# +# -> { "execute": "xen-load-devices-state", +# "arguments": { "filename": "/tmp/resume" } } +# <- { "return": {} } +# +## +{ 'command': 'xen-load-devices-state', 'data': {'filename': 'str'} } + +## +# @GICCapability: +# +# The struct describes capability for a specific GIC (Generic +# Interrupt Controller) version. These bits are not only decided by +# QEMU/KVM software version, but also decided by the hardware that +# the program is running upon. +# +# @version: version of GIC to be described. Currently, only 2 and 3 +# are supported. +# +# @emulated: whether current QEMU/hardware supports emulated GIC +# device in user space. +# +# @kernel: whether current QEMU/hardware supports hardware +# accelerated GIC device in kernel. +# +# Since: 2.6 +## +{ 'struct': 'GICCapability', + 'data': { 'version': 'int', + 'emulated': 'bool', + 'kernel': 'bool' } } + +## +# @query-gic-capabilities: +# +# This command is ARM-only. It will return a list of GICCapability +# objects that describe its capability bits. +# +# Returns: a list of GICCapability objects. +# +# Since: 2.6 +# +# Example: +# +# -> { "execute": "query-gic-capabilities" } +# <- { "return": [{ "version": 2, "emulated": true, "kernel": false }, +# { "version": 3, "emulated": false, "kernel": true } ] } +# +## +{ 'command': 'query-gic-capabilities', 'returns': ['GICCapability'] } + +## +# @CpuInstanceProperties: +# +# List of properties to be used for hotplugging a CPU instance, +# it should be passed by management with device_add command when +# a CPU is being hotplugged. +# +# @node-id: NUMA node ID the CPU belongs to +# @socket-id: socket number within node/board the CPU belongs to +# @core-id: core number within socket the CPU belongs to +# @thread-id: thread number within core the CPU belongs to +# +# Note: currently there are 4 properties that could be present +# but management should be prepared to pass through other +# properties with device_add command to allow for future +# interface extension. This also requires the filed names to be kept in +# sync with the properties passed to -device/device_add. +# +# Since: 2.7 +## +{ 'struct': 'CpuInstanceProperties', + 'data': { '*node-id': 'int', + '*socket-id': 'int', + '*core-id': 'int', + '*thread-id': 'int' + } +} + +## +# @HotpluggableCPU: +# +# @type: CPU object type for usage with device_add command +# @props: list of properties to be used for hotplugging CPU +# @vcpus-count: number of logical VCPU threads @HotpluggableCPU provides +# @qom-path: link to existing CPU object if CPU is present or +# omitted if CPU is not present. +# +# Since: 2.7 +## +{ 'struct': 'HotpluggableCPU', + 'data': { 'type': 'str', + 'vcpus-count': 'int', + 'props': 'CpuInstanceProperties', + '*qom-path': 'str' + } +} + +## +# @query-hotpluggable-cpus: +# +# Returns: a list of HotpluggableCPU objects. +# +# Since: 2.7 +# +# Example: +# +# For pseries machine type started with -smp 2,cores=3D2,maxcpus=3D4 -cpu = POWER8: +# +# -> { "execute": "query-hotpluggable-cpus" } +# <- {"return": [ +# { "props": { "core": 8 }, "type": "POWER8-spapr-cpu-core", +# "vcpus-count": 1 }, +# { "props": { "core": 0 }, "type": "POWER8-spapr-cpu-core", +# "vcpus-count": 1, "qom-path": "/machine/unattached/device[0]"} +# ]}' +# +# For pc machine type started with -smp 1,maxcpus=3D2: +# +# -> { "execute": "query-hotpluggable-cpus" } +# <- {"return": [ +# { +# "type": "qemu64-x86_64-cpu", "vcpus-count": 1, +# "props": {"core-id": 0, "socket-id": 1, "thread-id": 0} +# }, +# { +# "qom-path": "/machine/unattached/device[0]", +# "type": "qemu64-x86_64-cpu", "vcpus-count": 1, +# "props": {"core-id": 0, "socket-id": 0, "thread-id": 0} +# } +# ]} +# +# For s390x-virtio-ccw machine type started with -smp 1,maxcpus=3D2 -cpu q= emu +# (Since: 2.11): +# +# -> { "execute": "query-hotpluggable-cpus" } +# <- {"return": [ +# { +# "type": "qemu-s390x-cpu", "vcpus-count": 1, +# "props": { "core-id": 1 } +# }, +# { +# "qom-path": "/machine/unattached/device[0]", +# "type": "qemu-s390x-cpu", "vcpus-count": 1, +# "props": { "core-id": 0 } +# } +# ]} +# +## +{ 'command': 'query-hotpluggable-cpus', 'returns': ['HotpluggableCPU'] } + +## +# @GuidInfo: +# +# GUID information. +# +# @guid: the globally unique identifier +# +# Since: 2.9 +## +{ 'struct': 'GuidInfo', 'data': {'guid': 'str'} } + +## +# @query-vm-generation-id: +# +# Show Virtual Machine Generation ID +# +# Since: 2.9 +## +{ 'command': 'query-vm-generation-id', 'returns': 'GuidInfo' } diff --git a/qapi/run-state.json b/qapi/run-state.json index bca46a8785..a27c3c2a93 100644 --- a/qapi/run-state.json +++ b/qapi/run-state.json @@ -283,6 +283,16 @@ 'data': [ 'reset', 'shutdown', 'poweroff', 'pause', 'debug', 'none', 'inject-nmi' ] } =20 + +## +# @watchdog-set-action: +# +# Set watchdog action +# +# Since: 2.11 +## +{ 'command': 'watchdog-set-action', 'data' : {'action': 'WatchdogAction'} } + ## # @GUEST_PANICKED: # --=20 2.13.6