From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253344; cv=none; d=zohomail.com; s=zohoarc; b=iuQ8205TzjeqKqQRWrxtNklJLYU2q4CjYN3rsUpYYq0hnOMnQknn6qTOjHmFx0x+MgY3eu1vJ9Sx6GtzQ6XMty+ciOaKQ4SOiEVa8aK4TZmvwqCZ50EHtTkKYSWKNelw1QAKlfUI9Sv13VI9Ce8jNxKpcBRRQzt1v0cb4h6HNyY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253344; h=Content-Type: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; bh=iQ4eJHnp2DxKvrJF29stLYX3uThsxgfJxa46sj2Ia6g=; b=GbD4GXpU01bMx77wKc1PvX2WAHmtiyMVzBs6qTLwPUzlO2wSXFY6hM85QJJbh94kP1S4Qevhr24SvjvRekvTSvicZoBPDhJXvrjSp4asrtEgQ8Lx813fwif7iScnJtPIop+wvjlmEDRWQ+u+f1YSKR7nE0fTycIl+usDQ2MZojI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1583253344608936.4464090456851; Tue, 3 Mar 2020 08:35:44 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-120-QGgv40bmPd-nAErcZd738g-1; Tue, 03 Mar 2020 11:35:41 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4FF82801FC5; Tue, 3 Mar 2020 16:35:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2206C39B; Tue, 3 Mar 2020 16:35:35 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id BC64418089D5; Tue, 3 Mar 2020 16:35:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZAbh001153 for ; Tue, 3 Mar 2020 11:35:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id 54C7010027AB; Tue, 3 Mar 2020 16:35:10 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3C3B710013A1; Tue, 3 Mar 2020 16:35:07 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B293C11385ED; Tue, 3 Mar 2020 17:35:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253343; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=iQ4eJHnp2DxKvrJF29stLYX3uThsxgfJxa46sj2Ia6g=; b=URwD5mFO/u7TICNn9tzdTHYpLL+ZZSDpa+FKemaHUpoCBgQzm9hHg/VPpUS0rnX6JaI5n+ irztNvD2t/IemmXHQFLAKsFEaahGzg1Urvi74rBqRDnc5QsLS8dz1DZIdfqz0WpFBwN3WF khkOv8yRc0z79a9HsXS6Dw03aQcgwr8= X-MC-Unique: QGgv40bmPd-nAErcZd738g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 01/30] qemu-doc: Belatedly document QMP command arg & result deprecation Date: Tue, 3 Mar 2020 17:34:36 +0100 Message-Id: <20200303163505.32041-2-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" A number of deprecated QMP arguments and results were missed in commit eb22aeca65 "docs: document deprecation policy & deprecated features in appendix" (v2.10.0): * Commit b33945cfff "block: Accept device model name for blockdev-open/close-tray" (v2.8.0) deprecated blockdev-open-tray, blockdev-close-tray argument @device. * Commit fbe2d8163e "block: Accept device model name for eject" (v2.8.0) deprecated eject argument @device. * Commit 70e2cb3bd7 "block: Accept device model name for blockdev-change-medium" (v2.8.0) deprecated blockdev-change-medium argument @device. * Commit 7a9877a026 "block: Accept device model name for block_set_io_throttle" (v2.8.0) deprecated block_set_io_throttle argument @device. * Commit c01c214b69 "block: remove all encryption handling APIs" (v2.10.0) deprecated query-named-block-nodes result @encryption_key_missing and query-block result @inserted member @encryption_key_missing. * Commit c42e8742f5 "block: Use JSON null instead of "" to disable backing file" (v2.10.0) deprecated blockdev-add empty string argument @backing. Since then, we missed a few more: * Commit 3c605f4074 "commit: Add top-node/base-node options" (v3.1.0) deprecated block-commit arguments @base and @top. * Commit 4db6ceb0b5 "block/dirty-bitmap: add recording and busy properties" (v4.0.0) deprecated query-named-block-nodes result @dirty-bitmaps member @status, not just query-block. Make up for all that. Signed-off-by: Markus Armbruster --- qemu-deprecated.texi | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi index 66eca3a1de..b9ef56fd97 100644 --- a/qemu-deprecated.texi +++ b/qemu-deprecated.texi @@ -150,19 +150,51 @@ Use @option{-display sdl,show-cursor=3Don} or =20 Use ``blockdev-change-medium'' or ``change-vnc-password'' instead. =20 +@subsection blockdev-open-tray, blockdev-close-tray argument device (since= 2.8.0) + +Use argument ``id'' instead. + +@subsection eject argument device (since 2.8.0) + +Use argument ``id'' instead. + +@subsection blockdev-change-medium argument device (since 2.8.0) + +Use argument ``id'' instead. + +@subsection block_set_io_throttle argument device (since 2.8.0) + +Use argument ``id'' instead. + @subsection migrate_set_downtime and migrate_set_speed (since 2.8.0) =20 Use ``migrate-set-parameters'' instead. =20 +@subsection query-named-block-nodes result encryption_key_missing (since 2= .10.0) + +Always false. + +@subsection query-block result inserted.encryption_key_missing (since 2.10= .0) + +Always false. + +@subsection blockdev-add empty string argument backing (since 2.10.0) + +Use argument ``null'' instead. + @subsection migrate-set-cache-size and query-migrate-cache-size (since 2.1= 1.0) =20 Use ``migrate-set-parameters'' and ``query-migrate-parameters'' instead. =20 -@subsection query-block result field dirty-bitmaps[i].status (since 4.0) +@subsection block-commit arguments base and top (since 3.1.0) + +Use arguments ``base-node'' and ``top-node'' instead. + +@subsection query-named-block-nodes and query-block result dirty-bitmaps[i= ].status (since 4.0) =20 The ``status'' field of the ``BlockDirtyInfo'' structure, returned by -the query-block command is deprecated. Two new boolean fields, -``recording'' and ``busy'' effectively replace it. +these commands is deprecated. Two new boolean fields, ``recording'' and +``busy'' effectively replace it. =20 @subsection query-block result field dirty-bitmaps (Since 4.2) =20 --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253328; cv=none; d=zohomail.com; s=zohoarc; b=GH4BQnNL4k01Yy+gF3HvoaFsZnZqOcrDTpjmUvmcZ4Boy4C9R4ur/1bHZrjvQAVhzZGCRLBkfQWE+ClJ4MpZX6Ks871xYBpHdvi48eyE04A6h7oCeK/Pp0CKzFgEh/j/HIgWDdH7BjHlqV+PmIJnuprrEzZXMEg++7XV0M2y3yg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253328; h=Content-Type: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; bh=1rvAyJpM8UMVc6pLEJtcCaEzj3OieyggncMtCsiDiag=; b=gHaIdHNnDi+mmTGoiBImXCZq9eqQgJV3/daOqUyP3LfwDmKbQyYYHIJEKAJiSz/1TkKnwPVvE/IpAPel/nDn2R4oxtj5GtaVzvdXBq7n8N4uBFyshFbu4iYh8OuqDiA7NYii4eYu+C5vb+4pq7yG7F2K8XIc902WWziaDzxzC9A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1583253328886890.6036507306937; Tue, 3 Mar 2020 08:35:28 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-324-qRG5Ee-hOs-tdF1wyqihjg-1; Tue, 03 Mar 2020 11:35:23 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id DEB73801E7A; Tue, 3 Mar 2020 16:35:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A75E4100EBA4; Tue, 3 Mar 2020 16:35:17 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8BAF218089CD; Tue, 3 Mar 2020 16:35:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZAfT001159 for ; Tue, 3 Mar 2020 11:35:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5F7A55DA84; Tue, 3 Mar 2020 16:35:10 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 42AB05DA2C; Tue, 3 Mar 2020 16:35:07 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B4F7911385F4; Tue, 3 Mar 2020 17:35:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253325; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=1rvAyJpM8UMVc6pLEJtcCaEzj3OieyggncMtCsiDiag=; b=POuO+5TIETshUX9UAdCVgxdtDL1CbVmA+QumpcXzNwPEtfh1PVdt2P54TKnbGwLXPA/5pm 8kkICI4jpZW13YH132M8lQ0VfSkgp/NpG46JDtWyD3l3TizLqOzOgkcBF6pm4HNoFeOVCa crs4WHjvp7HfcU0YTO/cbO3iMpSb8vU= X-MC-Unique: qRG5Ee-hOs-tdF1wyqihjg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 02/30] qapi: Belatedly update doc comment for @wait deprecation Date: Tue, 3 Mar 2020 17:34:37 +0100 Message-Id: <20200303163505.32041-3-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Commit a9b305ba29 "socket: allow wait=3Dfalse for client socket" deprecated use of @wait for client socket chardevs, but neglected to update char.json's doc comment. Make up for that. Signed-off-by: Markus Armbruster --- qapi/char.json | 1 + 1 file changed, 1 insertion(+) diff --git a/qapi/char.json b/qapi/char.json index 6907b2bfdb..daceb20f84 100644 --- a/qapi/char.json +++ b/qapi/char.json @@ -258,6 +258,7 @@ # @server: create server socket (default: true) # @wait: wait for incoming connection on server # sockets (default: false). +# Silently ignored with server: false. This use is deprecated. # @nodelay: set TCP_NODELAY socket option (default: false) # @telnet: enable telnet protocol on server # sockets (default: false) --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253363; cv=none; d=zohomail.com; s=zohoarc; b=ffKwPA2RrxJPr4reewf8c13SH24N+iRlIcsMRLl93uYvISpxXFAmJdLRUwj/Gtcs55BO4odHtZBuep1UGnxgJpdh9Cv8AJBdhRyRDQ3Wbmv6q9iRL0OXG0iD8AUC3NlGycK7tLZtox+VuayczHORZT7qJEY1etOzNmo5npHOSjM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253363; h=Content-Type: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; bh=a/UYmOCxGxuVgibBYUMX0KvNJvGmm4H8hzsqVMEI/UA=; b=M1U161qKGKh7+47EvMWzzBPgF9a0ZoiZ2qJNPOjUYy4KpxCL+4WP32S7GMgO2B389SJ01e/jp5g9rSnUI089l98AsE8UfhfASa17ag4CiUnx8BU7zjNOejXJgrk5LBkAYGLphVZGeteeR0DabJ+/0ypwuV/WSgqSSIUUCNGGIeg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1583253363843296.8233010618475; Tue, 3 Mar 2020 08:36:03 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-408-rYz8Xb3NN4uT9lgSa54Q7w-1; Tue, 03 Mar 2020 11:35:22 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 30AA5801F7B; Tue, 3 Mar 2020 16:35:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8751C91D71; Tue, 3 Mar 2020 16:35:16 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8B9CC86A04; Tue, 3 Mar 2020 16:35:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZAiO001152 for ; Tue, 3 Mar 2020 11:35:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4BBCB91D6E; Tue, 3 Mar 2020 16:35:10 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4210591D71; Tue, 3 Mar 2020 16:35:07 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B88701138611; Tue, 3 Mar 2020 17:35:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253362; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=a/UYmOCxGxuVgibBYUMX0KvNJvGmm4H8hzsqVMEI/UA=; b=PLoOLU/79SyMLsDtDW7AxTWKmFpXco5B007ZjAU38V2xct6Vm0+Z9dej/hQB+9dVGUmKUT tFatOOmRYh1sGkrQ8mPlL3i6f0cQl1463sKEYYIgaAuJeR0NxkhxcEXwEUfKMBTDl+NGTY 3N+l8b1bbYlwEFVha1wHRSWqAuXjW+g= X-MC-Unique: rYz8Xb3NN4uT9lgSa54Q7w-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 03/30] docs/devel/qapi-code-gen: Clarify allow-oob introspection Date: Tue, 3 Mar 2020 17:34:38 +0100 Message-Id: <20200303163505.32041-4-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Mention SchemaInfo variant member "allow-oob" defaults to false. Signed-off-by: Markus Armbruster --- docs/devel/qapi-code-gen.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt index 59d6973e1e..5906602504 100644 --- a/docs/devel/qapi-code-gen.txt +++ b/docs/devel/qapi-code-gen.txt @@ -988,9 +988,9 @@ The SchemaInfo for a command has meta-type "command", a= nd variant members "arg-type", "ret-type" and "allow-oob". On the wire, the "arguments" member of a client's "execute" command must conform to the object type named by "arg-type". The "return" member that the server -passes in a success response conforms to the type named by -"ret-type". When "allow-oob" is set, it means the command supports -out-of-band execution. +passes in a success response conforms to the type named by "ret-type". +When "allow-oob" is true, it means the command supports out-of-band +execution. It defaults to false. =20 If the command takes no arguments, "arg-type" names an object type without members. Likewise, if the command returns nothing, "ret-type" --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253326; cv=none; d=zohomail.com; s=zohoarc; b=e8437cO7z105zFV0kU6Zn1q1oAOu/nWLqWd9mtMo86QuRElCYFl/De/duF7UUy0wnqiZhOg8r+PDAsV9P/2hfeivef0mvfVN7E++p1lyXub5gOvzz1HKlREDgWjNAcrXTyEgCmIqss1fuykOprZlzYiFzLaPWhEJZqzpYj61pOQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253326; h=Content-Type: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; bh=ErHcuT4cm1oXy3g+6iik/P+K8YdI7jU/ISt5Kmux1ac=; b=KtKBgLWRBShqiNCtGaBvUKT+fI8BR1DBTMlDZ8nKg7GXq1MXy4czLKCL8OXPfVRSsQ5aAItfl0hQYODfb4kvxfniHEZ4svLkb5nKuNqmAQYrgFsbdv5a/1JJx4+vWwwtC4SVyWEIXcjb13gNJrkce3yTgAlDKrrILHDJh6knRas= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1583253326597657.919114607997; Tue, 3 Mar 2020 08:35:26 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-408-fvg-fndMOS6A9uKGlzRSiw-1; Tue, 03 Mar 2020 11:35:22 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2903818CA250; Tue, 3 Mar 2020 16:35:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 552A97387C; Tue, 3 Mar 2020 16:35:16 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8BA2586A06; Tue, 3 Mar 2020 16:35:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZAWG001167 for ; Tue, 3 Mar 2020 11:35:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7CAC910013A1; Tue, 3 Mar 2020 16:35:10 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 459A61001920; Tue, 3 Mar 2020 16:35:07 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id BBB1F11366CB; Tue, 3 Mar 2020 17:35:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253325; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ErHcuT4cm1oXy3g+6iik/P+K8YdI7jU/ISt5Kmux1ac=; b=g3YgTXisfIQ7FmQWz+2p7jniZ+kEZF7kuCJR/AyuCbKbm1c+yX+SE5UGrRh4qkkUI0lmUY AxIShPxI5ispy9dFqHugHT4OEtfWrIPUs4qQWDL4JrowUcqegIEU9DzGppiDhCowY78YiU +qiangpeW5M2aaXxxXhHnhFFMbHQNVs= X-MC-Unique: fvg-fndMOS6A9uKGlzRSiw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 04/30] docs/devel/qapi-code-gen: Document 'features' introspection Date: Tue, 3 Mar 2020 17:34:39 +0100 Message-Id: <20200303163505.32041-5-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Commit 6a8c0b5102 "qapi: Add feature flags to struct types" neglected to update section "Client JSON Protocol introspection", and commit 23394b4c39 "qapi: Add feature flags to commands" didn't either. Make up for that. Signed-off-by: Markus Armbruster --- docs/devel/qapi-code-gen.txt | 43 +++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt index 5906602504..297a725084 100644 --- a/docs/devel/qapi-code-gen.txt +++ b/docs/devel/qapi-code-gen.txt @@ -642,13 +642,8 @@ that previously resulted in an error). QMP clients ma= y still need to know whether the extension is available. =20 For this purpose, a list of features can be specified for a command or -struct type. This is exposed to the client as a list of strings, -where each string signals that this build of QEMU shows a certain -behaviour. - -Each member of the 'features' array defines a feature. It can either -be { 'name': STRING, '*if': COND }, or STRING, which is shorthand for -{ 'name': STRING }. +struct type. Each list member can either be { 'name': STRING, '*if': +COND }, or STRING, which is shorthand for { 'name': STRING }. =20 The optional 'if' member specifies a conditional. See "Configuring the schema" below for more on this. @@ -659,6 +654,12 @@ Example: 'data': { 'number': 'int' }, 'features': [ 'allow-negative-numbers' ] } =20 +The feature strings are exposed to clients in introspection, as +explained in section "Client JSON Protocol introspection". + +Intended use is to have each feature string signal that this build of +QEMU shows a certain behaviour. + =20 =3D=3D=3D Naming rules and reserved names =3D=3D=3D =20 @@ -965,7 +966,7 @@ schema, along with the SchemaInfo type. This text atte= mpts to give an overview how things work. For details you need to consult the QAPI schema. =20 -SchemaInfo objects have common members "name" and "meta-type", and +SchemaInfo objects have common members "name", "meta-type", and additional variant members depending on the value of meta-type. =20 Each SchemaInfo object describes a wire ABI entity of a certain @@ -985,12 +986,13 @@ references by name. QAPI schema definitions not reachable that way are omitted. =20 The SchemaInfo for a command has meta-type "command", and variant -members "arg-type", "ret-type" and "allow-oob". On the wire, the -"arguments" member of a client's "execute" command must conform to the -object type named by "arg-type". The "return" member that the server -passes in a success response conforms to the type named by "ret-type". -When "allow-oob" is true, it means the command supports out-of-band -execution. It defaults to false. +members "arg-type", "ret-type", "allow-oob", and "features". On the +wire, the "arguments" member of a client's "execute" command must +conform to the object type named by "arg-type". The "return" member +that the server passes in a success response conforms to the type +named by "ret-type". When "allow-oob" is true, it means the command +supports out-of-band execution. It defaults to false. "features" +exposes the command's feature strings as a JSON array of strings. =20 If the command takes no arguments, "arg-type" names an object type without members. Likewise, if the command returns nothing, "ret-type" @@ -1025,7 +1027,8 @@ Example: the SchemaInfo for EVENT_C from section Even= ts =20 The SchemaInfo for struct and union types has meta-type "object". =20 -The SchemaInfo for a struct type has variant member "members". +The SchemaInfo for a struct type has variant members "members" and +"features". =20 The SchemaInfo for a union type additionally has variant members "tag" and "variants". @@ -1047,6 +1050,16 @@ Example: the SchemaInfo for MyType from section Stru= ct types { "name": "member2", "type": "int" }, { "name": "member3", "type": "str", "default": null } ] } =20 +"features" exposes the command's feature strings as a JSON array of +strings. + +Example: the SchemaInfo for TestType from section Features: + + { "name": "TestType", "meta-type": "object", + "members": [ + { "name": "number", "type": "int" } ], + "features": ["allow-negative-numbers"] } + "tag" is the name of the common member serving as type tag. "variants" is a JSON array describing the object's variant members. Each element is a JSON object with members "case" (the value of type --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253504; cv=none; d=zohomail.com; s=zohoarc; b=WmLACVkgtTPTYlf7CoAf/6FmfUgH4ZlkzuEbpajLUUlnQVHSFkVvEENuRnEKsisdNe/f8xU9cL/7r27KQ+XS0MtQp+ogDZgakS1bUFdF9kTX6T4B95MiPOrEa5KP0qyDcMGY8L3s3hosphFsFF7xCMlCnB2Nc+ojI0oceUb1dtM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253504; h=Content-Type: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; bh=gaqqrU7+ycxBpa7UVzZzOOY0KUMW86V9JtKDT0zf7k0=; b=MeV65BhTNjPRSu/o8GGGtdtZsPO7xE7cDnhfeAoP1YWoGjmfKy6TIS1qR7Bf17SA7kf15nFiPOhf9c4JYYFB/CRuTvCwnze56dWVupEg6fh6+gP+TFM8c0AWbNpN0CfVNS/ZZp4Fyxgm9atWEt5HACq1M1WWxVU7q/p3+VLEzjU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 15832535043067.396199457565217; Tue, 3 Mar 2020 08:38:24 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-236-BxpOFb57PfKVHWkws15D-A-1; Tue, 03 Mar 2020 11:36:01 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1FE93801E7A; Tue, 3 Mar 2020 16:35:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E71155C1D4; Tue, 3 Mar 2020 16:35:53 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8A54A86A19; Tue, 3 Mar 2020 16:35:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZEKM001253 for ; Tue, 3 Mar 2020 11:35:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8378E60C87; Tue, 3 Mar 2020 16:35:14 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8BC9960C80; Tue, 3 Mar 2020 16:35:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id BEFCA113639D; Tue, 3 Mar 2020 17:35:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253503; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=gaqqrU7+ycxBpa7UVzZzOOY0KUMW86V9JtKDT0zf7k0=; b=D+6qim1+0nraElF0bngVhu2D29YB0/rsRS1e2wpVXT0pwJewc5Yht2znWRqCDY2a8K1xfl xvtTZLH6TrnHmZndJSXdmHGmxpNxmKfqaXi36iL7YoSD0RbkKaBEJ7Pu0ZL/jpqBpJKRO4 7HovcV5P61o06FAqn0fLAbtPDZGlCto= X-MC-Unique: BxpOFb57PfKVHWkws15D-A-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 05/30] tests/test-qmp-cmds: Factor out qmp_dispatch() test helpers Date: Tue, 3 Mar 2020 17:34:40 +0100 Message-Id: <20200303163505.32041-6-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Checking the value of qmp_dispatch() is repetitive. Factor out helpers do_qmp_dispatch() and do_qmp_dispatch_error(). Without this, the next commit would make things even more repetitive. Signed-off-by: Markus Armbruster --- tests/test-qmp-cmds.c | 72 +++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 37 deletions(-) diff --git a/tests/test-qmp-cmds.c b/tests/test-qmp-cmds.c index 79507d9e54..b31064b064 100644 --- a/tests/test-qmp-cmds.c +++ b/tests/test-qmp-cmds.c @@ -145,34 +145,55 @@ __org_qemu_x_Union1 *qmp___org_qemu_x_command(__org_q= emu_x_EnumList *a, } =20 =20 +static QObject *do_qmp_dispatch(QDict *req, bool allow_oob) +{ + QDict *resp; + QObject *ret; + + resp =3D qmp_dispatch(&qmp_commands, QOBJECT(req), allow_oob); + g_assert(resp && !qdict_haskey(resp, "error")); + ret =3D qdict_get(resp, "return"); + g_assert(ret); + + qobject_ref(ret); + qobject_unref(resp); + return ret; +} + +static void do_qmp_dispatch_error(QDict *req, bool allow_oob, ErrorClass c= ls) +{ + QDict *resp; + + resp =3D qmp_dispatch(&qmp_commands, QOBJECT(req), allow_oob); + g_assert(resp && qdict_haskey(resp, "error")); + + qobject_unref(resp); +} + /* test commands with no input and no return value */ static void test_dispatch_cmd(void) { QDict *req =3D qdict_new(); - QDict *resp; + QObject *ret; =20 qdict_put_str(req, "execute", "user_def_cmd"); =20 - resp =3D qmp_dispatch(&qmp_commands, QOBJECT(req), false); - assert(resp !=3D NULL); - assert(!qdict_haskey(resp, "error")); + ret =3D do_qmp_dispatch(req, false); =20 - qobject_unref(resp); + qobject_unref(ret); qobject_unref(req); } =20 static void test_dispatch_cmd_oob(void) { QDict *req =3D qdict_new(); - QDict *resp; + QObject *ret; =20 qdict_put_str(req, "exec-oob", "test-flags-command"); =20 - resp =3D qmp_dispatch(&qmp_commands, QOBJECT(req), true); - assert(resp !=3D NULL); - assert(!qdict_haskey(resp, "error")); + ret =3D do_qmp_dispatch(req, true); =20 - qobject_unref(resp); + qobject_unref(ret); qobject_unref(req); } =20 @@ -181,15 +202,11 @@ static void test_dispatch_cmd_failure(void) { QDict *req =3D qdict_new(); QDict *args =3D qdict_new(); - QDict *resp; =20 qdict_put_str(req, "execute", "user_def_cmd2"); =20 - resp =3D qmp_dispatch(&qmp_commands, QOBJECT(req), false); - assert(resp !=3D NULL); - assert(qdict_haskey(resp, "error")); + do_qmp_dispatch_error(req, false, ERROR_CLASS_GENERIC_ERROR); =20 - qobject_unref(resp); qobject_unref(req); =20 /* check that with extra arguments it throws an error */ @@ -199,11 +216,8 @@ static void test_dispatch_cmd_failure(void) =20 qdict_put_str(req, "execute", "user_def_cmd"); =20 - resp =3D qmp_dispatch(&qmp_commands, QOBJECT(req), false); - assert(resp !=3D NULL); - assert(qdict_haskey(resp, "error")); + do_qmp_dispatch_error(req, false, ERROR_CLASS_GENERIC_ERROR); =20 - qobject_unref(resp); qobject_unref(req); } =20 @@ -218,20 +232,6 @@ static void test_dispatch_cmd_success_response(void) qobject_unref(req); } =20 -static QObject *test_qmp_dispatch(QDict *req) -{ - QDict *resp; - QObject *ret; - - resp =3D qmp_dispatch(&qmp_commands, QOBJECT(req), false); - assert(resp && !qdict_haskey(resp, "error")); - ret =3D qdict_get(resp, "return"); - assert(ret); - qobject_ref(ret); - qobject_unref(resp); - return ret; -} - /* test commands that involve both input parameters and return values */ static void test_dispatch_cmd_io(void) { @@ -254,7 +254,7 @@ static void test_dispatch_cmd_io(void) qdict_put(req, "arguments", args); qdict_put_str(req, "execute", "user_def_cmd2"); =20 - ret =3D qobject_to(QDict, test_qmp_dispatch(req)); + ret =3D qobject_to(QDict, do_qmp_dispatch(req, false)); =20 assert(!strcmp(qdict_get_str(ret, "string0"), "blah1")); ret_dict =3D qdict_get_qdict(ret, "dict1"); @@ -275,12 +275,10 @@ static void test_dispatch_cmd_io(void) qdict_put(req, "arguments", args3); qdict_put_str(req, "execute", "guest-get-time"); =20 - ret3 =3D qobject_to(QNum, test_qmp_dispatch(req)); + ret3 =3D qobject_to(QNum, do_qmp_dispatch(req, false)); g_assert(qnum_get_try_int(ret3, &val)); g_assert_cmpint(val, =3D=3D, 66); qobject_unref(ret3); - - qobject_unref(req); } =20 /* test generated dealloc functions for generated types */ --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253560; cv=none; d=zohomail.com; s=zohoarc; b=XRJTkKCw5ko5u92h3Yx4DyUUaGw/KmZQiufdVrhbt8hnHW8ItTZ/k06O5Re6un28g2+Dl/YOqlcAtVKyTTt4FuZB6gLxAIasUQZnrOqp8dMJWnqg4Urnh7SrRNvM9wIW0EZDOqjkasY4xYiBHUX3pE88rP/zw3FZT+rn66s1HWc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253560; h=Content-Type: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; bh=sW04fih2YXTfS8CLtTbDLCV2JzUFAWR4o8w8PMjp12g=; b=k3ZBoN3NjP1Ez0tK72+Jtk0GU4DAwsohaollRYPjb6COTlVX5D8ACW43xBL+QAGUeEIzX7c8XeqsWAm535DHOTxAb6zw4C2PY0hwo94AxjLJePJZdoILQ2jWaryz/RlwsHYEnB+1aIIwktUXkDR1/Zyuw4clAo0Y1O286q9RokQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1583253560705973.9252492546162; Tue, 3 Mar 2020 08:39:20 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-152-AJ-CgI0XOOi2MbibbY5-Sw-1; Tue, 03 Mar 2020 11:35:58 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A82B4802563; Tue, 3 Mar 2020 16:35:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 721205C1D8; Tue, 3 Mar 2020 16:35:50 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 11A6E1803C32; Tue, 3 Mar 2020 16:35:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZESh001240 for ; Tue, 3 Mar 2020 11:35:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5960660C05; Tue, 3 Mar 2020 16:35:14 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8EC9E60C84; Tue, 3 Mar 2020 16:35:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C26EA1135A4D; Tue, 3 Mar 2020 17:35:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253559; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=sW04fih2YXTfS8CLtTbDLCV2JzUFAWR4o8w8PMjp12g=; b=bRsHIoTAQUaX2bqTJgzkCi5Bx4vSn8MtuRA5yi67V3/QRM9S4MmrBGKU/SKGvz0u5Qqyrv MmaDr4pRvT8g5xpS2udfNG0DB+cB49uROVwECD3Ryc1jLbtlQmOyh8LeHmg6yFGcYpXH5R 7VU6J/lyNSWHNVhAF4CTlE6LgF3+KgA= X-MC-Unique: AJ-CgI0XOOi2MbibbY5-Sw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 06/30] tests/test-qmp-cmds: Check responses more thoroughly Date: Tue, 3 Mar 2020 17:34:41 +0100 Message-Id: <20200303163505.32041-7-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster --- tests/test-qmp-cmds.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/tests/test-qmp-cmds.c b/tests/test-qmp-cmds.c index b31064b064..464b370189 100644 --- a/tests/test-qmp-cmds.c +++ b/tests/test-qmp-cmds.c @@ -151,9 +151,10 @@ static QObject *do_qmp_dispatch(QDict *req, bool allow= _oob) QObject *ret; =20 resp =3D qmp_dispatch(&qmp_commands, QOBJECT(req), allow_oob); - g_assert(resp && !qdict_haskey(resp, "error")); + g_assert(resp); ret =3D qdict_get(resp, "return"); g_assert(ret); + g_assert(qdict_size(resp) =3D=3D 1); =20 qobject_ref(ret); qobject_unref(resp); @@ -163,9 +164,17 @@ static QObject *do_qmp_dispatch(QDict *req, bool allow= _oob) static void do_qmp_dispatch_error(QDict *req, bool allow_oob, ErrorClass c= ls) { QDict *resp; + QDict *error; =20 resp =3D qmp_dispatch(&qmp_commands, QOBJECT(req), allow_oob); - g_assert(resp && qdict_haskey(resp, "error")); + g_assert(resp); + error =3D qdict_get_qdict(resp, "error"); + g_assert(error); + g_assert_cmpstr(qdict_get_try_str(error, "class"), + =3D=3D, QapiErrorClass_str(cls)); + g_assert(qdict_get_try_str(error, "desc")); + g_assert(qdict_size(error) =3D=3D 2); + g_assert(qdict_size(resp) =3D=3D 1); =20 qobject_unref(resp); } @@ -174,11 +183,12 @@ static void do_qmp_dispatch_error(QDict *req, bool al= low_oob, ErrorClass cls) static void test_dispatch_cmd(void) { QDict *req =3D qdict_new(); - QObject *ret; + QDict *ret; =20 qdict_put_str(req, "execute", "user_def_cmd"); =20 - ret =3D do_qmp_dispatch(req, false); + ret =3D qobject_to(QDict, do_qmp_dispatch(req, false)); + assert(ret && qdict_size(ret) =3D=3D 0); =20 qobject_unref(ret); qobject_unref(req); @@ -187,11 +197,12 @@ static void test_dispatch_cmd(void) static void test_dispatch_cmd_oob(void) { QDict *req =3D qdict_new(); - QObject *ret; + QDict *ret; =20 qdict_put_str(req, "exec-oob", "test-flags-command"); =20 - ret =3D do_qmp_dispatch(req, true); + ret =3D qobject_to(QDict, do_qmp_dispatch(req, true)); + assert(ret && qdict_size(ret) =3D=3D 0); =20 qobject_unref(ret); qobject_unref(req); --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253428; cv=none; d=zohomail.com; s=zohoarc; b=NkUw/P8bSyetYN1YCpxKAxZ4jtpVjbW/lyz2YeaI8FLl3Xy40B8mcrki3Q7mPzbFc9gKC4zSpMuSQxx2RfhWX0+rOZY26PXxaE7qGFi+pl9OWTgF6eg96LiP3aDxwSLEgwcKZ6OyuTtsONnWHmWjZMXNlfXW3XHw/dc5wV2UQUc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253428; h=Content-Type: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; bh=qsx5CQhD0Sj0B/RGHS3CtiG1c1KmogdpqTcsiN6OJ1A=; b=lb/kryj1pe4B1oY21rFfSVFgffVu8Bs0dBujL/hBxxNt6i2ceo8gDfw7meNyCQJq324TWEvehvZrp/GXAe93GIkHN+YeE1SpsWTHgnLJFiaR9l6mJNoxBUTOrPAoIy7gCY/2cQlZPpwpY0Wk0CsxQtfG1kOGkLf0+UvQgkwSLAs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 158325342823919.967283921607645; Tue, 3 Mar 2020 08:37:08 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-304-2-HICnwTMw6vvTuC5ULzaQ-1; Tue, 03 Mar 2020 11:35:53 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2C4C6107ACC4; Tue, 3 Mar 2020 16:35:47 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F3E5A60C87; Tue, 3 Mar 2020 16:35:46 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A89EC1800B6F; Tue, 3 Mar 2020 16:35:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZEmJ001271 for ; Tue, 3 Mar 2020 11:35:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id E254B7386B; Tue, 3 Mar 2020 16:35:14 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9350D73880; Tue, 3 Mar 2020 16:35:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C59A2113525A; Tue, 3 Mar 2020 17:35:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253427; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=qsx5CQhD0Sj0B/RGHS3CtiG1c1KmogdpqTcsiN6OJ1A=; b=bbdAFr89CcDpqtE3azWYaipaBXOKZB5iSuhshWlTFHAEJmj55l7jCz7LdSpFrmFG/xfUC7 oFACY4y7Oca2a5npUTMjqO2h7Gz1tv8eWS2DGn2NMe6hnWqppS+cVvzYwnyWAXGv5q+b14 K5wjK1p/ZJYFlq/Agdbd8CELCBasOi8= X-MC-Unique: 2-HICnwTMw6vvTuC5ULzaQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 07/30] tests/test-qmp-cmds: Simplify test data setup Date: Tue, 3 Mar 2020 17:34:42 +0100 Message-Id: <20200303163505.32041-8-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Building requests with qdict_put() & friends is tedious to write and hard to read. Parse them from string literals with qdict_from_vjsonf_nofail() instead. Signed-off-by: Markus Armbruster --- tests/test-qmp-cmds.c | 93 ++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 55 deletions(-) diff --git a/tests/test-qmp-cmds.c b/tests/test-qmp-cmds.c index 464b370189..99013ff37b 100644 --- a/tests/test-qmp-cmds.c +++ b/tests/test-qmp-cmds.c @@ -1,5 +1,6 @@ #include "qemu/osdep.h" #include "qapi/qmp/qdict.h" +#include "qapi/qmp/qjson.h" #include "qapi/qmp/qnum.h" #include "qapi/qmp/qstring.h" #include "qapi/error.h" @@ -145,11 +146,16 @@ __org_qemu_x_Union1 *qmp___org_qemu_x_command(__org_q= emu_x_EnumList *a, } =20 =20 -static QObject *do_qmp_dispatch(QDict *req, bool allow_oob) +static QObject *do_qmp_dispatch(bool allow_oob, const char *template, ...) { - QDict *resp; + va_list ap; + QDict *req, *resp; QObject *ret; =20 + va_start(ap, template); + req =3D qdict_from_vjsonf_nofail(template, ap); + va_end(ap); + resp =3D qmp_dispatch(&qmp_commands, QOBJECT(req), allow_oob); g_assert(resp); ret =3D qdict_get(resp, "return"); @@ -158,14 +164,21 @@ static QObject *do_qmp_dispatch(QDict *req, bool allo= w_oob) =20 qobject_ref(ret); qobject_unref(resp); + qobject_unref(req); return ret; } =20 -static void do_qmp_dispatch_error(QDict *req, bool allow_oob, ErrorClass c= ls) +static void do_qmp_dispatch_error(bool allow_oob, ErrorClass cls, + const char *template, ...) { - QDict *resp; + va_list ap; + QDict *req, *resp; QDict *error; =20 + va_start(ap, template); + req =3D qdict_from_vjsonf_nofail(template, ap); + va_end(ap); + resp =3D qmp_dispatch(&qmp_commands, QOBJECT(req), allow_oob); g_assert(resp); error =3D qdict_get_qdict(resp, "error"); @@ -177,59 +190,43 @@ static void do_qmp_dispatch_error(QDict *req, bool al= low_oob, ErrorClass cls) g_assert(qdict_size(resp) =3D=3D 1); =20 qobject_unref(resp); + qobject_unref(req); } =20 /* test commands with no input and no return value */ static void test_dispatch_cmd(void) { - QDict *req =3D qdict_new(); QDict *ret; =20 - qdict_put_str(req, "execute", "user_def_cmd"); - - ret =3D qobject_to(QDict, do_qmp_dispatch(req, false)); + ret =3D qobject_to(QDict, + do_qmp_dispatch(false, + "{ 'execute': 'user_def_cmd' }")); assert(ret && qdict_size(ret) =3D=3D 0); - qobject_unref(ret); - qobject_unref(req); } =20 static void test_dispatch_cmd_oob(void) { - QDict *req =3D qdict_new(); QDict *ret; =20 - qdict_put_str(req, "exec-oob", "test-flags-command"); - - ret =3D qobject_to(QDict, do_qmp_dispatch(req, true)); + ret =3D qobject_to(QDict, + do_qmp_dispatch(true, + "{ 'exec-oob': 'test-flags-command' }= ")); assert(ret && qdict_size(ret) =3D=3D 0); - qobject_unref(ret); - qobject_unref(req); } =20 /* test commands that return an error due to invalid parameters */ static void test_dispatch_cmd_failure(void) { - QDict *req =3D qdict_new(); - QDict *args =3D qdict_new(); - - qdict_put_str(req, "execute", "user_def_cmd2"); - - do_qmp_dispatch_error(req, false, ERROR_CLASS_GENERIC_ERROR); - - qobject_unref(req); - - /* check that with extra arguments it throws an error */ - req =3D qdict_new(); - qdict_put_int(args, "a", 66); - qdict_put(req, "arguments", args); - - qdict_put_str(req, "execute", "user_def_cmd"); - - do_qmp_dispatch_error(req, false, ERROR_CLASS_GENERIC_ERROR); - - qobject_unref(req); + /* missing arguments */ + do_qmp_dispatch_error(false, ERROR_CLASS_GENERIC_ERROR, + "{ 'execute': 'user_def_cmd2' }"); + + /* extra arguments */ + do_qmp_dispatch_error(false, ERROR_CLASS_GENERIC_ERROR, + "{ 'execute': 'user_def_cmd'," + " 'arguments': { 'a': 66 } }"); } =20 static void test_dispatch_cmd_success_response(void) @@ -246,26 +243,15 @@ static void test_dispatch_cmd_success_response(void) /* test commands that involve both input parameters and return values */ static void test_dispatch_cmd_io(void) { - QDict *req =3D qdict_new(); - QDict *args =3D qdict_new(); - QDict *args3 =3D qdict_new(); - QDict *ud1a =3D qdict_new(); - QDict *ud1b =3D qdict_new(); QDict *ret, *ret_dict, *ret_dict_dict, *ret_dict_dict_userdef; QDict *ret_dict_dict2, *ret_dict_dict2_userdef; QNum *ret3; int64_t val; =20 - qdict_put_int(ud1a, "integer", 42); - qdict_put_str(ud1a, "string", "hello"); - qdict_put_int(ud1b, "integer", 422); - qdict_put_str(ud1b, "string", "hello2"); - qdict_put(args, "ud1a", ud1a); - qdict_put(args, "ud1b", ud1b); - qdict_put(req, "arguments", args); - qdict_put_str(req, "execute", "user_def_cmd2"); - - ret =3D qobject_to(QDict, do_qmp_dispatch(req, false)); + ret =3D qobject_to(QDict, do_qmp_dispatch(false, + "{ 'execute': 'user_def_cmd2', 'arguments': {" + " 'ud1a': { 'integer': 42, 'string': 'hello' }," + " 'ud1b': { 'integer': 422, 'string': 'hello2' } } }")); =20 assert(!strcmp(qdict_get_str(ret, "string0"), "blah1")); ret_dict =3D qdict_get_qdict(ret, "dict1"); @@ -282,11 +268,8 @@ static void test_dispatch_cmd_io(void) assert(!strcmp(qdict_get_str(ret_dict_dict2, "string"), "blah4")); qobject_unref(ret); =20 - qdict_put_int(args3, "a", 66); - qdict_put(req, "arguments", args3); - qdict_put_str(req, "execute", "guest-get-time"); - - ret3 =3D qobject_to(QNum, do_qmp_dispatch(req, false)); + ret3 =3D qobject_to(QNum, do_qmp_dispatch(false, + "{ 'execute': 'guest-get-time', 'arguments': { 'a': 66 } }")); g_assert(qnum_get_try_int(ret3, &val)); g_assert_cmpint(val, =3D=3D, 66); qobject_unref(ret3); --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253356; cv=none; d=zohomail.com; s=zohoarc; b=V5LSfPmO+7JWvf7q6uFjGbDqOY2AotumTiG5pNBzoBsnQcvm6KAaaC2kQlH1GCehoew7chsVIaTJznghz20MRKaAtgCot5dSFVaiSR3RknbcQbe01lo2EKt3qVf4HoEprHJE8KRx/l3kpOupBfooc9sFEuGanrkFQseGgcZ0pjA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253356; h=Content-Type: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; bh=txscctFiVA2U4b7jVQ1yKyvWF3aho58FNzAJU1Evot4=; b=Bu883rBG+Ew+Rn0YaaYVLjvH2KQv+zHJzgxGNLsR9ssGDOoXrev3ujOx+8uQO8mjY0tehjfgbd3/0bUA11eogsTSlAQ5lF/FSazuYatpO0NgFfSYTHlqXGD6LqPCwBtmYbfPkXLq4wNfBS6nzZ2OqR5OY6TtmRvjuLU8rTd8NBo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1583253356849390.2688371449615; Tue, 3 Mar 2020 08:35:56 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-292-s5gl7cUMMrK9Qqo9kJw1aw-1; Tue, 03 Mar 2020 11:35:52 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6524E8017CC; Tue, 3 Mar 2020 16:35:46 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 37BD45DA76; Tue, 3 Mar 2020 16:35:46 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id DD8E6180880B; Tue, 3 Mar 2020 16:35:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZDNM001219 for ; Tue, 3 Mar 2020 11:35:13 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5899391D70; Tue, 3 Mar 2020 16:35:13 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 972D291D63; Tue, 3 Mar 2020 16:35:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C905A113525C; Tue, 3 Mar 2020 17:35:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253354; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=txscctFiVA2U4b7jVQ1yKyvWF3aho58FNzAJU1Evot4=; b=X9MZ2UMXTSlmilL/Of+8CugnKpC9ubudcfc7eBGiaDCdG2gHHBFQ1IHPzJRis1+adZaVAW 4f9anndVbXsKgf/O/1GslxLnEPIO6EKmUS5jPHzVdttxUfhB9bf9AHnV26IgaqPdx8LWp5 /yOihRhlWe7b2DmiweNayuzMqGsaSEk= X-MC-Unique: s5gl7cUMMrK9Qqo9kJw1aw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 08/30] tests/test-qmp-event: Simplify test data setup Date: Tue, 3 Mar 2020 17:34:43 +0100 Message-Id: <20200303163505.32041-9-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Building expected data with qdict_put() & friends is tedious to write and hard to read. Parse them from string literals with qdict_from_jsonf_nofail() instead. While there, use initializers instead of assignments for initializing aggregate event arguments. Signed-off-by: Markus Armbruster --- tests/test-qmp-event.c | 93 ++++++++++++------------------------------ 1 file changed, 27 insertions(+), 66 deletions(-) diff --git a/tests/test-qmp-event.c b/tests/test-qmp-event.c index eee7e08ab6..430001e622 100644 --- a/tests/test-qmp-event.c +++ b/tests/test-qmp-event.c @@ -17,6 +17,7 @@ #include "qapi/error.h" #include "qapi/qmp/qbool.h" #include "qapi/qmp/qdict.h" +#include "qapi/qmp/qjson.h" #include "qapi/qmp/qnum.h" #include "qapi/qmp/qstring.h" #include "qapi/qmp-event.h" @@ -124,17 +125,13 @@ static void event_prepare(TestEventData *data, /* Global variable test_event_data was used to pass the expectation, so test cases can't be executed at same time. */ g_mutex_lock(&test_event_lock); - - data->expect =3D qdict_new(); test_event_data =3D data; } =20 static void event_teardown(TestEventData *data, const void *unused) { - qobject_unref(data->expect); test_event_data =3D NULL; - g_mutex_unlock(&test_event_lock); } =20 @@ -152,90 +149,54 @@ static void event_test_add(const char *testpath, static void test_event_a(TestEventData *data, const void *unused) { - QDict *d; - d =3D data->expect; - qdict_put_str(d, "event", "EVENT_A"); + data->expect =3D qdict_from_jsonf_nofail("{ 'event': 'EVENT_A' }"); qapi_event_send_event_a(); + qobject_unref(data->expect); } =20 static void test_event_b(TestEventData *data, const void *unused) { - QDict *d; - d =3D data->expect; - qdict_put_str(d, "event", "EVENT_B"); + data->expect =3D qdict_from_jsonf_nofail("{ 'event': 'EVENT_B' }"); qapi_event_send_event_b(); + qobject_unref(data->expect); } =20 static void test_event_c(TestEventData *data, const void *unused) { - QDict *d, *d_data, *d_b; - - UserDefOne b; - b.integer =3D 2; - b.string =3D g_strdup("test1"); - b.has_enum1 =3D false; - - d_b =3D qdict_new(); - qdict_put_int(d_b, "integer", 2); - qdict_put_str(d_b, "string", "test1"); - - d_data =3D qdict_new(); - qdict_put_int(d_data, "a", 1); - qdict_put(d_data, "b", d_b); - qdict_put_str(d_data, "c", "test2"); - - d =3D data->expect; - qdict_put_str(d, "event", "EVENT_C"); - qdict_put(d, "data", d_data); + UserDefOne b =3D { .integer =3D 2, .string =3D (char *)"test1" }; =20 + data->expect =3D qdict_from_jsonf_nofail( + "{ 'event': 'EVENT_C', 'data': {" + " 'a': 1, 'b': { 'integer': 2, 'string': 'test1' }, 'c': 'test2' }= }"); qapi_event_send_event_c(true, 1, true, &b, "test2"); - - g_free(b.string); + qobject_unref(data->expect); } =20 /* Complex type */ static void test_event_d(TestEventData *data, const void *unused) { - UserDefOne struct1; - EventStructOne a; - QDict *d, *d_data, *d_a, *d_struct1; - - struct1.integer =3D 2; - struct1.string =3D g_strdup("test1"); - struct1.has_enum1 =3D true; - struct1.enum1 =3D ENUM_ONE_VALUE1; - - a.struct1 =3D &struct1; - a.string =3D g_strdup("test2"); - a.has_enum2 =3D true; - a.enum2 =3D ENUM_ONE_VALUE2; - - d_struct1 =3D qdict_new(); - qdict_put_int(d_struct1, "integer", 2); - qdict_put_str(d_struct1, "string", "test1"); - qdict_put_str(d_struct1, "enum1", "value1"); - - d_a =3D qdict_new(); - qdict_put(d_a, "struct1", d_struct1); - qdict_put_str(d_a, "string", "test2"); - qdict_put_str(d_a, "enum2", "value2"); - - d_data =3D qdict_new(); - qdict_put(d_data, "a", d_a); - qdict_put_str(d_data, "b", "test3"); - qdict_put_str(d_data, "enum3", "value3"); - - d =3D data->expect; - qdict_put_str(d, "event", "EVENT_D"); - qdict_put(d, "data", d_data); + UserDefOne struct1 =3D { + .integer =3D 2, .string =3D (char *)"test1", + .has_enum1 =3D true, .enum1 =3D ENUM_ONE_VALUE1, + }; + EventStructOne a =3D { + .struct1 =3D &struct1, + .string =3D (char *)"test2", + .has_enum2 =3D true, + .enum2 =3D ENUM_ONE_VALUE2, + }; =20 + data->expect =3D qdict_from_jsonf_nofail( + "{ 'event': 'EVENT_D', 'data': {" + " 'a': {" + " 'struct1': { 'integer': 2, 'string': 'test1', 'enum1': 'value1'= }," + " 'string': 'test2', 'enum2': 'value2' }," + " 'b': 'test3', 'enum3': 'value3' } }"); qapi_event_send_event_d(&a, "test3", false, NULL, true, ENUM_ONE_VALUE= 3); - - g_free(struct1.string); - g_free(a.string); + qobject_unref(data->expect); } =20 int main(int argc, char **argv) --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253350; cv=none; d=zohomail.com; s=zohoarc; b=YwLcLhuCmkFRV66moVzmdUBm+2TtaUW5fssjaryUvTgWc8Gep6TSlADl/VHDYqaV7dAj8ZQS/Os9DIxINZSZ+aY4h1TSCnRROzVuz7RLIpbNJXE2Pqfyos1X6hwFAPOWGDBd5KKY5PWaCTusE+gyjoSa/Zry0lpta2lxzUMZseY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253350; h=Content-Type: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; bh=VNM4FcuvpDlHlX1gsPH6mZYVPEgw3i0rjSojdcghyfE=; b=lF9Xgu/R1/oMOSWumnGkJzU1Qmv+XALhZ0hMDZernVnvpSEzqgsPHG3xS5K3IDXrZX1GYZQF4g8wOe+AHQdYKpocWP7o6gXLwEUKfaw6B2XC0zGXPvJ9OpcjfQCO0S0uusTuq4iKoikfaM+RIZKAMa3tqy3JHM6R7LCOou4y1M4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1583253350485895.5851682320439; Tue, 3 Mar 2020 08:35:50 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-45-EQt6G7duO7GJ55NYGzyNxA-1; Tue, 03 Mar 2020 11:35:47 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 57B429B580; Tue, 3 Mar 2020 16:35:40 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 28D508AC30; Tue, 3 Mar 2020 16:35:40 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CC4B386A0A; Tue, 3 Mar 2020 16:35:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZCkp001202 for ; Tue, 3 Mar 2020 11:35:12 -0500 Received: by smtp.corp.redhat.com (Postfix) id 85EB45DA82; Tue, 3 Mar 2020 16:35:12 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9E82F5D9C9; Tue, 3 Mar 2020 16:35:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id CC33011336BC; Tue, 3 Mar 2020 17:35:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253349; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=VNM4FcuvpDlHlX1gsPH6mZYVPEgw3i0rjSojdcghyfE=; b=Eciy1qcMVwH79YkbY/xLfCmfzEK5+4NPfeD44jY/jbZDn0kS+J2f7QzKF9f7eQFS+vVCU4 vfTxxjocYuBipkm1BTZMyPqlz2/b7WPFMuVzuQYovfhk6kJEpxse73jKlqZghCtjPA226Z kiEF6xfzcyhGG97+5d/MzXKLUiWinBU= X-MC-Unique: EQt6G7duO7GJ55NYGzyNxA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 09/30] tests/test-qmp-event: Use qobject_is_equal() Date: Tue, 3 Mar 2020 17:34:44 +0100 Message-Id: <20200303163505.32041-10-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Locally defined helper qdict_cmp_simple() implements just enough of a comparison to serve here. Replace it by qobject_is_equal(), which implements all of it. Signed-off-by: Markus Armbruster --- tests/test-qmp-event.c | 66 +----------------------------------------- 1 file changed, 1 insertion(+), 65 deletions(-) diff --git a/tests/test-qmp-event.c b/tests/test-qmp-event.c index 430001e622..d64066139c 100644 --- a/tests/test-qmp-event.c +++ b/tests/test-qmp-event.c @@ -28,73 +28,9 @@ typedef struct TestEventData { QDict *expect; } TestEventData; =20 -typedef struct QDictCmpData { - QDict *expect; - bool result; -} QDictCmpData; - TestEventData *test_event_data; static GMutex test_event_lock; =20 -/* Only compares bool, int, string */ -static -void qdict_cmp_do_simple(const char *key, QObject *obj1, void *opaque) - -{ - QObject *obj2; - QDictCmpData d_new, *d =3D opaque; - int64_t val1, val2; - - if (!d->result) { - return; - } - - obj2 =3D qdict_get(d->expect, key); - if (!obj2) { - d->result =3D false; - return; - } - - if (qobject_type(obj1) !=3D qobject_type(obj2)) { - d->result =3D false; - return; - } - - switch (qobject_type(obj1)) { - case QTYPE_QBOOL: - d->result =3D (qbool_get_bool(qobject_to(QBool, obj1)) =3D=3D - qbool_get_bool(qobject_to(QBool, obj2))); - return; - case QTYPE_QNUM: - g_assert(qnum_get_try_int(qobject_to(QNum, obj1), &val1)); - g_assert(qnum_get_try_int(qobject_to(QNum, obj2), &val2)); - d->result =3D val1 =3D=3D val2; - return; - case QTYPE_QSTRING: - d->result =3D g_strcmp0(qstring_get_str(qobject_to(QString, obj1)), - qstring_get_str(qobject_to(QString, obj2))) = =3D=3D 0; - return; - case QTYPE_QDICT: - d_new.expect =3D qobject_to(QDict, obj2); - d_new.result =3D true; - qdict_iter(qobject_to(QDict, obj1), qdict_cmp_do_simple, &d_new); - d->result =3D d_new.result; - return; - default: - abort(); - } -} - -static bool qdict_cmp_simple(QDict *a, QDict *b) -{ - QDictCmpData d; - - d.expect =3D b; - d.result =3D true; - qdict_iter(a, qdict_cmp_do_simple, &d); - return d.result; -} - void test_qapi_event_emit(test_QAPIEvent event, QDict *d) { QDict *t; @@ -115,7 +51,7 @@ void test_qapi_event_emit(test_QAPIEvent event, QDict *d) =20 qdict_del(d, "timestamp"); =20 - g_assert(qdict_cmp_simple(d, test_event_data->expect)); + g_assert(qobject_is_equal(QOBJECT(d), QOBJECT(test_event_data->expect)= )); =20 } =20 --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253351; cv=none; d=zohomail.com; s=zohoarc; b=I6KzGobS3KhLTrD5F2mE0VII9+7jLIqD2jSlG0s5AYa9ChiqB+eBMPwlDeS4jNvf/SMUSgWsidYTmoI973bXFt3UYt6ZP6ooXdvz+KXOkXA9Qh09iFY2x0Mhp6XoUiUwyDiK4OUk+Fyx5d+n4WHfQdF4Lc1BlyxGuZJs/OZIBfg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253351; h=Content-Type: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; bh=G/K2SKoqOnDjysN1i+Hx5allTxM687zxIdK14NsSRSU=; b=cU20+/kd5pPQ4Wh3Mc/8WMxj036YrVbC1ZJykPpna86JX6KOYNZtQ/fZSCeYPx4aXmiiiooIwOyChLRdqc/qee7iDLXDqGx+Thz/A4I8ZvetTDO/pdGAL6QdQembH7Vq4ik9alebk6NYC5Q7peMTwJN5DGCJQxIH26EyULr5iFo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1583253351936994.7009455035871; Tue, 3 Mar 2020 08:35:51 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-429-VnQXKyPtN7yBiqpb3o47WQ-1; Tue, 03 Mar 2020 11:35:48 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 73FCE9B591; Tue, 3 Mar 2020 16:35:42 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4513B1001B2C; Tue, 3 Mar 2020 16:35:42 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E5D8318089D7; Tue, 3 Mar 2020 16:35:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZCca001189 for ; Tue, 3 Mar 2020 11:35:12 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1A32691D6E; Tue, 3 Mar 2020 16:35:12 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A1EC891D71; Tue, 3 Mar 2020 16:35:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id CF64911336BD; Tue, 3 Mar 2020 17:35:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253350; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=G/K2SKoqOnDjysN1i+Hx5allTxM687zxIdK14NsSRSU=; b=IuneHq6MD9lAJ1pkDxEVbzT7zFklYtJJH5aYdrrhIoG2kne3trvmpEGSg4qobmuIsBhjuO 5+6VtB0GR1uvVp7zb0btzsEMLX66ZjucAPIGaO9k+pXqgJMazF60AsquT9ubbQWayDvioZ G0Q2d10RHtrHje6tNlxvdVm2k5H1QCc= X-MC-Unique: VnQXKyPtN7yBiqpb3o47WQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 10/30] tests/test-qmp-event: Check event is actually emitted Date: Tue, 3 Mar 2020 17:34:45 +0100 Message-Id: <20200303163505.32041-11-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster --- tests/test-qmp-event.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test-qmp-event.c b/tests/test-qmp-event.c index d64066139c..7dd0053190 100644 --- a/tests/test-qmp-event.c +++ b/tests/test-qmp-event.c @@ -26,6 +26,7 @@ =20 typedef struct TestEventData { QDict *expect; + bool emitted; } TestEventData; =20 TestEventData *test_event_data; @@ -52,7 +53,7 @@ void test_qapi_event_emit(test_QAPIEvent event, QDict *d) qdict_del(d, "timestamp"); =20 g_assert(qobject_is_equal(QOBJECT(d), QOBJECT(test_event_data->expect)= )); - + test_event_data->emitted =3D true; } =20 static void event_prepare(TestEventData *data, @@ -87,6 +88,7 @@ static void test_event_a(TestEventData *data, { data->expect =3D qdict_from_jsonf_nofail("{ 'event': 'EVENT_A' }"); qapi_event_send_event_a(); + g_assert(data->emitted); qobject_unref(data->expect); } =20 @@ -95,6 +97,7 @@ static void test_event_b(TestEventData *data, { data->expect =3D qdict_from_jsonf_nofail("{ 'event': 'EVENT_B' }"); qapi_event_send_event_b(); + g_assert(data->emitted); qobject_unref(data->expect); } =20 @@ -107,6 +110,7 @@ static void test_event_c(TestEventData *data, "{ 'event': 'EVENT_C', 'data': {" " 'a': 1, 'b': { 'integer': 2, 'string': 'test1' }, 'c': 'test2' }= }"); qapi_event_send_event_c(true, 1, true, &b, "test2"); + g_assert(data->emitted); qobject_unref(data->expect); } =20 @@ -132,6 +136,7 @@ static void test_event_d(TestEventData *data, " 'string': 'test2', 'enum2': 'value2' }," " 'b': 'test3', 'enum3': 'value3' } }"); qapi_event_send_event_d(&a, "test3", false, NULL, true, ENUM_ONE_VALUE= 3); + g_assert(data->emitted); qobject_unref(data->expect); } =20 --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253346; cv=none; d=zohomail.com; s=zohoarc; b=bSQ/ctNWCkIzD8w36+uXO+aqtAPu9kaRT4i0pH9kgy0m0vf0SfbbhLiQTdSZyEGgZJlYWeCJ0takiKhxEKCHGV6YL/78MgVmKzerLJ1VPYN+Yg1+FjqjxN2MHSjUTJzD9wx5JnKsXUcW6wS7I3irAx4xv8V+ZlO2AM7fTUnAeQY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253346; h=Content-Type: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; bh=Fbo5JhnnTf0I02ZkCG4yrI4+5qo3vdDLrEPTR8T/fbg=; b=Gsn0A8VCS1qoEjZa/X+8kc+Zt2rU8Vb86Lujv/17Lr2QnwmSH2v35mobZLGXz0VfwElQ4FgxhApJ0ljR6qeDlNtNeNZlzyGKeccWLbtNE4soIROcZvC5J6CkRiovck8QRx+LxPG5lB1r7iVMt58XO7wUHZMVSgevvvGxTGq3dqM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1583253346081278.82395694405227; Tue, 3 Mar 2020 08:35:46 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-267-jDznNqMsMP-anoKzfpfmVA-1; Tue, 03 Mar 2020 11:35:42 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 51064801FC7; Tue, 3 Mar 2020 16:35:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 223055C1D4; Tue, 3 Mar 2020 16:35:35 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C5E9718089D6; Tue, 3 Mar 2020 16:35:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZCFr001182 for ; Tue, 3 Mar 2020 11:35:12 -0500 Received: by smtp.corp.redhat.com (Postfix) id F26421000322; Tue, 3 Mar 2020 16:35:11 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BC6E61001920; Tue, 3 Mar 2020 16:35:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id D29581133013; Tue, 3 Mar 2020 17:35:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253345; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Fbo5JhnnTf0I02ZkCG4yrI4+5qo3vdDLrEPTR8T/fbg=; b=VVPgcpHRjIwlZSILpOynvpm3KNU5wRkZ0YdKQJqP9oo1Wc/yxbIJFhR+74cRkgaLhcSWoG Jh4KBOl+fwRJP3DDyml/Gn1DYvntMCM/oNqAJbrzlrDIo3SLd3IQH4wkn0SDsUWmo/wF3n 1oKE5HqTby22kMHOGO1T2NV/rlYK4xs= X-MC-Unique: jDznNqMsMP-anoKzfpfmVA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 11/30] qapi/schema: Clean up around QAPISchemaEntity.connect_doc() Date: Tue, 3 Mar 2020 17:34:46 +0100 Message-Id: <20200303163505.32041-12-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" QAPISchemaEntity calls doc.connect_feature() in .check(). Improper since commit ee1e6a1f6c8 split .connect_doc() off .check(). Move the call. Requires making the children call super().connect_doc() as they should. Signed-off-by: Markus Armbruster --- scripts/qapi/schema.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index cfbb9758c4..1c8d126441 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -53,13 +53,13 @@ class QAPISchemaEntity: seen =3D {} for f in self.features: f.check_clash(self.info, seen) - if self.doc: - self.doc.connect_feature(f) - self._checked =3D True =20 def connect_doc(self, doc=3DNone): - pass + doc =3D doc or self.doc + if doc: + for f in self.features: + doc.connect_feature(f) =20 def check_doc(self): if self.doc: @@ -250,6 +250,7 @@ class QAPISchemaEnumType(QAPISchemaType): m.check_clash(self.info, seen) =20 def connect_doc(self, doc=3DNone): + super().connect_doc(doc) doc =3D doc or self.doc if doc: for m in self.members: @@ -392,6 +393,7 @@ class QAPISchemaObjectType(QAPISchemaType): m.check_clash(info, seen) =20 def connect_doc(self, doc=3DNone): + super().connect_doc(doc) doc =3D doc or self.doc if doc: if self.base and self.base.is_implicit(): @@ -668,6 +670,7 @@ class QAPISchemaAlternateType(QAPISchemaType): types_seen[qt] =3D v.name =20 def connect_doc(self, doc=3DNone): + super().connect_doc(doc) doc =3D doc or self.doc if doc: for v in self.variants.variants: @@ -734,6 +737,7 @@ class QAPISchemaCommand(QAPISchemaEntity): % self.ret_type.describe()) =20 def connect_doc(self, doc=3DNone): + super().connect_doc(doc) doc =3D doc or self.doc if doc: if self.arg_type and self.arg_type.is_implicit(): @@ -776,6 +780,7 @@ class QAPISchemaEvent(QAPISchemaEntity): % self.arg_type.describe()) =20 def connect_doc(self, doc=3DNone): + super().connect_doc(doc) doc =3D doc or self.doc if doc: if self.arg_type and self.arg_type.is_implicit(): --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253435; cv=none; d=zohomail.com; s=zohoarc; b=Go1Kprfp2jYwvQbJ3kI0wvMVeeaUj1QJVFHB0XaIiLt7PeMaI0oHU5T9+bVh/P5GDm/Weus0nrml6zuKMhKLf+83nkWHcbzbZ+3TzjtvwM7BP4UiaP67+LxI9egnXKfXXknW3aU3bSQEqkVKMolVDX15OAJL4kCKD1Wx/+DmZbo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253435; h=Content-Type: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; bh=rYBRTIxWrmmaNX+SQZ/hkAqDwcggwJmFe+zo7D36bDg=; b=RZaysSq860fCh5umnEF6Q8F5edE5soDWWWHrmAqWGXgkN5y/VzcdFICx2OCaZ7J2S4HTyRrn8Odv2D/uRTrpKi9xMaQvatWlFiwZLkIzb14O8Riifk6C5RvFFrEB0x8X48ZEU2v8COn1ivg7OCuYJCDoX5lIFJ9wN991vmi01+c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1583253435619263.01132852393255; Tue, 3 Mar 2020 08:37:15 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-236-L_awPtViM26mrOQFouJH5g-1; Tue, 03 Mar 2020 11:36:11 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2A561107B271; Tue, 3 Mar 2020 16:36:04 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E516560C84; Tue, 3 Mar 2020 16:36:03 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7921386A1E; Tue, 3 Mar 2020 16:36:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZFA5001288 for ; Tue, 3 Mar 2020 11:35:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3FB2F73876; Tue, 3 Mar 2020 16:35:15 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C13FB73881; Tue, 3 Mar 2020 16:35:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id D65EC1132D6D; Tue, 3 Mar 2020 17:35:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253434; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=rYBRTIxWrmmaNX+SQZ/hkAqDwcggwJmFe+zo7D36bDg=; b=SYskdcLDHMzLLU3acP3O2HD8JH9KeWBdMHPVsc85L/TQVvpJG5MA6CtDgBdHiM0d3wSU9d QH7FxQsPbqdTdMpapyAity1V1VEyS+TMYuOZ/I8xSZ8ZtR4Rtmgo2TqKN0OXFdMccZWhfF hYdY9GkxDs000djpqVjW9CIOg+LNLNk= X-MC-Unique: L_awPtViM26mrOQFouJH5g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 12/30] qapi: Add feature flags to remaining definitions Date: Tue, 3 Mar 2020 17:34:47 +0100 Message-Id: <20200303163505.32041-13-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" In v4.1.0, we added feature flags just to struct types (commit 6a8c0b5102^..f3ed93d545), to satisfy an immediate need (commit c9d4070991 "file-posix: Add dynamic-auto-read-only QAPI feature"). In v4.2.0, we added them to commands (commit 23394b4c39 "qapi: Add feature flags to commands") to satisfy another immediate need (commit d76744e65e "qapi: Allow introspecting fix for savevm's cooperation with blockdev"). Add them to the remaining definitions: enumeration types, union types, alternate types, and events. Signed-off-by: Markus Armbruster --- docs/devel/qapi-code-gen.txt | 54 +++++++++----- tests/qapi-schema/doc-good.texi | 30 ++++++++ qapi/introspect.json | 20 +++--- tests/test-qmp-cmds.c | 6 +- scripts/qapi/doc.py | 6 +- scripts/qapi/events.py | 2 +- scripts/qapi/expr.py | 11 ++- scripts/qapi/introspect.py | 31 ++++---- scripts/qapi/schema.py | 96 ++++++++++++++----------- scripts/qapi/types.py | 4 +- scripts/qapi/visit.py | 4 +- tests/qapi-schema/alternate-base.err | 2 +- tests/qapi-schema/doc-good.json | 17 +++++ tests/qapi-schema/doc-good.out | 15 ++++ tests/qapi-schema/qapi-schema-test.json | 29 ++++++-- tests/qapi-schema/qapi-schema-test.out | 27 +++++-- tests/qapi-schema/test-qapi.py | 9 ++- 17 files changed, 242 insertions(+), 121 deletions(-) diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt index 297a725084..9fce78dcad 100644 --- a/docs/devel/qapi-code-gen.txt +++ b/docs/devel/qapi-code-gen.txt @@ -172,7 +172,8 @@ Syntax: ENUM =3D { 'enum': STRING, 'data': [ ENUM-VALUE, ... ], '*prefix': STRING, - '*if': COND } + '*if': COND, + '*features': FEATURES } ENUM-VALUE =3D STRING | { 'name': STRING, '*if': COND } =20 @@ -207,6 +208,9 @@ the job satisfactorily. The optional 'if' member specifies a conditional. See "Configuring the schema" below for more on this. =20 +The optional 'features' member specifies features. See "Features" +below for more on this. + =20 =3D=3D=3D Type references and array types =3D=3D=3D =20 @@ -279,12 +283,14 @@ below for more on this. Syntax: UNION =3D { 'union': STRING, 'data': BRANCHES, - '*if': COND } + '*if': COND, + '*features': FEATURES } | { 'union': STRING, 'data': BRANCHES, 'base': ( MEMBERS | STRING ), 'discriminator': STRING, - '*if': COND } + '*if': COND, + '*features': FEATURES } BRANCHES =3D { BRANCH, ... } BRANCH =3D STRING : TYPE-REF | STRING : { 'type': TYPE-REF, '*if': COND } @@ -391,13 +397,17 @@ is identical on the wire to: The optional 'if' member specifies a conditional. See "Configuring the schema" below for more on this. =20 +The optional 'features' member specifies features. See "Features" +below for more on this. + =20 =3D=3D=3D Alternate types =3D=3D=3D =20 Syntax: ALTERNATE =3D { 'alternate': STRING, 'data': ALTERNATIVES, - '*if': COND } + '*if': COND, + '*features': FEATURES } ALTERNATIVES =3D { ALTERNATIVE, ... } ALTERNATIVE =3D STRING : TYPE-REF | STRING : { 'type': STRING, '*if': COND } @@ -441,6 +451,9 @@ following example objects: The optional 'if' member specifies a conditional. See "Configuring the schema" below for more on this. =20 +The optional 'features' member specifies features. See "Features" +below for more on this. + =20 =3D=3D=3D Commands =3D=3D=3D =20 @@ -584,6 +597,9 @@ started with --preconfig. The optional 'if' member specifies a conditional. See "Configuring the schema" below for more on this. =20 +The optional 'features' member specifies features. See "Features" +below for more on this. + =20 =3D=3D=3D Events =3D=3D=3D =20 @@ -595,7 +611,8 @@ Syntax: 'data': STRING, 'boxed': true, ) - '*if': COND } + '*if': COND, + '*features': FEATURES } =20 Member 'event' names the event. This is the event name used in the Client JSON Protocol. @@ -628,6 +645,9 @@ complex type. See section "Code generated for events" = for examples. The optional 'if' member specifies a conditional. See "Configuring the schema" below for more on this. =20 +The optional 'features' member specifies features. See "Features" +below for more on this. + =20 =3D=3D=3D Features =3D=3D=3D =20 @@ -966,8 +986,9 @@ schema, along with the SchemaInfo type. This text atte= mpts to give an overview how things work. For details you need to consult the QAPI schema. =20 -SchemaInfo objects have common members "name", "meta-type", and -additional variant members depending on the value of meta-type. +SchemaInfo objects have common members "name", "meta-type", +"features", and additional variant members depending on the value of +meta-type. =20 Each SchemaInfo object describes a wire ABI entity of a certain meta-type: a command, event or one of several kinds of type. @@ -980,19 +1001,21 @@ not. Therefore, the SchemaInfo for types have auto-= generated meaningless names. For readability, the examples in this section use meaningful type names instead. =20 +Optional member "features" exposes the entity's feature strings as a +JSON array of strings. + To examine a type, start with a command or event using it, then follow references by name. =20 QAPI schema definitions not reachable that way are omitted. =20 The SchemaInfo for a command has meta-type "command", and variant -members "arg-type", "ret-type", "allow-oob", and "features". On the -wire, the "arguments" member of a client's "execute" command must -conform to the object type named by "arg-type". The "return" member -that the server passes in a success response conforms to the type -named by "ret-type". When "allow-oob" is true, it means the command -supports out-of-band execution. It defaults to false. "features" -exposes the command's feature strings as a JSON array of strings. +members "arg-type", "ret-type" and "allow-oob". On the wire, the +"arguments" member of a client's "execute" command must conform to the +object type named by "arg-type". The "return" member that the server +passes in a success response conforms to the type named by "ret-type". +When "allow-oob" is true, it means the command supports out-of-band +execution. It defaults to false. =20 If the command takes no arguments, "arg-type" names an object type without members. Likewise, if the command returns nothing, "ret-type" @@ -1027,8 +1050,7 @@ Example: the SchemaInfo for EVENT_C from section Even= ts =20 The SchemaInfo for struct and union types has meta-type "object". =20 -The SchemaInfo for a struct type has variant members "members" and -"features". +The SchemaInfo for a struct type has variant member "members". =20 The SchemaInfo for a union type additionally has variant members "tag" and "variants". diff --git a/tests/qapi-schema/doc-good.texi b/tests/qapi-schema/doc-good.t= exi index d4b15dabf0..76b396dae6 100644 --- a/tests/qapi-schema/doc-good.texi +++ b/tests/qapi-schema/doc-good.texi @@ -88,6 +88,12 @@ The @emph{one} @{and only@} @item @code{two} Not documented @end table + +@b{Features:} +@table @asis +@item @code{enum-feat} +Also @emph{one} @{and only@} +@end table @code{two} is undocumented =20 @b{If:} @code{defined(IFCOND)} @@ -151,6 +157,12 @@ a feature @item The members of @code{Variant2} when @code{base1} is @t{"two"} (@b{If= :} @code{IFTWO}) @end table =20 +@b{Features:} +@table @asis +@item @code{union-feat1} +a feature +@end table + @end deftp =20 =20 @@ -167,6 +179,12 @@ One of @t{"one"}, @t{"two"} @item @code{data: Variant2} when @code{type} is @t{"two"} (@b{If:} @code{I= FTWO}) @end table =20 +@b{Features:} +@table @asis +@item @code{union-feat2} +a feature +@end table + @end deftp =20 =20 @@ -184,6 +202,12 @@ an integer Not documented @end table =20 +@b{Features:} +@table @asis +@item @code{alt-feat} +a feature +@end table + @end deftp =20 =20 @@ -283,5 +307,11 @@ another feature =20 @b{Arguments:} the members of @code{Object} =20 +@b{Features:} +@table @asis +@item @code{feat3} +a feature +@end table + @end deftypefn =20 diff --git a/qapi/introspect.json b/qapi/introspect.json index 8756e7920e..da3e176899 100644 --- a/qapi/introspect.json +++ b/qapi/introspect.json @@ -89,12 +89,18 @@ # # @meta-type: the entity's meta type, inherited from @base. # +# @features: names of features associated with the entity, in no +# particular order. +# (since 4.1 for object types, 4.2 for commands, 5.0 for +# the rest) +# # Additional members depend on the value of @meta-type. # # Since: 2.5 ## { 'union': 'SchemaInfo', - 'base': { 'name': 'str', 'meta-type': 'SchemaMetaType' }, + 'base': { 'name': 'str', 'meta-type': 'SchemaMetaType', + '*features': [ 'str' ] }, 'discriminator': 'meta-type', 'data': { 'builtin': 'SchemaInfoBuiltin', @@ -174,9 +180,6 @@ # 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 @@ -184,8 +187,7 @@ { 'struct': 'SchemaInfoObject', 'data': { 'members': [ 'SchemaInfoObjectMember' ], '*tag': 'str', - '*variants': [ 'SchemaInfoObjectVariant' ], - '*features': [ 'str' ] } } + '*variants': [ 'SchemaInfoObjectVariant' ] } } =20 ## # @SchemaInfoObjectMember: @@ -266,17 +268,13 @@ # @allow-oob: whether the command allows out-of-band execution, # defaults to false (Since: 2.12) # -# @features: names of features associated with the command, in no particul= ar -# order. (since 4.2) -# # TODO: @success-response (currently irrelevant, because it's QGA, not QMP) # # Since: 2.5 ## { 'struct': 'SchemaInfoCommand', 'data': { 'arg-type': 'str', 'ret-type': 'str', - '*allow-oob': 'bool', - '*features': [ 'str' ] } } + '*allow-oob': 'bool' } } =20 ## # @SchemaInfoEvent: diff --git a/tests/test-qmp-cmds.c b/tests/test-qmp-cmds.c index 99013ff37b..d12ff47e26 100644 --- a/tests/test-qmp-cmds.c +++ b/tests/test-qmp-cmds.c @@ -45,7 +45,7 @@ void qmp_user_def_cmd1(UserDefOne * ud1, Error **errp) { } =20 -void qmp_test_features(FeatureStruct0 *fs0, FeatureStruct1 *fs1, +void qmp_test_features0(FeatureStruct0 *fs0, FeatureStruct1 *fs1, FeatureStruct2 *fs2, FeatureStruct3 *fs3, FeatureStruct4 *fs4, CondFeatureStruct1 *cfs1, CondFeatureStruct2 *cfs2, CondFeatureStruct3 *cfs3, @@ -53,10 +53,6 @@ void qmp_test_features(FeatureStruct0 *fs0, FeatureStruc= t1 *fs1, { } =20 -void qmp_test_command_features0(Error **errp) -{ -} - void qmp_test_command_features1(Error **errp) { } diff --git a/scripts/qapi/doc.py b/scripts/qapi/doc.py index 1787a53d91..36e823338b 100644 --- a/scripts/qapi/doc.py +++ b/scripts/qapi/doc.py @@ -243,7 +243,7 @@ class QAPISchemaGenDocVisitor(QAPISchemaVisitor): def write(self, output_dir): self._gen.write(output_dir) =20 - def visit_enum_type(self, name, info, ifcond, members, prefix): + def visit_enum_type(self, name, info, ifcond, features, members, prefi= x): doc =3D self.cur_doc self._gen.add(texi_type('Enum', doc, ifcond, texi_members(doc, 'Values', @@ -257,7 +257,7 @@ class QAPISchemaGenDocVisitor(QAPISchemaVisitor): self._gen.add(texi_type('Object', doc, ifcond, texi_members(doc, 'Members', base, variant= s))) =20 - def visit_alternate_type(self, name, info, ifcond, variants): + def visit_alternate_type(self, name, info, ifcond, features, variants): doc =3D self.cur_doc self._gen.add(texi_type('Alternate', doc, ifcond, texi_members(doc, 'Members'))) @@ -270,7 +270,7 @@ class QAPISchemaGenDocVisitor(QAPISchemaVisitor): texi_arguments(doc, arg_type if boxed else None)= )) =20 - def visit_event(self, name, info, ifcond, arg_type, boxed): + def visit_event(self, name, info, ifcond, features, arg_type, boxed): doc =3D self.cur_doc self._gen.add(texi_msg('Event', doc, ifcond, texi_arguments(doc, diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py index a98b9f5099..b544af5a1c 100644 --- a/scripts/qapi/events.py +++ b/scripts/qapi/events.py @@ -189,7 +189,7 @@ void %(event_emit)s(%(event_enum)s event, QDict *qdict); event_emit=3Dself._event_emit_name, event_enum=3Dself._event_enum_name)) =20 - def visit_event(self, name, info, ifcond, arg_type, boxed): + def visit_event(self, name, info, ifcond, features, arg_type, boxed): with ifcontext(ifcond, self._genh, self._genc): self._genh.add(gen_event_send_decl(name, arg_type, boxed)) self._genc.add(gen_event_send(name, arg_type, boxed, diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index fecf466fa7..f9c4448980 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -219,7 +219,6 @@ def check_struct(expr, info): =20 check_type(members, info, "'data'", allow_dict=3Dname) check_type(expr.get('base'), info, "'base'") - check_features(expr.get('features'), info) =20 =20 def check_union(expr, info): @@ -267,7 +266,6 @@ def check_command(expr, info): raise QAPISemError(info, "'boxed': true requires 'data'") check_type(args, info, "'data'", allow_dict=3Dnot boxed) check_type(rets, info, "'returns'", allow_array=3DTrue) - check_features(expr.get('features'), info) =20 =20 def check_event(expr, info): @@ -319,18 +317,18 @@ def check_exprs(exprs): =20 if meta =3D=3D 'enum': check_keys(expr, info, meta, - ['enum', 'data'], ['if', 'prefix']) + ['enum', 'data'], ['if', 'features', 'prefix']) check_enum(expr, info) elif meta =3D=3D 'union': check_keys(expr, info, meta, ['union', 'data'], - ['base', 'discriminator', 'if']) + ['base', 'discriminator', 'if', 'features']) normalize_members(expr.get('base')) normalize_members(expr['data']) check_union(expr, info) elif meta =3D=3D 'alternate': check_keys(expr, info, meta, - ['alternate', 'data'], ['if']) + ['alternate', 'data'], ['if', 'features']) normalize_members(expr['data']) check_alternate(expr, info) elif meta =3D=3D 'struct': @@ -348,13 +346,14 @@ def check_exprs(exprs): check_command(expr, info) elif meta =3D=3D 'event': check_keys(expr, info, meta, - ['event'], ['data', 'boxed', 'if']) + ['event'], ['data', 'boxed', 'if', 'features']) normalize_members(expr.get('data')) check_event(expr, info) else: assert False, 'unexpected meta type' =20 check_if(expr, info, meta) + check_features(expr.get('features'), info) check_flags(expr, info) =20 return exprs diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index b5537eddc0..2e9e00aa1f 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -144,7 +144,7 @@ const QLitObject %(c_name)s =3D %(c_string)s; return '[' + self._use_type(typ.element_type) + ']' return self._name(typ.name) =20 - def _gen_qlit(self, name, mtype, obj, ifcond): + def _gen_qlit(self, name, mtype, obj, ifcond, features): extra =3D {} if mtype not in ('command', 'event', 'builtin', 'array'): if not self._unmask: @@ -154,6 +154,8 @@ const QLitObject %(c_name)s =3D %(c_string)s; name =3D self._name(name) obj['name'] =3D name obj['meta-type'] =3D mtype + if features: + obj['features'] =3D [(f.name, {'if': f.ifcond}) for f in featu= res] if ifcond: extra['if'] =3D ifcond if extra: @@ -178,18 +180,18 @@ const QLitObject %(c_name)s =3D %(c_string)s; {'if': variant.ifcond}) =20 def visit_builtin_type(self, name, info, json_type): - self._gen_qlit(name, 'builtin', {'json-type': json_type}, []) + self._gen_qlit(name, 'builtin', {'json-type': json_type}, [], None) =20 - def visit_enum_type(self, name, info, ifcond, members, prefix): + def visit_enum_type(self, name, info, ifcond, features, members, prefi= x): self._gen_qlit(name, 'enum', {'values': [(m.name, {'if': m.ifcond}) for m in members]}, - ifcond) + ifcond, features) =20 def visit_array_type(self, name, info, ifcond, element_type): element =3D self._use_type(element_type) self._gen_qlit('[' + element + ']', 'array', {'element-type': elem= ent}, - ifcond) + ifcond, None) =20 def visit_object_type_flat(self, name, info, ifcond, members, variants, features): @@ -197,16 +199,15 @@ const QLitObject %(c_name)s =3D %(c_string)s; 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] =20 - self._gen_qlit(name, 'object', obj, ifcond) + self._gen_qlit(name, 'object', obj, ifcond, features) =20 - def visit_alternate_type(self, name, info, ifcond, variants): + def visit_alternate_type(self, name, info, ifcond, features, variants): self._gen_qlit(name, 'alternate', {'members': [ ({'type': self._use_type(m.type)}, {'if': m.ifc= ond}) - for m in variants.variants]}, ifcond) + for m in variants.variants]}, + ifcond, features) =20 def visit_command(self, name, info, ifcond, arg_type, ret_type, gen, success_response, boxed, allow_oob, allow_preconfig, @@ -217,16 +218,12 @@ const QLitObject %(c_name)s =3D %(c_string)s; 'ret-type': self._use_type(ret_type)} if allow_oob: obj['allow-oob'] =3D allow_oob + self._gen_qlit(name, 'command', obj, ifcond, features) =20 - if features: - obj['features'] =3D [(f.name, {'if': f.ifcond}) for f in featu= res] - - self._gen_qlit(name, 'command', obj, ifcond) - - def visit_event(self, name, info, ifcond, arg_type, boxed): + def visit_event(self, name, info, ifcond, features, arg_type, boxed): arg_type =3D arg_type or self._schema.the_empty_object_type self._gen_qlit(name, 'event', {'arg-type': self._use_type(arg_type= )}, - ifcond) + ifcond, features) =20 =20 def gen_introspect(schema, output_dir, prefix, opt_unmask): diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 1c8d126441..98c9f3016c 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -109,7 +109,7 @@ class QAPISchemaVisitor: def visit_builtin_type(self, name, info, json_type): pass =20 - def visit_enum_type(self, name, info, ifcond, members, prefix): + def visit_enum_type(self, name, info, ifcond, features, members, prefi= x): pass =20 def visit_array_type(self, name, info, ifcond, element_type): @@ -123,7 +123,7 @@ class QAPISchemaVisitor: features): pass =20 - def visit_alternate_type(self, name, info, ifcond, variants): + def visit_alternate_type(self, name, info, ifcond, features, variants): pass =20 def visit_command(self, name, info, ifcond, arg_type, ret_type, gen, @@ -131,7 +131,7 @@ class QAPISchemaVisitor: features): pass =20 - def visit_event(self, name, info, ifcond, arg_type, boxed): + def visit_event(self, name, info, ifcond, features, arg_type, boxed): pass =20 =20 @@ -234,8 +234,8 @@ class QAPISchemaBuiltinType(QAPISchemaType): class QAPISchemaEnumType(QAPISchemaType): meta =3D 'enum' =20 - def __init__(self, name, info, doc, ifcond, members, prefix): - super().__init__(name, info, doc, ifcond) + def __init__(self, name, info, doc, ifcond, features, members, prefix): + super().__init__(name, info, doc, ifcond, features) for m in members: assert isinstance(m, QAPISchemaEnumMember) m.set_defined_in(name) @@ -271,15 +271,16 @@ class QAPISchemaEnumType(QAPISchemaType): =20 def visit(self, visitor): super().visit(visitor) - visitor.visit_enum_type(self.name, self.info, self.ifcond, - self.members, self.prefix) + visitor.visit_enum_type( + self.name, self.info, self.ifcond, self.features, + self.members, self.prefix) =20 =20 class QAPISchemaArrayType(QAPISchemaType): meta =3D 'array' =20 def __init__(self, name, info, element_type): - super().__init__(name, info, None, None) + super().__init__(name, info, None) assert isinstance(element_type, str) self._element_type_name =3D element_type self.element_type =3D None @@ -325,8 +326,8 @@ class QAPISchemaArrayType(QAPISchemaType): =20 =20 class QAPISchemaObjectType(QAPISchemaType): - def __init__(self, name, info, doc, ifcond, - base, local_members, variants, features): + def __init__(self, name, info, doc, ifcond, features, + base, local_members, variants): # 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 @@ -623,8 +624,8 @@ class QAPISchemaObjectTypeVariant(QAPISchemaObjectTypeM= ember): class QAPISchemaAlternateType(QAPISchemaType): meta =3D 'alternate' =20 - def __init__(self, name, info, doc, ifcond, variants): - super().__init__(name, info, doc, ifcond) + def __init__(self, name, info, doc, ifcond, features, variants): + super().__init__(name, info, doc, ifcond, features) assert isinstance(variants, QAPISchemaObjectTypeVariants) assert variants.tag_member variants.set_defined_in(name) @@ -684,16 +685,16 @@ class QAPISchemaAlternateType(QAPISchemaType): =20 def visit(self, visitor): super().visit(visitor) - visitor.visit_alternate_type(self.name, self.info, self.ifcond, - self.variants) + visitor.visit_alternate_type( + self.name, self.info, self.ifcond, self.features, self.variant= s) =20 =20 class QAPISchemaCommand(QAPISchemaEntity): meta =3D 'command' =20 - def __init__(self, name, info, doc, ifcond, arg_type, ret_type, - gen, success_response, boxed, allow_oob, allow_preconfig, - features): + def __init__(self, name, info, doc, ifcond, features, + arg_type, ret_type, + gen, success_response, boxed, allow_oob, allow_preconfig): super().__init__(name, info, doc, ifcond, features) assert not arg_type or isinstance(arg_type, str) assert not ret_type or isinstance(ret_type, str) @@ -756,8 +757,8 @@ class QAPISchemaCommand(QAPISchemaEntity): class QAPISchemaEvent(QAPISchemaEntity): meta =3D 'event' =20 - def __init__(self, name, info, doc, ifcond, arg_type, boxed): - super().__init__(name, info, doc, ifcond) + def __init__(self, name, info, doc, ifcond, features, arg_type, boxed): + super().__init__(name, info, doc, ifcond, features) assert not arg_type or isinstance(arg_type, str) self._arg_type_name =3D arg_type self.arg_type =3D None @@ -788,8 +789,9 @@ class QAPISchemaEvent(QAPISchemaEntity): =20 def visit(self, visitor): super().visit(visitor) - visitor.visit_event(self.name, self.info, self.ifcond, - self.arg_type, self.boxed) + visitor.visit_event( + self.name, self.info, self.ifcond, self.features, + self.arg_type, self.boxed) =20 =20 class QAPISchema: @@ -894,7 +896,7 @@ class QAPISchema: ('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, [], None) self._def_entity(self.the_empty_object_type) =20 qtypes =3D ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', @@ -902,10 +904,11 @@ class QAPISchema: qtype_values =3D self._make_enum_members( [{'name': n} for n in qtypes], None) =20 - self._def_entity(QAPISchemaEnumType('QType', None, None, None, + self._def_entity(QAPISchemaEnumType('QType', None, None, None, Non= e, qtype_values, 'QTYPE')) =20 - def _make_features(self, features, info): + def _make_features(self, expr, info): + features =3D expr.get('features', []) return [QAPISchemaFeature(f['name'], info, f.get('if')) for f in features] =20 @@ -917,7 +920,8 @@ class QAPISchema: # See also QAPISchemaObjectTypeMember.describe() name =3D name + 'Kind' # reserved by check_defn_name_str() self._def_entity(QAPISchemaEnumType( - name, info, None, ifcond, self._make_enum_members(values, info= ), + name, info, None, ifcond, None, + self._make_enum_members(values, info), None)) return name =20 @@ -945,8 +949,8 @@ class QAPISchema: # TODO kill simple unions or implement the disjunction assert (ifcond or []) =3D=3D typ._ifcond # pylint: disable=3Dp= rotected-access else: - self._def_entity(QAPISchemaObjectType(name, info, None, ifcond, - None, members, None, [])) + self._def_entity(QAPISchemaObjectType( + name, info, None, ifcond, None, None, members, None)) return name =20 def _def_enum_type(self, expr, info, doc): @@ -954,8 +958,9 @@ class QAPISchema: data =3D expr['data'] prefix =3D expr.get('prefix') ifcond =3D expr.get('if') + features =3D self._make_features(expr, info) self._def_entity(QAPISchemaEnumType( - name, info, doc, ifcond, + name, info, doc, ifcond, features, self._make_enum_members(data, info), prefix)) =20 def _make_member(self, name, typ, ifcond, info): @@ -977,12 +982,11 @@ class QAPISchema: base =3D expr.get('base') data =3D expr['data'] ifcond =3D expr.get('if') - features =3D expr.get('features', []) + features =3D self._make_features(expr, info) self._def_entity(QAPISchemaObjectType( - name, info, doc, ifcond, base, + name, info, doc, ifcond, features, base, self._make_members(data, info), - None, - self._make_features(features, info))) + None)) =20 def _make_variant(self, case, typ, ifcond, info): return QAPISchemaObjectTypeVariant(case, info, typ, ifcond) @@ -1001,6 +1005,7 @@ class QAPISchema: data =3D expr['data'] base =3D expr.get('base') ifcond =3D expr.get('if') + features =3D self._make_features(expr, info) tag_name =3D expr.get('discriminator') tag_member =3D None if isinstance(base, dict): @@ -1021,21 +1026,22 @@ class QAPISchema: tag_member =3D QAPISchemaObjectTypeMember('type', info, typ, F= alse) members =3D [tag_member] self._def_entity( - QAPISchemaObjectType(name, info, doc, ifcond, base, members, + QAPISchemaObjectType(name, info, doc, ifcond, features, + base, members, QAPISchemaObjectTypeVariants( - tag_name, info, tag_member, variants), - [])) + tag_name, info, tag_member, variants)= )) =20 def _def_alternate_type(self, expr, info, doc): name =3D expr['alternate'] data =3D expr['data'] ifcond =3D expr.get('if') + features =3D self._make_features(expr, info) variants =3D [self._make_variant(key, value['type'], value.get('if= '), info) for (key, value) in data.items()] tag_member =3D QAPISchemaObjectTypeMember('type', info, 'QType', F= alse) self._def_entity( - QAPISchemaAlternateType(name, info, doc, ifcond, + QAPISchemaAlternateType(name, info, doc, ifcond, features, QAPISchemaObjectTypeVariants( None, info, tag_member, variants))) =20 @@ -1049,27 +1055,31 @@ class QAPISchema: allow_oob =3D expr.get('allow-oob', False) allow_preconfig =3D expr.get('allow-preconfig', False) ifcond =3D expr.get('if') - features =3D expr.get('features', []) + features =3D self._make_features(expr, info) if isinstance(data, OrderedDict): data =3D self._make_implicit_object_type( - name, info, ifcond, 'arg', self._make_members(data, info)) + name, info, ifcond, + 'arg', self._make_members(data, info)) if isinstance(rets, list): assert len(rets) =3D=3D 1 rets =3D self._make_array_type(rets[0], info) - self._def_entity(QAPISchemaCommand(name, info, doc, ifcond, data, = rets, + self._def_entity(QAPISchemaCommand(name, info, doc, ifcond, featur= es, + data, rets, gen, success_response, - boxed, allow_oob, allow_preconf= ig, - self._make_features(features, i= nfo))) + boxed, allow_oob, allow_preconf= ig)) =20 def _def_event(self, expr, info, doc): name =3D expr['event'] data =3D expr.get('data') boxed =3D expr.get('boxed', False) ifcond =3D expr.get('if') + features =3D self._make_features(expr, info) if isinstance(data, OrderedDict): data =3D self._make_implicit_object_type( - name, info, ifcond, 'arg', self._make_members(data, info)) - self._def_entity(QAPISchemaEvent(name, info, doc, ifcond, data, bo= xed)) + name, info, ifcond, + 'arg', self._make_members(data, info)) + self._def_entity(QAPISchemaEvent(name, info, doc, ifcond, features, + data, boxed)) =20 def _def_exprs(self, exprs): for expr_elem in exprs: diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index 3c83b6e4be..d0d5c03646 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -278,7 +278,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaModularCVisito= r): self._genh.add(gen_type_cleanup_decl(name)) self._genc.add(gen_type_cleanup(name)) =20 - def visit_enum_type(self, name, info, ifcond, members, prefix): + def visit_enum_type(self, name, info, ifcond, features, members, prefi= x): with ifcontext(ifcond, self._genh, self._genc): self._genh.preamble_add(gen_enum(name, members, prefix)) self._genc.add(gen_enum_lookup(name, members, prefix)) @@ -306,7 +306,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaModularCVisito= r): # implicit types won't be directly allocated/freed self._gen_type_cleanup(name) =20 - def visit_alternate_type(self, name, info, ifcond, variants): + def visit_alternate_type(self, name, info, ifcond, features, variants): with ifcontext(ifcond, self._genh): self._genh.preamble_add(gen_fwd_object_or_array(name)) self._genh.add(gen_object(name, ifcond, None, diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index 421e5bd8cd..6e5ed781d7 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -316,7 +316,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaModularCVisit= or): ''', types=3Dtypes)) =20 - def visit_enum_type(self, name, info, ifcond, members, prefix): + def visit_enum_type(self, name, info, ifcond, features, members, prefi= x): with ifcontext(ifcond, self._genh, self._genc): self._genh.add(gen_visit_decl(name, scalar=3DTrue)) self._genc.add(gen_visit_enum(name)) @@ -342,7 +342,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaModularCVisit= or): self._genh.add(gen_visit_decl(name)) self._genc.add(gen_visit_object(name, base, members, varia= nts)) =20 - def visit_alternate_type(self, name, info, ifcond, variants): + def visit_alternate_type(self, name, info, ifcond, features, variants): with ifcontext(ifcond, self._genh, self._genc): self._genh.add(gen_visit_decl(name)) self._genc.add(gen_visit_alternate(name, variants)) diff --git a/tests/qapi-schema/alternate-base.err b/tests/qapi-schema/alter= nate-base.err index 31ebe56bbf..970a08ab26 100644 --- a/tests/qapi-schema/alternate-base.err +++ b/tests/qapi-schema/alternate-base.err @@ -1,3 +1,3 @@ alternate-base.json: In alternate 'Alt': alternate-base.json:4: alternate has unknown key 'base' -Valid keys are 'alternate', 'data', 'if'. +Valid keys are 'alternate', 'data', 'features', 'if'. diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.j= son index d992e713d9..457b8b2cdf 100644 --- a/tests/qapi-schema/doc-good.json +++ b/tests/qapi-schema/doc-good.json @@ -53,10 +53,14 @@ # @Enum: # @one: The _one_ {and only} # +# Features: +# @enum-feat: Also _one_ {and only} +# # @two is undocumented ## { 'enum': 'Enum', 'data': [ { 'name': 'one', 'if': 'defined(IFONE)' }, 'two' ], + 'features': [ 'enum-feat' ], 'if': 'defined(IFCOND)' } =20 ## @@ -86,24 +90,34 @@ =20 ## # @Object: +# Features: +# @union-feat1: a feature ## { 'union': 'Object', + 'features': [ 'union-feat1' ], 'base': 'Base', 'discriminator': 'base1', 'data': { 'one': 'Variant1', 'two': { 'type': 'Variant2', 'if': 'IFTWO' = } } } =20 ## # @SugaredUnion: +# Features: +# @union-feat2: a feature ## { 'union': 'SugaredUnion', + 'features': [ 'union-feat2' ], 'data': { 'one': 'Variant1', 'two': { 'type': 'Variant2', 'if': 'IFTWO' = } } } =20 ## # @Alternate: # @i: an integer # @b is undocumented +# +# Features: +# @alt-feat: a feature ## { 'alternate': 'Alternate', + 'features': [ 'alt-feat' ], 'data': { 'i': 'int', 'b': 'bool' } } =20 ## @@ -160,6 +174,9 @@ =20 ## # @EVT-BOXED: +# Features: +# @feat3: a feature ## { 'event': 'EVT-BOXED', 'boxed': true, + 'features': [ 'feat3' ], 'data': 'Object' } diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out index 4c9406a464..9bcb2b3e91 100644 --- a/tests/qapi-schema/doc-good.out +++ b/tests/qapi-schema/doc-good.out @@ -15,6 +15,7 @@ enum Enum if ['defined(IFONE)'] member two if ['defined(IFCOND)'] + feature enum-feat object Base member base1: Enum optional=3DFalse object Variant1 @@ -28,6 +29,7 @@ object Object case one: Variant1 case two: Variant2 if ['IFTWO'] + feature union-feat1 object q_obj_Variant1-wrapper member data: Variant1 optional=3DFalse object q_obj_Variant2-wrapper @@ -42,10 +44,12 @@ object SugaredUnion case one: q_obj_Variant1-wrapper case two: q_obj_Variant2-wrapper if ['IFTWO'] + feature union-feat2 alternate Alternate tag type case i: int case b: bool + feature alt-feat object q_obj_cmd-arg member arg1: int optional=3DFalse member arg2: str optional=3DTrue @@ -60,6 +64,7 @@ command cmd-boxed Object -> None feature cmd-feat2 event EVT-BOXED Object boxed=3DTrue + feature feat3 doc freeform body=3D =3D Section @@ -112,6 +117,8 @@ doc symbol=3DEnum The _one_ {and only} arg=3Dtwo =20 + feature=3Denum-feat +Also _one_ {and only} section=3DNone @two is undocumented doc symbol=3DBase @@ -134,11 +141,15 @@ doc symbol=3DVariant2 doc symbol=3DObject body=3D =20 + feature=3Dunion-feat1 +a feature doc symbol=3DSugaredUnion body=3D =20 arg=3Dtype =20 + feature=3Dunion-feat2 +a feature doc symbol=3DAlternate body=3D =20 @@ -147,6 +158,8 @@ an integer @b is undocumented arg=3Db =20 + feature=3Dalt-feat +a feature doc freeform body=3D =3D=3D Another subsection @@ -197,3 +210,5 @@ another feature doc symbol=3DEVT-BOXED body=3D =20 + feature=3Dfeat3 +a feature diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index 9abf175fe0..fa4f3a15da 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -252,7 +252,7 @@ 'bar': { 'type': ['TestIfEnum'], 'if': 'defined(TEST_IF_EVT_BAR)' } }, 'if': 'defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)' } =20 -# test 'features' for structs +# test 'features' =20 { 'struct': 'FeatureStruct0', 'data': { 'foo': 'int' }, @@ -281,7 +281,22 @@ 'data': { 'foo': 'int' }, 'features': [ { 'name': 'feature1', 'if': [ 'defined(TEST_IF_COND_1)', 'defined(TEST_IF_COND_2)'] }= ] } -{ 'command': 'test-features', + +{ 'enum': 'FeatureEnum1', + 'data': [ 'eins', 'zwei', 'drei' ], + 'features': [ 'feature1' ] } + +{ 'union': 'FeatureUnion1', + 'base': { 'tag': 'FeatureEnum1' }, + 'discriminator': 'tag', + 'data': { 'eins': 'FeatureStruct1' }, + 'features': [ 'feature1' ] } + +{ 'alternate': 'FeatureAlternate1', + 'data': { 'eins': 'FeatureStruct1' }, + 'features': [ 'feature1' ] } + +{ 'command': 'test-features0', 'data': { 'fs0': 'FeatureStruct0', 'fs1': 'FeatureStruct1', 'fs2': 'FeatureStruct2', @@ -289,12 +304,9 @@ 'fs4': 'FeatureStruct4', 'cfs1': 'CondFeatureStruct1', 'cfs2': 'CondFeatureStruct2', - 'cfs3': 'CondFeatureStruct3' } } - -# test 'features' for command - -{ 'command': 'test-command-features0', + 'cfs3': 'CondFeatureStruct3' }, 'features': [] } + { 'command': 'test-command-features1', 'features': [ 'feature1' ] } { 'command': 'test-command-features3', @@ -308,3 +320,6 @@ { 'command': 'test-command-cond-features3', 'features': [ { 'name': 'feature1', 'if': [ 'defined(TEST_IF_COND_1)', 'defined(TEST_IF_COND_2)'] }= ] } + +{ 'event': 'TEST-EVENT-FEATURES1', + 'features': [ 'feature1' ] } diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 9bd3c4a490..1cbd0802b3 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -387,7 +387,25 @@ 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 +enum FeatureEnum1 + member eins + member zwei + member drei + feature feature1 +object q_obj_FeatureUnion1-base + member tag: FeatureEnum1 optional=3DFalse +object FeatureUnion1 + base q_obj_FeatureUnion1-base + tag tag + case eins: FeatureStruct1 + case zwei: q_empty + case drei: q_empty + feature feature1 +alternate FeatureAlternate1 + tag type + case eins: FeatureStruct1 + feature feature1 +object q_obj_test-features0-arg member fs0: FeatureStruct0 optional=3DFalse member fs1: FeatureStruct1 optional=3DFalse member fs2: FeatureStruct2 optional=3DFalse @@ -396,9 +414,7 @@ object q_obj_test-features-arg 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 -command test-command-features0 None -> None +command test-features0 q_obj_test-features0-arg -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse command test-command-features1 None -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse @@ -421,6 +437,9 @@ command test-command-cond-features3 None -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse feature feature1 if ['defined(TEST_IF_COND_1)', 'defined(TEST_IF_COND_2)'] +event TEST-EVENT-FEATURES1 None + boxed=3DFalse + feature feature1 module include/sub-module.json include sub-sub-module.json object SecondArrayRef diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py index bee18ee344..af5b57a0b1 100755 --- a/tests/qapi-schema/test-qapi.py +++ b/tests/qapi-schema/test-qapi.py @@ -30,7 +30,7 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor): def visit_include(self, name, info): print('include %s' % name) =20 - def visit_enum_type(self, name, info, ifcond, members, prefix): + def visit_enum_type(self, name, info, ifcond, features, members, prefi= x): print('enum %s' % name) if prefix: print(' prefix %s' % prefix) @@ -38,6 +38,7 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor): print(' member %s' % m.name) self._print_if(m.ifcond, indent=3D8) self._print_if(ifcond) + self._print_features(features) =20 def visit_array_type(self, name, info, ifcond, element_type): if not info: @@ -58,10 +59,11 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor): self._print_if(ifcond) self._print_features(features) =20 - def visit_alternate_type(self, name, info, ifcond, variants): + def visit_alternate_type(self, name, info, ifcond, features, variants): print('alternate %s' % name) self._print_variants(variants) self._print_if(ifcond) + self._print_features(features) =20 def visit_command(self, name, info, ifcond, arg_type, ret_type, gen, success_response, boxed, allow_oob, allow_preconfig, @@ -74,10 +76,11 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor): self._print_if(ifcond) self._print_features(features) =20 - def visit_event(self, name, info, ifcond, arg_type, boxed): + def visit_event(self, name, info, ifcond, features, arg_type, boxed): print('event %s %s' % (name, arg_type and arg_type.name)) print(' boxed=3D%s' % boxed) self._print_if(ifcond) + self._print_features(features) =20 @staticmethod def _print_variants(variants): --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253386; cv=none; d=zohomail.com; s=zohoarc; b=nKhaDGTNAR+ut8TmgwGDgR8b5rD4CyMDi65rM9h0aBljGhJJ0nAAHC1Xn//EKpAYwjW8Uc0s754ENGB2VZU1eVaExfrw+A58TQ8Wyb8Tm81SfTJEV95Ni7Bdl7wcttblGn75AUHW+br4eoq3MjIWamovRS1QEebk5dgvLPbHDwo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253386; h=Content-Type: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; bh=wxa542ID+VKkpOZ+of1XQ+pUYDi2o1+LFFOqqIG2ZlY=; b=OukEB9IrN62oiKNFKLHoMnGKU0DHDVUekIov2nJPlT990q0x5n1IfbHjmvFNjF1kDmN5+kOfYaFU1KQ3RuGD2p+8sH6Lyd8orfNIJP1ZOWjZd2CvhWlFRLSVSNf7EWcR6i3WiiwqZJ9+U962m0G7Q8CaObOiMVrapA4RNobsTvs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1583253386021715.2244039731751; Tue, 3 Mar 2020 08:36:26 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-171-SwuRZh8cPfW9WJUXUNl3BA-1; Tue, 03 Mar 2020 11:36:22 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id AC5E49B581; Tue, 3 Mar 2020 16:36:14 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7864B10013A1; Tue, 3 Mar 2020 16:36:14 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2C82918034FF; Tue, 3 Mar 2020 16:36:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZIms001354 for ; Tue, 3 Mar 2020 11:35:18 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0596019C4F; Tue, 3 Mar 2020 16:35:18 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C1987196AE; Tue, 3 Mar 2020 16:35:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id D9B6B1132BD2; Tue, 3 Mar 2020 17:35:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253384; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=wxa542ID+VKkpOZ+of1XQ+pUYDi2o1+LFFOqqIG2ZlY=; b=aTxt4FGJ5AQ2bVZmmADfuHlbsVX0Oz9yHw1N/B+b2H3EUZ51twqCgUy1N2tRElH3W/+ZcB x0FFtineOmPKUi850hp0EqxY2LwNtRfMSkz14eSy2s2KDLzqNFcEDLHGwiqTE6Nize+Bpb gyh8dhrp/HX4ZhqyRqRKl78KFzou4V8= X-MC-Unique: SwuRZh8cPfW9WJUXUNl3BA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 13/30] qapi: Consistently put @features parameter right after @ifcond Date: Tue, 3 Mar 2020 17:34:48 +0100 Message-Id: <20200303163505.32041-14-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster --- scripts/qapi/commands.py | 6 +++--- scripts/qapi/doc.py | 10 +++++----- scripts/qapi/introspect.py | 10 +++++----- scripts/qapi/schema.py | 36 ++++++++++++++++------------------ scripts/qapi/types.py | 4 ++-- scripts/qapi/visit.py | 4 ++-- tests/qapi-schema/test-qapi.py | 10 +++++----- 7 files changed, 39 insertions(+), 41 deletions(-) diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index 0e13e82989..bc30876c88 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -283,9 +283,9 @@ void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds); prefix=3Dself._prefix)) self._genc.add(gen_registry(self._regy.get_content(), self._prefix= )) =20 - def visit_command(self, name, info, ifcond, arg_type, ret_type, gen, - success_response, boxed, allow_oob, allow_preconfig, - features): + def visit_command(self, name, info, ifcond, features, + arg_type, ret_type, gen, success_response, boxed, + allow_oob, allow_preconfig): if not gen: return # FIXME: If T is a user-defined type, the user is responsible diff --git a/scripts/qapi/doc.py b/scripts/qapi/doc.py index 36e823338b..92f584edcf 100644 --- a/scripts/qapi/doc.py +++ b/scripts/qapi/doc.py @@ -249,8 +249,8 @@ class QAPISchemaGenDocVisitor(QAPISchemaVisitor): texi_members(doc, 'Values', member_func=3Dtexi_enum_value= ))) =20 - def visit_object_type(self, name, info, ifcond, base, members, variant= s, - features): + def visit_object_type(self, name, info, ifcond, features, + base, members, variants): doc =3D self.cur_doc if base and base.is_implicit(): base =3D None @@ -262,9 +262,9 @@ class QAPISchemaGenDocVisitor(QAPISchemaVisitor): self._gen.add(texi_type('Alternate', doc, ifcond, texi_members(doc, 'Members'))) =20 - def visit_command(self, name, info, ifcond, arg_type, ret_type, gen, - success_response, boxed, allow_oob, allow_preconfig, - features): + def visit_command(self, name, info, ifcond, features, + arg_type, ret_type, gen, success_response, boxed, + allow_oob, allow_preconfig): doc =3D self.cur_doc self._gen.add(texi_msg('Command', doc, ifcond, texi_arguments(doc, diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 2e9e00aa1f..b54910510d 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -193,8 +193,8 @@ const QLitObject %(c_name)s =3D %(c_string)s; self._gen_qlit('[' + element + ']', 'array', {'element-type': elem= ent}, ifcond, None) =20 - def visit_object_type_flat(self, name, info, ifcond, members, variants, - features): + def visit_object_type_flat(self, name, info, ifcond, features, + members, variants): obj =3D {'members': [self._gen_member(m) for m in members]} if variants: obj.update(self._gen_variants(variants.tag_member.name, @@ -209,9 +209,9 @@ const QLitObject %(c_name)s =3D %(c_string)s; for m in variants.variants]}, ifcond, features) =20 - def visit_command(self, name, info, ifcond, arg_type, ret_type, gen, - success_response, boxed, allow_oob, allow_preconfig, - features): + def visit_command(self, name, info, ifcond, features, + arg_type, ret_type, gen, success_response, boxed, + allow_oob, allow_preconfig): arg_type =3D arg_type or self._schema.the_empty_object_type ret_type =3D ret_type or self._schema.the_empty_object_type obj =3D {'arg-type': self._use_type(arg_type), diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 98c9f3016c..e3353989e9 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -115,20 +115,20 @@ class QAPISchemaVisitor: def visit_array_type(self, name, info, ifcond, element_type): pass =20 - def visit_object_type(self, name, info, ifcond, base, members, variant= s, - features): + def visit_object_type(self, name, info, ifcond, features, + base, members, variants): pass =20 - def visit_object_type_flat(self, name, info, ifcond, members, variants, - features): + def visit_object_type_flat(self, name, info, ifcond, features, + members, variants): pass =20 def visit_alternate_type(self, name, info, ifcond, features, variants): pass =20 - def visit_command(self, name, info, ifcond, arg_type, ret_type, gen, - success_response, boxed, allow_oob, allow_preconfig, - features): + def visit_command(self, name, info, ifcond, features, + arg_type, ret_type, gen, success_response, boxed, + allow_oob, allow_preconfig): pass =20 def visit_event(self, name, info, ifcond, features, arg_type, boxed): @@ -436,12 +436,12 @@ class QAPISchemaObjectType(QAPISchemaType): =20 def visit(self, visitor): super().visit(visitor) - visitor.visit_object_type(self.name, self.info, self.ifcond, - 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.features) + visitor.visit_object_type( + self.name, self.info, self.ifcond, self.features, + self.base, self.local_members, self.variants) + visitor.visit_object_type_flat( + self.name, self.info, self.ifcond, self.features, + self.members, self.variants) =20 =20 class QAPISchemaMember: @@ -746,12 +746,10 @@ class QAPISchemaCommand(QAPISchemaEntity): =20 def visit(self, visitor): super().visit(visitor) - visitor.visit_command(self.name, self.info, self.ifcond, - self.arg_type, self.ret_type, - self.gen, self.success_response, - self.boxed, self.allow_oob, - self.allow_preconfig, - self.features) + visitor.visit_command( + self.name, self.info, self.ifcond, self.features, + self.arg_type, self.ret_type, self.gen, self.success_response, + self.boxed, self.allow_oob, self.allow_preconfig) =20 =20 class QAPISchemaEvent(QAPISchemaEntity): diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index d0d5c03646..3ad33af4ee 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -289,8 +289,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, - features): + def visit_object_type(self, name, info, ifcond, features, + base, members, variants): # 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 6e5ed781d7..23d9194aa4 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -326,8 +326,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, - features): + def visit_object_type(self, name, info, ifcond, features, + base, members, variants): # Nothing to do for the special empty builtin if name =3D=3D 'q_empty': return diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py index af5b57a0b1..8e09e54edb 100755 --- a/tests/qapi-schema/test-qapi.py +++ b/tests/qapi-schema/test-qapi.py @@ -46,8 +46,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, - features): + def visit_object_type(self, name, info, ifcond, features, + base, members, variants): print('object %s' % name) if base: print(' base %s' % base.name) @@ -65,9 +65,9 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor): self._print_if(ifcond) self._print_features(features) =20 - def visit_command(self, name, info, ifcond, arg_type, ret_type, gen, - success_response, boxed, allow_oob, allow_preconfig, - features): + def visit_command(self, name, info, ifcond, features, + arg_type, ret_type, gen, success_response, boxed, + allow_oob, allow_preconfig): print('command %s %s -> %s' % (name, arg_type and arg_type.name, ret_type and ret_type.name)) --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253370; cv=none; d=zohomail.com; s=zohoarc; b=ShJDNsXmugc1zT7zvlTP17FGQawKmpqdY1b4cNTab/02iZjshkk+QwtKjeRYA9ZsvtljFRV9IvLJz/y7GpcDkbhTEpFPWPR60rd+Md3HejJ/kswfxXMbayZNVSmWN0vfGUwUlTKIsKYTJ8+0oWLFVOWfRuB2vejBz37MYPOPRNA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253370; h=Content-Type: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; bh=osNV8uUZeUP5b4gAuB1lT2GZGquG+Lh6Va7VhUXUe8c=; b=C1PysiXGGOSe2WEbD+nhJos3wJr4sCBqofxrInqZ6q1o4Wzld0SZVxCfAJ9P0FuSGqE/dHo9eZL9YAgWby8GaXmHBBBxDidv5CXnovpM9OS1IW1xJEqwW77hsA8dUbuIxKiYBUONH3JgAmdFPVUiC45rtO+s5s3oZMpM1E8pGbQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 158325337010513.28595315053974; Tue, 3 Mar 2020 08:36:10 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-426-ALRxmyMNOr2f0S8bPKUXmg-1; Tue, 03 Mar 2020 11:36:06 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 345E88010EE; Tue, 3 Mar 2020 16:35:58 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F1AB239B; Tue, 3 Mar 2020 16:35:57 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 90AEB18037C8; Tue, 3 Mar 2020 16:35:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZF8X001298 for ; Tue, 3 Mar 2020 11:35:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7EE595C3FA; Tue, 3 Mar 2020 16:35:15 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C87405C1D8; Tue, 3 Mar 2020 16:35:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id DCF561132B2C; Tue, 3 Mar 2020 17:35:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253368; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=osNV8uUZeUP5b4gAuB1lT2GZGquG+Lh6Va7VhUXUe8c=; b=fQlctb8gBiMrRh8MNmlklb4o9gH02wGCP29jRcu2bEnmZN88rEQfye5Wlrjb3E7JH0oIvy unx7hqiHh4gwu+oufRvLhcwvOb15HMtTVZLlPcs1RzJcGz5JIBUy2CHD7K5k6Iz9S588GH weO1w4oZpYgQdSGuDvVscN+6c3njUJY= X-MC-Unique: ALRxmyMNOr2f0S8bPKUXmg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 14/30] qapi/introspect: Rename *qlit* to reduce confusion Date: Tue, 3 Mar 2020 17:34:49 +0100 Message-Id: <20200303163505.32041-15-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We generate the value of qmp_schema_qlit from an expression tree. The function doing that is named to_qlit(), and its inputs are accumulated in QAPISchemaGenIntrospectVisitor._qlits. We call both its input and its output "qlit". This is confusing. Use "tree" for input, and "qlit" only for output: rename to_qlit() to _tree_to_qlit(), ._qlits to ._trees, ._gen_qlit() to ._gen_tree(). Signed-off-by: Markus Armbruster --- scripts/qapi/introspect.py | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index b54910510d..e4fc9d90f1 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -16,7 +16,7 @@ from qapi.schema import (QAPISchemaArrayType, QAPISchemaB= uiltinType, QAPISchemaType) =20 =20 -def to_qlit(obj, level=3D0, suppress_first_indent=3DFalse): +def _tree_to_qlit(obj, level=3D0, suppress_first_indent=3DFalse): =20 def indent(level): return level * 4 * ' ' @@ -30,7 +30,7 @@ def to_qlit(obj, level=3D0, suppress_first_indent=3DFalse= ): ret +=3D indent(level) + '/* %s */\n' % comment if ifcond: ret +=3D gen_if(ifcond) - ret +=3D to_qlit(ifobj, level) + ret +=3D _tree_to_qlit(ifobj, level) if ifcond: ret +=3D '\n' + gen_endif(ifcond) return ret @@ -43,7 +43,7 @@ def to_qlit(obj, level=3D0, suppress_first_indent=3DFalse= ): elif isinstance(obj, str): ret +=3D 'QLIT_QSTR(' + to_c_string(obj) + ')' elif isinstance(obj, list): - elts =3D [to_qlit(elt, level + 1).strip('\n') + elts =3D [_tree_to_qlit(elt, level + 1).strip('\n') for elt in obj] elts.append(indent(level + 1) + "{}") ret +=3D 'QLIT_QLIST(((QLitObject[]) {\n' @@ -53,7 +53,8 @@ def to_qlit(obj, level=3D0, suppress_first_indent=3DFalse= ): elts =3D [] for key, value in sorted(obj.items()): elts.append(indent(level + 1) + '{ %s, %s }' % - (to_c_string(key), to_qlit(value, level + 1, True)= )) + (to_c_string(key), + _tree_to_qlit(value, level + 1, True))) elts.append(indent(level + 1) + '{}') ret +=3D 'QLIT_QDICT(((QLitDictEntry[]) {\n' ret +=3D ',\n'.join(elts) + '\n' @@ -79,7 +80,7 @@ class QAPISchemaGenIntrospectVisitor(QAPISchemaMonolithic= CVisitor): ' * QAPI/QMP schema introspection', __doc__) self._unmask =3D unmask self._schema =3D None - self._qlits =3D [] + self._trees =3D [] self._used_types =3D [] self._name_map =3D {} self._genc.add(mcgen(''' @@ -108,9 +109,9 @@ extern const QLitObject %(c_name)s; const QLitObject %(c_name)s =3D %(c_string)s; ''', c_name=3Dc_name(name), - c_string=3Dto_qlit(self._qlits))) + c_string=3D_tree_to_qlit(self._trees))) self._schema =3D None - self._qlits =3D [] + self._trees =3D [] self._used_types =3D [] self._name_map =3D {} =20 @@ -144,7 +145,7 @@ const QLitObject %(c_name)s =3D %(c_string)s; return '[' + self._use_type(typ.element_type) + ']' return self._name(typ.name) =20 - def _gen_qlit(self, name, mtype, obj, ifcond, features): + def _gen_tree(self, name, mtype, obj, ifcond, features): extra =3D {} if mtype not in ('command', 'event', 'builtin', 'array'): if not self._unmask: @@ -159,9 +160,9 @@ const QLitObject %(c_name)s =3D %(c_string)s; if ifcond: extra['if'] =3D ifcond if extra: - self._qlits.append((obj, extra)) + self._trees.append((obj, extra)) else: - self._qlits.append(obj) + self._trees.append(obj) =20 def _gen_member(self, member): ret =3D {'name': member.name, 'type': self._use_type(member.type)} @@ -180,17 +181,17 @@ const QLitObject %(c_name)s =3D %(c_string)s; {'if': variant.ifcond}) =20 def visit_builtin_type(self, name, info, json_type): - self._gen_qlit(name, 'builtin', {'json-type': json_type}, [], None) + self._gen_tree(name, 'builtin', {'json-type': json_type}, [], None) =20 def visit_enum_type(self, name, info, ifcond, features, members, prefi= x): - self._gen_qlit(name, 'enum', + self._gen_tree(name, 'enum', {'values': [(m.name, {'if': m.ifcond}) for m in members]}, ifcond, features) =20 def visit_array_type(self, name, info, ifcond, element_type): element =3D self._use_type(element_type) - self._gen_qlit('[' + element + ']', 'array', {'element-type': elem= ent}, + self._gen_tree('[' + element + ']', 'array', {'element-type': elem= ent}, ifcond, None) =20 def visit_object_type_flat(self, name, info, ifcond, features, @@ -200,10 +201,10 @@ const QLitObject %(c_name)s =3D %(c_string)s; obj.update(self._gen_variants(variants.tag_member.name, variants.variants)) =20 - self._gen_qlit(name, 'object', obj, ifcond, features) + self._gen_tree(name, 'object', obj, ifcond, features) =20 def visit_alternate_type(self, name, info, ifcond, features, variants): - self._gen_qlit(name, 'alternate', + self._gen_tree(name, 'alternate', {'members': [ ({'type': self._use_type(m.type)}, {'if': m.ifc= ond}) for m in variants.variants]}, @@ -218,11 +219,11 @@ const QLitObject %(c_name)s =3D %(c_string)s; 'ret-type': self._use_type(ret_type)} if allow_oob: obj['allow-oob'] =3D allow_oob - self._gen_qlit(name, 'command', obj, ifcond, features) + self._gen_tree(name, 'command', obj, ifcond, features) =20 def visit_event(self, name, info, ifcond, features, arg_type, boxed): arg_type =3D arg_type or self._schema.the_empty_object_type - self._gen_qlit(name, 'event', {'arg-type': self._use_type(arg_type= )}, + self._gen_tree(name, 'event', {'arg-type': self._use_type(arg_type= )}, ifcond, features) =20 =20 --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253358; cv=none; d=zohomail.com; s=zohoarc; b=Z4ZQe4Nxk1XiLN6SnxZ0qQQwZkyV3/pOfVVU2fERVa6r6ASkK/iKQRV7xh4OXf3BTzhXCOKsK5dB1WAB5umBTpgB8s11VzdVaU6ZGd82TjzBDIXNh5VUblE6iBS6zyzuH1H2ytatGdc4DWuIJV66qoTRpancdHyVi70hVJ5ihbo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253358; h=Content-Type: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; bh=LYRBn1WKH6uNvCj8WQZtPRk+MzbUUTNl8UbjVjr+4JU=; b=FMHtlyMXasM9Qjn/zxZzuXebHqJFDAIQE2xepli9/waAigFWhsnO4NcOmd0fXRUkERk0SHj0zT1My1ll4U6pZcdCt6eGdgKt2fbLgJRRi8RuIk88sAVyxiws4tV+1Qid3Oo9AIKvc1iFjX/U2mR5hVUONUuQrRdUsrlPnhTsR1c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 158325335891195.62015096652249; Tue, 3 Mar 2020 08:35:58 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-239-IE4pQcg5NDGqRiZwPHx2ZQ-1; Tue, 03 Mar 2020 11:35:53 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 924BB9B584; Tue, 3 Mar 2020 16:35:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6AB2491D62; Tue, 3 Mar 2020 16:35:45 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 13A0186A12; Tue, 3 Mar 2020 16:35:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZDLb001224 for ; Tue, 3 Mar 2020 11:35:13 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7A02210027AB; Tue, 3 Mar 2020 16:35:13 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 45D461001920; Tue, 3 Mar 2020 16:35:13 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E04E61132A03; Tue, 3 Mar 2020 17:35:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253355; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=LYRBn1WKH6uNvCj8WQZtPRk+MzbUUTNl8UbjVjr+4JU=; b=QwU8Ielm0AgUb1Ohd7ySh2+Q+P5T7ctgmHVE9GXfHp3VMAlPvqpq6J3jlZLh8oe7wBA6QY nt4ZPHB/fQXeoR1dKsH3wnI6/rQZejPxKS2JlOPnezYw4i4evQFCgP2UBfx2Sc5gjIEDNz hLWgMybp6HF/6veSe0rBmKVrzziIXA4= X-MC-Unique: IE4pQcg5NDGqRiZwPHx2ZQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 15/30] qapi/introspect: Factor out _make_tree() Date: Tue, 3 Mar 2020 17:34:50 +0100 Message-Id: <20200303163505.32041-16-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The value of @qmp_schema_qlit is generated from an expression tree. Tree nodes are created in several places. Factor out the common code into _make_tree(). This isn't much of a win now. It will pay off when we add feature flags in the next few commits. Signed-off-by: Markus Armbruster --- scripts/qapi/introspect.py | 44 +++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index e4fc9d90f1..a3fa9865db 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -16,6 +16,18 @@ from qapi.schema import (QAPISchemaArrayType, QAPISchema= BuiltinType, QAPISchemaType) =20 =20 +def _make_tree(obj, ifcond, features, extra=3DNone): + if extra is None: + extra =3D {} + if ifcond: + extra['if'] =3D ifcond + if features: + obj['features'] =3D [(f.name, {'if': f.ifcond}) for f in features] + if extra: + return (obj, extra) + return obj + + def _tree_to_qlit(obj, level=3D0, suppress_first_indent=3DFalse): =20 def indent(level): @@ -146,47 +158,38 @@ const QLitObject %(c_name)s =3D %(c_string)s; return self._name(typ.name) =20 def _gen_tree(self, name, mtype, obj, ifcond, features): - extra =3D {} + extra =3D None if mtype not in ('command', 'event', 'builtin', 'array'): if not self._unmask: # Output a comment to make it easy to map masked names # back to the source when reading the generated output. - extra['comment'] =3D '"%s" =3D %s' % (self._name(name), na= me) + extra =3D {'comment': '"%s" =3D %s' % (self._name(name), n= ame)} name =3D self._name(name) obj['name'] =3D name obj['meta-type'] =3D mtype - if features: - obj['features'] =3D [(f.name, {'if': f.ifcond}) for f in featu= res] - if ifcond: - extra['if'] =3D ifcond - if extra: - self._trees.append((obj, extra)) - else: - self._trees.append(obj) + self._trees.append(_make_tree(obj, ifcond, features, extra)) =20 def _gen_member(self, member): - ret =3D {'name': member.name, 'type': self._use_type(member.type)} + obj =3D {'name': member.name, 'type': self._use_type(member.type)} if member.optional: - ret['default'] =3D None - if member.ifcond: - ret =3D (ret, {'if': member.ifcond}) - return ret + obj['default'] =3D None + return _make_tree(obj, member.ifcond, None) =20 def _gen_variants(self, tag_name, variants): return {'tag': tag_name, 'variants': [self._gen_variant(v) for v in variants]} =20 def _gen_variant(self, variant): - return ({'case': variant.name, 'type': self._use_type(variant.type= )}, - {'if': variant.ifcond}) + obj =3D {'case': variant.name, 'type': self._use_type(variant.type= )} + return _make_tree(obj, variant.ifcond, None) =20 def visit_builtin_type(self, name, info, json_type): self._gen_tree(name, 'builtin', {'json-type': json_type}, [], None) =20 def visit_enum_type(self, name, info, ifcond, features, members, prefi= x): self._gen_tree(name, 'enum', - {'values': - [(m.name, {'if': m.ifcond}) for m in members]}, + {'values': [_make_tree(m.name, m.ifcond, None) + for m in members]}, ifcond, features) =20 def visit_array_type(self, name, info, ifcond, element_type): @@ -206,7 +209,8 @@ const QLitObject %(c_name)s =3D %(c_string)s; def visit_alternate_type(self, name, info, ifcond, features, variants): self._gen_tree(name, 'alternate', {'members': [ - ({'type': self._use_type(m.type)}, {'if': m.ifc= ond}) + _make_tree({'type': self._use_type(m.type)}, + m.ifcond, None) for m in variants.variants]}, ifcond, features) =20 --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253354; cv=none; d=zohomail.com; s=zohoarc; b=lXTIysnxIk8MSAPnTEBzPkM69Kd5m0gXKEglXakCVxBiofCaIYUbSTxqTdwKtW3/Y9LrjgBJAUYKUf3zggIqIhf+2YLDR/6i+Ds4PYoas0nd+5wrQSjcnTIhyDgvy7AHGPgBaPw0vpk8XLmNe2HvcJarGoOixECd+48f+pYcpH4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253354; h=Content-Type: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; bh=uB+w0cC+DhrU6e0Xdne2cU+tRz8mcHFIaGFH9tmvCpc=; b=KJ7bO5ZM+UdlV2FsV8x/HJKWqGYBCtwzykOMLOlk5JywoS4B4tORHKLfpzSLiivTasizyS0BX0PcoBcXmESzHYT8YpOm143n/vnVFRFzMfJRh9YnyhmNh/aF0pgQ7hgvu/IiuPaQDM43fZIngvI5LRT1lkqJ2auU88H9IXwsNAg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1583253354285618.937641332942; Tue, 3 Mar 2020 08:35:54 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-479-_KmqzuwjMYO1o81t3bs8pQ-1; Tue, 03 Mar 2020 11:35:51 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4480F100550E; Tue, 3 Mar 2020 16:35:43 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 15B5C60C84; Tue, 3 Mar 2020 16:35:43 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B2C3A86A0E; Tue, 3 Mar 2020 16:35:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZD7l001225 for ; Tue, 3 Mar 2020 11:35:13 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7BA5E101D4A0; Tue, 3 Mar 2020 16:35:13 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 47C7B1000322; Tue, 3 Mar 2020 16:35:13 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E454E1132A05; Tue, 3 Mar 2020 17:35:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253353; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=uB+w0cC+DhrU6e0Xdne2cU+tRz8mcHFIaGFH9tmvCpc=; b=LENOFU10AcW/NhKGgPrXLyoo+/RtlzsbIKILaIlpGGgvjebNEbaj6vIX/UNXhZ6fBhBMni O+3VgmTBOfYL1kRsePyL3xRQQTrZ28IQINvptw049SlOGFQS2U20ans8VGLC7PpRjo3yEY 6ra+wn9EnpgUdy0aF+Cfh7OfZS2D+H4= X-MC-Unique: _KmqzuwjMYO1o81t3bs8pQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 16/30] qapi/schema: Change _make_features() to a take feature list Date: Tue, 3 Mar 2020 17:34:51 +0100 Message-Id: <20200303163505.32041-17-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" QAPISchema._make_features() takes a definition expression, and extracts its 'features' member. The other ._make_FOO() leave destructuring expressions to their callers. Change ._make_features() to match them. Signed-off-by: Markus Armbruster --- scripts/qapi/schema.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index e3353989e9..2ab6dc67e4 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -905,8 +905,9 @@ class QAPISchema: self._def_entity(QAPISchemaEnumType('QType', None, None, None, Non= e, qtype_values, 'QTYPE')) =20 - def _make_features(self, expr, info): - features =3D expr.get('features', []) + def _make_features(self, features, info): + if features is None: + return [] return [QAPISchemaFeature(f['name'], info, f.get('if')) for f in features] =20 @@ -956,7 +957,7 @@ class QAPISchema: data =3D expr['data'] prefix =3D expr.get('prefix') ifcond =3D expr.get('if') - features =3D self._make_features(expr, info) + features =3D self._make_features(expr.get('features'), info) self._def_entity(QAPISchemaEnumType( name, info, doc, ifcond, features, self._make_enum_members(data, info), prefix)) @@ -980,7 +981,7 @@ class QAPISchema: base =3D expr.get('base') data =3D expr['data'] ifcond =3D expr.get('if') - features =3D self._make_features(expr, info) + features =3D self._make_features(expr.get('features'), info) self._def_entity(QAPISchemaObjectType( name, info, doc, ifcond, features, base, self._make_members(data, info), @@ -1003,7 +1004,7 @@ class QAPISchema: data =3D expr['data'] base =3D expr.get('base') ifcond =3D expr.get('if') - features =3D self._make_features(expr, info) + features =3D self._make_features(expr.get('features'), info) tag_name =3D expr.get('discriminator') tag_member =3D None if isinstance(base, dict): @@ -1033,7 +1034,7 @@ class QAPISchema: name =3D expr['alternate'] data =3D expr['data'] ifcond =3D expr.get('if') - features =3D self._make_features(expr, info) + features =3D self._make_features(expr.get('features'), info) variants =3D [self._make_variant(key, value['type'], value.get('if= '), info) for (key, value) in data.items()] @@ -1053,7 +1054,7 @@ class QAPISchema: allow_oob =3D expr.get('allow-oob', False) allow_preconfig =3D expr.get('allow-preconfig', False) ifcond =3D expr.get('if') - features =3D self._make_features(expr, info) + features =3D self._make_features(expr.get('features'), info) if isinstance(data, OrderedDict): data =3D self._make_implicit_object_type( name, info, ifcond, @@ -1071,7 +1072,7 @@ class QAPISchema: data =3D expr.get('data') boxed =3D expr.get('boxed', False) ifcond =3D expr.get('if') - features =3D self._make_features(expr, info) + features =3D self._make_features(expr.get('features'), info) if isinstance(data, OrderedDict): data =3D self._make_implicit_object_type( name, info, ifcond, --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253379; cv=none; d=zohomail.com; s=zohoarc; b=K4OmPehT8Ol3bcKG8YG/H+V5PXfm2dJCC/oXzj5WSXe1dux6LJ/1iOp+p428v7QkCq6+ALZGNEqiSfJyFqsMc04t46Tqf742h8+r1JrJyf9l+L/Mzv2f0LKz03SZFUZTNx+Yy15JFKzPrVPbbAtBh6LPc8P9poSEK3TNWWpht8A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253379; h=Content-Type: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; bh=xege0Pw+GKvVLkCuOgENwHcnrmc+6NSA93kTUN6HE3c=; b=SnLMjLrPnI6aHugaG1+oydSL/GLsdUzsOgVd/ArbTpohRY1d7Nzi8aSqUws8hCVgkiYO3Il5sXtWX2pM/IOyk66hOT9PWwMsEBIBUsZJQ5GFxfSbeoJfh0qgTbanULo56CECTRNVrudsZ9riLS9kmh2S+9nT585Hu13dtnU0hFE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1583253379207694.5265690434076; Tue, 3 Mar 2020 08:36:19 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-367-sHtzrfsePSGr-paEeEWSDA-1; Tue, 03 Mar 2020 11:36:02 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 94AB418FE86C; Tue, 3 Mar 2020 16:35:51 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 63B0889F1C; Tue, 3 Mar 2020 16:35:51 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 0147086A13; Tue, 3 Mar 2020 16:35:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZFoO001299 for ; Tue, 3 Mar 2020 11:35:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id 808915C578; Tue, 3 Mar 2020 16:35:15 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 656AA5C219; Tue, 3 Mar 2020 16:35:13 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E7B9D1132A06; Tue, 3 Mar 2020 17:35:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253377; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=xege0Pw+GKvVLkCuOgENwHcnrmc+6NSA93kTUN6HE3c=; b=L/c3j//gxKYiO3U7HLbjS76KXEitgSqpr950n9q6AwlapPrIEaXICY3n6AE8zZ2Bw5lH5g M26O2qzmRk40x7SVDR2czkQo2IUj4WIhWTeYc8L2Ar33hdHb2wvoUUbbro2ER1TG18zXeQ SLAlyrSKAyh/B1Q38hJuuD46UNUgkUk= X-MC-Unique: sHtzrfsePSGr-paEeEWSDA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 17/30] qapi/schema: Reorder classes so related ones are together Date: Tue, 3 Mar 2020 17:34:52 +0100 Message-Id: <20200303163505.32041-18-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Move QAPISchemaAlternateType up some, so that all QAPISchemaFOOType are together. Move QAPISchemaObjectTypeVariants right behind its users. Signed-off-by: Markus Armbruster --- scripts/qapi/schema.py | 284 ++++++++++++++++++++--------------------- 1 file changed, 142 insertions(+), 142 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 2ab6dc67e4..f0fb0d1c4d 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -444,82 +444,72 @@ class QAPISchemaObjectType(QAPISchemaType): self.members, self.variants) =20 =20 -class QAPISchemaMember: - """ Represents object members, enum members and features """ - role =3D 'member' - - def __init__(self, name, info, ifcond=3DNone): - assert isinstance(name, str) - self.name =3D name - self.info =3D info - self.ifcond =3D ifcond or [] - self.defined_in =3D None - - def set_defined_in(self, name): - assert not self.defined_in - self.defined_in =3D name - - def check_clash(self, info, seen): - cname =3D c_name(self.name) - if cname in seen: - raise QAPISemError( - info, - "%s collides with %s" - % (self.describe(info), seen[cname].describe(info))) - seen[cname] =3D self - - def describe(self, info): - role =3D self.role - defined_in =3D self.defined_in - assert defined_in - - if defined_in.startswith('q_obj_'): - # See QAPISchema._make_implicit_object_type() - reverse the - # mapping there to create a nice human-readable description - defined_in =3D defined_in[6:] - if defined_in.endswith('-arg'): - # Implicit type created for a command's dict 'data' - assert role =3D=3D 'member' - role =3D 'parameter' - elif defined_in.endswith('-base'): - # Implicit type created for a flat union's dict 'base' - role =3D 'base ' + role - else: - # Implicit type created for a simple union's branch - assert defined_in.endswith('-wrapper') - # Unreachable and not implemented - assert False - elif defined_in.endswith('Kind'): - # See QAPISchema._make_implicit_enum_type() - # Implicit enum created for simple union's branches - assert role =3D=3D 'value' - role =3D 'branch' - elif defined_in !=3D info.defn_name: - return "%s '%s' of type '%s'" % (role, self.name, defined_in) - return "%s '%s'" % (role, self.name) - - -class QAPISchemaEnumMember(QAPISchemaMember): - role =3D 'value' - - -class QAPISchemaFeature(QAPISchemaMember): - role =3D 'feature' - - -class QAPISchemaObjectTypeMember(QAPISchemaMember): - def __init__(self, name, info, typ, optional, ifcond=3DNone): - super().__init__(name, info, ifcond) - assert isinstance(typ, str) - assert isinstance(optional, bool) - self._type_name =3D typ - self.type =3D None - self.optional =3D optional +class QAPISchemaAlternateType(QAPISchemaType): + meta =3D 'alternate' + + def __init__(self, name, info, doc, ifcond, features, variants): + super().__init__(name, info, doc, ifcond, features) + assert isinstance(variants, QAPISchemaObjectTypeVariants) + assert variants.tag_member + variants.set_defined_in(name) + variants.tag_member.set_defined_in(self.name) + self.variants =3D variants =20 def check(self, schema): - assert self.defined_in - self.type =3D schema.resolve_type(self._type_name, self.info, - self.describe) + super().check(schema) + self.variants.tag_member.check(schema) + # Not calling self.variants.check_clash(), because there's nothing + # to clash with + self.variants.check(schema, {}) + # Alternate branch names have no relation to the tag enum values; + # so we have to check for potential name collisions ourselves. + seen =3D {} + types_seen =3D {} + for v in self.variants.variants: + v.check_clash(self.info, seen) + qtype =3D v.type.alternate_qtype() + if not qtype: + raise QAPISemError( + self.info, + "%s cannot use %s" + % (v.describe(self.info), v.type.describe())) + conflicting =3D set([qtype]) + if qtype =3D=3D 'QTYPE_QSTRING': + if isinstance(v.type, QAPISchemaEnumType): + for m in v.type.members: + if m.name in ['on', 'off']: + conflicting.add('QTYPE_QBOOL') + if re.match(r'[-+0-9.]', m.name): + # lazy, could be tightened + conflicting.add('QTYPE_QNUM') + else: + conflicting.add('QTYPE_QNUM') + conflicting.add('QTYPE_QBOOL') + for qt in conflicting: + if qt in types_seen: + raise QAPISemError( + self.info, + "%s can't be distinguished from '%s'" + % (v.describe(self.info), types_seen[qt])) + types_seen[qt] =3D v.name + + def connect_doc(self, doc=3DNone): + super().connect_doc(doc) + doc =3D doc or self.doc + if doc: + for v in self.variants.variants: + doc.connect_member(v) + + def c_type(self): + return c_name(self.name) + pointer_suffix + + def json_type(self): + return 'value' + + def visit(self, visitor): + super().visit(visitor) + visitor.visit_alternate_type( + self.name, self.info, self.ifcond, self.features, self.variant= s) =20 =20 class QAPISchemaObjectTypeVariants: @@ -613,6 +603,84 @@ class QAPISchemaObjectTypeVariants: v.type.check_clash(info, dict(seen)) =20 =20 +class QAPISchemaMember: + """ Represents object members, enum members and features """ + role =3D 'member' + + def __init__(self, name, info, ifcond=3DNone): + assert isinstance(name, str) + self.name =3D name + self.info =3D info + self.ifcond =3D ifcond or [] + self.defined_in =3D None + + def set_defined_in(self, name): + assert not self.defined_in + self.defined_in =3D name + + def check_clash(self, info, seen): + cname =3D c_name(self.name) + if cname in seen: + raise QAPISemError( + info, + "%s collides with %s" + % (self.describe(info), seen[cname].describe(info))) + seen[cname] =3D self + + def describe(self, info): + role =3D self.role + defined_in =3D self.defined_in + assert defined_in + + if defined_in.startswith('q_obj_'): + # See QAPISchema._make_implicit_object_type() - reverse the + # mapping there to create a nice human-readable description + defined_in =3D defined_in[6:] + if defined_in.endswith('-arg'): + # Implicit type created for a command's dict 'data' + assert role =3D=3D 'member' + role =3D 'parameter' + elif defined_in.endswith('-base'): + # Implicit type created for a flat union's dict 'base' + role =3D 'base ' + role + else: + # Implicit type created for a simple union's branch + assert defined_in.endswith('-wrapper') + # Unreachable and not implemented + assert False + elif defined_in.endswith('Kind'): + # See QAPISchema._make_implicit_enum_type() + # Implicit enum created for simple union's branches + assert role =3D=3D 'value' + role =3D 'branch' + elif defined_in !=3D info.defn_name: + return "%s '%s' of type '%s'" % (role, self.name, defined_in) + return "%s '%s'" % (role, self.name) + + +class QAPISchemaEnumMember(QAPISchemaMember): + role =3D 'value' + + +class QAPISchemaFeature(QAPISchemaMember): + role =3D 'feature' + + +class QAPISchemaObjectTypeMember(QAPISchemaMember): + def __init__(self, name, info, typ, optional, ifcond=3DNone): + super().__init__(name, info, ifcond) + assert isinstance(typ, str) + assert isinstance(optional, bool) + self._type_name =3D typ + self.type =3D None + self.optional =3D optional + + def check(self, schema): + assert self.defined_in + self.type =3D schema.resolve_type(self._type_name, self.info, + self.describe) + + class QAPISchemaObjectTypeVariant(QAPISchemaObjectTypeMember): role =3D 'branch' =20 @@ -621,74 +689,6 @@ class QAPISchemaObjectTypeVariant(QAPISchemaObjectType= Member): False, ifcond) =20 =20 -class QAPISchemaAlternateType(QAPISchemaType): - meta =3D 'alternate' - - def __init__(self, name, info, doc, ifcond, features, variants): - super().__init__(name, info, doc, ifcond, features) - assert isinstance(variants, QAPISchemaObjectTypeVariants) - assert variants.tag_member - variants.set_defined_in(name) - variants.tag_member.set_defined_in(self.name) - self.variants =3D variants - - def check(self, schema): - super().check(schema) - self.variants.tag_member.check(schema) - # Not calling self.variants.check_clash(), because there's nothing - # to clash with - self.variants.check(schema, {}) - # Alternate branch names have no relation to the tag enum values; - # so we have to check for potential name collisions ourselves. - seen =3D {} - types_seen =3D {} - for v in self.variants.variants: - v.check_clash(self.info, seen) - qtype =3D v.type.alternate_qtype() - if not qtype: - raise QAPISemError( - self.info, - "%s cannot use %s" - % (v.describe(self.info), v.type.describe())) - conflicting =3D set([qtype]) - if qtype =3D=3D 'QTYPE_QSTRING': - if isinstance(v.type, QAPISchemaEnumType): - for m in v.type.members: - if m.name in ['on', 'off']: - conflicting.add('QTYPE_QBOOL') - if re.match(r'[-+0-9.]', m.name): - # lazy, could be tightened - conflicting.add('QTYPE_QNUM') - else: - conflicting.add('QTYPE_QNUM') - conflicting.add('QTYPE_QBOOL') - for qt in conflicting: - if qt in types_seen: - raise QAPISemError( - self.info, - "%s can't be distinguished from '%s'" - % (v.describe(self.info), types_seen[qt])) - types_seen[qt] =3D v.name - - def connect_doc(self, doc=3DNone): - super().connect_doc(doc) - doc =3D doc or self.doc - if doc: - for v in self.variants.variants: - doc.connect_member(v) - - def c_type(self): - return c_name(self.name) + pointer_suffix - - def json_type(self): - return 'value' - - def visit(self, visitor): - super().visit(visitor) - visitor.visit_alternate_type( - self.name, self.info, self.ifcond, self.features, self.variant= s) - - class QAPISchemaCommand(QAPISchemaEntity): meta =3D 'command' =20 --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253384; cv=none; d=zohomail.com; s=zohoarc; b=LNnqnJFS7USmyiCmNlFbiAnn0pgGI7/R6LhSD+XszFLYGFKmQDJ+ZInEf5mw+emhC0xdQY/15pNFM4fEE+DakDjjrRcXbLmA7xBq1PVciFbkPa1bXwPyd3DiBLZXtt9MsxteUOuB3zO2OosRFpcED7ojshbcpWnIl71jYKODz1c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253384; h=Content-Type: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; bh=+nsHm7lGuvSQkmbgUuqCSHkftOO9RguOz9KIH2BqjnY=; b=KazuBJmFeut7fuTaq9ozHAtteE68aCC8/p5X2G4SbbH+gcL7IQqEn/hGMT5gu49r9mOk9TA27hdqhn5vGPTKTWqqD21vkE0DmfuEd/Tl7+kzsy9MdFLqp0mOo4xsQB6uWGR4wLJgJXB5i1vXCVbzCnCA3j5jG7O6XRukhwAAKbY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1583253384061949.7322905285658; Tue, 3 Mar 2020 08:36:24 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-100-INq_BqSqOliD3-NjhWGCPw-1; Tue, 03 Mar 2020 11:36:20 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 06EB218FE86E; Tue, 3 Mar 2020 16:36:12 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C3EF160C80; Tue, 3 Mar 2020 16:36:11 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6346E86A20; Tue, 3 Mar 2020 16:36:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZGmd001326 for ; Tue, 3 Mar 2020 11:35:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id 88A588D56B; Tue, 3 Mar 2020 16:35:16 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6C40319E9C; Tue, 3 Mar 2020 16:35:13 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id EB0691132A0B; Tue, 3 Mar 2020 17:35:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253382; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=+nsHm7lGuvSQkmbgUuqCSHkftOO9RguOz9KIH2BqjnY=; b=MPkfKZ3wfTWBqWb2dDAJ4FixeD8fRZ0UKZlJvLlWVThZy+b60wLbwqHQm+ydUMGVZE/bVU sVz8LFoZxee878be+WX/aJyNqCZjqUntcJjvXjr41Z5ic7HxCHWrZnCo69zRCHMU8j+osq AWk+Bj6f7AjV1FMKsqzzmdESzr84C3s= X-MC-Unique: INq_BqSqOliD3-NjhWGCPw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 18/30] qapi/schema: Rename QAPISchemaObjectType{Variant, Variants} Date: Tue, 3 Mar 2020 17:34:53 +0100 Message-Id: <20200303163505.32041-19-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" QAPISchemaObjectTypeVariants represents both object type and alternate type variants. Rename to QAPISchemaVariants. Rename QAPISchemaObjectTypeVariant the same way. Signed-off-by: Markus Armbruster --- scripts/qapi/schema.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index f0fb0d1c4d..3065f8e14d 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -338,7 +338,7 @@ class QAPISchemaObjectType(QAPISchemaType): assert isinstance(m, QAPISchemaObjectTypeMember) m.set_defined_in(name) if variants is not None: - assert isinstance(variants, QAPISchemaObjectTypeVariants) + assert isinstance(variants, QAPISchemaVariants) variants.set_defined_in(name) self._base_name =3D base self.base =3D None @@ -449,7 +449,7 @@ class QAPISchemaAlternateType(QAPISchemaType): =20 def __init__(self, name, info, doc, ifcond, features, variants): super().__init__(name, info, doc, ifcond, features) - assert isinstance(variants, QAPISchemaObjectTypeVariants) + assert isinstance(variants, QAPISchemaVariants) assert variants.tag_member variants.set_defined_in(name) variants.tag_member.set_defined_in(self.name) @@ -512,7 +512,7 @@ class QAPISchemaAlternateType(QAPISchemaType): self.name, self.info, self.ifcond, self.features, self.variant= s) =20 =20 -class QAPISchemaObjectTypeVariants: +class QAPISchemaVariants: def __init__(self, tag_name, info, tag_member, variants): # Flat unions pass tag_name but not tag_member. # Simple unions and alternates pass tag_member but not tag_name. @@ -522,7 +522,7 @@ class QAPISchemaObjectTypeVariants: assert (isinstance(tag_name, str) or isinstance(tag_member, QAPISchemaObjectTypeMember)) for v in variants: - assert isinstance(v, QAPISchemaObjectTypeVariant) + assert isinstance(v, QAPISchemaVariant) self._tag_name =3D tag_name self.info =3D info self.tag_member =3D tag_member @@ -572,8 +572,8 @@ class QAPISchemaObjectTypeVariants: cases =3D {v.name for v in self.variants} for m in self.tag_member.type.members: if m.name not in cases: - v =3D QAPISchemaObjectTypeVariant(m.name, self.info, - 'q_empty', m.ifcond) + v =3D QAPISchemaVariant(m.name, self.info, + 'q_empty', m.ifcond) v.set_defined_in(self.tag_member.defined_in) self.variants.append(v) if not self.variants: @@ -681,7 +681,7 @@ class QAPISchemaObjectTypeMember(QAPISchemaMember): self.describe) =20 =20 -class QAPISchemaObjectTypeVariant(QAPISchemaObjectTypeMember): +class QAPISchemaVariant(QAPISchemaObjectTypeMember): role =3D 'branch' =20 def __init__(self, name, info, typ, ifcond=3DNone): @@ -988,7 +988,7 @@ class QAPISchema: None)) =20 def _make_variant(self, case, typ, ifcond, info): - return QAPISchemaObjectTypeVariant(case, info, typ, ifcond) + return QAPISchemaVariant(case, info, typ, ifcond) =20 def _make_simple_variant(self, case, typ, ifcond, info): if isinstance(typ, list): @@ -997,7 +997,7 @@ class QAPISchema: typ =3D self._make_implicit_object_type( typ, info, self.lookup_type(typ), 'wrapper', [self._make_member('data', typ, None, info)]) - return QAPISchemaObjectTypeVariant(case, info, typ, ifcond) + return QAPISchemaVariant(case, info, typ, ifcond) =20 def _def_union_type(self, expr, info, doc): name =3D expr['union'] @@ -1027,7 +1027,7 @@ class QAPISchema: self._def_entity( QAPISchemaObjectType(name, info, doc, ifcond, features, base, members, - QAPISchemaObjectTypeVariants( + QAPISchemaVariants( tag_name, info, tag_member, variants)= )) =20 def _def_alternate_type(self, expr, info, doc): @@ -1041,7 +1041,7 @@ class QAPISchema: tag_member =3D QAPISchemaObjectTypeMember('type', info, 'QType', F= alse) self._def_entity( QAPISchemaAlternateType(name, info, doc, ifcond, features, - QAPISchemaObjectTypeVariants( + QAPISchemaVariants( None, info, tag_member, variants))) =20 def _def_command(self, expr, info, doc): --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253373; cv=none; d=zohomail.com; s=zohoarc; b=i5uoyTXM5OyQRNVm/dqctwTBYPsn8DI5GrnbcmIJsEMPxsUUENNSgRjdamVSsfjQwORILAGP2XN+FDRRqVb3k5bs6Val5EsYhSewMY9upbCjtnr1uDTuG0MhOw7XYlB4GlkUWyihEo/7li4nvj1pblnI/KOVAJ8r7oonSLn4FJI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253373; h=Content-Type: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; bh=WoIdsE0RIv5QLHQTPQ68t8HQ4FzsBgYcB5RaRipKZQI=; b=Zt91kXhI8yccKNbb9ZvEXzDeVz6Ttanzc1QMXDj3fdLQQXKgQT0BJ/HqDcujr/E6ucP0mul51Gl2+dXvloFrafkme/QEXcOcsMz9tDPujyViXVTl+sWNiQjwfirwFKDhUq08K6H+PeMxlqC7EUnHF7nenNCvWrn0vZoNKk26QzU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 158325337327936.086471822706926; Tue, 3 Mar 2020 08:36:13 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-473-r_-JRHWrNT6e8J-on894oQ-1; Tue, 03 Mar 2020 11:36:02 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E52441005512; Tue, 3 Mar 2020 16:35:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B0C405DA60; Tue, 3 Mar 2020 16:35:54 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4CAAA86A1B; Tue, 3 Mar 2020 16:35:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZEtn001263 for ; Tue, 3 Mar 2020 11:35:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id B631E73879; Tue, 3 Mar 2020 16:35:14 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C3F5A73883; Tue, 3 Mar 2020 16:35:13 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id EE3D211329C0; Tue, 3 Mar 2020 17:35:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253372; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=WoIdsE0RIv5QLHQTPQ68t8HQ4FzsBgYcB5RaRipKZQI=; b=OCWcoedwXexf3EePyf8L9q8OUnPhRoOKKDgmH2pLedXmQRcaG8mFt26+YfvPZneOyusIUF 60fdISlmGztl0LvyDxj3HM8/NZPnw6v8Nqx6F/HPV6hjzq4aYoc+lXJ7aid6T9xVIll9jE b5zCaGfE+HZ+4GjrNYLBWFuyyIlV0EM= X-MC-Unique: r_-JRHWrNT6e8J-on894oQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 19/30] qapi/schema: Call QAPIDoc.connect_member() in just one place Date: Tue, 3 Mar 2020 17:34:54 +0100 Message-Id: <20200303163505.32041-20-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The .connect_doc() of classes that have QAPISchemaMember connect them to their documentation. Change them to delegate the actual work to new QAPISchemaMember.connect_doc(). Matches the .connect_doc() that already exist. Signed-off-by: Markus Armbruster --- scripts/qapi/schema.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 3065f8e14d..8368745a3e 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -252,9 +252,8 @@ class QAPISchemaEnumType(QAPISchemaType): def connect_doc(self, doc=3DNone): super().connect_doc(doc) doc =3D doc or self.doc - if doc: - for m in self.members: - doc.connect_member(m) + for m in self.members: + m.connect_doc(doc) =20 def is_implicit(self): # See QAPISchema._make_implicit_enum_type() and ._def_predefineds() @@ -396,11 +395,10 @@ class QAPISchemaObjectType(QAPISchemaType): def connect_doc(self, doc=3DNone): super().connect_doc(doc) doc =3D doc or self.doc - if doc: - if self.base and self.base.is_implicit(): - self.base.connect_doc(doc) - for m in self.local_members: - doc.connect_member(m) + if self.base and self.base.is_implicit(): + self.base.connect_doc(doc) + for m in self.local_members: + m.connect_doc(doc) =20 @property def ifcond(self): @@ -496,9 +494,8 @@ class QAPISchemaAlternateType(QAPISchemaType): def connect_doc(self, doc=3DNone): super().connect_doc(doc) doc =3D doc or self.doc - if doc: - for v in self.variants.variants: - doc.connect_member(v) + for v in self.variants.variants: + v.connect_doc(doc) =20 def c_type(self): return c_name(self.name) + pointer_suffix @@ -627,6 +624,10 @@ class QAPISchemaMember: % (self.describe(info), seen[cname].describe(info))) seen[cname] =3D self =20 + def connect_doc(self, doc): + if doc: + doc.connect_member(self) + def describe(self, info): role =3D self.role defined_in =3D self.defined_in --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253360; cv=none; d=zohomail.com; s=zohoarc; b=Q6pMfUR5FPpl9oLIqb/0QIXg28X53+M2iKC3/e3coTBmx5q84M3+R4XYwQ+7AjN9JkwanY0AB6OhQDu0KmER/1+1XeO0idx7g0qEf4k0OeJQ/KLcwLxyImzL0gczCKXYHR7rX/J/OjDIBEfk16iHttl+6R0v+n7SnGfCwJqibYE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253360; h=Content-Type: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; bh=Bp5EbH/Kp4MBinsdHTQ0U4PgrwTqvS1mCzI/+Vn0cXU=; b=NtXgv/9AHEeCXVuc1HIPRzLJwmVJdzE9v9RsFuj4LwZuLCltJHDprqtX02EpcalP+m+GKTcEak+oxdvzLpxCFaULj5J7qrlI47XNbMP9OD1apw1c/omuHpODdBH7bcxfqtHZ4cIaUeGwXVNKl0jvr9j258OYkYb5nNLFyeeeGcg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1583253360587721.4898787286515; Tue, 3 Mar 2020 08:36:00 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-209-rTlFJzaFNxCEmMpTrCl-lw-1; Tue, 03 Mar 2020 11:35:56 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B720C80257F; Tue, 3 Mar 2020 16:35:49 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8734619C7F; Tue, 3 Mar 2020 16:35:49 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 204DF86A0E; Tue, 3 Mar 2020 16:35:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZEHk001242 for ; Tue, 3 Mar 2020 11:35:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 619655DA7C; Tue, 3 Mar 2020 16:35:14 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CC7C95D9C9; Tue, 3 Mar 2020 16:35:13 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id F294B11329C3; Tue, 3 Mar 2020 17:35:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253359; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Bp5EbH/Kp4MBinsdHTQ0U4PgrwTqvS1mCzI/+Vn0cXU=; b=SgxP/LpQVizDYh2YeMDoB92kEkyGTb+pcm0ZBqOUG7ak5ajZ0JKdPhzSvqsZXYI6RxMfbv DShjg7llsx/4Gb82zqFbld/wYnpnrgnSkp10Cib2ENs6yvQHW63HjpaO47ynd6cZ6/OkNy ZO13ixhAw3BatuvkGkbGRLQFfZ/KL6o= X-MC-Unique: rTlFJzaFNxCEmMpTrCl-lw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 20/30] qapi: Add feature flags to struct members Date: Tue, 3 Mar 2020 17:34:55 +0100 Message-Id: <20200303163505.32041-21-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster --- docs/devel/qapi-code-gen.txt | 4 +++- tests/qapi-schema/doc-good.texi | 2 ++ qapi/introspect.json | 6 +++++- scripts/qapi/expr.py | 3 ++- scripts/qapi/introspect.py | 2 +- scripts/qapi/schema.py | 25 ++++++++++++++++++++----- tests/qapi-schema/doc-good.json | 5 ++++- tests/qapi-schema/doc-good.out | 3 +++ tests/qapi-schema/qapi-schema-test.json | 2 +- tests/qapi-schema/qapi-schema-test.out | 1 + tests/qapi-schema/test-qapi.py | 7 ++++--- 11 files changed, 46 insertions(+), 14 deletions(-) diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt index 9fce78dcad..a1ef1cfd61 100644 --- a/docs/devel/qapi-code-gen.txt +++ b/docs/devel/qapi-code-gen.txt @@ -234,7 +234,9 @@ Syntax: '*features': FEATURES } MEMBERS =3D { MEMBER, ... } MEMBER =3D STRING : TYPE-REF - | STRING : { 'type': TYPE-REF, '*if': COND } + | STRING : { 'type': TYPE-REF, + '*if': COND, + '*features': FEATURES } =20 Member 'struct' names the struct type. =20 diff --git a/tests/qapi-schema/doc-good.texi b/tests/qapi-schema/doc-good.t= exi index 76b396dae6..7f28fb7a0f 100644 --- a/tests/qapi-schema/doc-good.texi +++ b/tests/qapi-schema/doc-good.texi @@ -132,6 +132,8 @@ Not documented @table @asis @item @code{variant1-feat} a feature +@item @code{member-feat} +a member feature @end table =20 @end deftp diff --git a/qapi/introspect.json b/qapi/introspect.json index da3e176899..b1aabd4cfd 100644 --- a/qapi/introspect.json +++ b/qapi/introspect.json @@ -206,11 +206,15 @@ # Future extension: if present and non-null, the parameter # is optional, and defaults to this value. # +# @features: names of features associated with the member, in no +# particular order. (since 5.0) +# # Since: 2.5 ## { 'struct': 'SchemaInfoObjectMember', - 'data': { 'name': 'str', 'type': 'str', '*default': 'any' } } + 'data': { 'name': 'str', 'type': 'str', '*default': 'any', # @default's type must be null or match @type + '*features': [ 'str' ] } } =20 ## # @SchemaInfoObjectVariant: diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index f9c4448980..2942520399 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -167,8 +167,9 @@ def check_type(value, info, source, allow_optional=3DTrue, permit_upper=3Dpermit_upper) if c_name(key, False) =3D=3D 'u' or c_name(key, False).startswith(= 'has_'): raise QAPISemError(info, "%s uses reserved name" % key_source) - check_keys(arg, info, key_source, ['type'], ['if']) + check_keys(arg, info, key_source, ['type'], ['if', 'features']) check_if(arg, info, key_source) + check_features(arg.get('features'), info) check_type(arg['type'], info, key_source, allow_array=3DTrue) =20 =20 diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index a3fa9865db..23652be810 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -173,7 +173,7 @@ const QLitObject %(c_name)s =3D %(c_string)s; obj =3D {'name': member.name, 'type': self._use_type(member.type)} if member.optional: obj['default'] =3D None - return _make_tree(obj, member.ifcond, None) + return _make_tree(obj, member.ifcond, member.features) =20 def _gen_variants(self, tag_name, variants): return {'tag': tag_name, diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 8368745a3e..2fb845303b 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -668,18 +668,31 @@ class QAPISchemaFeature(QAPISchemaMember): =20 =20 class QAPISchemaObjectTypeMember(QAPISchemaMember): - def __init__(self, name, info, typ, optional, ifcond=3DNone): + def __init__(self, name, info, typ, optional, ifcond=3DNone, features= =3DNone): super().__init__(name, info, ifcond) assert isinstance(typ, str) assert isinstance(optional, bool) + for f in features or []: + assert isinstance(f, QAPISchemaFeature) + f.set_defined_in(name) self._type_name =3D typ self.type =3D None self.optional =3D optional + self.features =3D features or [] =20 def check(self, schema): assert self.defined_in self.type =3D schema.resolve_type(self._type_name, self.info, self.describe) + seen =3D {} + for f in self.features: + f.check_clash(self.info, seen) + + def connect_doc(self, doc): + super().connect_doc(doc) + if doc: + for f in self.features: + doc.connect_feature(f) =20 =20 class QAPISchemaVariant(QAPISchemaObjectTypeMember): @@ -963,7 +976,7 @@ class QAPISchema: name, info, doc, ifcond, features, self._make_enum_members(data, info), prefix)) =20 - def _make_member(self, name, typ, ifcond, info): + def _make_member(self, name, typ, ifcond, features, info): optional =3D False if name.startswith('*'): name =3D name[1:] @@ -971,10 +984,12 @@ class QAPISchema: if isinstance(typ, list): assert len(typ) =3D=3D 1 typ =3D self._make_array_type(typ[0], info) - return QAPISchemaObjectTypeMember(name, info, typ, optional, ifcon= d) + return QAPISchemaObjectTypeMember(name, info, typ, optional, ifcon= d, + self._make_features(features, in= fo)) =20 def _make_members(self, data, info): - return [self._make_member(key, value['type'], value.get('if'), inf= o) + return [self._make_member(key, value['type'], value.get('if'), + value.get('features'), info) for (key, value) in data.items()] =20 def _def_struct_type(self, expr, info, doc): @@ -997,7 +1012,7 @@ class QAPISchema: typ =3D self._make_array_type(typ[0], info) typ =3D self._make_implicit_object_type( typ, info, self.lookup_type(typ), - 'wrapper', [self._make_member('data', typ, None, info)]) + 'wrapper', [self._make_member('data', typ, None, None, info)]) return QAPISchemaVariant(case, info, typ, ifcond) =20 def _def_union_type(self, expr, info, doc): diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.j= son index 457b8b2cdf..ddd89d1233 100644 --- a/tests/qapi-schema/doc-good.json +++ b/tests/qapi-schema/doc-good.json @@ -78,10 +78,13 @@ # # Features: # @variant1-feat: a feature +# @member-feat: a member feature ## { 'struct': 'Variant1', 'features': [ 'variant1-feat' ], - 'data': { 'var1': { 'type': 'str', 'if': 'defined(IFSTR)' } } } + 'data': { 'var1': { 'type': 'str', + 'features': [ 'member-feat' ], + 'if': 'defined(IFSTR)' } } } =20 ## # @Variant2: diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out index 9bcb2b3e91..6757dd26a2 100644 --- a/tests/qapi-schema/doc-good.out +++ b/tests/qapi-schema/doc-good.out @@ -21,6 +21,7 @@ object Base object Variant1 member var1: str optional=3DFalse if ['defined(IFSTR)'] + feature member-feat feature variant1-feat object Variant2 object Object @@ -135,6 +136,8 @@ Another paragraph (but no @var: line) =20 feature=3Dvariant1-feat a feature + feature=3Dmember-feat +a member feature doc symbol=3DVariant2 body=3D =20 diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index fa4f3a15da..f576c337af 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -258,7 +258,7 @@ 'data': { 'foo': 'int' }, 'features': [] } { 'struct': 'FeatureStruct1', - 'data': { 'foo': 'int' }, + 'data': { 'foo': { 'type': 'int', 'features': [ 'member-feature1' ] } }, 'features': [ 'feature1' ] } { 'struct': 'FeatureStruct2', 'data': { 'foo': 'int' }, diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 1cbd0802b3..cd863ae966 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -359,6 +359,7 @@ object FeatureStruct0 member foo: int optional=3DFalse object FeatureStruct1 member foo: int optional=3DFalse + feature member-feature1 feature feature1 object FeatureStruct2 member foo: int optional=3DFalse diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py index 8e09e54edb..f396b471eb 100755 --- a/tests/qapi-schema/test-qapi.py +++ b/tests/qapi-schema/test-qapi.py @@ -55,6 +55,7 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor): print(' member %s: %s optional=3D%s' % (m.name, m.type.name, m.optional)) self._print_if(m.ifcond, 8) + self._print_features(m.features, indent=3D8) self._print_variants(variants) self._print_if(ifcond) self._print_features(features) @@ -96,11 +97,11 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor): print('%sif %s' % (' ' * indent, ifcond)) =20 @classmethod - def _print_features(cls, features): + def _print_features(cls, features, indent=3D4): if features: for f in features: - print(' feature %s' % f.name) - cls._print_if(f.ifcond, 8) + print('%sfeature %s' % (' ' * indent, f.name)) + cls._print_if(f.ifcond, indent + 4) =20 =20 def test_frontend(fname): --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253393; cv=none; d=zohomail.com; s=zohoarc; b=EHuZWWV5aBlBP0qeps/MU8PrqSVsL7ISJut6XKLMt2iNiROhB6JmeD57OMayRtUtf45QwpJ6tkXS0ETfv56BKENfV5z26c2YkKeN2j6l4ZRFzZAg7Off/5BpLTZF45qwi14hmGZfgV5jG19wBTNz7l6p34oO7tlP/CwmXhQQhdY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253393; h=Content-Type: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; bh=33c4ueoVBGyZ2XGID+Hy1RjDbX+v1BvMmaf5/j0WSSg=; b=Fixqjjf6JmIpz74rpK8dxqMX407KRlJVSxP/lQFd93Ys/fMaixMmOve08ETJjccWnFbk7i9byKk4/YdzudsqbExtu2uWR9oqUsfe0oM7JWNfnhmbkd9u9SxcQR4DtH9YG+SgJf81L7VMMxY6jqZcoRqimnpj+JgELgfwhMdP5qo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 15832533935406.193899866703532; Tue, 3 Mar 2020 08:36:33 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-54-qzOl_wPBMcuTF9dMnJlVOw-1; Tue, 03 Mar 2020 11:36:29 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BEC578010EB; Tue, 3 Mar 2020 16:36:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 955D991D60; Tue, 3 Mar 2020 16:36:22 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 48E3186A2A; Tue, 3 Mar 2020 16:36:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZIRK001382 for ; Tue, 3 Mar 2020 11:35:18 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8B65F5DA82; Tue, 3 Mar 2020 16:35:18 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A587C5D9C9; Tue, 3 Mar 2020 16:35:14 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 01C4C11329FD; Tue, 3 Mar 2020 17:35:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253392; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=33c4ueoVBGyZ2XGID+Hy1RjDbX+v1BvMmaf5/j0WSSg=; b=djtEZ26ZhSXAy56oGOmATwvwwU1PSTFrJxawJPGuqMFrwDnad97cqWTqMPIo9n4nQzlvDC XMmNQq0Wr8dkVi3/+EFwEPh1QtIRnKcxizFhgNhMSVT9LU3qSiQH1KND4e2gEhnPIiJqAV /sP3NcAIZ+Ire5jFAiumatmZ+E2+uvc= X-MC-Unique: qzOl_wPBMcuTF9dMnJlVOw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 21/30] qapi: Inline do_qmp_dispatch() into qmp_dispatch() Date: Tue, 3 Mar 2020 17:34:56 +0100 Message-Id: <20200303163505.32041-22-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Both functions check @request is a QDict, and both have code for QCO_NO_SUCCESS_RESP. This wasn't the case back when they were created. It's a sign of muddled responsibilities. Inline. The next commits will clean up some more. Signed-off-by: Markus Armbruster --- qapi/qmp-dispatch.c | 90 +++++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 49 deletions(-) diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index bc264b3c9b..a588072523 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -75,19 +75,42 @@ static QDict *qmp_dispatch_check_obj(const QObject *req= uest, bool allow_oob, return dict; } =20 -static QObject *do_qmp_dispatch(QmpCommandList *cmds, QObject *request, - bool allow_oob, Error **errp) +QDict *qmp_error_response(Error *err) { - Error *local_err =3D NULL; + QDict *rsp; + + rsp =3D qdict_from_jsonf_nofail("{ 'error': { 'class': %s, 'desc': %s = } }", + QapiErrorClass_str(error_get_class(err)), + error_get_pretty(err)); + error_free(err); + return rsp; +} + +/* + * Does @qdict look like a command to be run out-of-band? + */ +bool qmp_is_oob(const QDict *dict) +{ + return qdict_haskey(dict, "exec-oob") + && !qdict_haskey(dict, "execute"); +} + +QDict *qmp_dispatch(QmpCommandList *cmds, QObject *request, + bool allow_oob) +{ + Error *err =3D NULL; bool oob; const char *command; - QDict *args, *dict; + QDict *args; QmpCommand *cmd; + QDict *dict =3D qobject_to(QDict, request); + QObject *id =3D dict ? qdict_get(dict, "id") : NULL; QObject *ret =3D NULL; + QDict *rsp; =20 - dict =3D qmp_dispatch_check_obj(request, allow_oob, errp); + dict =3D qmp_dispatch_check_obj(request, allow_oob, &err); if (!dict) { - return NULL; + goto out; } =20 command =3D qdict_get_try_str(dict, "execute"); @@ -99,27 +122,27 @@ static QObject *do_qmp_dispatch(QmpCommandList *cmds, = QObject *request, } cmd =3D qmp_find_command(cmds, command); if (cmd =3D=3D NULL) { - error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND, + error_set(&err, ERROR_CLASS_COMMAND_NOT_FOUND, "The command %s has not been found", command); - return NULL; + goto out; } if (!cmd->enabled) { - error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND, + error_set(&err, ERROR_CLASS_COMMAND_NOT_FOUND, "The command %s has been disabled for this instance", command); - return NULL; + goto out; } if (oob && !(cmd->options & QCO_ALLOW_OOB)) { - error_setg(errp, "The command %s does not support OOB", + error_setg(&err, "The command %s does not support OOB", command); - return NULL; + goto out; } =20 if (runstate_check(RUN_STATE_PRECONFIG) && !(cmd->options & QCO_ALLOW_PRECONFIG)) { - error_setg(errp, "The command '%s' isn't permitted in '%s' state", + error_setg(&err, "The command '%s' isn't permitted in '%s' state", cmd->name, RunState_str(RUN_STATE_PRECONFIG)); - return NULL; + goto out; } =20 if (!qdict_haskey(dict, "arguments")) { @@ -129,9 +152,9 @@ static QObject *do_qmp_dispatch(QmpCommandList *cmds, Q= Object *request, qobject_ref(args); } =20 - cmd->fn(args, &ret, &local_err); - if (local_err) { - error_propagate(errp, local_err); + cmd->fn(args, &ret, &err); + if (err) { + ; } else if (cmd->options & QCO_NO_SUCCESS_RESP) { g_assert(!ret); } else if (!ret) { @@ -141,38 +164,7 @@ static QObject *do_qmp_dispatch(QmpCommandList *cmds, = QObject *request, =20 qobject_unref(args); =20 - return ret; -} - -QDict *qmp_error_response(Error *err) -{ - QDict *rsp; - - rsp =3D qdict_from_jsonf_nofail("{ 'error': { 'class': %s, 'desc': %s = } }", - QapiErrorClass_str(error_get_class(err)), - error_get_pretty(err)); - error_free(err); - return rsp; -} - -/* - * Does @qdict look like a command to be run out-of-band? - */ -bool qmp_is_oob(const QDict *dict) -{ - return qdict_haskey(dict, "exec-oob") - && !qdict_haskey(dict, "execute"); -} - -QDict *qmp_dispatch(QmpCommandList *cmds, QObject *request, - bool allow_oob) -{ - Error *err =3D NULL; - QDict *dict =3D qobject_to(QDict, request); - QObject *ret, *id =3D dict ? qdict_get(dict, "id") : NULL; - QDict *rsp; - - ret =3D do_qmp_dispatch(cmds, request, allow_oob, &err); +out: if (err) { rsp =3D qmp_error_response(err); } else if (ret) { --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253370; cv=none; d=zohomail.com; s=zohoarc; b=PhiBXBR7lKUmcS9AVp9tTdzsIE77nXYINXcpY4ly7NA4i1dcI14WuF+i9TBqBeV6Q46VGRxPQ5ijwzpbXd8TCpMcCedh7EOlXw4gw8pM5oxaU9ePnxjzH2JG3cmTtyo9YZVO8jcnXRwkHblseBtbBB7lzVg1ifH5dJDoLatrl4I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253370; h=Content-Type: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; bh=rbSWSFCqRg7Dyhwyu1gGZIgG7CVGvmA7JcPtABc7N4A=; b=lSFw7u0DzNAv6eqO921nGvtDoJ4sZC4fbxGhjOCO8aN9QFLz6tMEY6RhitDDXUIfc7wZ58KCLL172ewvB5LJxxbiTUY6zT826uyENErPEHo4pJpHPMFNf6PhRB36kKSHJY0Z7VWKKR5/WU7O8zlBkhqn7Y4+biE45OPdlZ6ST5Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 158325337044798.21260383823437; Tue, 3 Mar 2020 08:36:10 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-344-Os95FDorPUSSUkg15wGdAQ-1; Tue, 03 Mar 2020 11:36:05 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 379E41005513; Tue, 3 Mar 2020 16:35:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F10D61001B2C; Tue, 3 Mar 2020 16:35:58 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8019086A1C; Tue, 3 Mar 2020 16:35:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZEUR001273 for ; Tue, 3 Mar 2020 11:35:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id E33895DA82; Tue, 3 Mar 2020 16:35:14 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A90335DA2C; Tue, 3 Mar 2020 16:35:14 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 050D511329FF; Tue, 3 Mar 2020 17:35:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253369; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=rbSWSFCqRg7Dyhwyu1gGZIgG7CVGvmA7JcPtABc7N4A=; b=SrsblZFGKkBVwuzKgBL5YKEjUCO24S93DPaqF+SXZZ5UnW5YXB9TytQ/X8X1ukj61MrbKB Uuk72TXlpbeDz/lM97UeHecgJfN1AIQyd1iT5kI1DKmqshybg0eAPuE9sHJ1DBflcT4Z1i z3Tsq606QUjxHNkWV1EJ4aZccNmOSHU= X-MC-Unique: Os95FDorPUSSUkg15wGdAQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 22/30] qapi: Simplify how qmp_dispatch() deals with QCO_NO_SUCCESS_RESP Date: Tue, 3 Mar 2020 17:34:57 +0100 Message-Id: <20200303163505.32041-23-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster --- qapi/qmp-dispatch.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index a588072523..550d1fe8d2 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -106,7 +106,7 @@ QDict *qmp_dispatch(QmpCommandList *cmds, QObject *requ= est, QDict *dict =3D qobject_to(QDict, request); QObject *id =3D dict ? qdict_get(dict, "id") : NULL; QObject *ret =3D NULL; - QDict *rsp; + QDict *rsp =3D NULL; =20 dict =3D qmp_dispatch_check_obj(request, allow_oob, &err); if (!dict) { @@ -151,31 +151,32 @@ QDict *qmp_dispatch(QmpCommandList *cmds, QObject *re= quest, args =3D qdict_get_qdict(dict, "arguments"); qobject_ref(args); } - cmd->fn(args, &ret, &err); + qobject_unref(args); if (err) { - ; - } else if (cmd->options & QCO_NO_SUCCESS_RESP) { + goto out; + } + + if (cmd->options & QCO_NO_SUCCESS_RESP) { g_assert(!ret); + return NULL; } else if (!ret) { /* TODO turn into assertion */ ret =3D QOBJECT(qdict_new()); } =20 - qobject_unref(args); + rsp =3D qdict_new(); + qdict_put_obj(rsp, "return", ret); =20 out: if (err) { + assert(!rsp); rsp =3D qmp_error_response(err); - } else if (ret) { - rsp =3D qdict_new(); - qdict_put_obj(rsp, "return", ret); - } else { - /* Can only happen for commands with QCO_NO_SUCCESS_RESP */ - rsp =3D NULL; } =20 - if (rsp && id) { + assert(rsp); + + if (id) { qdict_put_obj(rsp, "id", qobject_ref(id)); } =20 --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253390; cv=none; d=zohomail.com; s=zohoarc; b=Tb9bQcZNIWg2ALFzIjxm71yw7d1NpsghK7TdWnoFahme1gD39ClklkKpgqWBjyGTsDS8lCOhGcRavELc/mOSlGGRgo2RXcKZkP3jGQVko4kcvCa8HhxlXtTZcxNsQqiruBl4IvzDax3Hp7eGEuNhadYqrTFWZSLBtxu11wNRN3s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253390; h=Content-Type: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; bh=DolF0eQFcYj8TmoxPP0W7/I7b+3KWwKUpg3+CYqCpWk=; b=D5oXR5HEtwDtRmYkFidQ10ALvjqvXpww4w4OjH8ymySnCZb4y2UqoQYXalrtRatuG/onLxFGa5+akjCJjwsSjzTpQNIWK9ksKVW4EPtf/013VpPXq/aMjQGad37bGwgOZRqMbJaVEhktJB2MHOTkZmkev8iX2pr+xrlcvlaeJew= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1583253390175691.7710057229464; Tue, 3 Mar 2020 08:36:30 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-452-c0CIqPjRNT2zW9ya3y5dXw-1; Tue, 03 Mar 2020 11:36:26 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2EE199B58A; Tue, 3 Mar 2020 16:36:21 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0125560BF3; Tue, 3 Mar 2020 16:36:21 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8F42986A28; Tue, 3 Mar 2020 16:36:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZHKC001347 for ; Tue, 3 Mar 2020 11:35:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id D2225272CC; Tue, 3 Mar 2020 16:35:17 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C947719C4F; Tue, 3 Mar 2020 16:35:14 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 08DF611329BF; Tue, 3 Mar 2020 17:35:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253389; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=DolF0eQFcYj8TmoxPP0W7/I7b+3KWwKUpg3+CYqCpWk=; b=BUvi0hKkQEyndkwG5Jhlh30mEVXzQtEAs0gUaHA3QwLOxK3l46w7ZGTIOAyuQxx9zwjjPI chREz1dVEBQ8ualcmqYuNaFJJ/JrkFtLLvjErD3VvEYhGKWskROO9Q8OPJ7H7zP9zepg/X 6IvsBquKqVDXNlo5kYxhaCusIv50QLY= X-MC-Unique: c0CIqPjRNT2zW9ya3y5dXw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 23/30] qapi: Simplify how qmp_dispatch() gets the request ID Date: Tue, 3 Mar 2020 17:34:58 +0100 Message-Id: <20200303163505.32041-24-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We convert the request object to a QDict twice: first in qmp_dispatch() to get the request ID, and then again in qmp_dispatch_check_obj(), which converts to QDict, then checks and returns it. We can't get the request ID from the latter, because it's null when the qdict flunks the checks. Move getting the request ID into qmp_dispatch_check_obj(). Signed-off-by: Markus Armbruster --- qapi/qmp-dispatch.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index 550d1fe8d2..112d29a9ab 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -20,7 +20,7 @@ #include "qapi/qmp/qbool.h" =20 static QDict *qmp_dispatch_check_obj(const QObject *request, bool allow_oo= b, - Error **errp) + QObject **id, Error **errp) { const char *exec_key =3D NULL; const QDictEntry *ent; @@ -30,10 +30,13 @@ static QDict *qmp_dispatch_check_obj(const QObject *req= uest, bool allow_oob, =20 dict =3D qobject_to(QDict, request); if (!dict) { + *id =3D NULL; error_setg(errp, "QMP input must be a JSON object"); return NULL; } =20 + *id =3D qdict_get(dict, "id"); + for (ent =3D qdict_first(dict); ent; ent =3D qdict_next(dict, ent)) { arg_name =3D qdict_entry_key(ent); @@ -103,12 +106,12 @@ QDict *qmp_dispatch(QmpCommandList *cmds, QObject *re= quest, const char *command; QDict *args; QmpCommand *cmd; - QDict *dict =3D qobject_to(QDict, request); - QObject *id =3D dict ? qdict_get(dict, "id") : NULL; + QDict *dict; + QObject *id; QObject *ret =3D NULL; QDict *rsp =3D NULL; =20 - dict =3D qmp_dispatch_check_obj(request, allow_oob, &err); + dict =3D qmp_dispatch_check_obj(request, allow_oob, &id, &err); if (!dict) { goto out; } --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253388; cv=none; d=zohomail.com; s=zohoarc; b=e/kJkfky2jBAdT3pv4QVsIelv3UlOv+hLYkap6syTx2mBe5zdLKbgSeVSb+HxCOJcXMc9e7ggaVdBu1ImfwFgsQthhAQtWlGJ6t+2xzx094MDOqlcyjFHkJYuJIJfR54bliAm1/SsCnc0R4u3sU58W1HHeB8VUeOB7qSEFpdJZs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253388; h=Content-Type: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; bh=MOc7HeT+1s334JGeFcRwNRegWa0ts+HD+BGwpDGZNUc=; b=aciWhhIVWAKgTTOosDwbdX4Fs/RcK+k2mchtJ7MPW0Yik62Xzd9hulJTkkl+bznsa4XboPT+JULHcEmux/G34KwJyMdP74e3bjJW9w75nKDzAAuqchx6sfCyLrRNeAgpIE1+BoL/5uIk3E435/Epzy5TV7khJvssPQAJdnj8zGY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1583253388192496.9265662069738; Tue, 3 Mar 2020 08:36:28 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-451-mUSA-FLVM_iUuqrVPqNCkQ-1; Tue, 03 Mar 2020 11:36:24 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id D1A5A800D48; Tue, 3 Mar 2020 16:36:16 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A632C10013A1; Tue, 3 Mar 2020 16:36:16 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 587B086A21; Tue, 3 Mar 2020 16:36:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZG2Q001331 for ; Tue, 3 Mar 2020 11:35:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id DAAAC100EBA4; Tue, 3 Mar 2020 16:35:16 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C16271000322; Tue, 3 Mar 2020 16:35:14 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0C0F2113294C; Tue, 3 Mar 2020 17:35:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253386; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=MOc7HeT+1s334JGeFcRwNRegWa0ts+HD+BGwpDGZNUc=; b=erMpV/xXltyakRx+cg88kvZYfiZ3a2XTq+3LqzFK2n+0RUj6WRCe6pRW2a+vNlva9ACV06 YQ3s9ZpjcWddWO38wmT0PuQsl5x/fbPqkD6dpvEWLjMPKVOGPj4A5qJjd/qwr8KvgD3mAn JzjP949MmdB4WcbtqAEb1IiK4ozoeso= X-MC-Unique: mUSA-FLVM_iUuqrVPqNCkQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 24/30] qapi: Replace qmp_dispatch()'s TODO comment by an explanation Date: Tue, 3 Mar 2020 17:34:59 +0100 Message-Id: <20200303163505.32041-25-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster --- qapi/qmp-dispatch.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index 112d29a9ab..fb53687ce9 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -164,7 +164,11 @@ QDict *qmp_dispatch(QmpCommandList *cmds, QObject *req= uest, g_assert(!ret); return NULL; } else if (!ret) { - /* TODO turn into assertion */ + /* + * When the command's schema has no 'returns', cmd->fn() + * leaves @ret null. The QMP spec calls for an the empty + * object then; supply it. + */ ret =3D QOBJECT(qdict_new()); } =20 --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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; dkim=fail; spf=pass (zohomail.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=1583253417; cv=none; d=zohomail.com; s=zohoarc; b=E0WJLCSFPdn16r+Ly9edOb2gemPLpVQSm4CNgVRm93e66/gEKGxTLAdv8075I2Tdf3M9Ms9Ji6DkfOP5dbIR4hvjyyF0utN/rYP3VXejf8qj4RA5FPUQADA/VAk3r40/zQAc5VgH/cVu7AXlUesL8P/U1gLIKi4zFunRVQDS/94= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253417; h=Content-Type: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; bh=Owq39moJ6aAroKIFB1xDMy4nUoefRP75muZqMrDPTs4=; b=bbaxa+kBrsu1nCyxa0cKKa4/LQS1aAnOrmreswPHPnW3AAJt/eaUtv0IQqIm/MXc1G7MISkgqOk1OMVecpO0btbWo8P3jqZDMQaqPE1DwUFIfK8/OBhzdJBwfLtPbGCufbOLfRz8JcQpGL43rwJqsnZ7i2mQ/KH4/wPtdwgDFZM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1583253417697106.94200063570156; Tue, 3 Mar 2020 08:36:57 -0800 (PST) Received: from localhost ([::1]:49958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9AXQ-0006O3-HW for importer@patchew.org; Tue, 03 Mar 2020 11:36:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56958) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9AVv-0004Mj-15 for qemu-devel@nongnu.org; Tue, 03 Mar 2020 11:35:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9AVt-00032x-9Y for qemu-devel@nongnu.org; Tue, 03 Mar 2020 11:35:22 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:46630 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j9AVt-00032e-5o for qemu-devel@nongnu.org; Tue, 03 Mar 2020 11:35:21 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-180-9fr-dhZwOcGdwd5zxBBlGw-1; Tue, 03 Mar 2020 11:35:17 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4EBEF1005512; Tue, 3 Mar 2020 16:35:16 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D033910027AB; Tue, 3 Mar 2020 16:35:14 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0F5C711328A8; Tue, 3 Mar 2020 17:35:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253320; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Owq39moJ6aAroKIFB1xDMy4nUoefRP75muZqMrDPTs4=; b=Ur4dyfHz/1oLS01rHuD3pj1XiHx0izdIsjEQgiqY7QaUFX1D3mZnNNeN9eBa1oIdXU3Dq6 afxQiHID4ED60AGznVTtu/+BZgqCM8PsLxJVqYcUXpJ9A7cvfcioYbm6p5v774tMdsiquz vQgqNpNehC6iKfYrHtHU/H23oVCJ9tA= X-MC-Unique: 9fr-dhZwOcGdwd5zxBBlGw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 25/30] qapi: New special feature flag "deprecated" Date: Tue, 3 Mar 2020 17:35:00 +0100 Message-Id: <20200303163505.32041-26-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: libvir-list@redhat.com, berrange@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Unlike regular feature flags, the new special feature flag "deprecated" is recognized by the QAPI generator. For now, it's only permitted with commands, events, and struct members. It will be put to use shortly. Signed-off-by: Markus Armbruster --- docs/devel/qapi-code-gen.txt | 6 ++++++ scripts/qapi/schema.py | 6 ++++++ tests/Makefile.include | 1 + tests/qapi-schema/features-deprecated-type.err | 2 ++ tests/qapi-schema/features-deprecated-type.json | 3 +++ tests/qapi-schema/features-deprecated-type.out | 0 tests/qapi-schema/qapi-schema-test.json | 6 +++--- tests/qapi-schema/qapi-schema-test.out | 6 +++--- 8 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 tests/qapi-schema/features-deprecated-type.err create mode 100644 tests/qapi-schema/features-deprecated-type.json create mode 100644 tests/qapi-schema/features-deprecated-type.out diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt index a1ef1cfd61..823adbabda 100644 --- a/docs/devel/qapi-code-gen.txt +++ b/docs/devel/qapi-code-gen.txt @@ -683,6 +683,12 @@ Intended use is to have each feature string signal tha= t this build of QEMU shows a certain behaviour. =20 =20 +=3D=3D=3D=3D Special features =3D=3D=3D=3D + +Feature "deprecated" makes a command, event, or struct member as +deprecated. It is not supported elsewhere so far. + + =3D=3D=3D Naming rules and reserved names =3D=3D=3D =20 All names must begin with a letter, and contain only ASCII letters, diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 2fb845303b..b303a2631d 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -193,6 +193,12 @@ class QAPISchemaType(QAPISchemaEntity): return None return self.name =20 + def check(self, schema): + QAPISchemaEntity.check(self, schema) + if 'deprecated' in [f.name for f in self.features]: + raise QAPISemError( + self.info, "feature 'deprecated' is not supported for type= s") + def describe(self): assert self.meta return "%s type '%s'" % (self.meta, self.name) diff --git a/tests/Makefile.include b/tests/Makefile.include index edcbd475aa..bc74970cda 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -242,6 +242,7 @@ 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-deprecated-type.json qapi-schema +=3D features-duplicate-name.json qapi-schema +=3D features-if-invalid.json qapi-schema +=3D features-missing-name.json diff --git a/tests/qapi-schema/features-deprecated-type.err b/tests/qapi-sc= hema/features-deprecated-type.err new file mode 100644 index 0000000000..af4ffe20aa --- /dev/null +++ b/tests/qapi-schema/features-deprecated-type.err @@ -0,0 +1,2 @@ +features-deprecated-type.json: In struct 'S': +features-deprecated-type.json:2: feature 'deprecated' is not supported for= types diff --git a/tests/qapi-schema/features-deprecated-type.json b/tests/qapi-s= chema/features-deprecated-type.json new file mode 100644 index 0000000000..4b5bf5b86e --- /dev/null +++ b/tests/qapi-schema/features-deprecated-type.json @@ -0,0 +1,3 @@ +# Feature 'deprecated' is not supported for types +{ 'struct': 'S', 'data': {}, + 'features': [ 'deprecated' ] } diff --git a/tests/qapi-schema/features-deprecated-type.out b/tests/qapi-sc= hema/features-deprecated-type.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index f576c337af..6b1f05afa7 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -258,7 +258,7 @@ 'data': { 'foo': 'int' }, 'features': [] } { 'struct': 'FeatureStruct1', - 'data': { 'foo': { 'type': 'int', 'features': [ 'member-feature1' ] } }, + 'data': { 'foo': { 'type': 'int', 'features': [ 'deprecated' ] } }, 'features': [ 'feature1' ] } { 'struct': 'FeatureStruct2', 'data': { 'foo': 'int' }, @@ -308,7 +308,7 @@ 'features': [] } =20 { 'command': 'test-command-features1', - 'features': [ 'feature1' ] } + 'features': [ 'deprecated' ] } { 'command': 'test-command-features3', 'features': [ 'feature1', 'feature2' ] } =20 @@ -322,4 +322,4 @@ 'defined(TEST_IF_COND_2)'] }= ] } =20 { 'event': 'TEST-EVENT-FEATURES1', - 'features': [ 'feature1' ] } + 'features': [ 'deprecated' ] } diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index cd863ae966..891b4101e0 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -359,7 +359,7 @@ object FeatureStruct0 member foo: int optional=3DFalse object FeatureStruct1 member foo: int optional=3DFalse - feature member-feature1 + feature deprecated feature feature1 object FeatureStruct2 member foo: int optional=3DFalse @@ -419,7 +419,7 @@ command test-features0 q_obj_test-features0-arg -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse command test-command-features1 None -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse - feature feature1 + feature deprecated command test-command-features3 None -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse feature feature1 @@ -440,7 +440,7 @@ command test-command-cond-features3 None -> None if ['defined(TEST_IF_COND_1)', 'defined(TEST_IF_COND_2)'] event TEST-EVENT-FEATURES1 None boxed=3DFalse - feature feature1 + feature deprecated module include/sub-module.json include sub-sub-module.json object SecondArrayRef --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253395; cv=none; d=zohomail.com; s=zohoarc; b=hdmiLCSrjmtmUIV7HBk8LxsmeH05iFkNuzy/p0QUHc2hhsq1OXnlFpxpjufAnHgWFYYodXJ27BpbY+unnHNNkW1z4LL6CYa4v75GJ0rk4Ksgfx1jmRs+/CDtfoEurBFAXs7eCs8ML0JuTwl/X8czqs+RBclTmxfj5lwbDCUC4Hs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253395; h=Content-Type: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; bh=55JvxPt0KHUT+9UFXjq8IhzL9/3jplVc8pPi6x2GFII=; b=dHRYQ1zKBuJipQRnuwdkfOlBa/CM4uzuA2x8HDUqK4QYQsU08cM0/6kMyCSOyrCvdOEOWCwtKovgWKo5KpdpXGrjw+aRfd9mDrcFQWupshsi20MQEgEn18D4IHT05O8Fz8txDub3cBFfUa6Lgq9+LgLUQaxzWCL9zG0Pzp5yowc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1583253395908787.6451634282679; Tue, 3 Mar 2020 08:36:35 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-385-gt-fw8l6Ow6KWGgEvjHqlA-1; Tue, 03 Mar 2020 11:36:32 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 368F8107B273; Tue, 3 Mar 2020 16:36:25 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0566110013A1; Tue, 3 Mar 2020 16:36:25 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id AED7A86A2C; Tue, 3 Mar 2020 16:36:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZJ73001406 for ; Tue, 3 Mar 2020 11:35:19 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6D6EE5D9C9; Tue, 3 Mar 2020 16:35:19 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D15A25DA7C; Tue, 3 Mar 2020 16:35:14 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 12B26113287B; Tue, 3 Mar 2020 17:35:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253394; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=55JvxPt0KHUT+9UFXjq8IhzL9/3jplVc8pPi6x2GFII=; b=LJcqPt//7FAJeI3xq+OOhpI8PeF/AaGbcZ5gUkrU0DhREimk8jpryWmg9N3LULwDmqNRID BN35aN889IibwD/AjR4tn7ksl0UlTDxgb/S4mubHYGYsZcLXxxJblaW6QyRnKzX3UcmSJD Twnb7YtlTosdE303KC69QSQMoBkkW5o= X-MC-Unique: gt-fw8l6Ow6KWGgEvjHqlA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 26/30] qapi: Mark deprecated QMP parts with feature 'deprecated' Date: Tue, 3 Mar 2020 17:35:01 +0100 Message-Id: <20200303163505.32041-27-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Add feature 'deprecated' to the deprecated QMP commands, so their deprecation becomes visible in output of query-qmp-schema. Looks like this: {"name": "query-cpus", "ret-type": "[164]", "meta-type": "command", "arg-type": "0", ---> "features": ["deprecated"]} Management applications could conceivably use this for static checking. The deprecated commands are change, cpu-add, migrate-set-cache-size, migrate_set_downtime, migrate_set_speed, query-cpus, query-events, query-migrate-cache-size. The deprecated command arguments are block-commit arguments @base and @top, and block_set_io_throttle, blockdev-change-medium, blockdev-close-tray, blockdev-open-tray, eject argument @device. The deprecated command results are query-cpus-fast result @arch, query-block result @dirty-bitmaps, query-named-block-nodes result @encryption_key_missing and result @dirty-bitmaps's member @status. Same for query-block result @inserted, which mirrors query-named-block-nodes. Signed-off-by: Markus Armbruster --- qapi/block-core.json | 69 +++++++++++++++++++++++++++++++++----------- qapi/block.json | 9 ++++-- qapi/control.json | 11 ++++--- qapi/machine.json | 34 ++++++++++++---------- qapi/migration.json | 36 +++++++++++++++-------- qapi/misc.json | 13 +++++---- 6 files changed, 115 insertions(+), 57 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 85e27bb61f..bade02760c 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -297,7 +297,7 @@ # # @encrypted: true if the backing device is encrypted # -# @encryption_key_missing: Deprecated; always false +# @encryption_key_missing: always false # # @detect_zeroes: detect and optimize zero writes (Since 2.1) # @@ -363,13 +363,19 @@ # @dirty-bitmaps: dirty bitmaps information (only present if node # has one or more dirty bitmaps) (Since 4.2) # +# Features: +# @deprecated: Member @encryption_key_missing is deprecated. It is +# always false. +# # Since: 0.14.0 # ## { 'struct': 'BlockDeviceInfo', 'data': { 'file': 'str', '*node-name': 'str', 'ro': 'bool', 'drv': 'str', '*backing_file': 'str', 'backing_file_depth': 'int', - 'encrypted': 'bool', 'encryption_key_missing': 'bool', + 'encrypted': 'bool', + 'encryption_key_missing': { 'type': 'bool', + 'features': [ 'deprecated' ] }, 'detect_zeroes': 'BlockdevDetectZeroesOptions', 'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int', 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int', @@ -475,7 +481,7 @@ # # @granularity: granularity of the dirty bitmap in bytes (since 1.4) # -# @status: Deprecated in favor of @recording and @locked. (since 2.4) +# @status: current status of the dirty bitmap (since 2.4) # # @recording: true if the bitmap is recording new writes from the guest. # Replaces `active` and `disabled` statuses. (since 4.0) @@ -492,11 +498,17 @@ # @busy to be false. This bitmap cannot be used. To remove # it, use @block-dirty-bitmap-remove. (Since 4.0) # +# Features: +# @deprecated: Member @status is deprecated. Use @recording and +# @locked instead. +# # Since: 1.3 ## { 'struct': 'BlockDirtyInfo', 'data': {'*name': 'str', 'count': 'int', 'granularity': 'uint32', - 'recording': 'bool', 'busy': 'bool', 'status': 'DirtyBitmapStat= us', + 'recording': 'bool', 'busy': 'bool', + 'status': { 'type': 'DirtyBitmapStatus', + 'features': [ 'deprecated' ] }, 'persistent': 'bool', '*inconsistent': 'bool' } } =20 ## @@ -659,7 +671,6 @@ # # @dirty-bitmaps: dirty bitmaps information (only present if the # driver has one or more dirty bitmaps) (Since 2.0) -# Deprecated in 4.2; see BlockDeviceInfo instead. # # @io-status: @BlockDeviceIoStatus. Only present if the device # supports it and the VM is configured to stop on errors @@ -669,13 +680,18 @@ # @inserted: @BlockDeviceInfo describing the device if media is # present # +# Features: +# @deprecated: Member @dirty-bitmaps is deprecated. Use @inserted +# member @dirty-bitmaps instead. +# # Since: 0.14.0 ## { 'struct': 'BlockInfo', 'data': {'device': 'str', '*qdev': 'str', 'type': 'str', 'removable': 'b= ool', 'locked': 'bool', '*inserted': 'BlockDeviceInfo', '*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus', - '*dirty-bitmaps': ['BlockDirtyInfo'] } } + '*dirty-bitmaps': { 'type': ['BlockDirtyInfo'], + 'features': [ 'deprecated' ] } } } =20 ## # @BlockMeasureInfo: @@ -1616,7 +1632,7 @@ # @base: Same as @base-node, except that it is a file name rather than a n= ode # name. This must be the exact filename string that was used to ope= n the # node; other strings, even if addressing the same file, are not -# accepted (deprecated, use @base-node instead) +# accepted # # @top-node: The node name of the backing image within the image chain # which contains the topmost data to be committed down. If @@ -1625,7 +1641,7 @@ # @top: Same as @top-node, except that it is a file name rather than a node # name. This must be the exact filename string that was used to open= the # node; other strings, even if addressing the same file, are not -# accepted (deprecated, use @base-node instead) +# accepted # # @backing-file: The backing file string to write into the overlay # image of 'top'. If 'top' is the active layer, @@ -1679,6 +1695,10 @@ # list without user intervention. # Defaults to true. (Since 3.1) # +# Features: +# @deprecated: Members @base and @top are deprecated. Use @base-node +# and @top-node instead. +# # Returns: - Nothing on success # - If @device does not exist, DeviceNotFound # - Any other error returns a GenericError. @@ -1695,7 +1715,9 @@ ## { 'command': 'block-commit', 'data': { '*job-id': 'str', 'device': 'str', '*base-node': 'str', - '*base': 'str', '*top-node': 'str', '*top': 'str', + '*base': { 'type': 'str', 'features': [ 'deprecated' ] }, + '*top-node': 'str', + '*top': { 'type': 'str', 'features': [ 'deprecated' ] }, '*backing-file': 'str', '*speed': 'int', '*on-error': 'BlockdevOnError', '*filter-node-name': 'str', @@ -2433,7 +2455,7 @@ # # A set of parameters describing block throttling. # -# @device: Block device name (deprecated, use @id instead) +# @device: Block device name # # @id: The name or QOM path of the guest device (since: 2.8) # @@ -2501,10 +2523,14 @@ # # @group: throttle group name (Since 2.4) # +# Features: +# @deprecated: Member @device is deprecated. Use @id instead. +# # Since: 1.1 ## { 'struct': 'BlockIOThrottle', - 'data': { '*device': 'str', '*id': 'str', 'bps': 'int', 'bps_rd': 'int', + 'data': { '*device': { 'type': 'str', 'features': [ 'deprecated' ] }, + '*id': 'str', 'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int', 'iops': 'int', 'iops_rd': 'int', 'iops_wr': '= int', '*bps_max': 'int', '*bps_rd_max': 'int', '*bps_wr_max': 'int', '*iops_max': 'int', @@ -4776,7 +4802,7 @@ # to it # - if the guest device does not have an actual tray # -# @device: Block device name (deprecated, use @id instead) +# @device: Block device name # # @id: The name or QOM path of the guest device (since: 2.8) # @@ -4785,6 +4811,9 @@ # immediately); if true, the tray will be opened regardless of whe= ther # it is locked # +# Features: +# @deprecated: Member @device is deprecated. Use @id instead. +# # Since: 2.5 # # Example: @@ -4803,7 +4832,7 @@ # ## { 'command': 'blockdev-open-tray', - 'data': { '*device': 'str', + 'data': { '*device': { 'type': 'str', 'features': [ 'deprecated' ] }, '*id': 'str', '*force': 'bool' } } =20 @@ -4816,10 +4845,13 @@ # # If the tray was already closed before, this will be a no-op. # -# @device: Block device name (deprecated, use @id instead) +# @device: Block device name # # @id: The name or QOM path of the guest device (since: 2.8) # +# Features: +# @deprecated: Member @device is deprecated. Use @id instead. +# # Since: 2.5 # # Example: @@ -4838,7 +4870,7 @@ # ## { 'command': 'blockdev-close-tray', - 'data': { '*device': 'str', + 'data': { '*device': { 'type': 'str', 'features': [ 'deprecated' ] }, '*id': 'str' } } =20 ## @@ -4945,7 +4977,7 @@ # combines blockdev-open-tray, blockdev-remove-medium, blockdev-insert-med= ium # and blockdev-close-tray). # -# @device: Block device name (deprecated, use @id instead) +# @device: Block device name # # @id: The name or QOM path of the guest device # (since: 2.8) @@ -4958,6 +4990,9 @@ # @read-only-mode: change the read-only mode of the device; defaults # to 'retain' # +# Features: +# @deprecated: Member @device is deprecated. Use @id instead. +# # Since: 2.5 # # Examples: @@ -4992,7 +5027,7 @@ # ## { 'command': 'blockdev-change-medium', - 'data': { '*device': 'str', + 'data': { '*device': { 'type': 'str', 'features': [ 'deprecated' ] }, '*id': 'str', 'filename': 'str', '*format': 'str', diff --git a/qapi/block.json b/qapi/block.json index da19834db4..8314ef21d1 100644 --- a/qapi/block.json +++ b/qapi/block.json @@ -185,15 +185,18 @@ ## # @eject: # -# Ejects a device from a removable drive. +# Ejects the medium from a removable block device. # -# @device: Block device name (deprecated, use @id instead) +# @device: Block device name # # @id: The name or QOM path of the guest device (since: 2.8) # # @force: If true, eject regardless of whether the drive is locked. # If not specified, the default value is false. # +# Features: +# @deprecated: Member @device is deprecated. Use @id instead. +# # Returns: - Nothing on success # - If @device is not a valid block device, DeviceNotFound # Notes: Ejecting a device with no media results in success @@ -206,7 +209,7 @@ # <- { "return": {} } ## { 'command': 'eject', - 'data': { '*device': 'str', + 'data': { '*device': { 'type': 'str', 'features': [ 'deprecated' ] }, '*id': 'str', '*force': 'bool' } } =20 diff --git a/qapi/control.json b/qapi/control.json index 759c20e76f..cdb058eca0 100644 --- a/qapi/control.json +++ b/qapi/control.json @@ -174,13 +174,15 @@ # # Return information on QMP events. # +# Features: +# @deprecated: This command is deprecated, because its output doesn't +# reflect compile-time configuration. Use 'query-qmp-schema' +# instead. +# # Returns: A list of @EventInfo. # # Since: 1.2.0 # -# Note: This command is deprecated, because its output doesn't reflect -# compile-time configuration. Use query-qmp-schema instead. -# # Example: # # -> { "execute": "query-events" } @@ -198,7 +200,8 @@ # Note: This example has been shortened as the real response is too long. # ## -{ 'command': 'query-events', 'returns': ['EventInfo'] } +{ 'command': 'query-events', 'returns': ['EventInfo'], + 'features': [ 'deprecated' ] } =20 ## # @quit: diff --git a/qapi/machine.json b/qapi/machine.json index 6c11e3cf3a..0da3f3adc4 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -184,8 +184,11 @@ # This command causes vCPU threads to exit to userspace, which causes # a small interruption to guest CPU execution. This will have a negative # impact on realtime guests and other latency sensitive guest workloads. -# It is recommended to use @query-cpus-fast instead of this command to -# avoid the vCPU interruption. +# +# Features: +# @deprecated: This command is deprecated, because it interferes with +# the guest. Use 'query-cpus-fast' instead to avoid the vCPU +# interruption. # # Returns: a list of @CpuInfo for each virtual CPU # @@ -216,12 +219,9 @@ # ] # } # -# Notes: This interface is deprecated (since 2.12.0), and it is strongly -# recommended that you avoid using it. Use @query-cpus-fast to -# obtain information about virtual CPUs. -# ## -{ 'command': 'query-cpus', 'returns': ['CpuInfo'] } +{ 'command': 'query-cpus', 'returns': ['CpuInfo'], + 'features': [ 'deprecated' ] } =20 ## # @CpuInfoFast: @@ -237,12 +237,14 @@ # @props: properties describing to which node/socket/core/thread # virtual CPU belongs to, provided if supported by board # -# @arch: base architecture of the cpu; deprecated since 3.0.0 in favor -# of @target +# @arch: base architecture of the cpu # # @target: the QEMU system emulation target, which determines which # additional fields will be listed (since 3.0) # +# Features: +# @deprecated: Member @arch is deprecated. Use @target instead. +# # Since: 2.12 # ## @@ -251,7 +253,8 @@ 'qom-path' : 'str', 'thread-id' : 'int', '*props' : 'CpuInstanceProperties', - 'arch' : 'CpuInfoArch', + 'arch' : { 'type': 'CpuInfoArch', + 'features': [ 'deprecated' ] }, 'target' : 'SysEmuTarget' }, 'discriminator' : 'target', 'data' : { 's390x' : 'CpuInfoS390' } } @@ -307,21 +310,22 @@ # # @id: ID of CPU to be created, valid values [0..max_cpus) # +# Features: +# @deprecated: This command is deprecated. Use `device_add` instead. +# See the `query-hotpluggable-cpus` command for details. +# # Returns: Nothing on success # # Since: 1.5 # -# Note: This command is deprecated. The `device_add` command should be -# used instead. See the `query-hotpluggable-cpus` command for -# details. -# # Example: # # -> { "execute": "cpu-add", "arguments": { "id": 2 } } # <- { "return": {} } # ## -{ 'command': 'cpu-add', 'data': {'id': 'int'} } +{ 'command': 'cpu-add', 'data': {'id': 'int'}, + 'features': [ 'deprecated' ] } =20 ## # @MachineInfo: diff --git a/qapi/migration.json b/qapi/migration.json index d44d99cd78..b8b5eb195f 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1196,9 +1196,11 @@ # # @value: maximum downtime in seconds # -# Returns: nothing on success +# Features: +# @deprecated: This command is deprecated. Use +# 'migrate-set-parameters' instead. # -# Notes: This command is deprecated in favor of 'migrate-set-parameters' +# Returns: nothing on success # # Since: 0.14.0 # @@ -1208,7 +1210,8 @@ # <- { "return": {} } # ## -{ 'command': 'migrate_set_downtime', 'data': {'value': 'number'} } +{ 'command': 'migrate_set_downtime', 'data': {'value': 'number'}, + 'features': [ 'deprecated' ] } =20 ## # @migrate_set_speed: @@ -1217,9 +1220,11 @@ # # @value: maximum speed in bytes per second. # -# Returns: nothing on success +# Features: +# @deprecated: This command is deprecated. Use +# 'migrate-set-parameters' instead. # -# Notes: This command is deprecated in favor of 'migrate-set-parameters' +# Returns: nothing on success # # Since: 0.14.0 # @@ -1229,7 +1234,8 @@ # <- { "return": {} } # ## -{ 'command': 'migrate_set_speed', 'data': {'value': 'int'} } +{ 'command': 'migrate_set_speed', 'data': {'value': 'int'}, + 'features': [ 'deprecated' ] } =20 ## # @migrate-set-cache-size: @@ -1238,13 +1244,15 @@ # # @value: cache size in bytes # +# Features: +# @deprecated: This command is deprecated. Use +# 'migrate-set-parameters' instead. +# # The size will be rounded down to the nearest power of 2. # The cache size can be modified before and during ongoing migration # # Returns: nothing on success # -# Notes: This command is deprecated in favor of 'migrate-set-parameters' -# # Since: 1.2 # # Example: @@ -1254,17 +1262,20 @@ # <- { "return": {} } # ## -{ 'command': 'migrate-set-cache-size', 'data': {'value': 'int'} } +{ 'command': 'migrate-set-cache-size', 'data': {'value': 'int'}, + 'features': [ 'deprecated' ] } =20 ## # @query-migrate-cache-size: # # Query migration XBZRLE cache size # +# Features: +# @deprecated: This command is deprecated. Use +# 'query-migrate-parameters' instead. +# # Returns: XBZRLE cache size in bytes # -# Notes: This command is deprecated in favor of 'query-migrate-parameters' -# # Since: 1.2 # # Example: @@ -1273,7 +1284,8 @@ # <- { "return": 67108864 } # ## -{ 'command': 'query-migrate-cache-size', 'returns': 'int' } +{ 'command': 'query-migrate-cache-size', 'returns': 'int', + 'features': [ 'deprecated' ] } =20 ## # @migrate: diff --git a/qapi/misc.json b/qapi/misc.json index c18fe681fb..99b90ac80b 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -872,14 +872,14 @@ # If @device is 'vnc' and @target is 'password', this is the new VNC # password to set. See change-vnc-password for additional notes. # +# Features: +# @deprecated: This command is deprecated. For changing block +# devices, use 'blockdev-change-medium' instead; for changing VNC +# parameters, use 'change-vnc-password' instead. +# # Returns: - Nothing on success. # - If @device is not a valid block device, DeviceNotFound # -# Notes: This interface is deprecated, and it is strongly recommended that= you -# avoid using it. For changing block devices, use -# blockdev-change-medium; for changing VNC parameters, use -# change-vnc-password. -# # Since: 0.14.0 # # Example: @@ -900,7 +900,8 @@ # ## { 'command': 'change', - 'data': {'device': 'str', 'target': 'str', '*arg': 'str'} } + 'data': {'device': 'str', 'target': 'str', '*arg': 'str'}, + 'features': [ 'deprecated' ] } =20 ## # @xen-set-global-dirty-log: --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253376; cv=none; d=zohomail.com; s=zohoarc; b=ZD5sc1s2AHZD4/ANfGWm+eG+GwQfEge7DPRNNSuOEYPe+kPGXN9MhK96hw2giHG+pw4cPyCu/C0HLsfixZ9nqKQb6w7A6j+ujqpLBXYfgDIqv2Lwime1FkXhTeMmXKqwa5NHP6bKLx5vhMB+SG5vjZ0vKwYDgXsMQgVSXkznKk0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253376; h=Content-Type: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; bh=Jlo30X4GLrqRRWhmO6ugS7pBjmrmoB9UDccQD7F+uNk=; b=j7bhxmt0igO0xFrdPseCmLn4RIN5ORk3Q7SPObuEb1C2aE0y6nEwwymPTshxX1HDdr6qKEuxl6QbST0+o7nXlkTxhXNp7VPL4wYZEQxHZIP7X5ZRchx7bXpSAZqmZHyR6ftBrToOq7KUmy5qGAOixK9esNJizxqiN9HFXXxfgfg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1583253376844195.00923211885038; Tue, 3 Mar 2020 08:36:16 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-303-C3SSj9eGO8KIsMz4kCdcUw-1; Tue, 03 Mar 2020 11:36:13 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EA862100DFD1; Tue, 3 Mar 2020 16:36:02 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A9A925DA75; Tue, 3 Mar 2020 16:36:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 42DBD18034EE; Tue, 3 Mar 2020 16:36:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZG4s001310 for ; Tue, 3 Mar 2020 11:35:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id 078535DA82; Tue, 3 Mar 2020 16:35:16 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A3D7B5DA2C; Tue, 3 Mar 2020 16:35:15 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 16126113278C; Tue, 3 Mar 2020 17:35:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253375; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Jlo30X4GLrqRRWhmO6ugS7pBjmrmoB9UDccQD7F+uNk=; b=fK/r8qIaJ6a/d7eU5pvtGAbEw7JKcZxHIcOjIz51wbWwm2NaqCc8d7e5xdOuTkvUNVTXC3 KWYlvBMk+I9cG12u6BEr5FE3fGkDQSP8Um0nGshfFGXp3SvjdlsNeEVvXk87OlG01/kg8W qwmEvsRMznTt/mhyG8XOfpBtH2qAQH4= X-MC-Unique: C3SSj9eGO8KIsMz4kCdcUw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 27/30] qemu-options: New -compat to set policy for deprecated interfaces Date: Tue, 3 Mar 2020 17:35:02 +0100 Message-Id: <20200303163505.32041-28-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Policy is separate for input and output. Input policy can be "accept" (accept silently), or "reject" (reject the request with an error). Output policy can be "accept" (pass on unchanged), or "hide" (filter out the deprecated parts). Default is "accept". Policies other than "accept" are implemented later in this series. For now, -compat covers only syntactic aspects of QMP, i.e. stuff tagged with feature 'deprecated'. We may want to extend it to cover semantic aspects, CLI, and experimental features. The option is experimental. Signed-off-by: Markus Armbruster --- qapi/compat.json | 51 ++++++++++++++++++++++++++++++++++++ qapi/qapi-schema.json | 1 + include/qapi/compat-policy.h | 20 ++++++++++++++ qapi/qmp-dispatch.c | 3 +++ softmmu/vl.c | 17 ++++++++++++ qapi/Makefile.objs | 8 +++--- qemu-options.hx | 21 +++++++++++++++ 7 files changed, 117 insertions(+), 4 deletions(-) create mode 100644 qapi/compat.json create mode 100644 include/qapi/compat-policy.h diff --git a/qapi/compat.json b/qapi/compat.json new file mode 100644 index 0000000000..fd6f8e932c --- /dev/null +++ b/qapi/compat.json @@ -0,0 +1,51 @@ +# -*- Mode: Python -*- + +## +# =3D Compatibility policy +## + +## +# @CompatPolicyInput: +# +# Policy for handling "funny" input. +# +# @accept: Accept silently +# @reject: Reject with an error +# +# Since: 5.0 +## +{ 'enum': 'CompatPolicyInput', + 'data': [ 'accept', 'reject' ] } + +## +# @CompatPolicyOutput: +# +# Policy for handling "funny" output. +# +# @accept: Pass on unchanged +# @hide: Filter out +# +# Since: 5.0 +## +{ 'enum': 'CompatPolicyOutput', + 'data': [ 'accept', 'hide' ] } + +## +# @CompatPolicy: +# +# Policy for handling deprecated management interfaces. +# +# This is intended for testing users of the management interfaces. +# +# Limitation: covers only syntactic aspects of QMP, i.e. stuff tagged +# with feature 'deprecated'. We may want to extend it to cover +# semantic aspects, CLI, and experimental features. +# +# @deprecated-input: how to handle deprecated input (default 'accept') +# @deprecated-output: how to handle deprecated output (default 'accept') +# +# Since: 5.0 +## +{ 'struct': 'CompatPolicy', + 'data': { '*deprecated-input': 'CompatPolicyInput', + '*deprecated-output': 'CompatPolicyOutput' } } diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json index fe980ce437..fa800042e0 100644 --- a/qapi/qapi-schema.json +++ b/qapi/qapi-schema.json @@ -98,6 +98,7 @@ { 'include': 'migration.json' } { 'include': 'transaction.json' } { 'include': 'trace.json' } +{ 'include': 'compat.json' } { 'include': 'control.json' } { 'include': 'introspect.json' } { 'include': 'qom.json' } diff --git a/include/qapi/compat-policy.h b/include/qapi/compat-policy.h new file mode 100644 index 0000000000..8efb2c58aa --- /dev/null +++ b/include/qapi/compat-policy.h @@ -0,0 +1,20 @@ +/* + * Policy for handling "funny" management interfaces + * + * Copyright (C) 2019 Red Hat, Inc. + * + * Authors: + * Markus Armbruster , + * + * This work is licensed under the terms of the GNU GPL, version 2 or + * later. See the COPYING file in the top-level directory. + */ + +#ifndef QAPI_COMPAT_POLICY_H +#define QAPI_COMPAT_POLICY_H + +#include "qapi/qapi-types-compat.h" + +extern CompatPolicy compat_policy; + +#endif diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index fb53687ce9..80beab517f 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -12,6 +12,7 @@ */ =20 #include "qemu/osdep.h" +#include "qapi/compat-policy.h" #include "qapi/error.h" #include "qapi/qmp/dispatch.h" #include "qapi/qmp/qdict.h" @@ -19,6 +20,8 @@ #include "sysemu/runstate.h" #include "qapi/qmp/qbool.h" =20 +CompatPolicy compat_policy; + static QDict *qmp_dispatch_check_obj(const QObject *request, bool allow_oo= b, QObject **id, Error **errp) { diff --git a/softmmu/vl.c b/softmmu/vl.c index 5549f4b619..0d6b769587 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -26,6 +26,7 @@ #include "qemu-common.h" #include "qemu/units.h" #include "hw/qdev-properties.h" +#include "qapi/compat-policy.h" #include "qapi/error.h" #include "qemu-version.h" #include "qemu/cutils.h" @@ -104,6 +105,7 @@ #include "sysemu/replay.h" #include "qapi/qapi-events-run-state.h" #include "qapi/qapi-visit-block-core.h" +#include "qapi/qapi-visit-compat.h" #include "qapi/qapi-visit-ui.h" #include "qapi/qapi-commands-block-core.h" #include "qapi/qapi-commands-run-state.h" @@ -3748,6 +3750,21 @@ void qemu_init(int argc, char **argv, char **envp) qemu_opt_get_bool(opts, "mem-lock", false); enable_cpu_pm =3D qemu_opt_get_bool(opts, "cpu-pm", false); break; + case QEMU_OPTION_compat: + { + CompatPolicy *opts; + Visitor *v; + + v =3D qobject_input_visitor_new_str(optarg, NULL, + &error_fatal); + + visit_type_CompatPolicy(v, NULL, &opts, &error_fatal); + QAPI_CLONE_MEMBERS(CompatPolicy, &compat_policy, opts); + + qapi_free_CompatPolicy(opts); + visit_free(v); + break; + } case QEMU_OPTION_msg: opts =3D qemu_opts_parse_noisily(qemu_find_opts("msg"), op= targ, false); diff --git a/qapi/Makefile.objs b/qapi/Makefile.objs index 20fcc37c2c..6c71e5c701 100644 --- a/qapi/Makefile.objs +++ b/qapi/Makefile.objs @@ -5,10 +5,10 @@ util-obj-y +=3D opts-visitor.o qapi-clone-visitor.o util-obj-y +=3D qmp-event.o util-obj-y +=3D qapi-util.o =20 -QAPI_COMMON_MODULES =3D audio authz block-core block char common control c= rypto -QAPI_COMMON_MODULES +=3D dump error introspect job machine migration misc -QAPI_COMMON_MODULES +=3D net qdev qom rdma rocker run-state sockets tpm -QAPI_COMMON_MODULES +=3D trace transaction ui +QAPI_COMMON_MODULES =3D audio authz block-core block char common compat +QAPI_COMMON_MODULES +=3D control crypto dump error introspect job +QAPI_COMMON_MODULES +=3D machine migration misc net qdev qom rdma rocker +QAPI_COMMON_MODULES +=3D run-state sockets tpm trace transaction ui QAPI_TARGET_MODULES =3D machine-target misc-target QAPI_MODULES =3D $(QAPI_COMMON_MODULES) $(QAPI_TARGET_MODULES) =20 diff --git a/qemu-options.hx b/qemu-options.hx index 084a1c1f8c..d02d6bfc15 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3360,6 +3360,27 @@ STEXI @table @option ETEXI =20 +DEF("compat", HAS_ARG, QEMU_OPTION_compat, + "-compat [deprecated-input=3Daccept|reject][,deprecated-output=3Daccep= t|hide]\n" + " Policy for handling deprecated management interfaces\= n", + QEMU_ARCH_ALL) +STEXI +@item -compat [deprecated-input=3D@var{input-policy}][,deprecated-output= =3D@var{output-policy}] +@findex -compat +Set policy for handling deprecated management interfaces (experimental): +@table @option +@item deprecated-input=3Daccept (default) +Accept deprecated commands and arguments +@item deprecated-input=3Dreject +Reject deprecated commands and arguments +@item deprecated-output=3Daccept (default) +Emit deprecated command results and events +@item deprecated-output=3Dhide +Suppress deprecated command results and events +@end table +Limitation: covers only syntactic aspects of QMP. +ETEXI + DEF("fw_cfg", HAS_ARG, QEMU_OPTION_fwcfg, "-fw_cfg [name=3D],file=3D\n" " add named fw_cfg entry with contents from file\n" --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253441; cv=none; d=zohomail.com; s=zohoarc; b=jToH4A/rP5bSFoHZ5g4h9mKTbbA7rK8aSJjH94ugaU2mm9C3JbuJsUBkeelbfBp1y4eV+HICeS8mSGJpAPllPgYRn/I7rLh0ix+AKD6C53jAXQf3WIdZfCdY08lC4M8paNtn4AXd2sDZmtecwDRit3fhqOu1c3cGOv+f/JjVvLg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253441; h=Content-Type: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; bh=CE78sBukVjs/JoYhvN2C+YYIGXwK1DHp6rZgYjw2Qjg=; b=J82I8P5Oa/wnrOlK/c6zQE3S5AAUXELe7JX1dcQkbM4RdrpxkG7N5pzSP/k3SOnoAzxZtcfaeUXNmT7U607SbA24mPVnJPkpmzAieiAEzqYakItKijwMMtKilNy2Be4Ao7hqKC8Y/vN7Q4tPzL+MSfVxcbm+jxVe+gSU5Qg2xug= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1583253441941783.5667670101636; Tue, 3 Mar 2020 08:37:21 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-332-kOJ5gpGkO4utCDNCSctzDQ-1; Tue, 03 Mar 2020 11:36:25 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 800431005510; Tue, 3 Mar 2020 16:36:18 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4255D60BF3; Tue, 3 Mar 2020 16:36:18 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D191D86A26; Tue, 3 Mar 2020 16:36:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZISv001364 for ; Tue, 3 Mar 2020 11:35:18 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2A4D819C4F; Tue, 3 Mar 2020 16:35:18 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AA741272A9; Tue, 3 Mar 2020 16:35:15 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 198CB113274C; Tue, 3 Mar 2020 17:35:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253440; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=CE78sBukVjs/JoYhvN2C+YYIGXwK1DHp6rZgYjw2Qjg=; b=Sk/BE9pAcuDO3diVA13agKVURNHRctbl3He3cqo5qDW4bRt9AIoj7kE9NYAJ/IMRBmVMwG 9AjwIrfYR963odY5TCu/jVR+rsrH4ekCo2bBbvKDiB23sicBbJCczEbTYo55Uo7wSzkOQc NJqnYhVsR0CIj8QcJij4zCnndiSHl9U= X-MC-Unique: kOJ5gpGkO4utCDNCSctzDQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 28/30] qapi: Implement -compat deprecated-output=hide Date: Tue, 3 Mar 2020 17:35:03 +0100 Message-Id: <20200303163505.32041-29-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This policy suppresses deprecated command results and deprecated events, and thus permits "testing the future". Example: ---> {"execute": "query-cpus-fast"} <--- {"return": [{"thread-id": 9805, "props": {"core-id": 0, "thread-id= ": 0, "socket-id": 0}, "qom-path": "/machine/unattached/device[0]", "cpu-in= dex": 0, "target": "x86_64"}]} Note the absence of deprecated member "arch". No QMP event is deprecated right now. Signed-off-by: Markus Armbruster --- include/qapi/qobject-output-visitor.h | 9 ++++++ include/qapi/visitor-impl.h | 3 ++ include/qapi/visitor.h | 9 ++++++ qapi/qapi-visit-core.c | 9 ++++++ qapi/qobject-output-visitor.c | 19 +++++++++++ tests/test-qmp-cmds.c | 42 ++++++++++++++++++++++--- tests/test-qmp-event.c | 19 +++++++++++ qapi/trace-events | 1 + scripts/qapi/commands.py | 2 +- scripts/qapi/events.py | 14 +++++++-- scripts/qapi/visit.py | 12 +++++++ tests/qapi-schema/qapi-schema-test.json | 17 +++++----- tests/qapi-schema/qapi-schema-test.out | 18 +++++------ 13 files changed, 149 insertions(+), 25 deletions(-) diff --git a/include/qapi/qobject-output-visitor.h b/include/qapi/qobject-o= utput-visitor.h index 2b1726baf5..29f4ea6aad 100644 --- a/include/qapi/qobject-output-visitor.h +++ b/include/qapi/qobject-output-visitor.h @@ -53,4 +53,13 @@ typedef struct QObjectOutputVisitor QObjectOutputVisitor; */ Visitor *qobject_output_visitor_new(QObject **result); =20 +/* + * Create a QObject output visitor for @obj for use with QMP + * + * This is like qobject_output_visitor_new(), except it obeys the + * policy for handling deprecated management interfaces set with + * -compat. + */ +Visitor *qobject_output_visitor_new_qmp(QObject **result); + #endif diff --git a/include/qapi/visitor-impl.h b/include/qapi/visitor-impl.h index 8ccb3b6c20..a6b26b7a5b 100644 --- a/include/qapi/visitor-impl.h +++ b/include/qapi/visitor-impl.h @@ -110,6 +110,9 @@ struct Visitor The core takes care of the return type in the public interface. */ void (*optional)(Visitor *v, const char *name, bool *present); =20 + /* Optional */ + bool (*deprecated)(Visitor *v, const char *name); + /* Must be set */ VisitorType type; =20 diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index c5b23851a1..c89d51b2a4 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -449,6 +449,15 @@ void visit_end_alternate(Visitor *v, void **obj); */ bool visit_optional(Visitor *v, const char *name, bool *present); =20 +/* + * Should we visit deprecated member @name? + * + * @name must not be NULL. This function is only useful between + * visit_start_struct() and visit_end_struct(), since only objects + * have deprecated members. + */ +bool visit_deprecated(Visitor *v, const char *name); + /* * Visit an enum value. * diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c index 5365561b07..501b3ccdef 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qapi-visit-core.c @@ -137,6 +137,15 @@ bool visit_optional(Visitor *v, const char *name, bool= *present) return *present; } =20 +bool visit_deprecated(Visitor *v, const char *name) +{ + trace_visit_deprecated(v, name); + if (v->deprecated) { + return v->deprecated(v, name); + } + return true; +} + bool visit_is_input(Visitor *v) { return v->type =3D=3D VISITOR_INPUT; diff --git a/qapi/qobject-output-visitor.c b/qapi/qobject-output-visitor.c index 26d7be5ec9..84cee17596 100644 --- a/qapi/qobject-output-visitor.c +++ b/qapi/qobject-output-visitor.c @@ -13,6 +13,7 @@ */ =20 #include "qemu/osdep.h" +#include "qapi/compat-policy.h" #include "qapi/qobject-output-visitor.h" #include "qapi/visitor-impl.h" #include "qemu/queue.h" @@ -31,6 +32,8 @@ typedef struct QStackEntry { =20 struct QObjectOutputVisitor { Visitor visitor; + CompatPolicyOutput deprecated_policy; + QSLIST_HEAD(, QStackEntry) stack; /* Stack of unfinished containers */ QObject *root; /* Root of the output visit */ QObject **result; /* User's storage location for result */ @@ -198,6 +201,13 @@ static void qobject_output_type_null(Visitor *v, const= char *name, qobject_output_add(qov, name, qnull()); } =20 +static bool qobject_output_deprecated(Visitor *v, const char *name) +{ + QObjectOutputVisitor *qov =3D to_qov(v); + + return qov->deprecated_policy !=3D COMPAT_POLICY_OUTPUT_HIDE; +} + /* Finish building, and return the root object. * The root object is never null. The caller becomes the object's * owner, and should use qobject_unref() when done with it. */ @@ -247,6 +257,7 @@ Visitor *qobject_output_visitor_new(QObject **result) v->visitor.type_number =3D qobject_output_type_number; v->visitor.type_any =3D qobject_output_type_any; v->visitor.type_null =3D qobject_output_type_null; + v->visitor.deprecated =3D qobject_output_deprecated; v->visitor.complete =3D qobject_output_complete; v->visitor.free =3D qobject_output_free; =20 @@ -255,3 +266,11 @@ Visitor *qobject_output_visitor_new(QObject **result) =20 return &v->visitor; } + +Visitor *qobject_output_visitor_new_qmp(QObject **result) +{ + QObjectOutputVisitor *v =3D to_qov(qobject_output_visitor_new(result)); + + v->deprecated_policy =3D compat_policy.deprecated_output; + return &v->visitor; +} diff --git a/tests/test-qmp-cmds.c b/tests/test-qmp-cmds.c index d12ff47e26..82d599630c 100644 --- a/tests/test-qmp-cmds.c +++ b/tests/test-qmp-cmds.c @@ -1,4 +1,5 @@ #include "qemu/osdep.h" +#include "qapi/compat-policy.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qjson.h" #include "qapi/qmp/qnum.h" @@ -45,12 +46,17 @@ void qmp_user_def_cmd1(UserDefOne * ud1, Error **errp) { } =20 -void qmp_test_features0(FeatureStruct0 *fs0, FeatureStruct1 *fs1, - FeatureStruct2 *fs2, FeatureStruct3 *fs3, - FeatureStruct4 *fs4, CondFeatureStruct1 *cfs1, - CondFeatureStruct2 *cfs2, CondFeatureStruct3 *cfs3, - Error **errp) +FeatureStruct1 *qmp_test_features0(bool has_fs0, FeatureStruct0 *fs0, + bool has_fs1, FeatureStruct1 *fs1, + bool has_fs2, FeatureStruct2 *fs2, + bool has_fs3, FeatureStruct3 *fs3, + bool has_fs4, FeatureStruct4 *fs4, + bool has_cfs1, CondFeatureStruct1 *cfs1, + bool has_cfs2, CondFeatureStruct2 *cfs2, + bool has_cfs3, CondFeatureStruct3 *cfs3, + Error **errp) { + return g_new(FeatureStruct1, 1); } =20 void qmp_test_command_features1(Error **errp) @@ -271,6 +277,30 @@ static void test_dispatch_cmd_io(void) qobject_unref(ret3); } =20 +static void test_dispatch_cmd_ret_deprecated(void) +{ + const char *cmd =3D "{ 'execute': 'test-features0' }"; + QDict *ret; + + memset(&compat_policy, 0, sizeof(compat_policy)); + + /* default accept */ + ret =3D qobject_to(QDict, do_qmp_dispatch(false, cmd)); + assert(ret && qdict_size(ret) =3D=3D 1); + qobject_unref(ret); + + compat_policy.has_deprecated_output =3D true; + compat_policy.deprecated_output =3D COMPAT_POLICY_OUTPUT_ACCEPT; + ret =3D qobject_to(QDict, do_qmp_dispatch(false, cmd)); + assert(ret && qdict_size(ret) =3D=3D 1); + qobject_unref(ret); + + compat_policy.deprecated_output =3D COMPAT_POLICY_OUTPUT_HIDE; + ret =3D qobject_to(QDict, do_qmp_dispatch(false, cmd)); + assert(ret && qdict_size(ret) =3D=3D 0); + qobject_unref(ret); +} + /* test generated dealloc functions for generated types */ static void test_dealloc_types(void) { @@ -345,6 +375,8 @@ int main(int argc, char **argv) g_test_add_func("/qmp/dispatch_cmd_io", test_dispatch_cmd_io); g_test_add_func("/qmp/dispatch_cmd_success_response", test_dispatch_cmd_success_response); + g_test_add_func("/qmp/dispatch_cmd_ret_deprecated", + test_dispatch_cmd_ret_deprecated); g_test_add_func("/qmp/dealloc_types", test_dealloc_types); g_test_add_func("/qmp/dealloc_partial", test_dealloc_partial); =20 diff --git a/tests/test-qmp-event.c b/tests/test-qmp-event.c index 7dd0053190..ae4913ceb3 100644 --- a/tests/test-qmp-event.c +++ b/tests/test-qmp-event.c @@ -14,6 +14,7 @@ #include "qemu/osdep.h" =20 #include "qemu-common.h" +#include "qapi/compat-policy.h" #include "qapi/error.h" #include "qapi/qmp/qbool.h" #include "qapi/qmp/qdict.h" @@ -140,6 +141,23 @@ static void test_event_d(TestEventData *data, qobject_unref(data->expect); } =20 +static void test_event_deprecated(TestEventData *data, const void *unused) +{ + data->expect =3D qdict_from_jsonf_nofail("{ 'event': 'TEST-EVENT-FEATU= RES1' }"); + + memset(&compat_policy, 0, sizeof(compat_policy)); + + qapi_event_send_test_event_features1(); + g_assert(data->emitted); + + compat_policy.deprecated_output =3D COMPAT_POLICY_OUTPUT_HIDE; + data->emitted =3D false; + qapi_event_send_test_event_features1(); + g_assert(!data->emitted); + + qobject_unref(data->expect); +} + int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); @@ -148,6 +166,7 @@ int main(int argc, char **argv) event_test_add("/event/event_b", test_event_b); event_test_add("/event/event_c", test_event_c); event_test_add("/event/event_d", test_event_d); + event_test_add("/event/deprecated", test_event_deprecated); g_test_run(); =20 return 0; diff --git a/qapi/trace-events b/qapi/trace-events index 5eb4afa110..eff1fbd199 100644 --- a/qapi/trace-events +++ b/qapi/trace-events @@ -17,6 +17,7 @@ visit_start_alternate(void *v, const char *name, void *ob= j, size_t size) "v=3D%p n visit_end_alternate(void *v, void *obj) "v=3D%p obj=3D%p" =20 visit_optional(void *v, const char *name, bool *present) "v=3D%p name=3D%s= present=3D%p" +visit_deprecated(void *v, const char *name) "v=3D%p name=3D%s" =20 visit_type_enum(void *v, const char *name, int *obj) "v=3D%p name=3D%s obj= =3D%p" visit_type_int(void *v, const char *name, int64_t *obj) "v=3D%p name=3D%s = obj=3D%p" diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index bc30876c88..35b79c554d 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -69,7 +69,7 @@ static void qmp_marshal_output_%(c_name)s(%(c_type)s ret_= in, QObject **ret_out, Error *err =3D NULL; Visitor *v; =20 - v =3D qobject_output_visitor_new(ret_out); + v =3D qobject_output_visitor_new_qmp(ret_out); visit_type_%(c_name)s(v, "unused", &ret_in, &err); if (!err) { visit_complete(v, ret_out); diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py index b544af5a1c..95ca4b4753 100644 --- a/scripts/qapi/events.py +++ b/scripts/qapi/events.py @@ -61,7 +61,8 @@ def gen_param_var(typ): return ret =20 =20 -def gen_event_send(name, arg_type, boxed, event_enum_name, event_emit): +def gen_event_send(name, arg_type, features, boxed, + event_enum_name, event_emit): # FIXME: Our declaration of local variables (and of 'errp' in the # parameter list) can collide with exploded members of the event's # data type passed in as parameters. If this collision ever hits in @@ -86,6 +87,14 @@ def gen_event_send(name, arg_type, boxed, event_enum_nam= e, event_emit): if not boxed: ret +=3D gen_param_var(arg_type) =20 + if 'deprecated' in [f.name for f in features]: + ret +=3D mcgen(''' + + if (compat_policy.deprecated_output =3D=3D COMPAT_POLICY_OUTPUT_HIDE) { + return; + } +''') + ret +=3D mcgen(''' =20 qmp =3D qmp_event_build_dict("%(name)s"); @@ -154,6 +163,7 @@ class QAPISchemaGenEventVisitor(QAPISchemaModularCVisit= or): #include "%(prefix)sqapi-emit-events.h" #include "%(events)s.h" #include "%(visit)s.h" +#include "qapi/compat-policy.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" #include "qapi/qobject-output-visitor.h" @@ -192,7 +202,7 @@ void %(event_emit)s(%(event_enum)s event, QDict *qdict); def visit_event(self, name, info, ifcond, features, arg_type, boxed): with ifcontext(ifcond, self._genh, self._genc): self._genh.add(gen_event_send_decl(name, arg_type, boxed)) - self._genc.add(gen_event_send(name, arg_type, boxed, + self._genc.add(gen_event_send(name, arg_type, features, boxed, self._event_enum_name, self._event_emit_name)) # Note: we generate the enum member regardless of @ifcond, to diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index 23d9194aa4..21df3abed2 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -56,6 +56,7 @@ void visit_type_%(c_name)s_members(Visitor *v, %(c_name)s= *obj, Error **errp) c_type=3Dbase.c_name()) =20 for memb in members: + deprecated =3D 'deprecated' in [f.name for f in memb.features] ret +=3D gen_if(memb.ifcond) if memb.optional: ret +=3D mcgen(''' @@ -63,6 +64,12 @@ void visit_type_%(c_name)s_members(Visitor *v, %(c_name)= s *obj, Error **errp) ''', name=3Dmemb.name, c_name=3Dc_name(memb.name)) push_indent() + if deprecated: + ret +=3D mcgen(''' + if (visit_deprecated(v, "%(name)s")) { +''', + name=3Dmemb.name) + push_indent() ret +=3D mcgen(''' visit_type_%(c_type)s(v, "%(name)s", &obj->%(c_name)s, &err); if (err) { @@ -71,6 +78,11 @@ void visit_type_%(c_name)s_members(Visitor *v, %(c_name)= s *obj, Error **errp) ''', c_type=3Dmemb.type.c_name(), name=3Dmemb.name, c_name=3Dc_name(memb.name)) + if deprecated: + pop_indent() + ret +=3D mcgen(''' + } +''') if memb.optional: pop_indent() ret +=3D mcgen(''' diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index 6b1f05afa7..e4cce0d5b0 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -297,14 +297,15 @@ 'features': [ 'feature1' ] } =20 { 'command': 'test-features0', - 'data': { 'fs0': 'FeatureStruct0', - 'fs1': 'FeatureStruct1', - 'fs2': 'FeatureStruct2', - 'fs3': 'FeatureStruct3', - 'fs4': 'FeatureStruct4', - 'cfs1': 'CondFeatureStruct1', - 'cfs2': 'CondFeatureStruct2', - 'cfs3': 'CondFeatureStruct3' }, + 'data': { '*fs0': 'FeatureStruct0', + '*fs1': 'FeatureStruct1', + '*fs2': 'FeatureStruct2', + '*fs3': 'FeatureStruct3', + '*fs4': 'FeatureStruct4', + '*cfs1': 'CondFeatureStruct1', + '*cfs2': 'CondFeatureStruct2', + '*cfs3': 'CondFeatureStruct3' }, + 'returns': 'FeatureStruct1', 'features': [] } =20 { 'command': 'test-command-features1', diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 891b4101e0..cd53323abd 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -407,15 +407,15 @@ alternate FeatureAlternate1 case eins: FeatureStruct1 feature feature1 object q_obj_test-features0-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-features0 q_obj_test-features0-arg -> None + member fs0: FeatureStruct0 optional=3DTrue + member fs1: FeatureStruct1 optional=3DTrue + member fs2: FeatureStruct2 optional=3DTrue + member fs3: FeatureStruct3 optional=3DTrue + member fs4: FeatureStruct4 optional=3DTrue + member cfs1: CondFeatureStruct1 optional=3DTrue + member cfs2: CondFeatureStruct2 optional=3DTrue + member cfs3: CondFeatureStruct3 optional=3DTrue +command test-features0 q_obj_test-features0-arg -> FeatureStruct1 gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse command test-command-features1 None -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253377; cv=none; d=zohomail.com; s=zohoarc; b=afG2ZXvtPuUzH/uVDrIezFjsyBOI5Z4yyVTwH1oWzwDRoZVer9ju2Lri2kmy3yhZBnbBw7sQG3xXw2LO7nXPI1oYL/r2+jF91WrnMx41riHiH5x/wxDA0UC3Ftxs8tzI+oFVAplOLkGY88YcVvahK9i3EOQcZZREoMg/vku5WAc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253377; h=Content-Type: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; bh=namzcJL7H+P9R7eVK9JjD1sr8RCU31GMrX+vUBSmwYI=; b=ZiZbXbOHrLmbiFUwAPlL6H1tCAmlUL0hZafYOGhG0Gh2cOnAa2GfGWLXk4a55xYUmzBS+ERjRHlo19UHknU80Tdw9Gs9985OjRfhvyxVV1xE3AEw86Y7+Fidij6AGxeaG1cxppJBYzyhH4yRrx2n6TwlKpXLxJwdxcHdYo+QeEA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1583253377590787.777951572801; Tue, 3 Mar 2020 08:36:17 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-368-jfc5aagEPqOXYU1rp2WwKA-1; Tue, 03 Mar 2020 11:36:13 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7B99F8017CC; Tue, 3 Mar 2020 16:36:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4B60110013A1; Tue, 3 Mar 2020 16:36:07 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id EDBD018034FA; Tue, 3 Mar 2020 16:36:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZGNC001315 for ; Tue, 3 Mar 2020 11:35:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3BDCD7387C; Tue, 3 Mar 2020 16:35:16 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B11D373876; Tue, 3 Mar 2020 16:35:15 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1CE6211326E1; Tue, 3 Mar 2020 17:35:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253376; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=namzcJL7H+P9R7eVK9JjD1sr8RCU31GMrX+vUBSmwYI=; b=cCp9y3dn/ZT4FHHJTW7sczio4bJwwputQcokOp2q4ozL911vvQYgUn8/gSj6RjSylIUu45 bJCvS2C6n53KyzpdVvj1OxS3tX7qpiB+IQlmF0mgDZEY5sgO1jLug01rZcJZFQHmIEJluz qK+yGNfYAMr+X1BJUOwSnv3lI+RMEUM= X-MC-Unique: jfc5aagEPqOXYU1rp2WwKA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 29/30] qapi: Implement -compat deprecated-input=reject Date: Tue, 3 Mar 2020 17:35:04 +0100 Message-Id: <20200303163505.32041-30-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This policy makes deprecated commands fail like this: ---> {"execute": "query-cpus"} <--- {"error": {"class": "CommandNotFound", "desc": "Deprecated command= query-cpus disabled by policy"}} When the command is removed, the error will change to <--- {"error": {"class": "CommandNotFound", "desc": "The command query-= cpus has not been found"}} It makes commands with deprecated arguments fail like this: ---> {"execute": "block-commit", "arguments": {"device": "virtio0", "to= p": "/tmp/snap1.qcow2"}} <--- {"error": {"class": "GenericError", "desc": "Deprecated parameter = 'top' disabled by policy"}} When the argument is removed, the error will change to <--- {"error": {"class": "GenericError", "desc": "Parameter 'top' is un= expected"}} The policy thus permits "testing the future". Signed-off-by: Markus Armbruster --- include/qapi/qmp/dispatch.h | 1 + include/qapi/qobject-input-visitor.h | 9 +++++ include/qapi/visitor-impl.h | 2 +- include/qapi/visitor.h | 2 +- qapi/qapi-visit-core.c | 4 +-- qapi/qmp-dispatch.c | 13 ++++++++ qapi/qobject-input-visitor.c | 28 ++++++++++++++++ qapi/qobject-output-visitor.c | 3 +- tests/test-qmp-cmds.c | 49 ++++++++++++++++++++++++++++ scripts/qapi/commands.py | 12 ++++--- scripts/qapi/visit.py | 10 +++--- 11 files changed, 120 insertions(+), 13 deletions(-) diff --git a/include/qapi/qmp/dispatch.h b/include/qapi/qmp/dispatch.h index 9aa426a398..ef256f2bb7 100644 --- a/include/qapi/qmp/dispatch.h +++ b/include/qapi/qmp/dispatch.h @@ -24,6 +24,7 @@ typedef enum QmpCommandOptions QCO_NO_SUCCESS_RESP =3D (1U << 0), QCO_ALLOW_OOB =3D (1U << 1), QCO_ALLOW_PRECONFIG =3D (1U << 2), + QCO_DEPRECATED =3D (1U << 3), } QmpCommandOptions; =20 typedef struct QmpCommand diff --git a/include/qapi/qobject-input-visitor.h b/include/qapi/qobject-in= put-visitor.h index 95985e25e5..cbc54de4ac 100644 --- a/include/qapi/qobject-input-visitor.h +++ b/include/qapi/qobject-input-visitor.h @@ -58,6 +58,15 @@ typedef struct QObjectInputVisitor QObjectInputVisitor; */ Visitor *qobject_input_visitor_new(QObject *obj); =20 +/* + * Create a QObject input visitor for @obj for use with QMP + * + * This is like qobject_input_visitor_new(), except it obeys the + * policy for handling deprecated management interfaces set with + * -compat. + */ +Visitor *qobject_input_visitor_new_qmp(QObject *obj); + /* * Create a QObject input visitor for @obj for use with keyval_parse() * diff --git a/include/qapi/visitor-impl.h b/include/qapi/visitor-impl.h index a6b26b7a5b..ccc159a0d2 100644 --- a/include/qapi/visitor-impl.h +++ b/include/qapi/visitor-impl.h @@ -111,7 +111,7 @@ struct Visitor void (*optional)(Visitor *v, const char *name, bool *present); =20 /* Optional */ - bool (*deprecated)(Visitor *v, const char *name); + bool (*deprecated)(Visitor *v, const char *name, Error **errp); =20 /* Must be set */ VisitorType type; diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index c89d51b2a4..2a3c4d0407 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -456,7 +456,7 @@ bool visit_optional(Visitor *v, const char *name, bool = *present); * visit_start_struct() and visit_end_struct(), since only objects * have deprecated members. */ -bool visit_deprecated(Visitor *v, const char *name); +bool visit_deprecated(Visitor *v, const char *name, Error **errp); =20 /* * Visit an enum value. diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c index 501b3ccdef..71e4978a6f 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qapi-visit-core.c @@ -137,11 +137,11 @@ bool visit_optional(Visitor *v, const char *name, boo= l *present) return *present; } =20 -bool visit_deprecated(Visitor *v, const char *name) +bool visit_deprecated(Visitor *v, const char *name, Error **errp) { trace_visit_deprecated(v, name); if (v->deprecated) { - return v->deprecated(v, name); + return v->deprecated(v, name, errp); } return true; } diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index 80beab517f..516ee9b0b7 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -132,6 +132,19 @@ QDict *qmp_dispatch(QmpCommandList *cmds, QObject *req= uest, "The command %s has not been found", command); goto out; } + if (cmd->options & QCO_DEPRECATED) { + switch (compat_policy.deprecated_input) { + case COMPAT_POLICY_INPUT_ACCEPT: + break; + case COMPAT_POLICY_INPUT_REJECT: + error_set(&err, ERROR_CLASS_COMMAND_NOT_FOUND, + "Deprecated command %s disabled by policy", + command); + goto out; + default: + abort(); + } + } if (!cmd->enabled) { error_set(&err, ERROR_CLASS_COMMAND_NOT_FOUND, "The command %s has been disabled for this instance", diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c index 32236cbcb1..6ea93f5a7a 100644 --- a/qapi/qobject-input-visitor.c +++ b/qapi/qobject-input-visitor.c @@ -14,6 +14,7 @@ =20 #include "qemu/osdep.h" #include +#include "qapi/compat-policy.h" #include "qapi/error.h" #include "qapi/qobject-input-visitor.h" #include "qapi/visitor-impl.h" @@ -43,6 +44,7 @@ typedef struct StackObject { =20 struct QObjectInputVisitor { Visitor visitor; + CompatPolicyInput deprecated_policy; =20 /* Root of visit at visitor creation. */ QObject *root; @@ -640,6 +642,23 @@ static void qobject_input_optional(Visitor *v, const c= har *name, bool *present) *present =3D true; } =20 +static bool qobject_input_deprecated(Visitor *v, const char *name, + Error **errp) +{ + QObjectInputVisitor *qiv =3D to_qiv(v); + + switch (qiv->deprecated_policy) { + case COMPAT_POLICY_INPUT_ACCEPT: + return true; + case COMPAT_POLICY_INPUT_REJECT: + error_setg(errp, "Deprecated parameter '%s' disabled by policy", + name); + return false; + default: + abort(); + } +} + static void qobject_input_free(Visitor *v) { QObjectInputVisitor *qiv =3D to_qiv(v); @@ -674,6 +693,7 @@ static QObjectInputVisitor *qobject_input_visitor_base_= new(QObject *obj) v->visitor.end_list =3D qobject_input_end_list; v->visitor.start_alternate =3D qobject_input_start_alternate; v->visitor.optional =3D qobject_input_optional; + v->visitor.deprecated =3D qobject_input_deprecated; v->visitor.free =3D qobject_input_free; =20 v->root =3D qobject_ref(obj); @@ -696,6 +716,14 @@ Visitor *qobject_input_visitor_new(QObject *obj) return &v->visitor; } =20 +Visitor *qobject_input_visitor_new_qmp(QObject *obj) +{ + QObjectInputVisitor *v =3D to_qiv(qobject_input_visitor_new(obj)); + + v->deprecated_policy =3D compat_policy.deprecated_input; + return &v->visitor; +} + Visitor *qobject_input_visitor_new_keyval(QObject *obj) { QObjectInputVisitor *v =3D qobject_input_visitor_base_new(obj); diff --git a/qapi/qobject-output-visitor.c b/qapi/qobject-output-visitor.c index 84cee17596..73983ca5cc 100644 --- a/qapi/qobject-output-visitor.c +++ b/qapi/qobject-output-visitor.c @@ -201,7 +201,8 @@ static void qobject_output_type_null(Visitor *v, const = char *name, qobject_output_add(qov, name, qnull()); } =20 -static bool qobject_output_deprecated(Visitor *v, const char *name) +static bool qobject_output_deprecated(Visitor *v, const char *name, + Error **errp) { QObjectOutputVisitor *qov =3D to_qov(v); =20 diff --git a/tests/test-qmp-cmds.c b/tests/test-qmp-cmds.c index 82d599630c..4ca658acf9 100644 --- a/tests/test-qmp-cmds.c +++ b/tests/test-qmp-cmds.c @@ -277,6 +277,51 @@ static void test_dispatch_cmd_io(void) qobject_unref(ret3); } =20 +static void test_dispatch_cmd_deprecated(void) +{ + const char *cmd =3D "{ 'execute': 'test-command-features1' }"; + QDict *ret; + + memset(&compat_policy, 0, sizeof(compat_policy)); + + /* accept */ + ret =3D qobject_to(QDict, do_qmp_dispatch(false, cmd)); + assert(ret && qdict_size(ret) =3D=3D 0); + qobject_unref(ret); + + compat_policy.has_deprecated_input =3D true; + compat_policy.deprecated_input =3D COMPAT_POLICY_INPUT_ACCEPT; + ret =3D qobject_to(QDict, do_qmp_dispatch(false, cmd)); + assert(ret && qdict_size(ret) =3D=3D 0); + qobject_unref(ret); + + compat_policy.deprecated_input =3D COMPAT_POLICY_INPUT_REJECT; + do_qmp_dispatch_error(false, ERROR_CLASS_COMMAND_NOT_FOUND, cmd); +} + +static void test_dispatch_cmd_arg_deprecated(void) +{ + const char *cmd =3D "{ 'execute': 'test-features0'," + " 'arguments': { 'fs1': { 'foo': 42 } } }"; + QDict *ret; + + memset(&compat_policy, 0, sizeof(compat_policy)); + + /* accept */ + ret =3D qobject_to(QDict, do_qmp_dispatch(false, cmd)); + assert(ret && qdict_size(ret) =3D=3D 1); + qobject_unref(ret); + + compat_policy.has_deprecated_input =3D true; + compat_policy.deprecated_input =3D COMPAT_POLICY_INPUT_ACCEPT; + ret =3D qobject_to(QDict, do_qmp_dispatch(false, cmd)); + assert(ret && qdict_size(ret) =3D=3D 1); + qobject_unref(ret); + + compat_policy.deprecated_input =3D COMPAT_POLICY_INPUT_REJECT; + do_qmp_dispatch_error(false, ERROR_CLASS_GENERIC_ERROR, cmd); +} + static void test_dispatch_cmd_ret_deprecated(void) { const char *cmd =3D "{ 'execute': 'test-features0' }"; @@ -375,6 +420,10 @@ int main(int argc, char **argv) g_test_add_func("/qmp/dispatch_cmd_io", test_dispatch_cmd_io); g_test_add_func("/qmp/dispatch_cmd_success_response", test_dispatch_cmd_success_response); + g_test_add_func("/qmp/dispatch_cmd_deprecated", + test_dispatch_cmd_deprecated); + g_test_add_func("/qmp/dispatch_cmd_arg_deprecated", + test_dispatch_cmd_arg_deprecated); g_test_add_func("/qmp/dispatch_cmd_ret_deprecated", test_dispatch_cmd_ret_deprecated); g_test_add_func("/qmp/dealloc_types", test_dealloc_types); diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index 35b79c554d..3fb4ed42ed 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -132,7 +132,7 @@ def gen_marshal(name, arg_type, boxed, ret_type): push_indent() =20 ret +=3D mcgen(''' - v =3D qobject_input_visitor_new(QOBJECT(args)); + v =3D qobject_input_visitor_new_qmp(QOBJECT(args)); visit_start_struct(v, NULL, NULL, 0, &err); if (err) { goto out; @@ -194,9 +194,13 @@ out: return ret =20 =20 -def gen_register_command(name, success_response, allow_oob, allow_preconfi= g): +def gen_register_command(name, features, + success_response, allow_oob, allow_preconfig): options =3D [] =20 + if 'deprecated' in [f.name for f in features]: + options +=3D ['QCO_DEPRECATED'] + if not success_response: options +=3D ['QCO_NO_SUCCESS_RESP'] if allow_oob: @@ -302,8 +306,8 @@ void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds); self._genh.add(gen_command_decl(name, arg_type, boxed, ret_typ= e)) self._genh.add(gen_marshal_decl(name)) self._genc.add(gen_marshal(name, arg_type, boxed, ret_type)) - self._regy.add(gen_register_command(name, success_response, - allow_oob, allow_preconfig= )) + self._regy.add(gen_register_command( + name, features, success_response, allow_oob, allow_preconf= ig)) =20 =20 def gen_commands(schema, output_dir, prefix): diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index 21df3abed2..9119eb015b 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -66,15 +66,12 @@ void visit_type_%(c_name)s_members(Visitor *v, %(c_name= )s *obj, Error **errp) push_indent() if deprecated: ret +=3D mcgen(''' - if (visit_deprecated(v, "%(name)s")) { + if (visit_deprecated(v, "%(name)s", &err)) { ''', name=3Dmemb.name) push_indent() ret +=3D mcgen(''' visit_type_%(c_type)s(v, "%(name)s", &obj->%(c_name)s, &err); - if (err) { - goto out; - } ''', c_type=3Dmemb.type.c_name(), name=3Dmemb.name, c_name=3Dc_name(memb.name)) @@ -82,6 +79,11 @@ void visit_type_%(c_name)s_members(Visitor *v, %(c_name)= s *obj, Error **errp) pop_indent() ret +=3D mcgen(''' } +''') + ret +=3D mcgen(''' + if (err) { + goto out; + } ''') if memb.optional: pop_indent() --=20 2.21.1 From nobody Sun May 5 14:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253369; cv=none; d=zohomail.com; s=zohoarc; b=l07nzC62x+gpFrnHlOKegyafswj4+7ky1ofYxbAxu8eOzpt84Mq5cRZ/32bfSMujGlmuuMMHdDZ45+kwc3iRbWKKrtf5JHzw0af4HFcKZZzNVxsJts3iPmd9TsN7YAhTu8z/mjcQPvfPN9MB9PK7gvV6xDchnFrlDC7POTK0nps= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253369; h=Content-Type: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; bh=Lv+Y3uORPyKTvnxkqiYkWuE9C0PyzcV1+KlOv2igoQI=; b=XglN0iZ55mVrvvy4WzwH+vMo1ZPaaFL/iQd2EARViGsS+VMvUh0yvYr1/RBHMnt4DlM8LmG5t9TEEtVkYfd8UOfQEc8RmTgbacQyoh3c/yvkktNH6Wa+kDNae26/Hb7fua1TJqcY0pEaOF7Hx9+FZmDonxdPFmpczcRU3oK8NfA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1583253369293180.41348299835784; Tue, 3 Mar 2020 08:36:09 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-290-TfWaqoVzOYumoI8LnIGosA-1; Tue, 03 Mar 2020 11:36:05 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1B025800D4E; Tue, 3 Mar 2020 16:35:57 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E061773886; Tue, 3 Mar 2020 16:35:56 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 915841803C40; Tue, 3 Mar 2020 16:35:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZH7q001339 for ; Tue, 3 Mar 2020 11:35:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id B4AFC101D482; Tue, 3 Mar 2020 16:35:17 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B99B710027B1; Tue, 3 Mar 2020 16:35:15 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 201361130356; Tue, 3 Mar 2020 17:35:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253368; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Lv+Y3uORPyKTvnxkqiYkWuE9C0PyzcV1+KlOv2igoQI=; b=PtgS+Xjr7APOC9jMpGqLBpogZGHUeDdSpSLWEhlDtQibj30btzd1V5wnnU+NCtUNZkkYBn /bi9FHH8hEE8XTvcEsSyQNJDUwtBat2HnXqpPXCIDvERT144/1OUa7WfUp+PdWqCSx+ld+ MbkjQ7LwuwRTXx7r1kHuxv7+3KokXEY= X-MC-Unique: TfWaqoVzOYumoI8LnIGosA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 30/30] qapi: New -compat deprecated-input=crash Date: Tue, 3 Mar 2020 17:35:05 +0100 Message-Id: <20200303163505.32041-31-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Policy "crash" calls abort() when deprecated input is received. Bugs in integration tests may mask the error from policy "reject". Provide a larger hammer: crash outright. Masking that seems unlikely. Signed-off-by: Markus Armbruster --- qapi/compat.json | 3 ++- qapi/qmp-dispatch.c | 1 + qapi/qobject-input-visitor.c | 1 + qemu-options.hx | 4 +++- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/qapi/compat.json b/qapi/compat.json index fd6f8e932c..ec24567639 100644 --- a/qapi/compat.json +++ b/qapi/compat.json @@ -11,11 +11,12 @@ # # @accept: Accept silently # @reject: Reject with an error +# @crash: abort() the process # # Since: 5.0 ## { 'enum': 'CompatPolicyInput', - 'data': [ 'accept', 'reject' ] } + 'data': [ 'accept', 'reject', 'crash' ] } =20 ## # @CompatPolicyOutput: diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index 516ee9b0b7..2c8fac02cd 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -141,6 +141,7 @@ QDict *qmp_dispatch(QmpCommandList *cmds, QObject *requ= est, "Deprecated command %s disabled by policy", command); goto out; + case COMPAT_POLICY_INPUT_CRASH: default: abort(); } diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c index 6ea93f5a7a..a74c901be9 100644 --- a/qapi/qobject-input-visitor.c +++ b/qapi/qobject-input-visitor.c @@ -654,6 +654,7 @@ static bool qobject_input_deprecated(Visitor *v, const = char *name, error_setg(errp, "Deprecated parameter '%s' disabled by policy", name); return false; + case COMPAT_POLICY_INPUT_CRASH: default: abort(); } diff --git a/qemu-options.hx b/qemu-options.hx index d02d6bfc15..7e49f778f4 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3361,7 +3361,7 @@ STEXI ETEXI =20 DEF("compat", HAS_ARG, QEMU_OPTION_compat, - "-compat [deprecated-input=3Daccept|reject][,deprecated-output=3Daccep= t|hide]\n" + "-compat [deprecated-input=3Daccept|reject|crash][,deprecated-output= =3Daccept|hide]\n" " Policy for handling deprecated management interfaces\= n", QEMU_ARCH_ALL) STEXI @@ -3373,6 +3373,8 @@ Set policy for handling deprecated management interfa= ces (experimental): Accept deprecated commands and arguments @item deprecated-input=3Dreject Reject deprecated commands and arguments +@item deprecated-input=3Dcrash +Crash on deprecated command @item deprecated-output=3Daccept (default) Emit deprecated command results and events @item deprecated-output=3Dhide --=20 2.21.1