From nobody Thu Mar 28 08:32:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560358649; cv=none; d=zoho.com; s=zohoarc; b=H9YO2CDLYoIjzxGiRnfi1OhO4DA3lAD3D9Bd4TBFpwVVOv9snpGC2wGSYorqBLX0DwoEr3zAhI3eqxYKi5cf745RRQ6Oj4RykqVSZqrYortkS3jQVjKHQuSAZktBbo8UQepF7efXw+rq4rIiP8pm8CdUquZ7NVuCQqJmPVa4f+A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560358649; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=hfUHN2tyTxZk3wofbav+YkNr1EJu5nvOBLse6hfHzxM=; b=WcJ/4wQalQ0/Fzb6n3cHAL0Che91zN7RKgEO9AHfJ64VYYjcQgIAEwmoPFBeXaOqjkar/wvhHEKakswkrrrlz+tOsneIgYyalLZRuhzt1qXerLKabn684VqeJykOpQ5r9e+nMmmBnXDVW2/392r7CBfRvDMXZt7KDnht+Ss6K5E= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15603586491011005.4081930848411; Wed, 12 Jun 2019 09:57:29 -0700 (PDT) Received: from localhost ([::1]:33844 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb6Yv-0001b6-12 for importer@patchew.org; Wed, 12 Jun 2019 12:57:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57829) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb6UI-0007Pb-Pv for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:52:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hb6UE-0006Bg-Oz for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:52:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35042) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hb6UC-00069Y-OY for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:52:32 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 43BB430872CC for ; Wed, 12 Jun 2019 16:52: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 1568160CCD; Wed, 12 Jun 2019 16:52:31 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8BEC81138660; Wed, 12 Jun 2019 18:52:29 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 12 Jun 2019 18:52:19 +0200 Message-Id: <20190612165229.26976-2-armbru@redhat.com> In-Reply-To: <20190612165229.26976-1-armbru@redhat.com> References: <20190612165229.26976-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 12 Jun 2019 16:52:31 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 01/11] qdev: Delete unused LostTickPolicy "merge" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Commit 4e4fa398db6 "qdev: Introduce lost tick policy property" (v1.1.0) created PropertyType PROP_TYPE_LOSTTICKPOLICY with values "discard", "delay", "merge", and "slew". Value "merge" has never been used. Delete it. Signed-off-by: Markus Armbruster Message-Id: <20190401150140.29151-1-armbru@redhat.com> Reviewed-by: Eric Blake --- qapi/misc.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/qapi/misc.json b/qapi/misc.json index 8b3ca4fdd3..dc4cf9da20 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -172,17 +172,13 @@ # @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' ] } + 'data': ['discard', 'delay', 'slew' ] } =20 ## # @add_client: --=20 2.21.0 From nobody Thu Mar 28 08:32:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560359182; cv=none; d=zoho.com; s=zohoarc; b=nj+kMHNODWhCMK2fCcsz5e0P4ZV5H25iAAQapQVtkW69Ci+0ei4fBJ7SbM6qh+epiFuf/DxHPdSQEoRMZPBBOTIYxnavHdcJR8xQCDucleZZ4qrulFmLOiObqt2E3sBjkkj1CUijLv5L3iWzJqAuUaUL3nKEIsaQ+hjSmxmcDDk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560359182; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=dhIIgxRoUajgZLMMROyAOjE8EE4imjGSNnyYiEf8pk4=; b=ZSB0v5dpQwEcGs5zk4XCNhD2uCjn9YepuStG/3I8xcAXXRh6A7b5HwEvszXVMY6FUZt0PGivsTcNXQKTf5omPCAOd70C8bvpA8lecfIttdmSDfWo+d+l7BKjQqdzQtGiurMXTt177HPnilY01M7kTXIO6zfiAjdoTlBXZKA8gHQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560359182658220.2198965042054; Wed, 12 Jun 2019 10:06:22 -0700 (PDT) Received: from localhost ([::1]:33924 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb6hT-0008Qa-Tk for importer@patchew.org; Wed, 12 Jun 2019 13:06:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57846) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb6UK-0007Qr-9k for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:52:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hb6UG-0006Cu-KU for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:52:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35318) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hb6UC-00069X-U2 for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:52:34 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 402E030832E3 for ; Wed, 12 Jun 2019 16:52: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 1051B51C6A; Wed, 12 Jun 2019 16:52:31 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9591E1138661; Wed, 12 Jun 2019 18:52:29 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 12 Jun 2019 18:52:20 +0200 Message-Id: <20190612165229.26976-3-armbru@redhat.com> In-Reply-To: <20190612165229.26976-1-armbru@redhat.com> References: <20190612165229.26976-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 12 Jun 2019 16:52:31 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 02/11] qapi/block-core: update documentation of preallocation parameter X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Stefano Garzarella Add default and available values in the documentation block of each block device or protocol that supports the 'preallocation' parameter during the image creation. Suggested-by: Markus Armbruster Signed-off-by: Stefano Garzarella Reviewed-by: Markus Armbruster Message-Id: <20190524075848.23781-2-sgarzare@redhat.com> Signed-off-by: Markus Armbruster --- qapi/block-core.json | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 1defcde048..175ccfe896 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -4121,7 +4121,10 @@ # # @filename Filename for the new image file # @size Size of the virtual disk in bytes -# @preallocation Preallocation mode for the new image (default: off) +# @preallocation Preallocation mode for the new image (default: off; +# allowed values: off, +# falloc (if defined CONFIG_POSIX_FALLOCATE), +# full (if defined CONFIG_POSIX)) # @nocow Turn off copy-on-write (valid only on btrfs; default: = off) # # Since: 2.12 @@ -4139,7 +4142,10 @@ # # @location Where to store the new image file # @size Size of the virtual disk in bytes -# @preallocation Preallocation mode for the new image (default: off) +# @preallocation Preallocation mode for the new image (default: off; +# allowed values: off, +# falloc (if defined CONFIG_GLUSTERFS_FALLOCATE), +# full (if defined CONFIG_GLUSTERFS_ZEROFILL)) # # Since: 2.12 ## @@ -4243,7 +4249,8 @@ # @backing-fmt Name of the block driver to use for the backing file # @encrypt Encryption options if the image should be encrypted # @cluster-size qcow2 cluster size in bytes (default: 65536) -# @preallocation Preallocation mode for the new image (default: off) +# @preallocation Preallocation mode for the new image (default: off; +# allowed values: off, falloc, full, metadata) # @lazy-refcounts True if refcounts may be updated lazily (default: off) # @refcount-bits Width of reference counts in bits (default: 16) # @@ -4426,7 +4433,8 @@ # @location Where to store the new image file # @size Size of the virtual disk in bytes # @backing-file File name of a base image -# @preallocation Preallocation mode (allowed values: off, full) +# @preallocation Preallocation mode for the new image (default: off; +# allowed values: off, full) # @redundancy Redundancy of the image # @object-size Object size of the image # @@ -4461,8 +4469,8 @@ # # @file Node to create the image format on # @size Size of the virtual disk in bytes -# @preallocation Preallocation mode for the new image (allowed values: = off, -# metadata; default: off) +# @preallocation Preallocation mode for the new image (default: off; +# allowed values: off, metadata) # # Since: 2.12 ## --=20 2.21.0 From nobody Thu Mar 28 08:32:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560359432; cv=none; d=zoho.com; s=zohoarc; b=LWCq5HO9urmWdTWjd8WwU8HFhh85hjQT1lnxYS1ebwWkU0TggHU1IQa8uQmLaUAm9uf2FZdF3D62808Pbz0AUB2DXKEpN4Jij7I+iMW+3Q5R8lc/6O8bRdx+HhT5Z35GjpRFYU+/RGB/K2ryzq2V/WpoNb6QrmBtxp8neDJFd0A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560359432; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=gVPKWpBOu1AEIr9fNytH9Xl2FU3BAwhonceUbauaxhw=; b=huqXasgg/0EvJ5BPs5aPb/bDArllejxF6uLbj9J7t0cBS9j3DnojvylGss0sg4sdltHxjX7fO7MJOMF8XSTr1KFVjyeQ5a9n0bVwK1dwg06reyHTw8WUwT5BPPSvOMfz2Zi7kZUpx6wqZQHOnGaQTql16kL43l+RSBmoDWvhAiI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560359432893853.0909673771638; Wed, 12 Jun 2019 10:10:32 -0700 (PDT) Received: from localhost ([::1]:33954 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb6lU-000410-UP for importer@patchew.org; Wed, 12 Jun 2019 13:10:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57891) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb6UU-0007RQ-3X for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:52:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hb6UP-0006NK-Ro for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:52:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57988) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hb6UM-0006Ce-9n for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:52:43 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 432263082E24 for ; Wed, 12 Jun 2019 16:52: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 145025C298; Wed, 12 Jun 2019 16:52:31 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9BBD9113860E; Wed, 12 Jun 2019 18:52:29 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 12 Jun 2019 18:52:21 +0200 Message-Id: <20190612165229.26976-4-armbru@redhat.com> In-Reply-To: <20190612165229.26976-1-armbru@redhat.com> References: <20190612165229.26976-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 12 Jun 2019 16:52:31 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 03/11] block/file-posix: update .help of BLOCK_OPT_PREALLOC option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Stefano Garzarella Show 'falloc' among the allowed values of 'preallocation' option, only when it is supported (if defined CONFIG_POSIX_FALLOCATE) Signed-off-by: Stefano Garzarella Reviewed-by: Markus Armbruster Message-Id: <20190524075848.23781-3-sgarzare@redhat.com> Signed-off-by: Markus Armbruster --- block/file-posix.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/block/file-posix.c b/block/file-posix.c index 6e6bf3f4a5..83ab1b78ef 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2752,7 +2752,11 @@ static QemuOptsList raw_create_opts =3D { { .name =3D BLOCK_OPT_PREALLOC, .type =3D QEMU_OPT_STRING, - .help =3D "Preallocation mode (allowed values: off, falloc, fu= ll)" + .help =3D "Preallocation mode (allowed values: off" +#ifdef CONFIG_POSIX_FALLOCATE + ", falloc" +#endif + ", full)" }, { /* end of list */ } } --=20 2.21.0 From nobody Thu Mar 28 08:32:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560359256; cv=none; d=zoho.com; s=zohoarc; b=DI2OMXFWAXVvxBzf2/JbrVt8i5yD7jMJedd25J1w8OIRIY3xA0TcPOfF732JcnJ/gOierRuSBRbjCZIwGTva1wBL2gNPsOLexTXQq0dkRx+b4uUar04JJDBFhytUVrL6WlxRRfuZ166M+Hl9Sqg+FepieosFGGCO/EbpE7uC6QI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560359256; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=IiMjZI4O5OqolTDlErE0Q1Jur2lVuspnHQf+oaCfBoI=; b=HjGAmiwbJIZGtAU0HkUjYJ6Z13BbtdPgsGFlajg8u3YOSb6snHMSOU22M+P5qJwE1Xpy2KvdF228QDSoHUC9xS8Ac1BA/Zg56ZbVrTIuIAzMrAyRFmokbjgiTkMUpUxVwz1AArgrw+mgHEz3doFd24mTxn8CII+1kM8bWGNQLXI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560359256253796.6619764307179; Wed, 12 Jun 2019 10:07:36 -0700 (PDT) Received: from localhost ([::1]:33926 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb6il-00018N-5x for importer@patchew.org; Wed, 12 Jun 2019 13:07:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57877) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb6UP-0007Qv-U6 for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:52:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hb6UO-0006M8-1A for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:52:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51784) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hb6UK-0006Cf-9G for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:52:42 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 490F0308795E for ; Wed, 12 Jun 2019 16:52: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 19A101001B11; Wed, 12 Jun 2019 16:52:31 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A173C11385D4; Wed, 12 Jun 2019 18:52:29 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 12 Jun 2019 18:52:22 +0200 Message-Id: <20190612165229.26976-5-armbru@redhat.com> In-Reply-To: <20190612165229.26976-1-armbru@redhat.com> References: <20190612165229.26976-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Wed, 12 Jun 2019 16:52:31 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 04/11] block/gluster: update .help of BLOCK_OPT_PREALLOC option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Stefano Garzarella Add missing 'falloc' among the allowed values of 'preallocation' option; show it and 'full' only when they are supported. ('falloc' is supported if defined CONFIG_GLUSTERFS_FALLOCATE, 'full' is supported if defined CONFIG_GLUSTERFS_ZEROFILL) Signed-off-by: Stefano Garzarella Reviewed-by: Markus Armbruster Message-Id: <20190524075848.23781-4-sgarzare@redhat.com> Signed-off-by: Markus Armbruster --- block/gluster.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/block/gluster.c b/block/gluster.c index dc16f0c329..62f8ff2147 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -98,7 +98,14 @@ static QemuOptsList qemu_gluster_create_opts =3D { { .name =3D BLOCK_OPT_PREALLOC, .type =3D QEMU_OPT_STRING, - .help =3D "Preallocation mode (allowed values: off, full)" + .help =3D "Preallocation mode (allowed values: off" +#ifdef CONFIG_GLUSTERFS_FALLOCATE + ", falloc" +#endif +#ifdef CONFIG_GLUSTERFS_ZEROFILL + ", full" +#endif + ")" }, { .name =3D GLUSTER_OPT_DEBUG, --=20 2.21.0 From nobody Thu Mar 28 08:32:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560359262; cv=none; d=zoho.com; s=zohoarc; b=nfieXLuFYHWtjtzgGDK5PIleOm1C/Ocvg8J4u8Xj8XEa97o/qoZ8Cn5EkkSPqQ1aoJkfij01yc7TIenhJcq2LwiQcQqlboMELKVDy1AdYLmiUOEKTRUvbvg9UxK+iCBEZpudr0IgmI9nHhSRHfAD6z/mHtYNqelRV0usQ09lE34= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560359262; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=H+RvY8EC6xf+ADLJ07FElV/tKb0FeJHrDHsM7mIp9Uc=; b=TSBixwapz1z8AvI7oRLwuhULxPQXtLuYJ3FYKXzqg18tnUiQy2dHkSCLRKA9qzjgX28wcZOXzGb0oYYDmecFa5SQw2FG1/KCjzzs9I3ZYjOfobWlJ+W9HhGF6BXtU9ZBmVdfmzF1etT8xInl+hEFNi4z2amG8t7e3cV/5nHpf+A= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560359262767136.86066947228244; Wed, 12 Jun 2019 10:07:42 -0700 (PDT) Received: from localhost ([::1]:33928 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb6in-0001Bk-MZ for importer@patchew.org; Wed, 12 Jun 2019 13:07:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57978) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb6Ug-0007UQ-4m for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:53:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hb6Uc-0006YW-0I for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:53:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34664) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hb6Ub-0006Fk-MP for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:52:57 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D11D9C002965 for ; Wed, 12 Jun 2019 16:52:33 +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 7DD395C298; Wed, 12 Jun 2019 16:52:32 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A716311385D5; Wed, 12 Jun 2019 18:52:29 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 12 Jun 2019 18:52:23 +0200 Message-Id: <20190612165229.26976-6-armbru@redhat.com> In-Reply-To: <20190612165229.26976-1-armbru@redhat.com> References: <20190612165229.26976-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 12 Jun 2019 16:52:33 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 05/11] qapi: Add feature flags to struct types X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Kevin Wolf Sometimes, the behaviour of QEMU changes without a change in the QMP syntax (usually by allowing values or operations that previously resulted in an error). QMP clients may still need to know whether they can rely on the changed behavior. Let's add feature flags to the QAPI schema language, so that we can make such changes visible with schema introspection. An example for a schema definition using feature flags looks like this: { 'struct': 'TestType', 'data': { 'number': 'int' }, 'features': [ 'allow-negative-numbers' ] } Introspection information then looks like this: { "name": "TestType", "meta-type": "object", "members": [ { "name": "number", "type": "int" } ], "features": [ "allow-negative-numbers" ] } This patch implements feature flags only for struct types. We'll implement them more widely as needed. Signed-off-by: Kevin Wolf Message-Id: <20190606153803.5278-2-armbru@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- docs/devel/qapi-code-gen.txt | 38 +++++++++++++++ qapi/introspect.json | 6 ++- scripts/qapi/common.py | 66 ++++++++++++++++++++++---- scripts/qapi/doc.py | 3 +- scripts/qapi/introspect.py | 6 ++- scripts/qapi/types.py | 3 +- scripts/qapi/visit.py | 3 +- tests/qapi-schema/double-type.err | 2 +- tests/qapi-schema/test-qapi.py | 3 +- tests/qapi-schema/unknown-expr-key.err | 2 +- 10 files changed, 114 insertions(+), 18 deletions(-) diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt index b517b0cfbf..e8ec8ac1de 100644 --- a/docs/devel/qapi-code-gen.txt +++ b/docs/devel/qapi-code-gen.txt @@ -719,6 +719,34 @@ any non-empty complex type (struct, union, or alternat= e), and a pointer to that QAPI type is passed as a single argument. =20 =20 +=3D=3D=3D Features =3D=3D=3D + +Sometimes, the behaviour of QEMU changes compatibly, but without a +change in the QMP syntax (usually by allowing values or operations that +previously resulted in an error). QMP clients may still need to know +whether the extension is available. + +For this purpose, a list of features can be specified for a struct type. +This is exposed to the client as a list of string, where each string +signals that this build of QEMU shows a certain behaviour. + +In the schema, features can be specified as simple strings, for example: + +{ 'struct': 'TestType', + 'data': { 'number': 'int' }, + 'features': [ 'allow-negative-numbers' ] } + +Another option is to specify features as dictionaries, where the key +'name' specifies the feature string to be exposed to clients: + +{ 'struct': 'TestType', + 'data': { 'number': 'int' }, + 'features': [ { 'name': 'allow-negative-numbers' } ] } + +This expanded form is necessary if you want to make the feature +conditional (see below in "Configuring the schema"). + + =3D=3D=3D Downstream extensions =3D=3D=3D =20 QAPI schema names that are externally visible, say in the Client JSON @@ -771,6 +799,16 @@ Example: a conditional 'bar' enum member. [ 'foo', { 'name' : 'bar', 'if': 'defined(IFCOND)' } ] } =20 +Similarly, features can be specified as a dictionary with a 'name' and +an 'if' key. + +Example: a conditional 'allow-negative-numbers' feature + +{ 'struct': 'TestType', + 'data': { 'number': 'int' }, + 'features': [ { 'name': 'allow-negative-numbers', + 'if' 'defined(IFCOND)' } ] } + Please note that you are responsible to ensure that the C code will compile with an arbitrary combination of conditions, since the generators are unable to check it at this point. diff --git a/qapi/introspect.json b/qapi/introspect.json index 3d22166b2b..1843c1cb17 100644 --- a/qapi/introspect.json +++ b/qapi/introspect.json @@ -174,6 +174,9 @@ # and may even differ from the order of the values of the # enum type of the @tag. # +# @features: names of features associated with the type, in no particular +# order. (since: 4.1) +# # Values of this type are JSON object on the wire. # # Since: 2.5 @@ -181,7 +184,8 @@ { 'struct': 'SchemaInfoObject', 'data': { 'members': [ 'SchemaInfoObjectMember' ], '*tag': 'str', - '*variants': [ 'SchemaInfoObjectVariant' ] } } + '*variants': [ 'SchemaInfoObjectVariant' ], + '*features': [ 'str' ] } } =20 ## # @SchemaInfoObjectMember: diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index f07869ec73..9e4b6c00b5 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -886,12 +886,26 @@ def check_enum(expr, info): def check_struct(expr, info): name =3D expr['struct'] members =3D expr['data'] + features =3D expr.get('features') =20 check_type(info, "'data' for struct '%s'" % name, members, allow_dict=3DTrue, allow_optional=3DTrue) check_type(info, "'base' for struct '%s'" % name, expr.get('base'), allow_metas=3D['struct']) =20 + if features: + if not isinstance(features, list): + raise QAPISemError(info, + "Struct '%s' requires an array for 'feature= s'" % + name) + for f in features: + assert isinstance(f, dict) + check_known_keys(info, "feature of struct %s" % name, f, + ['name'], ['if']) + + check_if(f, info) + check_name(info, "Feature of struct %s" % name, f['name']) + =20 def check_known_keys(info, source, keys, required, optional): =20 @@ -948,6 +962,12 @@ def normalize_members(members): members[key] =3D {'type': arg} =20 =20 +def normalize_features(features): + if isinstance(features, list): + features[:] =3D [f if isinstance(f, dict) else {'name': f} + for f in features] + + def check_exprs(exprs): global all_names =20 @@ -986,8 +1006,10 @@ def check_exprs(exprs): normalize_members(expr['data']) elif 'struct' in expr: meta =3D 'struct' - check_keys(expr_elem, 'struct', ['data'], ['base', 'if']) + check_keys(expr_elem, 'struct', ['data'], + ['base', 'if', 'features']) normalize_members(expr['data']) + normalize_features(expr.get('features')) struct_types[expr[meta]] =3D expr elif 'command' in expr: meta =3D 'command' @@ -1126,10 +1148,12 @@ class QAPISchemaVisitor(object): def visit_array_type(self, name, info, ifcond, element_type): pass =20 - def visit_object_type(self, name, info, ifcond, base, members, variant= s): + def visit_object_type(self, name, info, ifcond, base, members, variant= s, + features): pass =20 - def visit_object_type_flat(self, name, info, ifcond, members, variants= ): + def visit_object_type_flat(self, name, info, ifcond, members, variants, + features): pass =20 def visit_alternate_type(self, name, info, ifcond, variants): @@ -1290,7 +1314,7 @@ class QAPISchemaArrayType(QAPISchemaType): =20 class QAPISchemaObjectType(QAPISchemaType): def __init__(self, name, info, doc, ifcond, - base, local_members, variants): + base, local_members, variants, features): # struct has local_members, optional base, and no variants # flat union has base, variants, and no local_members # simple union has local_members, variants, and no base @@ -1302,11 +1326,15 @@ class QAPISchemaObjectType(QAPISchemaType): if variants is not None: assert isinstance(variants, QAPISchemaObjectTypeVariants) variants.set_owner(name) + for f in features: + assert isinstance(f, QAPISchemaFeature) + f.set_owner(name) self._base_name =3D base self.base =3D None self.local_members =3D local_members self.variants =3D variants self.members =3D None + self.features =3D features =20 def check(self, schema): QAPISchemaType.check(self, schema) @@ -1332,6 +1360,12 @@ class QAPISchemaObjectType(QAPISchemaType): self.variants.check(schema, seen) assert self.variants.tag_member in self.members self.variants.check_clash(self.info, seen) + + # Features are in a name space separate from members + seen =3D {} + for f in self.features: + f.check_clash(self.info, seen) + if self.doc: self.doc.check() =20 @@ -1368,12 +1402,15 @@ class QAPISchemaObjectType(QAPISchemaType): =20 def visit(self, visitor): visitor.visit_object_type(self.name, self.info, self.ifcond, - self.base, self.local_members, self.vari= ants) + self.base, self.local_members, self.vari= ants, + self.features) visitor.visit_object_type_flat(self.name, self.info, self.ifcond, - self.members, self.variants) + self.members, self.variants, + self.features) =20 =20 class QAPISchemaMember(object): + """ Represents object members, enum members and features """ role =3D 'member' =20 def __init__(self, name, ifcond=3DNone): @@ -1419,6 +1456,10 @@ class QAPISchemaMember(object): return "'%s' %s" % (self.name, self._pretty_owner()) =20 =20 +class QAPISchemaFeature(QAPISchemaMember): + role =3D 'feature' + + class QAPISchemaObjectTypeMember(QAPISchemaMember): def __init__(self, name, typ, optional, ifcond=3DNone): QAPISchemaMember.__init__(self, name, ifcond) @@ -1675,7 +1716,7 @@ class QAPISchema(object): ('null', 'null', 'QNull' + pointer_suffix)]: self._def_builtin_type(*t) self.the_empty_object_type =3D QAPISchemaObjectType( - 'q_empty', None, None, None, None, [], None) + 'q_empty', None, None, None, None, [], None, []) self._def_entity(self.the_empty_object_type) =20 qtypes =3D ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', @@ -1685,6 +1726,9 @@ class QAPISchema(object): self._def_entity(QAPISchemaEnumType('QType', None, None, None, qtype_values, 'QTYPE')) =20 + def _make_features(self, features): + return [QAPISchemaFeature(f['name'], f.get('if')) for f in feature= s] + def _make_enum_members(self, values): return [QAPISchemaMember(v['name'], v.get('if')) for v in values] =20 @@ -1721,7 +1765,7 @@ class QAPISchema(object): assert ifcond =3D=3D typ._ifcond # pylint: disable=3Dprotected= -access else: self._def_entity(QAPISchemaObjectType(name, info, doc, ifcond, - None, members, None)) + None, members, None, [])) return name =20 def _def_enum_type(self, expr, info, doc): @@ -1752,9 +1796,11 @@ class QAPISchema(object): base =3D expr.get('base') data =3D expr['data'] ifcond =3D expr.get('if') + features =3D expr.get('features', []) self._def_entity(QAPISchemaObjectType(name, info, doc, ifcond, bas= e, self._make_members(data, inf= o), - None)) + None, + self._make_features(features= ))) =20 def _make_variant(self, case, typ, ifcond): return QAPISchemaObjectTypeVariant(case, typ, ifcond) @@ -1795,7 +1841,7 @@ class QAPISchema(object): QAPISchemaObjectType(name, info, doc, ifcond, base, members, QAPISchemaObjectTypeVariants(tag_name, tag_member, - variants))) + variants), [= ])) =20 def _def_alternate_type(self, expr, info, doc): name =3D expr['alternate'] diff --git a/scripts/qapi/doc.py b/scripts/qapi/doc.py index 5c8c136899..433e9fcbfb 100755 --- a/scripts/qapi/doc.py +++ b/scripts/qapi/doc.py @@ -220,7 +220,8 @@ class QAPISchemaGenDocVisitor(qapi.common.QAPISchemaVis= itor): body=3Dtexi_entity(doc, 'Values', ifcond, member_func=3Dtexi_enum_va= lue))) =20 - def visit_object_type(self, name, info, ifcond, base, members, variant= s): + def visit_object_type(self, name, info, ifcond, base, members, variant= s, + features): doc =3D self.cur_doc if base and base.is_implicit(): base =3D None diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index f7f2ca07e4..f62cf0a2e1 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -188,11 +188,15 @@ const QLitObject %(c_name)s =3D %(c_string)s; self._gen_qlit('[' + element + ']', 'array', {'element-type': elem= ent}, ifcond) =20 - def visit_object_type_flat(self, name, info, ifcond, members, variants= ): + def visit_object_type_flat(self, name, info, ifcond, members, variants, + features): obj =3D {'members': [self._gen_member(m) for m in members]} if variants: obj.update(self._gen_variants(variants.tag_member.name, variants.variants)) + if features: + obj['features'] =3D [(f.name, {'if': f.ifcond}) for f in featu= res] + self._gen_qlit(name, 'object', obj, ifcond) =20 def visit_alternate_type(self, name, info, ifcond, variants): diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index 2bd6fcd44f..3edd9374aa 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -227,7 +227,8 @@ class QAPISchemaGenTypeVisitor(QAPISchemaModularCVisito= r): self._genh.add(gen_array(name, element_type)) self._gen_type_cleanup(name) =20 - def visit_object_type(self, name, info, ifcond, base, members, variant= s): + def visit_object_type(self, name, info, ifcond, base, members, variant= s, + features): # Nothing to do for the special empty builtin if name =3D=3D 'q_empty': return diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index fd356151d2..484ebb66ad 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -324,7 +324,8 @@ class QAPISchemaGenVisitVisitor(QAPISchemaModularCVisit= or): self._genh.add(gen_visit_decl(name)) self._genc.add(gen_visit_list(name, element_type)) =20 - def visit_object_type(self, name, info, ifcond, base, members, variant= s): + def visit_object_type(self, name, info, ifcond, base, members, variant= s, + features): # Nothing to do for the special empty builtin if name =3D=3D 'q_empty': return diff --git a/tests/qapi-schema/double-type.err b/tests/qapi-schema/double-t= ype.err index 799193dba1..69457173a7 100644 --- a/tests/qapi-schema/double-type.err +++ b/tests/qapi-schema/double-type.err @@ -1,2 +1,2 @@ tests/qapi-schema/double-type.json:2: Unknown key 'command' in struct 'bar' -Valid keys are 'base', 'data', 'if', 'struct'. +Valid keys are 'base', 'data', 'features', 'if', 'struct'. diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py index d21fca01fc..f2d6815c86 100644 --- a/tests/qapi-schema/test-qapi.py +++ b/tests/qapi-schema/test-qapi.py @@ -38,7 +38,8 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor): print('array %s %s' % (name, element_type.name)) self._print_if(ifcond) =20 - def visit_object_type(self, name, info, ifcond, base, members, variant= s): + def visit_object_type(self, name, info, ifcond, base, members, variant= s, + features): print('object %s' % name) if base: print(' base %s' % base.name) diff --git a/tests/qapi-schema/unknown-expr-key.err b/tests/qapi-schema/unk= nown-expr-key.err index 6ff8bb99c5..4340eaf894 100644 --- a/tests/qapi-schema/unknown-expr-key.err +++ b/tests/qapi-schema/unknown-expr-key.err @@ -1,2 +1,2 @@ tests/qapi-schema/unknown-expr-key.json:2: Unknown keys 'bogus', 'phony' i= n struct 'bar' -Valid keys are 'base', 'data', 'if', 'struct'. +Valid keys are 'base', 'data', 'features', 'if', 'struct'. --=20 2.21.0 From nobody Thu Mar 28 08:32:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560359370; cv=none; d=zoho.com; s=zohoarc; b=IYiDmH3a8wwHu+sLu6bCSC+mixlfiebyUcWcs6IHdVUvEBijii2e2kp3K9cM4kNB/qwYvYcrm6KXGSODWdry+rD7Oi4qnnWaNUjNh3lwxrYUGbEZCp2N6vqRxMUnMdx9doq0Kk9dGng5trtQZ+LQzHe2Lmf+ahydgiZX+jvaAP8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560359370; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ORE4S2T1lH9VM7g+jGzbHmbBDlHTOpU+IT5TSME00qA=; b=QClXQ3YLuFI+2dnqmyPky8LA2gRDpUE6mzKS3twtVgKsGD/JkIk+NsU6nwKBzzZrluqMazE4ilKYU/kGSrFw9kw4+hByJkxMgetuXCWsHxhLgoVI4LQqSAIVvHhS+GQzVTZmWiN7PF/wwShArcosoSMbNOUpUAvAISgSAwavcZY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560359370373114.66141141105822; Wed, 12 Jun 2019 10:09:30 -0700 (PDT) Received: from localhost ([::1]:33952 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb6kT-0002oO-BL for importer@patchew.org; Wed, 12 Jun 2019 13:09:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57863) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb6UM-0007Qs-AV for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:52:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hb6UI-0006FS-QU for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:52:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57976) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hb6UG-0006Ab-6J for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:52:36 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D52A330001DA for ; Wed, 12 Jun 2019 16:52:32 +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 7E90851C60; Wed, 12 Jun 2019 16:52:32 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id AA6BE11384AA; Wed, 12 Jun 2019 18:52:29 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 12 Jun 2019 18:52:24 +0200 Message-Id: <20190612165229.26976-7-armbru@redhat.com> In-Reply-To: <20190612165229.26976-1-armbru@redhat.com> References: <20190612165229.26976-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 12 Jun 2019 16:52:32 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 06/11] tests/qapi-schema: Test for good feature lists in structs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Kevin Wolf Signed-off-by: Kevin Wolf Message-Id: <20190606153803.5278-3-armbru@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- tests/qapi-schema/qapi-schema-test.json | 39 ++++++++++++++++++++++ tests/qapi-schema/qapi-schema-test.out | 43 +++++++++++++++++++++++++ tests/qapi-schema/test-qapi.py | 4 +++ tests/test-qmp-cmds.c | 8 +++++ 4 files changed, 94 insertions(+) diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index 0952c68734..c6d59acc3e 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -242,3 +242,42 @@ { 'foo': 'TestIfStruct', 'bar': { 'type': ['TestIfEnum'], 'if': 'defined(TEST_IF_EVT_BAR)' } }, 'if': 'defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)' } + +# test 'features' for structs + +{ 'struct': 'FeatureStruct0', + 'data': { 'foo': 'int' }, + 'features': [] } +{ 'struct': 'FeatureStruct1', + 'data': { 'foo': 'int' }, + 'features': [ 'feature1' ] } +{ 'struct': 'FeatureStruct2', + 'data': { 'foo': 'int' }, + 'features': [ { 'name': 'feature1' } ] } +{ 'struct': 'FeatureStruct3', + 'data': { 'foo': 'int' }, + 'features': [ 'feature1', 'feature2' ] } +{ 'struct': 'FeatureStruct4', + 'data': { 'namespace-test': 'int' }, + 'features': [ 'namespace-test', 'int', 'name', 'if' ] } + +{ 'struct': 'CondFeatureStruct1', + 'data': { 'foo': 'int' }, + 'features': [ { 'name': 'feature1', 'if': 'defined(TEST_IF_FEATURE_1)'} = ] } +{ 'struct': 'CondFeatureStruct2', + 'data': { 'foo': 'int' }, + 'features': [ { 'name': 'feature1', 'if': 'defined(TEST_IF_FEATURE_1)'}, + { 'name': 'feature2', 'if': 'defined(TEST_IF_FEATURE_2)'} = ] } +{ 'struct': 'CondFeatureStruct3', + 'data': { 'foo': 'int' }, + 'features': [ { 'name': 'feature1', 'if': [ 'defined(TEST_IF_COND_1)', + 'defined(TEST_IF_COND_2)'] }= ] } +{ 'command': 'test-features', + 'data': { 'fs0': 'FeatureStruct0', + 'fs1': 'FeatureStruct1', + 'fs2': 'FeatureStruct2', + 'fs3': 'FeatureStruct3', + 'fs4': 'FeatureStruct4', + 'cfs1': 'CondFeatureStruct1', + 'cfs2': 'CondFeatureStruct2', + 'cfs3': 'CondFeatureStruct3' } } diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 77fb1e1aa9..85d510bc00 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -354,3 +354,46 @@ object q_obj_TestIfEvent-arg event TestIfEvent q_obj_TestIfEvent-arg boxed=3DFalse if ['defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)'] +object FeatureStruct0 + member foo: int optional=3DFalse +object FeatureStruct1 + member foo: int optional=3DFalse + feature feature1 +object FeatureStruct2 + member foo: int optional=3DFalse + feature feature1 +object FeatureStruct3 + member foo: int optional=3DFalse + feature feature1 + feature feature2 +object FeatureStruct4 + member namespace-test: int optional=3DFalse + feature namespace-test + feature int + feature name + feature if +object CondFeatureStruct1 + member foo: int optional=3DFalse + feature feature1 + if ['defined(TEST_IF_FEATURE_1)'] +object CondFeatureStruct2 + member foo: int optional=3DFalse + feature feature1 + if ['defined(TEST_IF_FEATURE_1)'] + feature feature2 + if ['defined(TEST_IF_FEATURE_2)'] +object CondFeatureStruct3 + member foo: int optional=3DFalse + feature feature1 + if ['defined(TEST_IF_COND_1)', 'defined(TEST_IF_COND_2)'] +object q_obj_test-features-arg + member fs0: FeatureStruct0 optional=3DFalse + member fs1: FeatureStruct1 optional=3DFalse + member fs2: FeatureStruct2 optional=3DFalse + member fs3: FeatureStruct3 optional=3DFalse + member fs4: FeatureStruct4 optional=3DFalse + member cfs1: CondFeatureStruct1 optional=3DFalse + member cfs2: CondFeatureStruct2 optional=3DFalse + member cfs3: CondFeatureStruct3 optional=3DFalse +command test-features q_obj_test-features-arg -> None + gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py index f2d6815c86..b0f770b9bd 100644 --- a/tests/qapi-schema/test-qapi.py +++ b/tests/qapi-schema/test-qapi.py @@ -49,6 +49,10 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor): self._print_if(m.ifcond, 8) self._print_variants(variants) self._print_if(ifcond) + if features: + for f in features: + print(' feature %s' % f.name) + self._print_if(f.ifcond, 8) =20 def visit_alternate_type(self, name, info, ifcond, variants): print('alternate %s' % name) diff --git a/tests/test-qmp-cmds.c b/tests/test-qmp-cmds.c index f0b95dcbc3..ab389f42da 100644 --- a/tests/test-qmp-cmds.c +++ b/tests/test-qmp-cmds.c @@ -43,6 +43,14 @@ void qmp_user_def_cmd1(UserDefOne * ud1, Error **errp) { } =20 +void qmp_test_features(FeatureStruct0 *fs0, FeatureStruct1 *fs1, + FeatureStruct2 *fs2, FeatureStruct3 *fs3, + FeatureStruct4 *fs4, CondFeatureStruct1 *cfs1, + CondFeatureStruct2 *cfs2, CondFeatureStruct3 *cfs3, + Error **errp) +{ +} + UserDefTwo *qmp_user_def_cmd2(UserDefOne *ud1a, bool has_udb1, UserDefOne *ud1b, Error **errp) --=20 2.21.0 From nobody Thu Mar 28 08:32:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560358979; cv=none; d=zoho.com; s=zohoarc; b=H9ewYlp3gexQ7ZCOFKdKVwIemnP/pVBmVZhtBV7PtfmOIqwZXIk27ABbF6Rk00wT0S4EURxwo6ourGETgPLP9T8vXSTnxaWQjBuPb9yPBhfdAni2uHZOR83/fA5X52tqzD1DgcVJS/YFWgtIA2+ztVS31FBnJUzkpkU0HoyX8/I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560358979; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=NsKrNG8BWRdMBaOD0vbYs036NRoLNT4OfXx3N8uHXU8=; b=IXC9TZSWQOCK+dVUlpEFVolrvewNfmwWjMP/Lx2HgFRqX8WWTirw3vQ05ilGTq4sJaCBJti9lFHdleo3A+MqM9m7u1KcUQzb8m3falpyXM+hdqqyAd4VTtF74LIukNZbWtxbBDX+Ffe9qoSZl0qwVWn8aHHnWPsEu61Lg1mNrb0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 156035897919012.644324362208181; Wed, 12 Jun 2019 10:02:59 -0700 (PDT) Received: from localhost ([::1]:33876 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb6eC-0005Mi-T1 for importer@patchew.org; Wed, 12 Jun 2019 13:02:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57929) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb6Ue-0007TU-1W for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:53:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hb6Ub-0006YI-TH for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:52:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35098) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hb6UW-0006Fq-MJ for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:52:55 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DFA6330872C2 for ; Wed, 12 Jun 2019 16:52:33 +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 7ED9F600CC; Wed, 12 Jun 2019 16:52:32 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B030711384DA; Wed, 12 Jun 2019 18:52:29 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 12 Jun 2019 18:52:25 +0200 Message-Id: <20190612165229.26976-8-armbru@redhat.com> In-Reply-To: <20190612165229.26976-1-armbru@redhat.com> References: <20190612165229.26976-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 12 Jun 2019 16:52:33 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 07/11] tests/qapi-schema: Error case tests for features in structs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Kevin Wolf Signed-off-by: Kevin Wolf Message-Id: <20190606153803.5278-4-armbru@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- tests/Makefile.include | 6 ++++++ tests/qapi-schema/features-bad-type.err | 1 + tests/qapi-schema/features-bad-type.exit | 1 + tests/qapi-schema/features-bad-type.json | 3 +++ tests/qapi-schema/features-bad-type.out | 0 tests/qapi-schema/features-duplicate-name.err | 1 + tests/qapi-schema/features-duplicate-name.exit | 1 + tests/qapi-schema/features-duplicate-name.json | 3 +++ tests/qapi-schema/features-duplicate-name.out | 0 tests/qapi-schema/features-missing-name.err | 1 + tests/qapi-schema/features-missing-name.exit | 1 + tests/qapi-schema/features-missing-name.json | 3 +++ tests/qapi-schema/features-missing-name.out | 0 tests/qapi-schema/features-name-bad-type.err | 1 + tests/qapi-schema/features-name-bad-type.exit | 1 + tests/qapi-schema/features-name-bad-type.json | 3 +++ tests/qapi-schema/features-name-bad-type.out | 0 tests/qapi-schema/features-no-list.err | 1 + tests/qapi-schema/features-no-list.exit | 1 + tests/qapi-schema/features-no-list.json | 3 +++ tests/qapi-schema/features-no-list.out | 0 tests/qapi-schema/features-unknown-key.err | 2 ++ tests/qapi-schema/features-unknown-key.exit | 1 + tests/qapi-schema/features-unknown-key.json | 3 +++ tests/qapi-schema/features-unknown-key.out | 0 25 files changed, 37 insertions(+) create mode 100644 tests/qapi-schema/features-bad-type.err create mode 100644 tests/qapi-schema/features-bad-type.exit create mode 100644 tests/qapi-schema/features-bad-type.json create mode 100644 tests/qapi-schema/features-bad-type.out create mode 100644 tests/qapi-schema/features-duplicate-name.err create mode 100644 tests/qapi-schema/features-duplicate-name.exit create mode 100644 tests/qapi-schema/features-duplicate-name.json create mode 100644 tests/qapi-schema/features-duplicate-name.out create mode 100644 tests/qapi-schema/features-missing-name.err create mode 100644 tests/qapi-schema/features-missing-name.exit create mode 100644 tests/qapi-schema/features-missing-name.json create mode 100644 tests/qapi-schema/features-missing-name.out create mode 100644 tests/qapi-schema/features-name-bad-type.err create mode 100644 tests/qapi-schema/features-name-bad-type.exit create mode 100644 tests/qapi-schema/features-name-bad-type.json create mode 100644 tests/qapi-schema/features-name-bad-type.out create mode 100644 tests/qapi-schema/features-no-list.err create mode 100644 tests/qapi-schema/features-no-list.exit create mode 100644 tests/qapi-schema/features-no-list.json create mode 100644 tests/qapi-schema/features-no-list.out create mode 100644 tests/qapi-schema/features-unknown-key.err create mode 100644 tests/qapi-schema/features-unknown-key.exit create mode 100644 tests/qapi-schema/features-unknown-key.json create mode 100644 tests/qapi-schema/features-unknown-key.out diff --git a/tests/Makefile.include b/tests/Makefile.include index 0cd5f465b7..db750dd6d0 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -378,6 +378,12 @@ qapi-schema +=3D event-boxed-empty.json qapi-schema +=3D event-case.json qapi-schema +=3D event-member-invalid-dict.json qapi-schema +=3D event-nest-struct.json +qapi-schema +=3D features-bad-type.json +qapi-schema +=3D features-duplicate-name.json +qapi-schema +=3D features-missing-name.json +qapi-schema +=3D features-name-bad-type.json +qapi-schema +=3D features-no-list.json +qapi-schema +=3D features-unknown-key.json qapi-schema +=3D flat-union-array-branch.json qapi-schema +=3D flat-union-bad-base.json qapi-schema +=3D flat-union-bad-discriminator.json diff --git a/tests/qapi-schema/features-bad-type.err b/tests/qapi-schema/fe= atures-bad-type.err new file mode 100644 index 0000000000..5fb95c2f90 --- /dev/null +++ b/tests/qapi-schema/features-bad-type.err @@ -0,0 +1 @@ +tests/qapi-schema/features-bad-type.json:1: Feature of struct FeatureStruc= t0 requires a string name diff --git a/tests/qapi-schema/features-bad-type.exit b/tests/qapi-schema/f= eatures-bad-type.exit new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/tests/qapi-schema/features-bad-type.exit @@ -0,0 +1 @@ +1 diff --git a/tests/qapi-schema/features-bad-type.json b/tests/qapi-schema/f= eatures-bad-type.json new file mode 100644 index 0000000000..57db5540e7 --- /dev/null +++ b/tests/qapi-schema/features-bad-type.json @@ -0,0 +1,3 @@ +{ 'struct': 'FeatureStruct0', + 'data': { 'foo': 'int' }, + 'features': [ [ 'a feature cannot be an array' ] ] } diff --git a/tests/qapi-schema/features-bad-type.out b/tests/qapi-schema/fe= atures-bad-type.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qapi-schema/features-duplicate-name.err b/tests/qapi-sch= ema/features-duplicate-name.err new file mode 100644 index 0000000000..c0a4cccae6 --- /dev/null +++ b/tests/qapi-schema/features-duplicate-name.err @@ -0,0 +1 @@ +tests/qapi-schema/features-duplicate-name.json:1: 'foo' (feature of Featur= eStruct0) collides with 'foo' (feature of FeatureStruct0) diff --git a/tests/qapi-schema/features-duplicate-name.exit b/tests/qapi-sc= hema/features-duplicate-name.exit new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/tests/qapi-schema/features-duplicate-name.exit @@ -0,0 +1 @@ +1 diff --git a/tests/qapi-schema/features-duplicate-name.json b/tests/qapi-sc= hema/features-duplicate-name.json new file mode 100644 index 0000000000..29358e6220 --- /dev/null +++ b/tests/qapi-schema/features-duplicate-name.json @@ -0,0 +1,3 @@ +{ 'struct': 'FeatureStruct0', + 'data': { 'foo': 'int' }, + 'features': [ 'foo', 'bar', 'foo' ] } diff --git a/tests/qapi-schema/features-duplicate-name.out b/tests/qapi-sch= ema/features-duplicate-name.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qapi-schema/features-missing-name.err b/tests/qapi-schem= a/features-missing-name.err new file mode 100644 index 0000000000..4f1d2715aa --- /dev/null +++ b/tests/qapi-schema/features-missing-name.err @@ -0,0 +1 @@ +tests/qapi-schema/features-missing-name.json:1: Key 'name' is missing from= feature of struct FeatureStruct0 diff --git a/tests/qapi-schema/features-missing-name.exit b/tests/qapi-sche= ma/features-missing-name.exit new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/tests/qapi-schema/features-missing-name.exit @@ -0,0 +1 @@ +1 diff --git a/tests/qapi-schema/features-missing-name.json b/tests/qapi-sche= ma/features-missing-name.json new file mode 100644 index 0000000000..2314f97c00 --- /dev/null +++ b/tests/qapi-schema/features-missing-name.json @@ -0,0 +1,3 @@ +{ 'struct': 'FeatureStruct0', + 'data': { 'foo': 'int' }, + 'features': [ { 'if': 'defined(NAMELESS_FEATURES)' } ] } diff --git a/tests/qapi-schema/features-missing-name.out b/tests/qapi-schem= a/features-missing-name.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qapi-schema/features-name-bad-type.err b/tests/qapi-sche= ma/features-name-bad-type.err new file mode 100644 index 0000000000..8a3eecb972 --- /dev/null +++ b/tests/qapi-schema/features-name-bad-type.err @@ -0,0 +1 @@ +tests/qapi-schema/features-name-bad-type.json:1: Feature of struct Feature= Struct0 requires a string name diff --git a/tests/qapi-schema/features-name-bad-type.exit b/tests/qapi-sch= ema/features-name-bad-type.exit new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/tests/qapi-schema/features-name-bad-type.exit @@ -0,0 +1 @@ +1 diff --git a/tests/qapi-schema/features-name-bad-type.json b/tests/qapi-sch= ema/features-name-bad-type.json new file mode 100644 index 0000000000..b07139978a --- /dev/null +++ b/tests/qapi-schema/features-name-bad-type.json @@ -0,0 +1,3 @@ +{ 'struct': 'FeatureStruct0', + 'data': { 'foo': 'int' }, + 'features': [ { 'name': { 'feature-type': 'object' } } ] } diff --git a/tests/qapi-schema/features-name-bad-type.out b/tests/qapi-sche= ma/features-name-bad-type.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qapi-schema/features-no-list.err b/tests/qapi-schema/fea= tures-no-list.err new file mode 100644 index 0000000000..61ed68612b --- /dev/null +++ b/tests/qapi-schema/features-no-list.err @@ -0,0 +1 @@ +tests/qapi-schema/features-no-list.json:1: Struct 'FeatureStruct0' require= s an array for 'features' diff --git a/tests/qapi-schema/features-no-list.exit b/tests/qapi-schema/fe= atures-no-list.exit new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/tests/qapi-schema/features-no-list.exit @@ -0,0 +1 @@ +1 diff --git a/tests/qapi-schema/features-no-list.json b/tests/qapi-schema/fe= atures-no-list.json new file mode 100644 index 0000000000..9484fd94fc --- /dev/null +++ b/tests/qapi-schema/features-no-list.json @@ -0,0 +1,3 @@ +{ 'struct': 'FeatureStruct0', + 'data': { 'foo': 'int' }, + 'features': 'bar' } diff --git a/tests/qapi-schema/features-no-list.out b/tests/qapi-schema/fea= tures-no-list.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qapi-schema/features-unknown-key.err b/tests/qapi-schema= /features-unknown-key.err new file mode 100644 index 0000000000..a1d693030d --- /dev/null +++ b/tests/qapi-schema/features-unknown-key.err @@ -0,0 +1,2 @@ +tests/qapi-schema/features-unknown-key.json:1: Unknown key 'colour' in fea= ture of struct FeatureStruct0 +Valid keys are 'if', 'name'. diff --git a/tests/qapi-schema/features-unknown-key.exit b/tests/qapi-schem= a/features-unknown-key.exit new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/tests/qapi-schema/features-unknown-key.exit @@ -0,0 +1 @@ +1 diff --git a/tests/qapi-schema/features-unknown-key.json b/tests/qapi-schem= a/features-unknown-key.json new file mode 100644 index 0000000000..134df3b503 --- /dev/null +++ b/tests/qapi-schema/features-unknown-key.json @@ -0,0 +1,3 @@ +{ 'struct': 'FeatureStruct0', + 'data': { 'foo': 'int' }, + 'features': [ { 'name': 'bar', 'colour': 'red' } ] } diff --git a/tests/qapi-schema/features-unknown-key.out b/tests/qapi-schema= /features-unknown-key.out new file mode 100644 index 0000000000..e69de29bb2 --=20 2.21.0 From nobody Thu Mar 28 08:32:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560359559; cv=none; d=zoho.com; s=zohoarc; b=HxfcQlY7FXUovXyM+vhhg2HBQ3un2AW+ArjmhE+lfatJNrHO+M4qvVKGsfvSlgH3k6jrdONqMgCDfmtKWgSifSTq6YyuF3AUNvzEbjhkp0joXJxUlmlt53t7olj279KS8+GdQOuVBsvAPWj+Fez9JcS1wNEeMP9/vCHuNoR+pAM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560359559; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=OeAAHI2PygTSnDnyhC6RjNA3TcgU0wjto43ErnHKW84=; b=Zj1Ss2D99IiHCgEByao92lEyrX6C51qRqtRvcQS6V3CS3Mkrg9XDyA3CeBLvSQgtylym0Jg4r3ukcCYM6xeUYwScMejlDI1cp40DuDN+A1WhlYP0e4kMJvpO13hnY7mbqcUEg+nfeE72q7zXzjyLV7GQU3N87nIKdNhQXjg9Kyw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560359559816767.9122632559328; Wed, 12 Jun 2019 10:12:39 -0700 (PDT) Received: from localhost ([::1]:33970 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb6na-0006UK-1M for importer@patchew.org; Wed, 12 Jun 2019 13:12:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57874) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb6UP-0007Qu-Ri for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:52:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hb6UK-0006I7-Q5 for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:52:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59144) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hb6UG-0006Ac-ND for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:52:38 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D99592F8BF2 for ; Wed, 12 Jun 2019 16:52:32 +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 81AB46014E; Wed, 12 Jun 2019 16:52:32 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B75961136420; Wed, 12 Jun 2019 18:52:29 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 12 Jun 2019 18:52:26 +0200 Message-Id: <20190612165229.26976-9-armbru@redhat.com> In-Reply-To: <20190612165229.26976-1-armbru@redhat.com> References: <20190612165229.26976-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 12 Jun 2019 16:52:32 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 08/11] qapi: Disentangle QAPIDoc code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Kevin Wolf Documentation comments follow a certain structure: First, we have a text with a general description (called QAPIDoc.body). After this, descriptions of the arguments follow. Finally, we have a part that contains various named sections. The code doesn't show this structure, but just checks various attributes that indicate indirectly which part is being processed, so it happens to do the right set of things in the right phase. This is hard to follow, and adding support for documentation of features would be even harder. This patch restructures the code so that the three parts are clearly separated. The code becomes a bit longer, but easier to follow. The resulting output remains unchanged. Signed-off-by: Kevin Wolf Message-Id: <20190606153803.5278-5-armbru@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- scripts/qapi/common.py | 127 +++++++++++++++++++++++++++++++++-------- 1 file changed, 102 insertions(+), 25 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 9e4b6c00b5..f40a2cd4c5 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -120,6 +120,24 @@ class QAPIDoc(object): def connect(self, member): self.member =3D member =20 + class DocPart: + """ + Describes which part of the documentation we're parsing right now. + + Expression documentation blocks consist of + * a BODY part: first line naming the expression, plus an + optional overview + * an ARGS part: description of each argument (for commands and + events) or member (for structs, unions and alternates), + * a VARIOUS part: optional tagged sections. + + Free-form documentation blocks consist only of a BODY part. + """ + # TODO Make it a subclass of Enum when Python 2 support is removed + BODY =3D 1 + ARGS =3D 2 + VARIOUS =3D 3 + def __init__(self, parser, info): # self._parser is used to report errors with QAPIParseError. The # resulting error position depends on the state of the parser. @@ -135,6 +153,7 @@ class QAPIDoc(object): self.sections =3D [] # the current section self._section =3D self.body + self._part =3D QAPIDoc.DocPart.BODY =20 def has_section(self, name): """Return True if we have a section with this name.""" @@ -144,7 +163,27 @@ class QAPIDoc(object): return False =20 def append(self, line): - """Parse a comment line and add it to the documentation.""" + """ + Parse a comment line and add it to the documentation. + + The way that the line is dealt with depends on which part of + the documentation we're parsing right now: + + BODY means that we're ready to process free-form text into + self.body. A symbol name is only allowed if no other text was + parsed yet. It is interpreted as the symbol name that + describes the currently documented object. On getting the + second symbol name, we proceed to ARGS. + + ARGS means that we're parsing the arguments section. Any + symbol name is interpreted as an argument and an ArgSection is + created for it. + + VARIOUS is the final part where free-form sections may appear. + This includes named sections such as "Return:" as well as + unnamed paragraphs. Symbols are not allowed any more in this + part. + """ line =3D line[1:] if not line: self._append_freeform(line) @@ -154,37 +193,85 @@ class QAPIDoc(object): raise QAPIParseError(self._parser, "Missing space after #") line =3D line[1:] =20 + if self._part =3D=3D QAPIDoc.DocPart.BODY: + self._append_body_line(line) + elif self._part =3D=3D QAPIDoc.DocPart.ARGS: + self._append_args_line(line) + elif self._part =3D=3D QAPIDoc.DocPart.VARIOUS: + self._append_various_line(line) + else: + assert False + + def end_comment(self): + self._end_section() + + @staticmethod + def _is_section_tag(name): + return name in ('Returns:', 'Since:', + # those are often singular or plural + 'Note:', 'Notes:', + 'Example:', 'Examples:', + 'TODO:') + + def _append_body_line(self, line): + name =3D line.split(' ', 1)[0] # FIXME not nice: things like '# @foo:' and '# @foo: ' aren't # recognized, and get silently treated as ordinary text - if self.symbol: - self._append_symbol_line(line) - elif not self.body.text and line.startswith('@'): + if not self.symbol and not self.body.text and line.startswith('@'): if not line.endswith(':'): raise QAPIParseError(self._parser, "Line should end with := ") self.symbol =3D line[1:-1] # FIXME invalid names other than the empty string aren't flagg= ed if not self.symbol: raise QAPIParseError(self._parser, "Invalid name") + elif self.symbol: + # We already know that we document some symbol + if name.startswith('@') and name.endswith(':'): + self._part =3D QAPIDoc.DocPart.ARGS + self._append_args_line(line) + elif self._is_section_tag(name): + self._part =3D QAPIDoc.DocPart.VARIOUS + self._append_various_line(line) + else: + self._append_freeform(line.strip()) else: - self._append_freeform(line) + # This is free-form documentation without a symbol + self._append_freeform(line.strip()) =20 - def end_comment(self): - self._end_section() - - def _append_symbol_line(self, line): + def _append_args_line(self, line): name =3D line.split(' ', 1)[0] =20 if name.startswith('@') and name.endswith(':'): line =3D line[len(name)+1:] self._start_args_section(name[1:-1]) - elif name in ('Returns:', 'Since:', - # those are often singular or plural - 'Note:', 'Notes:', - 'Example:', 'Examples:', - 'TODO:'): + elif self._is_section_tag(name): + self._part =3D QAPIDoc.DocPart.VARIOUS + self._append_various_line(line) + return + elif (self._section.text.endswith('\n\n') + and line and not line[0].isspace()): + self._start_section() + self._part =3D QAPIDoc.DocPart.VARIOUS + self._append_various_line(line) + return + + self._append_freeform(line.strip()) + + def _append_various_line(self, line): + name =3D line.split(' ', 1)[0] + + if name.startswith('@') and name.endswith(':'): + raise QAPIParseError(self._parser, + "'%s' can't follow '%s' section" + % (name, self.sections[0].name)) + elif self._is_section_tag(name): line =3D line[len(name)+1:] self._start_section(name[:-1]) =20 + if (not self._section.name or + not self._section.name.startswith('Example')): + line =3D line.strip() + self._append_freeform(line) =20 def _start_args_section(self, name): @@ -194,10 +281,7 @@ class QAPIDoc(object): if name in self.args: raise QAPIParseError(self._parser, "'%s' parameter name duplicated" % name) - if self.sections: - raise QAPIParseError(self._parser, - "'@%s:' can't follow '%s' section" - % (name, self.sections[0].name)) + assert not self.sections self._end_section() self._section =3D QAPIDoc.ArgSection(name) self.args[name] =3D self._section @@ -219,13 +303,6 @@ class QAPIDoc(object): self._section =3D None =20 def _append_freeform(self, line): - in_arg =3D isinstance(self._section, QAPIDoc.ArgSection) - if (in_arg and self._section.text.endswith('\n\n') - and line and not line[0].isspace()): - self._start_section() - if (in_arg or not self._section.name - or not self._section.name.startswith('Example')): - line =3D line.strip() match =3D re.match(r'(@\S+:)', line) if match: raise QAPIParseError(self._parser, --=20 2.21.0 From nobody Thu Mar 28 08:32:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560359696; cv=none; d=zoho.com; s=zohoarc; b=EBCU4Sfxy0UxCYsF9E88EhkU/vh57difEosYcsGV8AAcS+//8RU06t62nU+oSdryHNk9PyhYLAHKzIiEr8goVLId2iXzThTUt36suhgEVCaJO2eLWSSZKJchX/qsdWbk03bzi8v3HbhwDrY3jIL9zMBgwoY+DzWWiu0CJhLA3FM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560359696; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Ruw5rPQBoYzwTgZoJW4PtWFGGbm+SJO64EeqDw2HOXU=; b=RyR0rf5IOmM+ehb6cy/wToNPdT10VMhf+7UXHk/AciPXETt5nEQ7rEhbt5/wmEI2ReFPN25Eudtxc1v8WIikLCO0E74i4ro1PUAcEdhYQ3gytGKiOoeFpmySe5OESYJ6MqpddSPZXueX57eTDch45LOt0O9jDQax3E28LZWhNCA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156035969675168.36920997724667; Wed, 12 Jun 2019 10:14:56 -0700 (PDT) Received: from localhost ([::1]:34000 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb6po-0000gg-Ou for importer@patchew.org; Wed, 12 Jun 2019 13:14:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57966) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb6Ug-0007U9-0p for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:53:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hb6Ue-0006dK-2w for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:53:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56432) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hb6Uc-0006ET-0Q for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:52:59 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DD2413086232 for ; Wed, 12 Jun 2019 16:52:32 +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 87E261FC; Wed, 12 Jun 2019 16:52:32 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id BABA01136421; Wed, 12 Jun 2019 18:52:29 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 12 Jun 2019 18:52:27 +0200 Message-Id: <20190612165229.26976-10-armbru@redhat.com> In-Reply-To: <20190612165229.26976-1-armbru@redhat.com> References: <20190612165229.26976-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 12 Jun 2019 16:52:32 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 09/11] qapi: Allow documentation for features X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Kevin Wolf Features will be documented in a new part introduced by a "Features:" line, after arguments and before named sections. Signed-off-by: Kevin Wolf Message-Id: <20190606153803.5278-6-armbru@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- scripts/qapi/common.py | 43 ++++++++++++++++++++++++++++++++++++++---- scripts/qapi/doc.py | 12 ++++++++++++ 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index f40a2cd4c5..1164301edf 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -129,6 +129,7 @@ class QAPIDoc(object): optional overview * an ARGS part: description of each argument (for commands and events) or member (for structs, unions and alternates), + * a FEATURES part: description of each feature, * a VARIOUS part: optional tagged sections. =20 Free-form documentation blocks consist only of a BODY part. @@ -136,7 +137,8 @@ class QAPIDoc(object): # TODO Make it a subclass of Enum when Python 2 support is removed BODY =3D 1 ARGS =3D 2 - VARIOUS =3D 3 + FEATURES =3D 3 + VARIOUS =3D 4 =20 def __init__(self, parser, info): # self._parser is used to report errors with QAPIParseError. The @@ -149,6 +151,7 @@ class QAPIDoc(object): self.body =3D QAPIDoc.Section() # dict mapping parameter name to ArgSection self.args =3D OrderedDict() + self.features =3D OrderedDict() # a list of Section self.sections =3D [] # the current section @@ -197,6 +200,8 @@ class QAPIDoc(object): self._append_body_line(line) elif self._part =3D=3D QAPIDoc.DocPart.ARGS: self._append_args_line(line) + elif self._part =3D=3D QAPIDoc.DocPart.FEATURES: + self._append_features_line(line) elif self._part =3D=3D QAPIDoc.DocPart.VARIOUS: self._append_various_line(line) else: @@ -229,6 +234,8 @@ class QAPIDoc(object): if name.startswith('@') and name.endswith(':'): self._part =3D QAPIDoc.DocPart.ARGS self._append_args_line(line) + elif line =3D=3D 'Features:': + self._part =3D QAPIDoc.DocPart.FEATURES elif self._is_section_tag(name): self._part =3D QAPIDoc.DocPart.VARIOUS self._append_various_line(line) @@ -248,6 +255,28 @@ class QAPIDoc(object): self._part =3D QAPIDoc.DocPart.VARIOUS self._append_various_line(line) return + elif (self._section.text.endswith('\n\n') + and line and not line[0].isspace()): + if line =3D=3D 'Features:': + self._part =3D QAPIDoc.DocPart.FEATURES + else: + self._start_section() + self._part =3D QAPIDoc.DocPart.VARIOUS + self._append_various_line(line) + return + + self._append_freeform(line.strip()) + + def _append_features_line(self, line): + name =3D line.split(' ', 1)[0] + + if name.startswith('@') and name.endswith(':'): + line =3D line[len(name)+1:] + self._start_features_section(name[1:-1]) + elif self._is_section_tag(name): + self._part =3D QAPIDoc.DocPart.VARIOUS + self._append_various_line(line) + return elif (self._section.text.endswith('\n\n') and line and not line[0].isspace()): self._start_section() @@ -274,17 +303,23 @@ class QAPIDoc(object): =20 self._append_freeform(line) =20 - def _start_args_section(self, name): + def _start_symbol_section(self, symbols_dict, name): # FIXME invalid names other than the empty string aren't flagged if not name: raise QAPIParseError(self._parser, "Invalid parameter name") - if name in self.args: + if name in symbols_dict: raise QAPIParseError(self._parser, "'%s' parameter name duplicated" % name) assert not self.sections self._end_section() self._section =3D QAPIDoc.ArgSection(name) - self.args[name] =3D self._section + symbols_dict[name] =3D self._section + + def _start_args_section(self, name): + self._start_symbol_section(self.args, name) + + def _start_features_section(self, name): + self._start_symbol_section(self.features, name) =20 def _start_section(self, name=3DNone): if name in ('Returns', 'Since') and self.has_section(name): diff --git a/scripts/qapi/doc.py b/scripts/qapi/doc.py index 433e9fcbfb..5fc0fc7e06 100755 --- a/scripts/qapi/doc.py +++ b/scripts/qapi/doc.py @@ -182,6 +182,17 @@ def texi_members(doc, what, base, variants, member_fun= c): return '\n@b{%s:}\n@table @asis\n%s@end table\n' % (what, items) =20 =20 +def texi_features(doc): + """Format the table of features""" + items =3D '' + for section in doc.features.values(): + desc =3D texi_format(section.text) + items +=3D '@item @code{%s}\n%s' % (section.name, desc) + if not items: + return '' + return '\n@b{Features:}\n@table @asis\n%s@end table\n' % (items) + + def texi_sections(doc, ifcond): """Format additional sections following arguments""" body =3D '' @@ -201,6 +212,7 @@ def texi_entity(doc, what, ifcond, base=3DNone, variant= s=3DNone, member_func=3Dtexi_member): return (texi_body(doc) + texi_members(doc, what, base, variants, member_func) + + texi_features(doc) + texi_sections(doc, ifcond)) =20 =20 --=20 2.21.0 From nobody Thu Mar 28 08:32:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560359700; cv=none; d=zoho.com; s=zohoarc; b=CxdO3GJR7BT+GMJZBiTEW4lo8MvkpCLgUMCbF8W7B4nGj7veTbNWFefgM0rtiLrt0JiTngkf7W96eJJORtzcqxmQ503F2GYjY4LjutHIIu55HkQI1J6mR8W5SVeuBqMBiAGsusMMhf16Rx69s0dx6Yb5dOyN/1oYkLKqkvGQLO8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560359700; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=hZyMEajNdJNbqH8oBPV7zZ+rh1nr++RKZ1PU17E09fs=; b=G3/WLp0+6CuCwo3cOPMwrZlDYCf8bPrpKRtfAyXpgSjdR/ldUrz5F4wFr+nrF7VrsGlogHIXnr2DoqSd203GHdKEmAONt2wDoti0CZEPzjO5Md0MS5MFxSe1HgoAwMKeqlqC/eDhW9lKmi0VHe95ul6Zr5hJmKYroJ5w2pIYCkM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560359700177542.2604927578037; Wed, 12 Jun 2019 10:15:00 -0700 (PDT) Received: from localhost ([::1]:34002 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb6pq-0000ji-7S for importer@patchew.org; Wed, 12 Jun 2019 13:14:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57973) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb6Ug-0007UE-2U for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:53:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hb6Ud-0006ck-UY for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:53:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35092) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hb6Ub-0006EB-U1 for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:52:58 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B877D30872D0 for ; Wed, 12 Jun 2019 16:52:32 +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 871961001B11; Wed, 12 Jun 2019 16:52:32 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id BF66E1136422; Wed, 12 Jun 2019 18:52:29 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 12 Jun 2019 18:52:28 +0200 Message-Id: <20190612165229.26976-11-armbru@redhat.com> In-Reply-To: <20190612165229.26976-1-armbru@redhat.com> References: <20190612165229.26976-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 12 Jun 2019 16:52:32 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 10/11] file-posix: Add dynamic-auto-read-only QAPI feature X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Kevin Wolf In commit 23dece19da4 ('file-posix: Make auto-read-only dynamic') , auto-read-only=3Don changed its behaviour in file-posix for the 4.0 release. This change cannot be detected through the usual mechanisms like schema introspection. Add a new feature flag to the schema to allow libvirt to detect the presence of the new behaviour. Signed-off-by: Kevin Wolf Message-Id: <20190606153803.5278-7-armbru@redhat.com> Reviewed-by: Markus Armbruster [Comment tweaked on Eric Blake's advice] Signed-off-by: Markus Armbruster --- qapi/block-core.json | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 175ccfe896..fcd054fcb1 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2859,6 +2859,15 @@ # file is large, do not use in production. # (default: off) (since: 3.0) # +# Features: +# @dynamic-auto-read-only: If present, enabled auto-read-only means that t= he +# driver will open the image read-only at first, +# dynamically reopen the image file read-write wh= en +# the first writer is attached to the node and re= open +# read-only when the last writer is detached. This +# allows giving QEMU write permissions only on de= mand +# when an operation actually needs write access. +# # Since: 2.9 ## { 'struct': 'BlockdevOptionsFile', @@ -2868,7 +2877,9 @@ '*aio': 'BlockdevAioOptions', '*drop-cache': {'type': 'bool', 'if': 'defined(CONFIG_LINUX)'}, - '*x-check-cache-dropped': 'bool' } } + '*x-check-cache-dropped': 'bool' }, + 'features': [ { 'name': 'dynamic-auto-read-only', + 'if': 'defined(CONFIG_POSIX)' } ] } =20 ## # @BlockdevOptionsNull: --=20 2.21.0 From nobody Thu Mar 28 08:32:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560359613; cv=none; d=zoho.com; s=zohoarc; b=BjD27AwLk+5bmXmRhIv9H9GTzkOMrEr4DRyXMnhVcKIHPvEPBy7BqeYiC4V02SD7jrMcbK9hydaWL5Vzx+MLxxNsjsOvnyX4AXxkWExkJ9pOSXYUPb6vRwfGT6gaqSRZdFDzpJKkP/WXrXWU83pNbKKN9aBB29AZ2G3ijXRVN14= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560359613; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ggaaVifWcOiujNwRa4YG1shvdYEXtw0h0ftVmGoASQA=; b=KveOZ3qvCA17RUu8m0Acfbkm+q7yxZLjHT9ARmA1P2H3J4q7OArF7o51rHt1aJ5mdknowzi7iaz28lTRYJMbsskqxyyoYcqV4vVTshzKyt4tG1/WhZ7B3eEhymHNqZ9JD6LFTz2vcoGz4GJztmPMz8/kPg0WGlSI92tHCYSzYGM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560359613903265.0293824757182; Wed, 12 Jun 2019 10:13:33 -0700 (PDT) Received: from localhost ([::1]:33984 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb6oN-0007E5-3i for importer@patchew.org; Wed, 12 Jun 2019 13:13:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57905) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb6Ub-0007SE-RY for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:52:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hb6UU-0006SB-IS for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:52:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34658) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hb6UP-0006Ef-SF for qemu-devel@nongnu.org; Wed, 12 Jun 2019 12:52:47 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 181FBC18B2E9 for ; Wed, 12 Jun 2019 16:52:33 +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 B71FF60BF1; Wed, 12 Jun 2019 16:52:32 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C7FE41136423; Wed, 12 Jun 2019 18:52:29 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 12 Jun 2019 18:52:29 +0200 Message-Id: <20190612165229.26976-12-armbru@redhat.com> In-Reply-To: <20190612165229.26976-1-armbru@redhat.com> References: <20190612165229.26976-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 12 Jun 2019 16:52:33 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 11/11] qapi: Simplify how QAPIDoc implements its state machine X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" QAPIDoc uses a state machine to for processing of documentation lines. Its state is encoded as an enum QAPIDoc._state (well, as enum-like class actually, thanks to our infatuation with Python 2). All we ever do with the state is calling the state's function to process a line of documentation. The enum values effectively serve as handles for the functions. Eliminate the rather wordy indirection: store the function to call in QAPIDoc._append_line. Update and improve comments. Signed-off-by: Markus Armbruster Message-Id: <20190606153803.5278-8-armbru@redhat.com> Reviewed-by: Kevin Wolf [Commit message typo fixed] --- scripts/qapi/common.py | 125 ++++++++++++++++++++++------------------- 1 file changed, 68 insertions(+), 57 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 1164301edf..d61bfdc526 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -102,6 +102,24 @@ class QAPISemError(QAPIError): =20 =20 class QAPIDoc(object): + """ + A documentation comment block, either expression or free-form + + Expression documentation blocks consist of + + * a body section: one line naming the expression, followed by an + overview (any number of lines) + + * argument sections: a description of each argument (for commands + and events) or member (for structs, unions and alternates) + + * features sections: a description of each feature flag + + * additional (non-argument) sections, possibly tagged + + Free-form documentation blocks consist only of a body section. + """ + class Section(object): def __init__(self, name=3DNone): # optional section name (argument/member or section name) @@ -120,26 +138,6 @@ class QAPIDoc(object): def connect(self, member): self.member =3D member =20 - class DocPart: - """ - Describes which part of the documentation we're parsing right now. - - Expression documentation blocks consist of - * a BODY part: first line naming the expression, plus an - optional overview - * an ARGS part: description of each argument (for commands and - events) or member (for structs, unions and alternates), - * a FEATURES part: description of each feature, - * a VARIOUS part: optional tagged sections. - - Free-form documentation blocks consist only of a BODY part. - """ - # TODO Make it a subclass of Enum when Python 2 support is removed - BODY =3D 1 - ARGS =3D 2 - FEATURES =3D 3 - VARIOUS =3D 4 - def __init__(self, parser, info): # self._parser is used to report errors with QAPIParseError. The # resulting error position depends on the state of the parser. @@ -156,7 +154,7 @@ class QAPIDoc(object): self.sections =3D [] # the current section self._section =3D self.body - self._part =3D QAPIDoc.DocPart.BODY + self._append_line =3D self._append_body_line =20 def has_section(self, name): """Return True if we have a section with this name.""" @@ -171,21 +169,10 @@ class QAPIDoc(object): =20 The way that the line is dealt with depends on which part of the documentation we're parsing right now: - - BODY means that we're ready to process free-form text into - self.body. A symbol name is only allowed if no other text was - parsed yet. It is interpreted as the symbol name that - describes the currently documented object. On getting the - second symbol name, we proceed to ARGS. - - ARGS means that we're parsing the arguments section. Any - symbol name is interpreted as an argument and an ArgSection is - created for it. - - VARIOUS is the final part where free-form sections may appear. - This includes named sections such as "Return:" as well as - unnamed paragraphs. Symbols are not allowed any more in this - part. + * The body section: ._append_line is ._append_body_line + * An argument section: ._append_line is ._append_args_line + * A features section: ._append_line is ._append_features_line + * An additional section: ._append_line is ._append_various_line """ line =3D line[1:] if not line: @@ -195,17 +182,7 @@ class QAPIDoc(object): if line[0] !=3D ' ': raise QAPIParseError(self._parser, "Missing space after #") line =3D line[1:] - - if self._part =3D=3D QAPIDoc.DocPart.BODY: - self._append_body_line(line) - elif self._part =3D=3D QAPIDoc.DocPart.ARGS: - self._append_args_line(line) - elif self._part =3D=3D QAPIDoc.DocPart.FEATURES: - self._append_features_line(line) - elif self._part =3D=3D QAPIDoc.DocPart.VARIOUS: - self._append_various_line(line) - else: - assert False + self._append_line(line) =20 def end_comment(self): self._end_section() @@ -219,6 +196,19 @@ class QAPIDoc(object): 'TODO:') =20 def _append_body_line(self, line): + """ + Process a line of documentation text in the body section. + + If this a symbol line and it is the section's first line, this + is an expression documentation block for that symbol. + + If it's an expression documentation block, another symbol line + begins the argument section for the argument named by it, and + a section tag begins an additional section. Start that + section and append the line to it. + + Else, append the line to the current section. + """ name =3D line.split(' ', 1)[0] # FIXME not nice: things like '# @foo:' and '# @foo: ' aren't # recognized, and get silently treated as ordinary text @@ -230,38 +220,49 @@ class QAPIDoc(object): if not self.symbol: raise QAPIParseError(self._parser, "Invalid name") elif self.symbol: - # We already know that we document some symbol + # This is an expression documentation block if name.startswith('@') and name.endswith(':'): - self._part =3D QAPIDoc.DocPart.ARGS + self._append_line =3D self._append_args_line self._append_args_line(line) elif line =3D=3D 'Features:': - self._part =3D QAPIDoc.DocPart.FEATURES + self._append_line =3D self._append_features_line elif self._is_section_tag(name): - self._part =3D QAPIDoc.DocPart.VARIOUS + self._append_line =3D self._append_various_line self._append_various_line(line) else: self._append_freeform(line.strip()) else: - # This is free-form documentation without a symbol + # This is a free-form documentation block self._append_freeform(line.strip()) =20 def _append_args_line(self, line): + """ + Process a line of documentation text in an argument section. + + A symbol line begins the next argument section, a section tag + section or a non-indented line after a blank line begins an + additional section. Start that section and append the line to + it. + + Else, append the line to the current section. + + """ name =3D line.split(' ', 1)[0] =20 if name.startswith('@') and name.endswith(':'): line =3D line[len(name)+1:] self._start_args_section(name[1:-1]) elif self._is_section_tag(name): - self._part =3D QAPIDoc.DocPart.VARIOUS + self._append_line =3D self._append_various_line self._append_various_line(line) return elif (self._section.text.endswith('\n\n') and line and not line[0].isspace()): if line =3D=3D 'Features:': - self._part =3D QAPIDoc.DocPart.FEATURES + self._append_line =3D self._append_features_line else: self._start_section() - self._part =3D QAPIDoc.DocPart.VARIOUS + self._append_line =3D self._append_various_line self._append_various_line(line) return =20 @@ -274,19 +275,29 @@ class QAPIDoc(object): line =3D line[len(name)+1:] self._start_features_section(name[1:-1]) elif self._is_section_tag(name): - self._part =3D QAPIDoc.DocPart.VARIOUS + self._append_line =3D self._append_various_line self._append_various_line(line) return elif (self._section.text.endswith('\n\n') and line and not line[0].isspace()): self._start_section() - self._part =3D QAPIDoc.DocPart.VARIOUS + self._append_line =3D self._append_various_line self._append_various_line(line) return =20 self._append_freeform(line.strip()) =20 def _append_various_line(self, line): + """ + Process a line of documentation text in an additional section. + + A symbol line is an error. + + A section tag begins an additional section. Start that + section and append the line to it. + + Else, append the line to the current section. + """ name =3D line.split(' ', 1)[0] =20 if name.startswith('@') and name.endswith(':'): --=20 2.21.0